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

Electric Motors and Controllers
andrea_104kg   100 W

100 W
Posts: 156
Joined: Mar 05 2018 5:51pm

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

Post by andrea_104kg » Aug 22 2019 4:10pm

what's the logic of new emtb?
Thank's for your hard work!
Thank's for your hard work!
Thank's for your hard work!
Thank's for your hard work!
Thank's for your hard work!
Thank's for your hard work!
Thank's for your hard work!

buba   10 kW

10 kW
Posts: 587
Joined: Aug 31 2018 12:36am

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

Post by buba » Aug 22 2019 5:47pm

andrea_104kg wrote:
Aug 22 2019 4:10pm
what's the logic of new emtb?
Thank's for your hard work!
Thank's for your hard work!
Thank's for your hard work!
Thank's for your hard work!
Thank's for your hard work!
Thank's for your hard work!
Thank's for your hard work!
Thank you, thank you and thank you! :)

It is the same logic as before and it is based on pedal torque. Did you wish for it to be based on pedal power?

Current eMTB logic:
Motor torque = Pedal torque ^ X

What you would want(?):
Motor power = (Pedal torque * pedal cadence * [assist multiplier]) ^ X

EDIT: There are many ways to implement different riding modes. But there is usually no way to measure how "good" a riding mode is except evaluating feedback from users. The feedback is based on the experience and feeling from actually testing the riding mode. Sadly, this means that something can be perceived as good by some but not so much by others. Therefore it is very beneficial to have several different riding modes and also use this great community as a feedback loop. (Feedback is gold so thanks!)

eMTB has been improved, in some small way or another, four times in the 0.20.0 firmware version. I can only imagine that it is going to change even more in the future. What I am trying to say is that this project is in continuous development and we are working in steps defined by releases. So whatever is released in the 0.20.0 is only the stepping stone for the future improvements and changes.
Last edited by buba on Aug 22 2019 7:32pm, edited 2 times in total.
GitHub: https://github.com/leon927
PayPal: leonstor at bredband.net

vadda   100 mW

100 mW
Posts: 43
Joined: Dec 21 2009 6:22am

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

Post by vadda » Aug 22 2019 5:57pm

Hi Buba,
it's possibile to have more filtered values in sub-field where it's show the istantaneous Amp absorbed and fill the First character with a symbol like "A" ?
I think it's a good thinks fill, where it's possibile, all the first character of any sub-field to improve readibility.

Thanks

buba   10 kW

10 kW
Posts: 587
Joined: Aug 31 2018 12:36am

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

Post by buba » Aug 22 2019 7:45pm

vadda wrote:
Aug 22 2019 5:57pm
Hi Buba,
it's possibile to have more filtered values in sub-field where it's show the istantaneous Amp absorbed and fill the First character with a symbol like "A" ?
I think it's a good thinks fill, where it's possibile, all the first character of any sub-field to improve readibility.

Thanks
That is a good suggestion and is otherwise very possible to implement. But there is only a small amount of available program space left in the KT-LCD3. It would be very difficult to add more characters and logic to handle those characters. A lot of work needed to rewrite the print functions and try to optimize away other things so everything can fit, if at all possible.

I am very sorry about this, Vadda! But what I can do is to put it on a list of suggestions. So you know that it is at least written down if for any reason there is some space in the future!

If you want me to increase the filtering on the current, voltage, cadence or any other data please let me know. That is very simple to do and I have no problem changing that. On the contrary, would love to hear some thoughts about that from you or anyone else!
GitHub: https://github.com/leon927
PayPal: leonstor at bredband.net

mctubster   100 W

100 W
Posts: 208
Joined: Feb 26 2018 6:21am

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

Post by mctubster » Aug 22 2019 10:20pm

Hi Buba,

I was reviewing and trying to understand the eMBT code. At the start you define some strings for each level of eMBT assist ... what are these values and how are they used?

Also trying to understand the /20 ... is that simply a scaling factor to convert "torque" to current supplied by the controller?

Cheers

Peetsyo   10 mW

10 mW
Posts: 20
Joined: May 16 2018 3:41pm

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

Post by Peetsyo » Aug 23 2019 2:25am

