TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Electric Motors and Controllers
casainho   1 GW

1 GW
Posts: 3190
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » Jan 10 2019 10:42am

spiked wrote:
Jan 10 2019 10:36am
casainho wrote:
Jan 09 2019 1:34pm
New stable flexible OpenSource firmware v0.17.0, get it here: https://github.com/OpenSource-EBike-fir ... ag/v0.17.0
Thanks, casainho, and all who contributed!

Will give 0.17 a try ASAP in my LCD3.

Do I have to update my motor controller firmware to 0.17? Or are there no changes from 0.16?

Thanks!

Neil
No changes on motor controller side.

I hope it works, as the previous user reported error.
Developer of the Flexible OpenSource firmware for EBike motor controllers (TSDZ2 and KT) and LCDs (KT-LCD3 and Bafang 850C color LCD).

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

Rafe   1 W

1 W
Posts: 62
Joined: Oct 16 2018 5:56pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by Rafe » Jan 10 2019 10:48am

Is 17.0 the wrong file? It loads but the LCD3 display will not flash up afterwards I've had to revert back to 17.0 beta 5


The file size looks too small, smaller than 16.0, buba's 16.1 and all the 17.0 betas


It is the same size as the controller firmware too and LCD3 firmware is usually larger. Also strange is both throttle an non throttle are the same size

https://github.com/OpenSource-EBike-fir ... e/releases

spiked   1 mW

1 mW
Posts: 15
Joined: Sep 07 2018 10:20am

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by spiked » Jan 10 2019 11:14am

casainho wrote:
Jan 10 2019 10:42am

No changes on motor controller side.

I hope it works, as the previous user reported error.
Thanks, I'll hold off until the 0.17 LCD3 file issues are sorted out.

casainho   1 GW

1 GW
Posts: 3190
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » Jan 10 2019 2:15pm

spiked wrote:
Jan 10 2019 11:14am
casainho wrote:
Jan 10 2019 10:42am

No changes on motor controller side.

I hope it works, as the previous user reported error.
Thanks, I'll hold off until the 0.17 LCD3 file issues are sorted out.
Found the issue and I did uploaded the correct files: https://github.com/OpenSource-EBike-fir ... ag/v0.17.0
Developer of the Flexible OpenSource firmware for EBike motor controllers (TSDZ2 and KT) and LCDs (KT-LCD3 and Bafang 850C color LCD).

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

Rafe   1 W

1 W
Posts: 62
Joined: Oct 16 2018 5:56pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by Rafe » Jan 10 2019 3:03pm

This new 82.1k 17.0 has gone in no problem at all the old one was only 56.7k cheers :thumb:

casainho   1 GW

1 GW
Posts: 3190
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » Jan 10 2019 3:07pm

Rafe wrote:
Jan 10 2019 3:03pm
This new 82.1k 17.0 has gone in no problem at all the old one was only 56.7k cheers :thumb:
Thanks for the feedback. The previous was just the motor controller firmware, there was an issue with the script that builds all the firmware (that I jist did).
Developer of the Flexible OpenSource firmware for EBike motor controllers (TSDZ2 and KT) and LCDs (KT-LCD3 and Bafang 850C color LCD).

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

User avatar
stancecoke   10 kW

10 kW
Posts: 973
Joined: Aug 02 2017 2:56pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by stancecoke » Jan 11 2019 4:42am

casainho wrote:
Jan 09 2019 3:53pm
marcoq, can you please create a new thread for user support to your branch?
Perhaps we could build a Java Tool, that creates the hex-file (e.g. EEPROM.hex) for the EEPROM content and then flashes the file via a batchfile that calls the STVP commandline tool (like it is done for optionbytes and program memory in the existing Java Tool already). This would avoid that the end user has to compile the whole code.

The hex-file structure is quite easy, a "blueprint" can be created by saving the recent state from the Data Memory tab in the ST Visual Programmer (see attachment).

The command in the batch file for writing the EEPROM Data should be:

Code: Select all

