TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (r0mko fork, torque only)

HughF

100 W
Joined
Jan 23, 2020
Messages
266
Location
Dorset, England
I decided to start this thread to help all single speed riders who want to get the best performance when using a TSDZ2 motor for assistance. With a single speed geartrain you have low cadence when starting out, but high torque. You want maximum assistance, and you want it to cut in fast.

The standard codebase for the latest displays uses pedal power as part of the algorithm to calculate motor current. When pedal rpm is below the minimum the cadence sensor can reliably resolve, motor current stays at zero, this makes the assistance slow to cut in on single speed bikes.

User r0mko has made a fork that uses purely pedal torque to calculate motor current, and also has a much faster current ramp programmed into the firmware. It absolutely rips on single speed bikes.

To save cluttering up the other thread, and at the request of Casainho, please use this thread for discussion of this code fork.

https://github.com/r0mko/TSDZ2-Smart-EBike/releases/tag/v0.57.10
 
This is also useful for technical mountain biking trails, sometimes you need high torque at low speed
I love the torque only and eMTB features on the 0.20 beta 1 firmware from buba

silvocross is tinkering with the code in order to implement a customizable eMTB feature

silvocross said:
casainho said:
Now you only need to increment ui8_usart1_tx_buffer size as also increment the Len of the package as the crc will be done for the package len.

Thank you very much, with the suggested changes the communication is now properly working.
So the status from my side:
1. In the Level assist configuration menu there are now 2 additional fields: eMTB Factor (1-100) and eMTB Exponential (1-3)
2. Choosing eMTB Exponential == 1 (default), the motor current delivery will be proportional to the human power as standard.
3. Choosing eMTB Exponential == 2, a quadratic factor will be added to the standard calculation
4. Choosing eMTB Exponential == 3, a cubic factor will be added to the standard calculation
5. eMTB factor is used to scale up or down the added contribution.
I will now perform some tests in order to find a good default parameter configuration and then post the files, in case anyone will like to perform some beta testing.

I think it's best to not fork and make pull request on main branch instead, in order to have a single updated version for users
 
NexusG said:
This is also useful for technical mountain biking trails, sometimes you need high torque at low speed
I love the torque only and eMTB features on the 0.20 beta 1 firmware from buba

silvocross is tinkering with the code in order to implement a customizable eMTB feature

silvocross said:
casainho said:
Now you only need to increment ui8_usart1_tx_buffer size as also increment the Len of the package as the crc will be done for the package len.

Thank you very much, with the suggested changes the communication is now properly working.
So the status from my side:
1. In the Level assist configuration menu there are now 2 additional fields: eMTB Factor (1-100) and eMTB Exponential (1-3)
2. Choosing eMTB Exponential == 1 (default), the motor current delivery will be proportional to the human power as standard.
3. Choosing eMTB Exponential == 2, a quadratic factor will be added to the standard calculation
4. Choosing eMTB Exponential == 3, a cubic factor will be added to the standard calculation
5. eMTB factor is used to scale up or down the added contribution.
I will now perform some tests in order to find a good default parameter configuration and then post the files, in case anyone will like to perform some beta testing.

I think it's best to not fork and make pull request on main branch instead, in order to have a single updated version for users
It is my understanding that Casainho is happy with the current branch of his firmware using power and does not yet anticipate a way forward to safely use only the torque sensor. You can see over in the other thread our discussion.

Personally, for me, for single speed riding on the street, the torque only mode with the very high current ramp is perfect.
 
Yes but that torque only with fast ramp up was why the blue gears get trashed on the standard factory setup, it may mean you have to live with the extra noise of a brass gear.
 
Waynemarlow said:
Yes but that torque only with fast ramp up was why the blue gears get trashed on the standard factory setup, it may mean you have to live with the extra noise of a brass gear.
That is of no issue to me, I am only interested in performance.
 
Three benefits to using this fork and an up to date display:

1. On display torque sensor calibration, not possible with eMTB firmware in 0.19/0.20 and a stock display

2. No need to try and disable street mode and enable eMTB mode at boot up, that was such a pain in the backside on the vlcd6 display

3. Up to date displays and latest firmware supports coulomb counting for %soc display rather than just voltage steps

Those three features make this superior to 0.20 beta, for me anyway. Personally I use sw102 and really like this compact display.
 
NexusG said:
I think it's best to not fork and make pull request on main branch instead, in order to have a single updated version for users
I asked for this developers to contribute by doing a pull request to my repository and I would accept. That is the best way to go - but this is also a decision that only this developers can do.