casainho wrote:
Aug 22 2019 1:59pm
Peetsyo wrote:
Aug 22 2019 12:05pm
If the motor overheats , does it switch off as if switched off from button (display goes off) or motor just becomes unresponsive and display stays on ?
Can you switch on immediately after that and ride on ?

I am not sure if i have problem with battery connection or the motor actually overheats.
Which version of our OpenSource firmware are you using?
v 0.16

casainho   1.21 GW

1.21 GW
Posts: 3710
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Aug 23 2019 2:29am

Peetsyo wrote:
Aug 23 2019 2:25am
casainho wrote:
Aug 22 2019 1:59pm
Peetsyo wrote:
Aug 22 2019 12:05pm
If the motor overheats , does it switch off as if switched off from button (display goes off) or motor just becomes unresponsive and display stays on ?
Can you switch on immediately after that and ride on ?

I am not sure if i have problem with battery connection or the motor actually overheats.
Which version of our OpenSource firmware are you using?
v 0.16
Are you using the temperature sensor? In any case, if motor overheats, the display never turns off.

Well, unless there is any kind of short circuit and your BMS is shutting off.
Developer of the Flexible OpenSource firmware for EBike motor controllers (TSDZ2 and KT) and displays (Bafang 850C color, SW102 Bluetooth and KT-LCD3).

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   10 kW

10 kW
Posts: 587
Joined: Aug 31 2018 12:36am

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

Post by buba » Aug 23 2019 6:08am

mctubster wrote:
Aug 22 2019 10:20pm
Hi Buba,

I was reviewing and trying to understand the eMBT code. At the start you define some strings for each level of eMBT assist ... what are these values and how are they used?
Hello, Mctubster!

Those values are in an array called a lookup table. We use that whenever there is are heavy computational operations that would take more time to compute than to simply access a precalculated value from memory. Another reason for using lookup tables is to limit library dependencies and also reduce the program space needed to solve those operations.

When using a lookup table we only waste time and program logic to retrieve values from a certain address in the program memory. That value holds the answer to our calculation instead of having to calculate it.

Here is an example showing a function that would take a lot of operations to calculate:

eMTB_currentTarget = PedalTorque^1.85

But if this is precalculated and the results are stored in the array we can just get the result from the appropriate address in the array:

eMTB_currentTarget = powerFunction_1_85[PedalTorque]


mctubster wrote:
Aug 22 2019 10:20pm
Also trying to understand the /20 ... is that simply a scaling factor to convert "torque" to current supplied by the controller?

Cheers
The /20 is to scale the curves so you are totally correct. This was primarily used when developing the original eMTB. But it is not needed in the new eMTB code in Alpha 8. Have not yet pushed the Alpha 8 so you are looking at the Alpha 7 code.

Let me know if you have more questions! I think it is important to keep the code simple and accessible to everyone! That ensures that we have the highest probability for users to try out their own changes. That would be very exciting and would result in a much faster development! So always let me know if there is anything you would want me to simplify or if you see any room for improvement.

Cheers!
GitHub: https://github.com/leon927
PayPal: leonstor at bredband.net

emyr666   10 µW

10 µW
Posts: 5
Joined: Feb 26 2019 5:31pm

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

Post by emyr666 » Aug 23 2019 8:10am

When will there be a beta in GitHub so we can get access to the code?

buba   10 kW

10 kW
Posts: 587
Joined: Aug 31 2018 12:36am

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

Post by buba » Aug 23 2019 8:25am

emyr666 wrote:
Aug 23 2019 8:10am
When will there be a beta in GitHub so we can get access to the code?
You can already access the source code. And I just pushed the Alpha 8 if you wish to see the latest changes:

https://github.com/leon927/TSDZ2-Smart- ... ng-pwm-acc
GitHub: https://github.com/leon927
PayPal: leonstor at bredband.net

buba   10 kW

10 kW
Posts: 587
Joined: Aug 31 2018 12:36am

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

Post by buba » Aug 23 2019 8:32am

Alpha 8 is ready for you!

------------------------

Here is the wiki (work in progress):
https://github.com/OpenSource-EBike-fir ... %7C-Manual

------------------------

