TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Electric Motors and Controllers
casainho   10 GW

10 GW
Posts: 4074
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Jul 09 2019 3:02am

Rydon wrote:
Jul 08 2019 12:26am
casainho wrote:
Jul 06 2019 8:26pm
Image

This is the current state of 850C LCD firmware. The graph is missing some data points, I think it is because system is running slow for all the calculations it need to do. I wish I could implement the top white line on the graph, for it be like an envelope.

And I wish human power could be calculated correctly to be shown on the graph...
Looks great. Can I try it out? Do you have a hex file and some instructions?
There are some small issues that make problematic this firmware, things that I can handle myself but would be a problem for final user. I need to finish a few things before release a version, it is taking more time than what I expected but I didn't stopped yet, I really want it and today I will install this 850C LCD over the KT-LCD3 on my girlfriend bicycle, so I really need it working well.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers 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   10 GW

10 GW
Posts: 4074
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Jul 09 2019 3:08am

Kisazul wrote:
Jul 08 2019 9:06pm
After another heavy trip through the mud with water, I decided to disassemble the motor for prevention. There was water behind the gear cover (I am now redoing the protection cover and installing a rubber seal for a tighter connection, later I will show what happened). I took off the torque sensor and was surprised as the surface of the coils became bare. PCB layer disappeared completely. In casainho photo up in some message later does not have this layer either. What could lead to its destruction? Was water mixed with grease? or something different? I will try to restore the sensor, install thin rings from the PCB. And then adjust the sensor with bolts.
It is really nice to disassembly the motor from time to time, clean and grease the gears, etc. I think advanced users should want to do this, specially the ones that use hard his motor!!

My coils are just like that and they work, I think this are a different version of coils, just that.

As we can see by your pictures, the ferrite core on your coils are broken, just like mine although they still work. But the more we touch on them, the more they broke.

Can you please tell me how much springs being the coil are on your torque sensor?? there are 6 holes, 3 of them for 3 round metal parts that are glued on the back of the coil and the other 3 holes should have 3 coils as per TSDZ2 disassembly manual, right?? -- because seems I just have 1 spring or I just loose the other 2 springs...
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers 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   10 GW

10 GW
Posts: 4074
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Jul 09 2019 3:44am

buba wrote:
Jul 08 2019 4:37pm
casainho wrote:
Jul 08 2019 8:51am
I just calibrate my torque sensor and found it can now measure up to 40 kgs, which is 4x more than before and this means I will get 4x more motor power assistance when I stop and after I need a quick and strong response from the motor, like when I am doing mountain biking!!

I am sure we all want a good torque sensor, that is why most of us prefer TSDZ2 over a Bafang. It is a really fun game, to apply more force with our legs and feel a strong answer from the motor!!

I wrote a wiki page with the process I used to calibrate my sensor (note that I did this process twice, on 2 different torque sensors):

How to calibrate the torque sensor --> https://github.com/OpenSource-EBike-fir ... que-sensor

Just looked at the code to check the ADC conversion:

Code: Select all

// ADC torque sensor
#define PEDAL_TORQUE_PER_8_BIT_ADC_STEP_X100                      52 // see note below

/*---------------------------------------------------------

  NOTE: regarding the torque sensor output values

  Torque (force) value found experimentaly.
  
  Measured with a cheap digital hook scale, we found that
  each torque sensor unit is equal to 0.52 Nm. Using the 
  scale it was found that 0.33 kg was measured as 1 torque 
  sensor unit.
  
  Force (Nm) = 1 Kg * 9.18 * 0.17 (0.17 = arm cranks size)
---------------------------------------------------------*/
So the value of 52 is too low due to: Force (Nm) = 1 Kg * 9.18 * 0.17 (0.17 = arm cranks size)

It should be: Force (Nm) = 1 Kg * 9.81 * 0.17 (0.17 = arm cranks size)

And therefore the conversion should be 54, up from 52.

Also noticed it says 0.33 kg per ADC step. Assuming that is 10 bit ADC steps it would mean that the 8 bit ADC steps represent 0.33 * 4 = 1.32 kg. Looking at your new data I see that when applying 40 kg on the pedals you get a delta of 25 ADC steps. This is a conversion of at least 62, up from 54.