Anyway, I think anyone can take advantage as long as the firmware is OpenSource. Maybe any other developer in future will make the pull request.
 
HughF said:
I decided to start this thread to help all single speed riders who want to get the best performance when using a TSDZ2 motor for assistance. With a single speed geartrain you have low cadence when starting out, but high torque. You want maximum assistance, and you want it to cut in fast.

The standard codebase for the latest displays uses pedal power as part of the algorithm to calculate motor current. When pedal rpm is below the minimum the cadence sensor can reliably resolve, motor current stays at zero, this makes the assistance slow to cut in on single speed bikes.

User r0mko has made a fork that uses purely pedal torque to calculate motor current, and also has a much faster current ramp programmed into the firmware. It absolutely rips on single speed bikes.

To save cluttering up the other thread, and at the request of Casainho, please use this thread for discussion of this code fork.

https://github.com/r0mko/TSDZ2-Smart-EBike/releases/tag/v0.57.10
I actually experimented with torque only mode. I created a firmware where there is a torque only mode up to 40rpm and then there is a pedal power mode after 40rpm. My verdict - I think this firmware will destroy your drivetrain - chain and cassette as well as the motor clutch and a motor blue gear. For singlespeed bikes I think it is much better to use direct drive motor in the wheel. It will be much more reliable. I like how Casainho firmware slowly pics up and pushes you once you already started moving pedals. But it is a personal preference as I value reliability more than everything. I transport kids on my bike and my bike is the sole means of transportation.

I also experimented with the calibration. I personally prefer original logarithmic uncalibrated curve rather than linear. With linear curve it requires to push pedal much harder to get the same assistance. I don't see mich of the value for me. The only advantage is that with calibration feature I can create custom torque curves to imitate bosch emtb mode. But this is really not that important for me as I ride a cargo bike.
 
vshitikov said:
I think this firmware will destroy your drivetrain - chain and cassette as well as the motor clutch and a motor blue gear.

Why do you think it will destroy the drivetrain ? Your current ramp is too agressive ?
I use torque only 0.20 beta 1 without issue on the drivetrain but I have the brass gear


vshitikov said:
The only advantage is that with calibration feature I can create custom torque curves to imitate bosch emtb mode.

How are you doing that ?
 
NexusG said:
vshitikov said:
I think this firmware will destroy your drivetrain - chain and cassette as well as the motor clutch and a motor blue gear.

Why do you think it will destroy the drivetrain ? Your current ramp is too agressive ?
I use torque only 0.20 beta 1 without issue on the drivetrain but I have the brass gear


vshitikov said:
The only advantage is that with calibration feature I can create custom torque curves to imitate bosch emtb mode.

How are you doing that ?

Well I think I used an exaggerated language - it will not destroy your drivetrain immideately but I certanly puts more stress on it and wears it faster. The typical case is when you stopped on the redlight but didn't change down your gear. Once you start again the motor puts full torque as you press hard on the pedals. Luckily current motor control implementation does not succeed in in applying maximum torque at 0 rpm. I don't know why. But still the motor at 0rpm and 100%pwm has plenty of torque. So this may wear the mechanics much faster. However I didn't use enough my bike to give my return of experience on this. I was primarly using my regular bikes for years before buying a cargo bike. For cargo bike current Casainho implementation is perfect as it is very smooth and pushes you smoothly once you started pedaling already. Also we should not forget that Tongsheng is relatively small motor which was not designed for such overstress. Compared to BBSHD it is much smaller and more fragile.


Regarding the custom curves:
The general idea is following:

Current sensor calibration algorithm takes real curve and tries to make a linear curve out of it. It takes the delta of the torque sensor values and divides it by the delta of the weight values that you have entered. Thus the calibrated curve becomes linear.
By tricking the values of the sensor output that you enter during the calibration you can create the calibrated curve that is not linear. Basically you can create any shape of the torque curve. If I have more time I will show the example in the .xls file that I have used to calibrate mine.
 
vshitikov said:
I actually experimented with torque only mode. I created a firmware where there is a torque only mode up to 40rpm and then there is a pedal power mode after 40rpm. My verdict - I think this firmware will destroy your drivetrain - chain and cassette as well as the motor clutch and a motor blue gear. For singlespeed bikes I think it is much better to use direct drive motor in the wheel. It will be much more reliable. I like how Casainho firmware slowly pics up and pushes you once you already started moving pedals. But it is a personal preference as I value reliability more than everything. I transport kids on my bike and my bike is the sole means of transportation.