STVP_CmdLine -BoardName=ST-LINK -ProgMode=SWIM -Port=USB -Device=STM8S105x6 -FileData=EEPROM.hex -verbose -no_loop
regards
stancecoke
Attachments
EEPROM.hex.txt
(2.42 KiB) Downloaded 28 times
Last edited by stancecoke on Jan 11 2019 12:19pm, edited 2 times in total.

casainho   1 GW

1 GW
Posts: 3190
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » Jan 11 2019 4:50am

stancecoke wrote:
Jan 11 2019 4:42am
casainho wrote:
Jan 09 2019 3:53pm
marcoq, can you please create a new thread for user support to your branch?
Perhaps we could build a Java Tool, that creates the hex-file (e.g. EEPROM.hex) for the EEPROM content and then flashes the file via a batchfile that calls the STVP commandline tool (like it is done for opitonbytes and program memory in the existing Java Tool already). This would avoid that the end user has to compile the whole code.

The hex-file structure is quite easy, a "blueprint" can be created by saving the recent state from the Data Memory tab in the ST Visual Programmer.

The command in the batch file for writing the EEPROM Data should be:

Code: Select all

STVP_CmdLine -BoardName=ST-LINK -ProgMode=SWIM -Port=USB -Device=STM8S105x6 -FileData=EEPROM.hex -verbose -no_loop
That is also my suggestion!! On KT motor controllers firmware user needs to build the firmware because there are so many options, like it works with many different motors and sensors. The advantage of TSDZ2 project is that hardware is almost the same for everyone, so the firmware file can be just one and that simplifies a lot the process compared to KT motor controller firmware.

I think stancecoke suggestions are good -- he has very good experience with KT motor controller firmware ;-)
Developer of the Flexible OpenSource firmware for EBike motor controllers (TSDZ2 and KT) and LCDs (KT-LCD3 and Bafang 850C color LCD).

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

casainho   1 GW

1 GW
Posts: 3190
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » Jan 11 2019 5:29am

I submitted a talk proposal to Pixel Camp, where I plan to talk about TSDZ2 flexible OpenSource firmware (motor controller and both LCDs). I learn a lot every time I goes there and I find a lot of interested and cool developers, so I am very excited to be there again.

Pixels Camp is the largest technology event in Portugal, consisting of 3 days of non-stop tech, talks, workshops and 48-hour hackathon.

https://pixels.camp

Image
Developer of the Flexible OpenSource firmware for EBike motor controllers (TSDZ2 and KT) and LCDs (KT-LCD3 and Bafang 850C color LCD).

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

buba   100 W

100 W
Posts: 215
Joined: Aug 31 2018 12:36am

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by buba » Jan 11 2019 1:27pm

This will be a big one…

I have worked on a couple of new functions, features and overall KT-LCD3 and controller firmware improvements.

Some changes from stable version 0.17.0:
-------------------------------------------------------------------------------------------------------------------------

- Walk assist: works with different power levels adjustable by user. Set the desired power level simply by choosing assist level. There is a new configuration menu where you can enable or disable the function and also set the power values for each and every assist level. Can be activated at speeds below 8 km/h or around 5 mph with DOWN button hold. Based on open loop controller firmware that is settable from the display (KT-LCD3). An open loop controller is the best controller implementation for the walk assist function as it enables slower speeds.

- Cruise function (BETA): this is a great new function for those days you need kind of a “virtual throttle”. When at speeds above 8 km/h or around 5 mph simply hold down the DOWN button and the bike will do the rest. The speed will automatically be maintained. Feedback controller firmware. Great for countries where a real throttle is illegal. Really a fun function!

- Current ramp up: it is now possible to set the current ramp up when the motor is accelerating. Configurable from the display (KT-LCD3) under configuration menu 8: Various. Users can have a longer lasting blue gear by simply slowing down the acceleration or just enjoy a smoother acceleration and feeling. The opposite is possible too: set a faster acceleration if you wish for a quick bike.