Another problem is that the conversion is based on 10 bit values. So for the previous value of 52 it was calculated with:
(1) Force (Nm) = 0.33 * 9.18 * 0.17 ≈ 0.52 -> 52

But should have been calculated:
(2) Force (Nm) = 0.33 * 9.81 * 0.17 ≈ 0.54 -> 54

And with your new data and testing it should be around :
(3) Force (Nm) = 0.4 * 9.81 * 0.17 ≈ 0.67 -> 67

But this only holds true for 10 bit values. The 8 bit values are:

(1) Force (Nm) = 1.32 * 9.18 * 0.17 ≈ 2.05 -> 205

(2) Force (Nm) = 1.32 * 9.81 * 0.17 ≈ 2.20 -> 220

(3) Force (Nm) = 1.6 * 9.81 * 0.17 ≈ 2.67 -> 267

Using the new conversion factor would result in around 5 times higher human power readings. When I was giving full power with the new development firmware I only got around 100 - 150 watts human power, even less than that. With the new conversion factor I would get closer to 500 - 750 watts. Which is more plausible in a high power situation.
Well, I also have very low power values than what I expected. I was looking at the ADC values while riding, to see real values for the torque sensor as also pedal cadence.

For me, one example when I was doing a lot of power were: 20 ADC torque sensor and 45 pedal cadence.

So here is the formula, the same as you wrote:

// torque sensor
#define ADC_STEP_PEDAL_TORQUE_X100 267

/*---------------------------------------------------------
NOTE: regarding torque sensor

Torque (force) value found experimentaly.

Measured with a cheap digital hook scale, we found that
each ADC 8 bits step measures 1.6kgs.
Full ADC range of 10 bits, it can measure as low as 0.4 kgs.

Force (Nm) = 1.6 Kg * 9.81 * 0.17 (0.17 = arm cranks size)
Force per each ADC 8 bits step = 2.67 Nm
---------------------------------------------------------*/

I am considering 1.6 kg per ADC step because: 25 steps for 40 kgs, 40/25 = 1.6. And for the 4 different torque sensors I did measure, on TSDZ2 motors bought on very different months/years, I think the 1.6 Kg per each8 bits ADC step is equal for every of them and so I expect it is equal for everyone.

So now calculating human power for the max possible value of 40 kg force that my well calibrated torque sensor can measure at a relative high cadence of 60:

Power = ((25 adc torque sensor * 267) * 60 pedal cadence * 3.14) / (60 * 100) = 210 watts.

I weight 100 kgs and I can get up using only one of my legs and that means I can give pulses of 100 kgs when I want to fast start, however the torque sensor can't measure that, it can only go up to 40 kgs. In future, trying to extend the range over the 40 kgs by using the 10 bits ADC and some interpolation on the no linear range, I think the sensor can measure maybe up to 60 or 70 kgs max -- that would be good as for mountain biking I feel that I need an high range on the force measured on the torque sensor, so I can have fine control, maybe from motor assisting from 50W up to 500W without me having to change assist levels, only by doing the game of increasing/decreasing the amount of force I do with my legs.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers 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.

chri27.5   10 mW

10 mW
Posts: 33
Joined: Jan 25 2019 9:46am

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

Post by chri27.5 » Jul 09 2019 4:05am

Buongiorno a tutti sono nuovo del forum, mi presento, sono Italiano e scusatemi per eventuali errori di scrittura perché uso il traduttore di Google.
Volevo ringraziare a tutti gli sviluppatori che hanno permesso tutto questo.
Leggendo il problema della taratura del sensore di coppia, volevo sottoporre un problema legato al gioco assiale tra il perno quadro e il suo alloggiamento, ho notato che su quattro motori che che usiamo si è creato un gioco di 0.20 mm, questo sicuramente influenza la distanza del sensore al perno.
Ho realizzato un video dove faccio vedere come si può tranquillamente sistemare inserendo uno spessore di 0.07 mm.
Grazie mille è spero che vi potrà essere di aiuto.
Chri27.5