I also experimented with the calibration. I personally prefer original logarithmic uncalibrated curve rather than linear. With linear curve it requires to push pedal much harder to get the same assistance. I don't see mich of the value for me. The only advantage is that with calibration feature I can create custom torque curves to imitate bosch emtb mode. But this is really not that important for me as I ride a cargo bike.

The most assistance I can get when labouring hard up a hill at slow speed, or when starting from a standstill with very low cadence is about 200w. This is simply a function of motor current and RPM. If a cheap (EUR10) single speed KMC chain and a rear freewheel cannot handle this type of load for a few thousand km's before needing to be replaced then there is something wrong with the world.

Bike chain and drivetrain parts are basically disposable at the price point they are manufactured to. Unless you get sucked into the world of Shimano XTR and all that marketing BS :)
 
HughF said:
vshitikov said:
I actually experimented with torque only mode. I created a firmware where there is a torque only mode up to 40rpm and then there is a pedal power mode after 40rpm. My verdict - I think this firmware will destroy your drivetrain - chain and cassette as well as the motor clutch and a motor blue gear. For singlespeed bikes I think it is much better to use direct drive motor in the wheel. It will be much more reliable. I like how Casainho firmware slowly pics up and pushes you once you already started moving pedals. But it is a personal preference as I value reliability more than everything. I transport kids on my bike and my bike is the sole means of transportation.

I also experimented with the calibration. I personally prefer original logarithmic uncalibrated curve rather than linear. With linear curve it requires to push pedal much harder to get the same assistance. I don't see mich of the value for me. The only advantage is that with calibration feature I can create custom torque curves to imitate bosch emtb mode. But this is really not that important for me as I ride a cargo bike.

The most assistance I can get when labouring hard up a hill at slow speed, or when starting from a standstill with very low cadence is about 200w. This is simply a function of motor current and RPM. If a cheap (EUR10) single speed KMC chain and a rear freewheel cannot handle this type of load for a few thousand km's before needing to be replaced then there is something wrong with the world.

Bike chain and drivetrain parts are basically disposable at the price point they are manufactured to. Unless you get sucked into the world of Shimano XTR and all that marketing BS :)

well, all depends how you set up your bike - I set the limit a 16A 36V which gives me 576W power. Some people here install temperature sensors and go up to 750W, which I'm not personally a fan of. This is a whole different story from the 200W... Torque mode might be useful when limiting the max power to 250W legal in EU.
 
I run 675w maximum, that's easily available once my cadance comes up. Plenty of motorbike chain lube sees my drive train holding up well at about 500km so far. If the chain breaks, I will throw another one on.
 
HughF wrote: ↑May 06 2020 8:33am
If you want instant performance from a standstill you need to use the torque only version of this firmware, imho... The cadence sensor does not resolve cadence below a certain RPM, and this firmware uses pedal power (speed * torque) to calculate motor current, so you will never get assistance until the cadence increases above the minimum that can be resolved.

Try the r0mko fork (it is based on 0.57 so works nicely with SW102) and let us know if that gives you the performance you want. It certainly did for me.

It is as close as you will get to the marcoq code whilst having all the benefits of the work Casainho has done on the firmware recently.

Is this the latest version https://github.com/r0mko/TSDZ2-Smart-EB ... g/v0.57.13?
Is it compatible with the display firmware 1.0.0 or do I have go back to the 0.8? I remember there were some problems to downgrade the SW102 firmware
 
Nfer said:
HughF wrote: ↑May 06 2020 8:33am
If you want instant performance from a standstill you need to use the torque only version of this firmware, imho... The cadence sensor does not resolve cadence below a certain RPM, and this firmware uses pedal power (speed * torque) to calculate motor current, so you will never get assistance until the cadence increases above the minimum that can be resolved.

Try the r0mko fork (it is based on 0.57 so works nicely with SW102) and let us know if that gives you the performance you want. It certainly did for me.

It is as close as you will get to the marcoq code whilst having all the benefits of the work Casainho has done on the firmware recently.

Is this the latest version https://github.com/r0mko/TSDZ2-Smart-EB ... g/v0.57.13?
Is it compatible with the display firmware 1.0.0 or do I have go back to the 0.8?
The link in my original post has the latest version. I use it with display software version 0.7.0.