- Speed, average speed and max speed: there is a new menu in the main display (KT-LCD3) where users can see the current speed, average speed since power on and peak speed since power on.

- EXPERIMENTAL higher cadence mode for the 48 V motor: there is a new motor type to choose under configuration menu 8: Various. This is a experimental mode for the 48 V motor based on previous values supplied by user Jbalat. Test with caution as this is an experimental function. Have not personally tested this and it is advised to not choose this if not sure what it is. This is where future field weakening modes might end up.

Here is an updated wiki (BETA) with some more information: https://github.com/OpenSource-EBike-fir ... 8.X-(beta)
-------------------------------------------------------------------------------------------------------------------------


Coming updates and improvements (maybe):
-------------------------------------------------------------------------------------------------------------------------

- Walk assist enabled without having to hold the DOWN button (maybe not a good idea). Disables immediately if user presses ANY button.

- Cruise function enabled without having to hold the DOWN button (maybe not a good idea). Disables immediately if user presses ANY button.

- Cruise function with more functionality and function enable/disable switch.

- More average speed functionality.

- Experimental functions with field weakening.

- User ideas.
-------------------------------------------------------------------------------------------------------------------------


Will submit pull request from my fork ( https://github.com/leon927/TSDZ2-Smart-EBike ) and the branch I have been working on as soon as I have tested the changes and feel comfortable with everything safety wise. But just wanted to give an quick update!

This is such a cool and great community, love all the development! As usual, feedback is much appreciated!
GitHub: https://github.com/leon927
PayPal: leonstor at bredband.net

User avatar
elem   10 W

10 W
Posts: 81
Joined: May 26 2017 4:27pm
Location: alpes maritimes
Contact:

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by elem » Jan 11 2019 2:09pm

- Walk assist enabled without having to hold the DOWN button (maybe not a good idea). Disables immediately if user presses ANY button.
it s a good idea, i have friends with yamaha motor, and walk assist button is a pain, i suggested them to use a simple on/off switch .
Bosh walk assist is good, no timer and big button, easy to use
but activate walk assist and stopping it just with any button is good too, may be the easy way in mountain biking .
RockRider 9.1 TSDZ2 open source firmware .
https://www.strava.com/athletes/20806862

markjiizs   100 µW

100 µW
Posts: 9
Joined: Oct 25 2018 9:49pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by markjiizs » Jan 11 2019 2:20pm

I agree that both cruise and walk assist like that would be perfect implementation. I think then the firmware would have everything I want :) :thumb: Thanks for the development and let us know when we can test the firmwares :)

Nick   1 W

1 W
Posts: 59
Joined: Jan 11 2019 5:24pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by Nick » Jan 11 2019 5:40pm

buba wrote:
Jan 11 2019 1:27pm

- Walk assist enabled without having to hold the DOWN button (maybe not a good idea). Disables immediately if user presses ANY button.
What bothers me most with normal walk assist is if you let loose the down button for just a blink of an eye (which happens quite often to me :cry:) you have to go through the complete procedure "hold the button - wait - walk assist kicks in".
Maybe there is a safety/comfort compromise:
If walk assist is active and you let loose the down button you are able to instantly reactivate walk assist by pressing&hold the button again within f.i. 2 secs. But if this period elapses or you press any other button you have to begin from scratch...

Greetings
Nick

casainho   1 GW

1 GW
Posts: 3190
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » Jan 11 2019 5:45pm

Nick wrote:
Jan 11 2019 5:40pm
buba wrote:
Jan 11 2019 1:27pm

- Walk assist enabled without having to hold the DOWN button (maybe not a good idea). Disables immediately if user presses ANY button.
What bothers me most with normal walk assist is if you let loose the down button for just a blink of an eye (which happens quite often to me :cry:) you have to go through the complete procedure "hold the button - wait - walk assist kicks in".
Maybe there is a safety/comfort compromise:
If walk assist is active and you let loose the down button you are able to instantly reactivate walk assist by pressing&hold the button again within f.i. 2 secs. But if this period elapses you have to begin from scratch...