casainho   10 GW

10 GW
Posts: 4074
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Jul 09 2019 4:09am

chri27.5 wrote:
Jul 09 2019 4:05am
Buongiorno a tutti sono nuovo del forum, mi presento, sono Italiano e scusatemi per eventuali errori di scrittura perché uso il traduttore di Google.
Volevo ringraziare a tutti gli sviluppatori che hanno permesso tutto questo.
Leggendo il problema della taratura del sensore di coppia, volevo sottoporre un problema legato al gioco assiale tra il perno quadro e il suo alloggiamento, ho notato che su quattro motori che che usiamo si è creato un gioco di 0.20 mm, questo sicuramente influenza la distanza del sensore al perno.
Ho realizzato un video dove faccio vedere come si può tranquillamente sistemare inserendo uno spessore di 0.07 mm.
Grazie mille è spero che vi potrà essere di aiuto.
Chri27.5
Hi.

Please post the video on youtube and share with us. I would like to better understand "we have created a 0.20 mm clearance, this definitely affects the distance of the sensor to the pin".
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers 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.

chri27.5   10 mW

10 mW
Posts: 33
Joined: Jan 25 2019 9:46am

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

Post by chri27.5 » Jul 09 2019 4:16am

Image
Attachments
S90709-111505.jpg
Spessore da 0.07 mm in acciaio temperato

chri27.5   10 mW

10 mW
Posts: 33
Joined: Jan 25 2019 9:46am

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

Post by chri27.5 » Jul 09 2019 4:22am

Ciao casainho,
devo capire come postare il video, e la prima volta che uso questo forum.

casainho   10 GW

10 GW
Posts: 4074
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Jul 09 2019 4:25am

chri27.5 wrote:
Jul 09 2019 4:22am
Ciao casainho,
devo capire come postare il video, e la prima volta che uso questo forum.
Just put here the link or

Code: Select all

[youtube]LAST_NUMBERS_OF_YOUTUBE_LINK[/youtube]
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers 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.

chri27.5   10 mW

10 mW
Posts: 33
Joined: Jan 25 2019 9:46am

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

Post by chri27.5 » Jul 09 2019 6:00am

Hi everyone, here's the video link,

https://youtu.be/5dGDz1jzuvc

buba   10 kW

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

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

Post by buba » Jul 09 2019 6:07am

casainho wrote:
Jul 09 2019 3:44am
I weight 100 kgs and I can get up using only one of my legs and that means I can give pulses of 100 kgs when I want to fast start, however the torque sensor can't measure that, it can only go up to 40 kgs. In future, trying to extend the range over the 40 kgs by using the 10 bits ADC and some interpolation on the no linear range, I think the sensor can measure maybe up to 60 or 70 kgs max -- that would be good as for mountain biking I feel that I need an high range on the force measured on the torque sensor, so I can have fine control, maybe from motor assisting from 50W up to 500W without me having to change assist levels, only by doing the game of increasing/decreasing the amount of force I do with my legs.
It is a shame it can not read from 0 to at least 150 kg so we can get really good values. It would be a great feeling. The resolution with your calibrated sensor and maximum force:
Calculated human power for every cadence step and full force on pedals.png
Calculated human power for every cadence step and full force on pedals.png (14.68 KiB) Viewed 1190 times

Kisazul   1 W

1 W
Posts: 53
Joined: Jun 18 2018 10:32pm

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

Post by Kisazul » Jul 09 2019 7:32am

casainho wrote:
Jul 09 2019 3:08am
Kisazul wrote:
Jul 08 2019 9:06pm
After another heavy trip through the mud with water, I decided to disassemble the motor for prevention. There was water behind the gear cover (I am now redoing the protection cover and installing a rubber seal for a tighter connection, later I will show what happened). I took off the torque sensor and was surprised as the surface of the coils became bare. PCB layer disappeared completely. In casainho photo up in some message later does not have this layer either. What could lead to its destruction? Was water mixed with grease? or something different? I will try to restore the sensor, install thin rings from the PCB. And then adjust the sensor with bolts.
It is really nice to disassembly the motor from time to time, clean and grease the gears, etc. I think advanced users should want to do this, specially the ones that use hard his motor!!