If you scroll back through the 'other' thread to around page 200 then r0mko discusses his work there. Note that this fork has the current ramp set to 3* the defined value in the display configuration so it can destroy your blue gear. However it totally rips out on the road - it has very different performance to Casainho's code.
 
HughF said:
If you scroll back through the 'other' thread to around page 200 then r0mko discusses his work there. Note that this fork has the current ramp set to 3* the defined value in the display configuration so it can destroy your blue gear. However it totally rips out on the road - it has very different performance to Casainho's code.

It is risky, right? I will give it a try if I am able to downgrade the display firmware
 
Nfer said:
HughF said:
If you scroll back through the 'other' thread to around page 200 then r0mko discusses his work there. Note that this fork has the current ramp set to 3* the defined value in the display configuration so it can destroy your blue gear. However it totally rips out on the road - it has very different performance to Casainho's code.

It is risky, right? I will give it a try if I am able to downgrade the display firmware
I have done 300kms on this fork on my single speed, riding it hard - no strange noises yet, no issues... It might fail next ride, it might go 2000km. A price I am prepared to pay for the performance.

Downgrading is easy with the nrf toolbox application on Android that I guess you used to flash it in the first place?
 
HughF said:
Nfer said:
HughF said:
If you scroll back through the 'other' thread to around page 200 then r0mko discusses his work there. Note that this fork has the current ramp set to 3* the defined value in the display configuration so it can destroy your blue gear. However it totally rips out on the road - it has very different performance to Casainho's code.

It is risky, right? I will give it a try if I am able to downgrade the display firmware
I have done 300kms on this fork on my single speed, riding it hard - no strange noises yet, no issues... It might fail next ride, it might go 2000km. A price I am prepared to pay for the performance.

Downgrading is easy with the nrf toolbox application on Android that I guess you used to flash it in the first place?
Yes, I used nrf toolbox. What value are you using for the current ramp? Are you limiting the maximum power with the street mode enable? I don't want to kill the blue gear
 
Nfer said:
HughF said:
Nfer said:
HughF said:
If you scroll back through the 'other' thread to around page 200 then r0mko discusses his work there. Note that this fork has the current ramp set to 3* the defined value in the display configuration so it can destroy your blue gear. However it totally rips out on the road - it has very different performance to Casainho's code.

It is risky, right? I will give it a try if I am able to downgrade the display firmware
I have done 300kms on this fork on my single speed, riding it hard - no strange noises yet, no issues... It might fail next ride, it might go 2000km. A price I am prepared to pay for the performance.

Downgrading is easy with the nrf toolbox application on Android that I guess you used to flash it in the first place?
Yes, I used nrf toolbox. What value are you using for the current ramp? Are you limiting the maximum power with the street mode enable? I don't want to kill the blue gear
No, I do not use street mode. My current ramp is set to maximum in the display, which is then multiplied by 3 in the firmware.
My max current is set to 16a in the battery settings section, iirc. I think my battery has a 20a BMS, I am not sure.

I can easily see sustained power outputs of 650w motor power when climbing hills and/or accelerating away from traffic
 
HughF, I see you're now using Casainho et al.'s version 1.0.0. Do the recent changes bring it close(r) to this fork?
 
sparked said:
HughF, I see you're now using Casainho et al.'s version 1.0.0. Do the recent changes bring it close(r) to this fork?
I find the latest 1.0.0 to be as good as the r0mko fork, when it is set up correctly.
 
Thank you r0nko for this great alternative firmware! honestly it suits me much better than casainhos osf and its weak and slow power/cadence based motor control algorithm. i love the sw102 display and thanks to you now i can finally use my favourite display combined with a fine tork only control.

Do you plan to update your firmware to 1.1 or later in the near future? Casainhos ANT project looks quite promissing but depends on a more up to date firmware version. Won‘t change fork and update to test as long as you don’t offer a torque only version.
thx in advance
 
Peacepirate said:
Thank you r0nko for this great alternative firmware! honestly it suits me much better than casainhos osf and its weak and slow power/cadence based motor control algorithm. i love the sw102 display and thanks to you now i can finally use my favourite display combined with a fine tork only control.

Do you plan to update your firmware to 1.1 or later in the near future? Casainhos ANT project looks quite promissing but depends on a more up to date firmware version. Won‘t change fork and update to test as long as you don’t offer a torque only version.
thx in advance

Interesting - I find the latest Casainho code to be equal to the r0mko fork in terms of performance. Actually I now ride in power mode rather than torque mode, I find it less jerky.
 
Back
Top