Here is my Google Drive folder with the Alpha 8:
https://drive.google.com/open?id=1CPGT- ... bYtY4_JH2R

------------------------

Here is my branch where you can see the source code and latest changes:
https://github.com/leon927/TSDZ2-Smart- ... ng-pwm-acc

------------------------

Here are the changes from Alpha 7:
- eMTB improved and optimized, more sensitivity values
- Button debounce on Walk Assist and Cruise, very safe implementation
- Overall improvements

------------------------

Comment:
No need to update unless you want to get the latest changes. If you are using eMTB, Walk Assist or Cruise I recommend to update!

------------------------

From previous post:
Alpha 8 will introduce a better eMTB with more options for sensitivity. At the same time it will be drastically space and speed optimized. That means it takes up less program space and executes faster. So the result is that we will have more available space in the motor controller and not compromise on functionality.

The Walk Assist and Cruise will have a really clever button debounce feature that can differentiate accidental activation from real activation. If you accidentally and quickly press the DOWN button it will immediately deactivate Walk Assist or Cruise as soon as you let go. But if you are holding the DOWN button for a longer time the system will understand and allow for some button debouncing. Cruise has a lower debounce time than Walk Assist but that is by design. This is actually a really safe implementation and I hope it will be approved by the community. It is also dynamic so it adjusts for the time the user holds down the button and so on. Needs to be tested and I look forward to feedback.

There will also be some other small changes and improvements in the Alpha 8.
GitHub: https://github.com/leon927
PayPal: leonstor at bredband.net

casainho   1.21 GW

1.21 GW
Posts: 3710
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Aug 23 2019 8:54am

buba wrote:
Aug 23 2019 8:32am
Alpha 8 is ready for you!
Buba, I saw that your tables of for emtb are really big, even more then the ones already existing the previous firmware version (the ones used for the motor controller).

Why don't you use the way smaller table of 8 points as I implemented for torque sensor full calibration?
Developer of the Flexible OpenSource firmware for EBike motor controllers (TSDZ2 and KT) and displays (Bafang 850C color, SW102 Bluetooth and KT-LCD3).

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.

btslo   1 W

1 W
Posts: 50
Joined: Apr 17 2019 8:55am

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

Post by btslo » Aug 23 2019 8:55am

Do I need to reconfigure if I update from beta 7? (Will it wipe the settings?)

buba   10 kW

10 kW
Posts: 587
Joined: Aug 31 2018 12:36am

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

Post by buba » Aug 23 2019 9:52am

casainho wrote:
Aug 23 2019 8:54am
buba wrote:
Aug 23 2019 8:32am
Alpha 8 is ready for you!
Buba, I saw that your tables of for emtb are really big, even more then the ones already existing the previous firmware version (the ones used for the motor controller).

Why don't you use the way smaller table of 8 points as I implemented for torque sensor full calibration?
Mainly due to simplicity during development and feedback. It is far easier and quicker to generate the values in this form and make changes. I have basically automated the process. When we have validated that eMTB is okay and everyone is satisfied with the layout we can further optimize and refactor so we get a really nice and light code. It is always possible to change later on and optimize as much as we need!

(But still decided to optimize slightly and am now using 8 bit tables and not 16 bit.)
GitHub: https://github.com/leon927
PayPal: leonstor at bredband.net

buba   10 kW

10 kW
Posts: 587
Joined: Aug 31 2018 12:36am

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

Post by buba » Aug 23 2019 9:53am

btslo wrote:
Aug 23 2019 8:55am
Do I need to reconfigure if I update from beta 7? (Will it wipe the settings?)
It will not wipe anything! Just update and you are set! :)
GitHub: https://github.com/leon927
PayPal: leonstor at bredband.net

Rafe   10 W

10 W
Posts: 91
Joined: Oct 16 2018 5:56pm

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

Post by Rafe » Aug 23 2019 2:46pm

Re A8, Sorry Buba because I realise you have put a lot of work in.

The mod to the walk assist which means that the bike carries on for another three feet after releasing the button is not acceptable for me. I need the bike to stop as soon as I release the button especially on a route I use which has sections of steps on a cliff. I realise why you've done the mod but as soon as I found the bike kept on moving after a deliberate release I realised the obvious problem and for me it would be safer without the anti bounce facility.