My coils are just like that and they work, I think this are a different version of coils, just that.

As we can see by your pictures, the ferrite core on your coils are broken, just like mine although they still work. But the more we touch on them, the more they broke.

Can you please tell me how much springs being the coil are on your torque sensor?? there are 6 holes, 3 of them for 3 round metal parts that are glued on the back of the coil and the other 3 holes should have 3 coils as per TSDZ2 disassembly manual, right?? -- because seems I just have 1 spring or I just loose the other 2 springs...
I have 3 springs. They provide a uniform fit of the coils to each other. I have several motors and all have 3 springs. Apparently you lost. I quite often disassembled the motor for lubrication, as I live in a humid climate. But only this time I found a coil without a PCB cover. Coverage is erased. And my guess is that water got into lithium grease, mixed and spread all around, damaging a thin PCB layer. After all, our sensor is not isolated from the lubricant. But I must say that the motor worked from the torque sensor before opening it!

thineight   100 W

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

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

Post by thineight » Jul 09 2019 7:33am

casainho wrote:
Jul 09 2019 3:08am

Can you please tell me how much springs being the coil are on your torque sensor?? there are 6 holes, 3 of them for 3 round metal parts that are glued on the back of the coil and the other 3 holes should have 3 coils as per TSDZ2 disassembly manual, right?? -- because seems I just have 1 spring or I just loose the other 2 springs...
Casainho, just for info I have 3 springs to place in the three slots between the two coils. The other slots are for the keys on the magnet that prevent it to rotate. Those are the trickier part to keep together in the right place without losing the springs while pressing the sensor assembly back in place.
MTB KTM Ultra 29" - City bike DAYTONA 28"

perryscope   100 W

100 W
Posts: 106
Joined: Jan 06 2019 4:29pm
Contact:

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

Post by perryscope » Jul 09 2019 7:39am

buba wrote:
Jul 06 2019 7:43am

* Have implemented a Torque Assist function. This one only relies on the pedal torque applied. Similar to how the original firmware does and other commercial versions. Very responsive.

* Have implemented a Cadence Assist. This one is useful for some users that need a more traditional ebike. Not added this implementation yet to my GitHub to reduce complexity in testing but planned for next beta.

* eMTB Assist. No introduction needed! Not added yet to reduce complexity but planned for next beta.
Great news Buba

Really looking forward to trying out all of these modes. For me on the Mountain bike its torque assist / eMTB assist all the way, but the Cadence assist is very interesting for my trike rider with the prosthetic Leg. At the moment the plan was to switch to a bafang BBS02 for the trike to test a PAS mode, but if I can test a beta first It may be an even better solution!

Also just a but of feedback we tested V 0.19 last week over 5 days riding 330Km and I have to say it performed fantastically. On the first day we rode (75KM, 900 Meter overall climbing)and it used only 40% battery! Thats a 48V 13aH battery running a 36V motor in high cadence mode. My 17yr old son (green helmet) was riding it so he is a little fitter than me but he said he was using assist quiet a bit and we averaged 20kmph. Very impressed, in comparison i almost went through three 36V 11aH batteries on the Bafang BBS02 equipped towing bike towing my wife in a recumbent trike so usually only get half the range compared to not towing.
Lots of interest about the firmware from alot of the riders. :)
IMG-20190704-WA0003.jpg
Full blog report of the ride here... https://empoweredpeople.co.uk/2019/07/0 ... he-island/
Empowered people support rider and trustee
www.empoweredpeople.co.uk

fi7ippo   10 mW

10 mW
Posts: 24
Joined: Aug 26 2018 2:29am

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

Post by fi7ippo » Jul 09 2019 10:55am