Greetings
Nick
Previous experimental implementation from EndlessCadence did that, did filter small/quick button loose so this can be done and was already thought. That code is on the pull request that is not closed yet.
Developer of the Flexible OpenSource firmware for EBike motor controllers (TSDZ2 and KT) and LCDs (KT-LCD3 and Bafang 850C color LCD).

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

Rydon   100 W

100 W
Posts: 218
Joined: Aug 11 2016 5:26pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by Rydon » Jan 11 2019 10:27pm

buba wrote:
Jan 11 2019 1:27pm
This will be a big one…
Great stuff buba!! I can't wait to try it. Thanks!!

Rydon   100 W

100 W
Posts: 218
Joined: Aug 11 2016 5:26pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by Rydon » Jan 11 2019 10:33pm

buba wrote:
Jan 11 2019 1:27pm
- Walk assist enabled without having to hold the DOWN button (maybe not a good idea). Disables immediately if user presses ANY button.

- Cruise function enabled without having to hold the DOWN button (maybe not a good idea). Disables immediately if user presses ANY button.

- Cruise function with more functionality and function enable/disable switch.

This is such a cool and great community, love all the development! As usual, feedback is much appreciated!
Pressing any button to disable sounds safe enough. I assume it would also disable on braking if cutoffs installed? That is as good as the way cruise control works on cars.

I also agree on the community comments. :) Kudos to the developers and contributors!

Rafe   1 W

1 W
Posts: 62
Joined: Oct 16 2018 5:56pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by Rafe » Jan 12 2019 4:04am

Excellent news Buba, I was only looking at the LCD3 manual a few days ago and thinking it would be great to have all its other functions enabled but not expecting anyone to do it. Just a shame it does not have a battery to store time/date.

As for walk assist or any other function that rotates the wheel without having to hold a button or pedal I would strongly caution against that. The obvious is an accident with the rider not able to switch the motor off, but these bikes also go into crowded public spaces including trains where it is all too easy to have them activated inadvertanly even without the owner present. The finger bounce delay sounds like a good idea though, the same principle as a train driver's dead man handle or button.

e3s   10 mW

10 mW
Posts: 32
Joined: Jan 08 2018 12:40pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by e3s » Jan 12 2019 7:21am

The throttle could be used to control the walk assist

dameri   10 W

10 W
Posts: 97
Joined: Sep 20 2018 10:57am

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by dameri » Jan 13 2019 9:13am

I drove for the first time yesterday open source firmaware v017.0. Everything works very well. Better than stock firmaware. Kudos for everyone who has take part to developing.

Now I'm wondering if the main screen in KT-LCD3 can be configured? I don't need time measurement, can I for example put cadence instead, and if I can, please explain how.

samuelsson87   1 µW

1 µW
Posts: 4
Joined: Jan 10 2019 3:40pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by samuelsson87 » Jan 13 2019 11:51am

HI!

I have the coaster version of the Tongsheng TSDZ2 and gets a kick from the cranks when releasing torque too fast.

It seems that this is because the controller/firmware is for the non-coaster version. Right? What to do?
Can I flash the controller to the "coaster-version-firmware" or can I solve it with the FOS-firmware?

Regards
David

markjiizs   100 µW

100 µW
Posts: 9
Joined: Oct 25 2018 9:49pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by markjiizs » Jan 13 2019 2:14pm

Rafe wrote:
Jan 12 2019 4:04am

As for walk assist or any other function that rotates the wheel without having to hold a button or pedal I would strongly caution against that. The obvious is an accident with the rider not able to switch the motor off, but these bikes also go into crowded public spaces including trains where it is all too easy to have them activated inadvertanly even without the owner present. The finger bounce delay sounds like a good idea though, the same principle as a train driver's dead man handle or button.
If I would go mountainbiking I would put a jetski style kill switch, you can get even reed (magnetic) switch and some piece of metal to attach your magnet. The greatness of open source is in letting people to choose on their own responsibility what they want and what not. I like the idea a lot for scenic long drives where you just want to look around without pushing anything. Analogy with motorbikes, most of the touring ones have a cruise control, that does not mean that there are more accidents, actually it is even good for safety to mantain constant speed...