Yesterday I had a smile on my face using eMTB mode because it was perfect and the bike responded as if it knew exactly what I wanted from it, be it just a little power all the way up to full on let rip. It wasn't doing that tonight but I guess I need to get used to 20 levels of sensitivity now.
Last edited by Rafe on Aug 24 2019 4:29am, edited 1 time in total.

Peetsyo   10 mW

10 mW
Posts: 20
Joined: May 16 2018 3:41pm

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

Post by Peetsyo » Aug 23 2019 4:00pm

casainho wrote:
Aug 23 2019 2:29am
Peetsyo wrote:
Aug 23 2019 2:25am
casainho wrote:
Aug 22 2019 1:59pm
Peetsyo wrote:
Aug 22 2019 12:05pm
If the motor overheats , does it switch off as if switched off from button (display goes off) or motor just becomes unresponsive and display stays on ?
Can you switch on immediately after that and ride on ?

I am not sure if i have problem with battery connection or the motor actually overheats.
Which version of our OpenSource firmware are you using?
v 0.16
Are you using the temperature sensor? In any case, if motor overheats, the display never turns off.

Well, unless there is any kind of short circuit and your BMS is shutting off.

I do not have temp sensor yet.
I have the programming cable connected , not the speed sensor.

Does it switch off the controller , if there is no speed input for some time ?

thineight   100 W

100 W
Posts: 191
Joined: Oct 05 2018 3:53am

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

Post by thineight » Aug 23 2019 4:06pm

Rafe wrote:
Aug 23 2019 2:46pm
Sorry Buba because I realise you have put a lot of work in.

The mod to the walk assist which means that the bike carries on for another three feet after releasing the button is not acceptable for me. I need the bike to stop as soon as I release the button especially on a route I use which has sections of steps on a cliff. I realise why you've done the mod but as soon as I found the bike kept on moving after a deliberate release I realised the obvious problem and for me it would be safer without the anti bounce facility.


Yesterday I had a smile on my face using eMTB mode because it was perfect and the bike responded as if it knew exactly what I wanted from it, be it just a little power all the way up to full on let rip. It wasn't doing that tonight but I guess I need to get used to 20 levels of sensitivity now.
Rafe, do you have the brake sensors installed? I think that is the safest of the options for both the walk assist stop and to save the blue gear on steep rough terrains.
I have not tried the alpha8 but I assume that the brake sensors, if pressed, override the denounce feature.

Hope this can be sorted because I see there are 2 philosophies here :wink:
Buba, in case is there any chance to let the user configure in the menu the preferred option, e.g. option 1 without denounce and option 2 with denounce?
MTB KTM Ultra 29" - City bike DAYTONA 28"

casainho   1.21 GW

1.21 GW
Posts: 3710
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Aug 23 2019 4:09pm

Peetsyo wrote:
Aug 23 2019 4:00pm
Does it switch off the controller , if there is no speed input for some time ?
Yes.
Developer of the Flexible OpenSource firmware for EBike motor controllers (TSDZ2 and KT) and displays (Bafang 850C color, SW102 Bluetooth and KT-LCD3).

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.21 GW

1.21 GW
Posts: 3710
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Aug 23 2019 4:10pm

thineight wrote:
Aug 23 2019 4:06pm
Rafe, do you have the brake sensors installed? I think that is the safest of the options for both the walk assist stop and to save the blue gear on steep rough terrains.
I have not tried the alpha8 but I assume that the brake sensors, if pressed, override the denounce feature.
Yes, brake sensors are a must and they immediately disabled the motor.
Developer of the Flexible OpenSource firmware for EBike motor controllers (TSDZ2 and KT) and displays (Bafang 850C color, SW102 Bluetooth and KT-LCD3).

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.

spiked   1 mW

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

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

Post by spiked » Aug 23 2019 5:29pm

Hey all,

Enjoying the 20 beta 3.

Have a question - if my display is set to Imperial, is EVERY applicable menu item in imperial units? Specifically, is the torque sensor reading in menu 10 in pounds? I was checking my calibration with a digital luggage scale, and it appears to be bang on - if the reading on the LCD3 is in pounds...

Thanks!

Neil