buba wrote:
Jul 07 2019 10:59am
fi7ippo wrote:
Jul 07 2019 6:27am
For calibration the torque sensor the rest value is read every time the unit is powered on, right?
Yes, it is calibrated every time the system is powered on. But it is not calibrated properly in 0.19.0 and previous firmware versions. Noticed it with my particular torque sensor. So I rewrote the calibration process in my development version and now the current and torque are calibrated better and adjusts for every user and their hardware. This also helped to gain a lot of resolution and improved a lot of other things as well.


fi7ippo wrote:
Jul 07 2019 6:27am
So for improve sensor torque experience and resolution it would take a user modifiable parameter regarding the maximum ADC value (the parameter can be easily read from menu 9 - 2 from each user by applying the maximum pressure on the pedals)

Another usefull parameter for fine calibrating the user human power could be an editable parameter that adjust the kg applied for each ADC step (assuming the linear output of sensor)

Thanks guys, your work on this firmware is exceptional!
Yes, assuming the torque is linear it would be possible to further develop tools for higher accuracy. Great comments, thank you!
Hi Buba I've some data from my torque sensor test, and Yes seems the readings are almost linear!
Here there is a video uploaded on youtube of my test
and I've attached data extracted form the video on pdf below
TSDZ2 - Torque Sensor Data.pdf
(429.04 KiB) Downloaded 59 times
I think the best way to adapt the torque sensor to the various users is:

1- Read the rest value of ADC steps during power on and add a low pass filter of one or two ADC steps (for resting value);
2- Create a user parameter that set the ADC value for a know Force applied maybe 30Kg could be a good value for a well calibrated sensor;

Thats all doing this we have everything we need to perfectly calibrate each unit!

Doing this, the maximum ADC parameter is no longer needed!

I also have a spare brand new torque sensor for another test, so I'll repeat the same test and post the results in a few days, but, from what I've seen if the value at rest is between 25 and 40 the sensor can be defined as linear and greatly simplify the logic. This is the only really important thing.

For Buba, I hope to see soon your new Beta Torque Sensor version I'm really forward to see this huge improvement!

Thank You guys!

buba   10 kW

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

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

Post by buba » Jul 09 2019 4:26pm

fi7ippo wrote:
Jul 09 2019 10:55am
Hi Buba I've some data from my torque sensor test, and Yes seems the readings are almost linear!
Here there is a video uploaded on youtube of my test
and I've attached data extracted form the video on pdf below TSDZ2 - Torque Sensor Data.pdf
What an amazing job! :bigthumb: I think I speak for the whole community when I say that what you have done is very valuable and we all are very grateful. Thanks for the data, time and the money invested in instruments! Together with data provided by Casainho and his great tutorial for adjusting the torque sensor we now know what the appropriate next steps are. Also, a big thanks to every other user that has helped to give the community a better understanding!


fi7ippo wrote:
Jul 09 2019 10:55am
I think the best way to adapt the torque sensor to the various users is:

1- Read the rest value of ADC steps during power on and add a low pass filter of one or two ADC steps (for resting value);
2- Create a user parameter that set the ADC value for a know Force applied maybe 30Kg could be a good value for a well calibrated sensor;

Thats all doing this we have everything we need to perfectly calibrate each unit!
1. Already fixed in the new firmware.
2. Nothing to add to your suggestion, will do!


fi7ippo wrote:
Jul 09 2019 10:55am
Doing this, the maximum ADC parameter is no longer needed!
The new code has no max ADC value so already fixed!


fi7ippo wrote:
Jul 09 2019 10:55am
I also have a spare brand new torque sensor for another test, so I'll repeat the same test and post the results in a few days, but, from what I've seen if the value at rest is between 25 and 40 the sensor can be defined as linear and greatly simplify the logic. This is the only really important thing.

For Buba, I hope to see soon your new Beta Torque Sensor version I'm really forward to see this huge improvement!

Thank You guys!
Great!

Here is a chart comparing Casainho's values to your values in the same range:
chart.png
chart.png (14.17 KiB) Viewed 1037 times

buba   10 kW

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

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

Post by buba » Jul 09 2019 4:57pm