Rydon   100 W

100 W
Posts: 218
Joined: Aug 11 2016 5:26pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by Rydon » Jan 13 2019 7:45pm

samuelsson87 wrote:
Jan 13 2019 11:51am
HI!

I have the coaster version of the Tongsheng TSDZ2 and gets a kick from the cranks when releasing torque too fast.

It seems that this is because the controller/firmware is for the non-coaster version. Right? What to do?
Can I flash the controller to the "coaster-version-firmware" or can I solve it with the FOS-firmware?

Regards
David
As sometimes happens with TongSheng it appears that your controller got flashed with the regular firmware instead of the coaster brake firmware either at the factory or later. The correct controller has a"BK" next to the part number for coaster brake. So you can buy a coaster brake controller or find the firmware and flash it per this site or do the FOS firmware per this site. Any of the above would fix your problem. Before I knew about this issue I put a regular controller on a coaster brake motor and experienced exactly what you describe. :)

How many volts is your motor? I may be able to get the firmware for you.

shaddi   100 mW

100 mW
Posts: 35
Joined: May 30 2018 3:20pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by shaddi » Jan 14 2019 2:40am

buba wrote:
Jan 11 2019 1:27pm
- Cruise function (BETA): this is a great new function for those days you need kind of a “virtual throttle”. When at speeds above 8 km/h or around 5 mph simply hold down the DOWN button and the bike will do the rest. The speed will automatically be maintained. Feedback controller firmware. Great for countries where a real throttle is illegal. Really a fun function!
yeeess! Cant wait to test this!
This Function should also be disabled in offroad-mode inactive state if offroad-mode is enabled...

flufferty   10 mW

10 mW
Posts: 23
Joined: Apr 22 2017 4:00pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by flufferty » Jan 14 2019 4:13am

Did anyone try to flash back to stock from the flexible firmware?
I have a 36v motor and a 52v battery, and trying to get back to stock with the 52v-profiles from eyebsickle, left me with the controller thinking the battery is empty. So it wont run. But I used the same profiles before the flexible, successfully.

I made sure to double-check the voltage/amps in eeprom-file before flashing.
Sorry to use this thread but the main question is what do I need to go back to stock from flexible?

1. Flash stock program (-s flash in stm8flash)
2. Flash data eeprom (-s eeprom)

Missing anything?
Do I need to relock or flash the opt?

perryscope   100 mW

100 mW
Posts: 47
Joined: Jan 06 2019 4:29pm
Contact:

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by perryscope » Jan 14 2019 9:14am

flufferty wrote:
Jan 14 2019 4:13am
Did anyone try to flash back to stock from the flexible firmware?
I have a 36v motor and a 52v battery, and trying to get back to stock with the 52v-profiles from eyebsickle, left me with the controller thinking the battery is empty. So it wont run. But I used the same profiles before the flexible, successfully.

I made sure to double-check the voltage/amps in eeprom-file before flashing.
Sorry to use this thread but the main question is what do I need to go back to stock from flexible?

1. Flash stock program (-s flash in stm8flash)
2. Flash data eeprom (-s eeprom)

Missing anything?
Do I need to relock or flash the opt?
I did this to test stock firmware on a new battery (I went to 48V Stock). I originally bought the motor as 36V and took a copy of stock firmware before I did anything Program, Data, and Opt.

For me the only way I could get stock (48V) to work was to use the 36V opt backup i originally took. without it my battery would show empty.

This worked well for me, I'm not sure of the opt would be different between stock firmware. Have you got one to try? or has anyone got a 48V/52v stock opt hex file to compare with?

Welcome to share my 36V opt hex file if it would help?
Empowered people support rider and techie.
www.empoweredpeople.co.uk

Post Reply