User avatar
elem   100 W

100 W
Posts: 135
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 » Aug 24 2019 11:36am

From previous test i found in " advanced technical data ", using my weight ( 64 kg ) on pedals ;

with V0.19 ;
ADC pedal torque sensor : static = 53, right = 89, left = 86
pedal torque sensor dynamic ( pedaling ) : 0 to 170
human power : average 200/300w, hitting 600w for short time .

with V0.20 alpha 6 ;
ADC torque sensor : static = 217, left and right = 340
torque sensor dynamic ( pedaling ) = hiting 320 witch is less than static and very different than V 0.19

do you thinck it's necessary to calibrate ( hardware ) the torque sensor ?
is there any way to calibrate it without openning the mid drive ( casainho explained ) .

******************************************************************************************************
Testing my son'bike witch is a bosh powered with eMTB
power mode eco/tour/speed/boost, with eMTB replacing speed mode ( using ratio from tour to speed mode ) .
boost is a vast of power
eco work fine if you'r strong pedaling ;)
tour seem too strong for me but must be good for people with weight more than 80 kg
speed/eMTB : same remark than for tour mode

what i found : there is a big accelerating ramp 3* the power of absolute of the mode, too bad if you want to save battery, each times you change gear or level assit or stoping pedaling and pedaling and it s seem it s not customizable ( but may be !? )

accelerating ramp it's about 2 seconds

each level seems to be customizable for power limit ( with bosh program not for user exepted may be with the biggest display nyon ( about 500$ )
the motor is very powerfull and torque sensor very progressive and effective, 3* the stock TSDZ2 sensor i thinck .

power mode seem to work as in OSF , exepted the motor could be push easily to 115 rpm and the power grow with rpm .

accelerating ramp is too strong even in eco mode, lack of power and battery ...

The motor is "only " 75 Nm but you got it even in smaller rpm/gear
RockRider 9.1 TSDZ2 open source firmware .

casainho   1.21 GW

1.21 GW
Posts: 3710
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Aug 24 2019 12:13pm

elem wrote:
Aug 24 2019 11:36am
From previous test i found in " advanced technical data ", using my weight ( 64 kg ) on pedals ;

with V0.19 ;
ADC pedal torque sensor : static = 53, right = 89, left = 86
pedal torque sensor dynamic ( pedaling ) : 0 to 170
human power : average 200/300w, hitting 600w for short time .
You should wait for any release we will do for torque sensor calibration or go find on previous messages my explanation how to use a specific version based on 0.19.0 and do the calibration on the firmware only.
Developer of the Flexible OpenSource firmware for EBike motor controllers (TSDZ2 and KT) and displays (Bafang 850C color, SW102 Bluetooth and KT-LCD3).

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.

vadda   100 mW

100 mW
Posts: 43
Joined: Dec 21 2009 6:22am

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

Post by vadda » Aug 24 2019 12:22pm

Hi Buba,
installed A8, all ok.
The debounce on walk assist in now perfect.
:wink:
Thanks
The eMtb was impoved a lot but ,for me, It Is only usabile in certain situation.
:thumb:

rippledabs   1 µW

1 µW
Posts: 3
Joined: Aug 24 2019 8:39pm

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

Post by rippledabs » Aug 24 2019 8:46pm

Hey guys, I have been following this effort for a while and finally got all the equipment today! Thanks for all the work on this.

However, I'm stuck. I got the 850C flashed and the TSDZ2 flashed using the directions from the wiki. Everything seems to communicate ok, however, I am getting no power assist.

Things I tried:
- Torque sensor seems to be reading in the menu.
- The cadence and human power field does not update (Even under aggressive pedaling)
- Walk mode works
- The power-under-no-pedaling works. It goes to 250W then ramps down to zero, then I have no pedal assist.

Any help would be very appreciated.

Here is my hardware:
- "52V" throttle version of the TSDZ2.
- 850C Display
- 14S battery
- No throttle or Brake sensor wired in yet.

My Software:
- Used STM32 to flash using the ST-Link "Bafang_LCD_850C_firmware-v0.4.0.bin"
- Used STVP to flash using "TSDZ2-v0.19.0.hex"

Dat Le

Post Reply