perryscope wrote:
Jul 09 2019 7:39am
Really looking forward to trying out all of these modes. For me on the Mountain bike its torque assist / eMTB assist all the way, but the Cadence assist is very interesting for my trike rider with the prosthetic Leg. At the moment the plan was to switch to a bafang BBS02 for the trike to test a PAS mode, but if I can test a beta first It may be an even better solution!
Glad you are looking forward to the new riding modes! The Cadence Assist is something you brought to my attention and if I remember correctly you mentioned it would benefit some users to have that riding mode. Did not forget that.


perryscope wrote:
Jul 09 2019 7:39am
Also just a but of feedback we tested V 0.19 last week over 5 days riding 330Km and I have to say it performed fantastically. On the first day we rode (75KM, 900 Meter overall climbing)and it used only 40% battery! Thats a 48V 13aH battery running a 36V motor in high cadence mode. My 17yr old son (green helmet) was riding it so he is a little fitter than me but he said he was using assist quiet a bit and we averaged 20kmph. Very impressed, in comparison i almost went through three 36V 11aH batteries on the Bafang BBS02 equipped towing bike towing my wife in a recumbent trike so usually only get half the range compared to not towing.
Lots of interest about the firmware from alot of the riders. :)

IMG-20190704-WA0003.jpg

Full blog report of the ride here... https://empoweredpeople.co.uk/2019/07/0 ... he-island/
Absolutely wonderful and what a scenery! Hope we get more users onboard :wink:

Zeggi   10 µW

10 µW
Posts: 5
Joined: Jul 09 2019 5:23pm

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

Post by Zeggi » Jul 09 2019 5:30pm

Deleted
Last edited by Zeggi on Jul 10 2019 3:34pm, edited 1 time in total.

casainho   10 GW

10 GW
Posts: 4074
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Jul 10 2019 5:23am

buba wrote:
Jul 09 2019 4:26pm
Here is a chart comparing Casainho's values to your values in the same range:
Buba, now that I have the same formula as you for the human power (which do not depends as much as before from cadence), and that I have 850C showing a numeric field and a graph for human power, I see that I have a lot of variation of human power and I guess the issue is that the system is fast enough to read the peaks and the zeros of the torque sensor value and I guess we should do as KT firmware is doing, as Stancecoke did mention, read the value each 20 PAS magnet transition, then store the max value and finally apply the value for average of a sinewave -- can I do this or are you doing this already?

I do not feel on the motor the variations on the human power measurements but I guess that his due to PWM "slow change" speed and maybe inertia of the motor, etc.

And by the way, reading more carefully the torque sensor of my girlfriend I found that it is really different as it has about double of the resolution per kg compared to others and also it measure a value over 100, while others measure max about 80(I tested to touch with sensor on magnets and it never did measure more than 80).

So, for calibration we will need to setup on LCD the rate of ADC steps per each kg.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers 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.

fi7ippo   10 mW

10 mW
Posts: 24
Joined: Aug 26 2018 2:29am

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

Post by fi7ippo » Jul 10 2019 5:48am

buba wrote:
Jul 09 2019 4:26pm
fi7ippo wrote:
Jul 09 2019 10:55am
I think the best way to adapt the torque sensor to the various users is:

1- Read the rest value of ADC steps during power on and add a low pass filter of one or two ADC steps (for resting value);
2- Create a user parameter that set the ADC value for a know Force applied maybe 30Kg could be a good value for a well calibrated sensor;

Thats all doing this we have everything we need to perfectly calibrate each unit!
1. Already fixed in the new firmware.
2. Nothing to add to your suggestion, will do!
I am very happy that you like the idea, but I was thinking, and I believe that if it is not too much trouble, and there is enough memory space, the ideal would be to have two parameters that can be changed by the user:

1- User calibration weight available with an approximation of 0.1 or 0.5 kg (this is because it would be difficult for everyone to have an identical weight to be applied for the ADC reading);

2- ADC value detected by applying the calibration weight;

By doing so, we have 2 points that are enough to accurately calculate the linearity of each sensor, which could be very different from unit to unit, as Casainho discovered!

Thanks Buba, I hope I haven't complicated coding too much!

Have a nice day

buba   10 kW

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

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

Post by buba » Jul 10 2019 6:38am

casainho wrote:
Jul 10 2019 5:23am
buba wrote:
Jul 09 2019 4:26pm
Here is a chart comparing Casainho's values to your values in the same range:
Buba, now that I have the same formula as you for the human power (which do not depends as much as before from cadence), and that I have 850C showing a numeric field and a graph for human power, I see that I have a lot of variation of human power and I guess the issue is that the system is fast enough to read the peaks and the zeros of the torque sensor value and I guess we should do as KT firmware is doing, as Stancecoke did mention, read the value each 20 PAS magnet transition, then store the max value and finally apply the value for average of a sinewave -- can I do this or are you doing this already?
Thanks for asking!

I do not want to stop you in any way so you can do what you think it best. But I am hoping to be finished with everything by the end of the week and maybe sooner. So if you can wait it would be great. I have done some work to increase the control resolution and make a faster response that reacts almost instantly to force changes on the pedals. Maybe this will solve the slow response you have!! I would love for you to test this by the end of the week when I am finished and maybe this will give you the better feeling you are looking for without adding torque sensing code to the PWM interrupt and making it slower.

Also, for better response, it is equally important to have a good current control with finer resolution. We now have around 40 watts per step and I will decrease this to 10 watts with better filtering without making PWM interrupt slower!! Will also make the system even more responsive! If you think it is okay to wait a couple of days that would be great but it is definitely your choice to do whatever you feel like if you can not wait.

casainho wrote:
Jul 10 2019 5:23am
And by the way, reading more carefully the torque sensor of my girlfriend I found that it is really different as it has about double of the resolution per kg compared to others and also it measure a value over 100, while others measure max about 80(I tested to touch with sensor on magnets and it never did measure more than 80).

So, for calibration we will need to setup on LCD the rate of ADC steps per each kg.
Yes this is something I am planning to add today!
Last edited by buba on Jul 10 2019 7:00am, edited 1 time in total.

buba   10 kW

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

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

Post by buba » Jul 10 2019 6:57am

fi7ippo wrote:
Jul 10 2019 5:48am
I am very happy that you like the idea, but I was thinking, and I believe that if it is not too much trouble, and there is enough memory space, the ideal would be to have two parameters that can be changed by the user:

1- User calibration weight available with an approximation of 0.1 or 0.5 kg (this is because it would be difficult for everyone to have an identical weight to be applied for the ADC reading);

2- ADC value detected by applying the calibration weight;

By doing so, we have 2 points that are enough to accurately calculate the linearity of each sensor, which could be very different from unit to unit, as Casainho discovered!

Thanks Buba, I hope I haven't complicated coding too much!

Have a nice day
I will do my best and try to manage the little space left. The first beta that comes is not final and will become better with feedback!

I have added so many functions and optimized so much space it is insane. But there is a limit. Trying to make the firmware react so good that we do not need Startup Boost and get some space back. But I think some have needed that function because of the inaccurate human power calculations and lack of assistance during startup. This is one of the things I have tried to solve.

But at the same time I do not want to remove it as some users might want to keep it anyway :( Also I am not in a position to make these kind of decisions so am trying to do my best and still keep everything as is.

In short, will do my best!

dameri   100 W

100 W
Posts: 146
Joined: Sep 20 2018 10:57am

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

Post by dameri » Jul 10 2019 11:07am

fi7ippo wrote:
Jul 10 2019 5:48am
buba wrote:
Jul 09 2019 4:26pm
fi7ippo wrote:
Jul 09 2019 10:55am
I think the best way to adapt the torque sensor to the various users is:

1- Read the rest value of ADC steps during power on and add a low pass filter of one or two ADC steps (for resting value);
2- Create a user parameter that set the ADC value for a know Force applied maybe 30Kg could be a good value for a well calibrated sensor;

Thats all doing this we have everything we need to perfectly calibrate each unit!
1. Already fixed in the new firmware.
2. Nothing to add to your suggestion, will do!
I am very happy that you like the idea, but I was thinking, and I believe that if it is not too much trouble, and there is enough memory space, the ideal would be to have two parameters that can be changed by the user:

1- User calibration weight available with an approximation of 0.1 or 0.5 kg (this is because it would be difficult for everyone to have an identical weight to be applied for the ADC reading);

2- ADC value detected by applying the calibration weight;

By doing so, we have 2 points that are enough to accurately calculate the linearity of each sensor, which could be very different from unit to unit, as Casainho discovered!

Thanks Buba, I hope I haven't complicated coding too much!

Have a nice day
Excuse me for coming to this technical discussion. How does the driver's weight work? At least I sit in the saddle practically every time I cycle. So I don't push my pedal at full weight almost ever. And I think many others do the same when driving on an electric bike.

thineight   100 W

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

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

Post by thineight » Jul 10 2019 12:16pm

buba wrote:
Jul 10 2019 6:57am
fi7ippo wrote:
Jul 10 2019 5:48am
I am very happy that you like the idea, but I was thinking, and I believe that if it is not too much trouble, and there is enough memory space, the ideal would be to have two parameters that can be changed by the user:

1- User calibration weight available with an approximation of 0.1 or 0.5 kg (this is because it would be difficult for everyone to have an identical weight to be applied for the ADC reading);

2- ADC value detected by applying the calibration weight;

By doing so, we have 2 points that are enough to accurately calculate the linearity of each sensor, which could be very different from unit to unit, as Casainho discovered!

Thanks Buba, I hope I haven't complicated coding too much!

Have a nice day
I will do my best and try to manage the little space left. The first beta that comes is not final and will become better with feedback!

I have added so many functions and optimized so much space it is insane. But there is a limit. Trying to make the firmware react so good that we do not need Startup Boost and get some space back. But I think some have needed that function because of the inaccurate human power calculations and lack of assistance during startup. This is one of the things I have tried to solve.

But at the same time I do not want to remove it as some users might want to keep it anyway :( Also I am not in a position to make these kind of decisions so am trying to do my best and still keep everything as is.

In short, will do my best!
Thanks for the effort and the new ideas guys! This project has now the right people onboard to obtain a great product!! :thumb: :thumb:
I will try to test the range of my torque sensor in the next days to see if it is linear or not..
Is it sufficient to have the bike on the ground (brakes activated) and apply the force on one pedal only with a luggage scale? Any better idea?

Thanks again
MTB KTM Ultra 29" - City bike DAYTONA 28"

casainho   10 GW

10 GW
Posts: 4074
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Jul 10 2019 1:13pm

thineight wrote:
Jul 10 2019 12:16pm
I will try to test the range of my torque sensor in the next days to see if it is linear or not..
Is it sufficient to have the bike on the ground (brakes activated) and apply the force on one pedal only with a luggage scale? Any better idea?
measuring the force using a digital fish scale (note that pedals must be horizontal and you should apply force on vertical)

Yes, keep brakes active.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers 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.

flufferty   100 mW

100 mW
Posts: 37
Joined: Apr 22 2017 4:00pm

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

Post by flufferty » Jul 10 2019 1:33pm

I may be completely out of the loop here, but why do we need the human power to be accurate?
It seems that all the TSDZ2-units have differently calibrated sensors, and perhaps the stock firmware is compensating for that (undocumented eeprom-data?), perhaps it isn't.

Couldn't we include a calibration routine that takes the resting value, and then records the highest torque value read, and uses that for dynamically applying the power-factor. (given we don't need real-watt human power, we only need a deterministic torque-sensor range)

The firmware could continuously save the highest torque recorded, and use that. So the harder you press your bike (torque sensor range allowing) the higher you'll raise the torque-range (until its saturated, or you cant push it more).
So given a "well-calibrated" physical torque sensor, you will get a larger/finer range, but someone with a badly calibrated physical torque sensor, will have the same range, but with worse resolution.

If needed, perhaps a new "weaker" person wants to use THAT motor, you reset the calibrated value in a menu-option.
With the above option of "dynamic" high-point, a child could ride the motor and enjoy it's full benefits, even without reaching the 40kg or so where the torque sensors seems to max out.

Post Reply