New TSDZ2 Open Source firmware with Bluetooth interface

Hi Everyone,

Really cool project! I'm looking to get on board and am wondering whether anyone here has some spare boards lying around... It'd make life easier than ordering some myself. I'm in the Netherlands for shipping and would take 2 of them to also upgrade my wife's bike.

Thanks!
Daniel
 
Dear @mspider65;
still a big fan of your project!
I have a question, though: Could you consider implementing a torque calibration option similar to the one mbrusas last versions have?
(3 weight points: min, max and intermediate "27kg" interpolation)
This is done in mbrusas f/w with the highlighted parameters in the snapshot below.

Reason I am asking: I have meanwhile 6 TSDZ2 Motors in the family and their torque sensitivities are really all over the place.
That makes it almost impossible to set the motor-support levels such that we all have roughly the same support at each assistant level.

Please let me know what you think.

Thanks again for this open-source project!
calibration_parameter.JPG

PS: On a related side note: Are you aware of this topic reg. exitation frequency of the torque sensor and its potential relation to the sensitivity:
https://endless-sphere.com/forums/viewtopic.php?f=30&t=116510&p=1719702&hilit=mspider65#p1719702
 
djwlindenaar said:
Hi Everyone,

Really cool project! I'm looking to get on board and am wondering whether anyone here has some spare boards lying around... It'd make life easier than ordering some myself. I'm in the Netherlands for shipping and would take 2 of them to also upgrade my wife's bike.

Thanks!
Daniel

Hi, i have 2 boards left, i'm from the Netherlands....
 
endlessolli said:
Dear @mspider65;
still a big fan of your project!
I have a question, though: Could you consider implementing a torque calibration option similar to the one mbrusas last versions have?

Currently the sensor response is modeled with a line with the two parameters "Torque ADC Offset" and "Torque ADC Factor" and then you can adapt the response according to the sensitivity of your sensor.
Using the new "Torque Sensor Configuration" screen it is very easy to calculate and enter the correct values ​​based on your sensor.

It is however an aspect that can be improved by using a curve (polynomial interpolation) instead of a line.
It's on the to-do list but right now I don't have the time and motivation to do it.
Maybe in the future...


PS: On a related side note: Are you aware of this topic reg. exitation frequency of the torque sensor and its potential relation to the sensitivity:
https://endless-sphere.com/forums/viewtopic.php?f=30&t=116510&p=1719702&hilit=mspider65#p1719702

No i wasn't.
Yes, I assume that by changing the duty cycle of the coil excitation signal it is possible to amplify or attenuate the sensor signal.
However, if the sensor is bad you will still have a bad signal output.
For example, there have been users who have reported having the sensor vary its output by 20/25% of the entire range simply by rotating the pedals without any load.

It can however be a way to normalize the output signal to a certain level so that all the other sensor setup parameters do not depend too much on the level provided by each different sensor.
 
mspider65 said:
Currently the sensor response is modeled with a line with the two parameters "Torque ADC Offset" and "Torque ADC Factor" and then you can adapt the response according to the sensitivity of your sensor.
Using the new "Torque Sensor Configuration" screen it is very easy to calculate and enter the correct values ​​based on your sensor.

It is however an aspect that can be improved by using a curve (polynomial interpolation) instead of a line.
It's on the to-do list but right now I don't have the time and motivation to do it.
Maybe in the future.

Thanks for the feedback, @mspider65

polynomial interpolation is not needed for my use case.
linear interpolation is fine; however, if I understand correctly, you offer 1 point ("Torque ADC Offset") and a slope ("Torque ADC Factor") as parameters to do the interpolation and I did not know how to "translate" that when having 2 points measured for calibration (min and max weight on pedal). But thinking of it I can do trial and error until I find a "Torque ADC Factor" setting, which gives me the desired Torquevalue for a given calibration weight.... I'll try that. (Obvously there is also some simple math behind behind the connection, but I was not able to calculate something which corresponds to the results from mbrusas calculations from the Java screen - there are probably some factors used that I dont know / dont find in the code.)

Anyway - I am fine with trying trial&error for now.
Thanks for pointing me this way!
 
endlessolli said:
polynomial interpolation is not needed for my use case.
linear interpolation is fine; however, if I understand correctly, you offer 1 point ("Torque ADC Offset") and a slope ("Torque ADC Factor") as parameters to do the interpolation and I did not know how to "translate" that when having 2 points measured for calibration (min and max weight on pedal). But thinking of it I can do trial and error until I find a "Torque ADC Factor" setting, which gives me the desired Torque value for a given calibration weight.... I'll try that. (Obvously there is also some simple math behind behind the connection, but I was not able to calculate something which corresponds to the results from mbrusas calculations from the Java screen - there are probably some factors used that I dont know / dont find in the code.)

Anyway - I am fine with trying trial&error for now.
Thanks for pointing me this way!

Yes, "Torque ADC Offset" should be the Torque ADC value with no load and "Torque ADC Factor" is the multiplying factor of the Torque Delta value (Torque ADC value - Torque ADC Offset)

I don't know the mbrusa's SW but I guess from the number of parameters it uses, that the model in its case is a bit more complex.

In our case the calculation is simple.
Parameters:
To = Torque ADC Offset
Tf = Torque ADC Factor
Tv = Current Torque ADC value
Tdelta = Tv - To

For Power Assist Mode:
Ct = Cyclist Torque (Nm) = Tdelta * Tf / 100
Cp = Cyclist Power (W) = Ct* 2 * Pi / 60 * Cadence
Mp = Motor Power = Cp * Power assist factor / 100
Target Current = Motor Power / Battery Voltage

For Torque Assist Mode:
Target Current = Tdelta * Torque assist factor / FIXED_SCALE_FACTOR

So, if you have a "lazy" torque sensor with limited range, you should:
1) for Power Assist mode: increase the Torque ADC Factor parameter
2) for Torque Assist mode: increase the Torque Mode assist level parameters
 
Hi all. I recently bought a secondhand TSDZ2, used emmebrusa's firmware for a bit, now switched to this, mainly because of the features of the app, so first of all thanks @mspider65 for the work!

My setup is:
Bike: TSDZ2 250W
Battery: 36V 13Ah / 468Wh 10S5P
Software: TSDZ2_ESP32v2.1.12.apk (Adapted for Android12+), ESP32: TSDZ2-ESP32-Mainv1.2.1.zip, STM8: TSDZ2-v16.zip

:lowbatt: :lowbatt: :lowbatt:
I think my battery is bad, but am not sure, anyone here who can give me some pointers how to determine that? Or help me out after reading my situation:

Since I'm using this firmware, I'm only getting +- 12km of range, on eco mode, with the default battery settings.
When I'm riding my bike and it shuts down, I can't turn it on by pressing the power button on my display,
If I disconnect the battery & connect again (immediately) I can turn it on by pressing the power button on my display (it works as normal). The battery is then back up to 35.8V (confirmed with multimeter).

This is the log of my battery Voltage & Current, it does not go below the 29V cut off Voltage:
(i stopped a few times during my trip, to unplug and replug the battery):
QqZ1Sq1.png


I measured my cells (CMICR18650F8 3.7V 2600mAh) (10S5P) and they don't seem to be too bad:
3.85 - 3.84 - 3.83 - 3.9 - 3.8 - 3.85 - 3.85 - 3.8 - 3.85 - 3.85
Fully charged my battery is ...V.


Screenshots of other graphs:
- battery setup
- Speed + Motor ERPS
- Battery current + Torque max
- FOC Angle


And If anyone has problems with the Android app on Android 12+:
I'm working on an update to fix this (new permission implementation), here is the repo
 
Hi @mspider65
Congrats for your bt interface and thanks for your effort, I really liked your "man in the middle" design so I ordered a v4 pcb in pcbway. Could you please confirm if the position of d1 diode is fine so I can confirm pcbway to finish the order?
Thanks¡¡
 

Attachments

  • 1.jpg
    1.jpg
    3.4 MB · Views: 693
washichi said:
I think my battery is bad, but am not sure, anyone here who can give me some pointers how to determine that? Or help me out after reading my situation:

Since I'm using this firmware, I'm only getting +- 12km of range, on eco mode, with the default battery settings.
When I'm riding my bike and it shuts down, I can't turn it on by pressing the power button on my display,
If I disconnect the battery & connect again (immediately) I can turn it on by pressing the power button on my display (it works as normal). The battery is then back up to 35.8V (confirmed with multimeter).
If the system goes down, it is most likely the BMS that cuts the power.
The firmware, if it detects a low battery voltage, only stops the motor.

And If anyone has problems with the Android app on Android 12+:
I'm working on an update to fix this (new permission implementation), here is the repo
I don't have an Android 12 device to test.
However Android 12 should support legacy Bluetooth permissions if the APK is compiled with older SDK.
However I will try to update to the new Bluetooth permissions as soon as I have some free time
 
kensender said:
Hi @mspider65
Congrats for your bt interface and thanks for your effort, I really liked your "man in the middle" design so I ordered a v4 pcb in pcbway. Could you please confirm if the position of d1 diode is fine so I can confirm pcbway to finish the order?
Thanks¡¡

Did you ordered more and you are from EU?
 
Has anybody PCB to sell from EU? If not I can order a few if anybody is interested.
 
atlet said:
Has anybody PCB to sell from EU? If not I can order a few if anybody is interested.
Hi, I`m also from EU and i have found seller from Netherlands @marktplaats.nl, but he offers version 3.
Also found this on PCBWay site, but there is no price and also version 3 is shown:
https://www.pcbway.com/project/shareproject/TSDZ2_ESP32.html

I`m new to this and still don`t own motor, but considering it.
My question is can i cut display cable (XH-18) and mount TSDZ2-ESP32 in case (no thermal sensor)?
Flashing TSDZ2 motor controller i guess is possible without disassembling the motor. If i open motor case (to mount ESP32 module), that will void warranty and then will consider installing heatsink plate for better thermal transfer
 
v85 said:
atlet said:
Has anybody PCB to sell from EU? If not I can order a few if anybody is interested.
Hi, I`m also from EU and i have found seller from Netherlands @marktplaats.nl, but he offers version 3.
Also found this on PCBWay site, but there is no price and also version 3 is shown:
https://www.pcbway.com/project/shareproject/TSDZ2_ESP32.html

I`m new to this and still don`t own motor, but considering it.
My question is can i cut display cable (XH-18) and mount TSDZ2-ESP32 in case (no thermal sensor)?
Flashing TSDZ2 motor controller i guess is possible without disassembling the motor. If i open motor case (to mount ESP32 module), than will void warranty and than also will consider installing heatsink plate for better thermal transfer

From PCBWay is minimum order 5 pieces. Price is around $85.

I think that you need this cable: https://www.pswpower.com/products/electric-bicycle-110cm-6pin-vlcd5-xh-18-lcd6-display-tsdz2-speed-sensor-extension-cable-for-tsdz2-mid-drive-?DIST=QERCFA%3D%3D I was thinking also to put it in box and connect with cables, without opening the motor.
 
Also this can help with cooling: https://www.thingiverse.com/thing:5549559

I didn't try it jet.
 
@mspider65:
Still a big fan of your firm- and hardware for the TSDZ2. However, today I noticed a problem: I rode my bike without using your App / coupling it to a phone. I had a long slope down (2-3 km) where I did not have to pedal - probably more than 5 minutes. After the end of the slope, when I pedaled again, I did not get any support. (Display was still on and responsive). Only Powercycling the system resolved it. I then replicated the procedure (long downhill w/o pedaling and w/o coupling w/ the App) and I could replicate the problem (no support). This time, I did not Powercycle, but coupled the App - and Support was immediately working again.
Is this a bug? Do I do something wrong? Can anyone confirm this issue?
 
endlessolli said:
@mspider65:
Still a big fan of your firm- and hardware for the TSDZ2. However, today I noticed a problem: I rode my bike without using your App / coupling it to a phone. I had a long slope down (2-3 km) where I did not have to pedal - probably more than 5 minutes. After the end of the slope, when I pedaled again, I did not get any support. (Display was still on and responsive). Only Powercycling the system resolved it. I then replicated the procedure (long downhill w/o pedaling and w/o coupling w/ the App) and I could replicate the problem (no support). This time, I did not Powercycle, but coupled the App - and Support was immediately working again.
Is this a bug? Do I do something wrong? Can anyone confirm this issue?

I don't see anything in the SW that can cause this problem. There is only one loop that sends a bluetooth notification only if there is an active connection, and the controller knows nothing about if there is an active bluetooth connection.

My opinion is that it could be an electrical problem in the communication between lcd-esp32-controller which occurs only with low power consumption (no active bluetooth connection). Bluetooth and wifi are the most power hungry features of the ESP32.
But these kinds of problems are only notified to the Android app, so in this case there is no way to know ...
Does it only happen downhill?
What level of assistance was set during the long descent?
 
mspider65 said:
endlessolli said:
@mspider65:
Still a big fan of your firm- and hardware for the TSDZ2. However, today I noticed a problem: I rode my bike without using your App / coupling it to a phone. I had a long slope down (2-3 km) where I did not have to pedal - probably more than 5 minutes. After the end of the slope, when I pedaled again, I did not get any support. (Display was still on and responsive). Only Powercycling the system resolved it. I then replicated the procedure (long downhill w/o pedaling and w/o coupling w/ the App) and I could replicate the problem (no support). This time, I did not Powercycle, but coupled the App - and Support was immediately working again.
Is this a bug? Do I do something wrong? Can anyone confirm this issue?

I don't see anything in the SW that can cause this problem. There is only one loop that sends a bluetooth notification only if there is an active connection, and the controller knows nothing about if there is an active bluetooth connection.

My opinion is that it could be an electrical problem in the communication between lcd-esp32-controller which occurs only with low power consumption (no active bluetooth connection). Bluetooth and wifi are the most power hungry features of the ESP32.
But these kinds of problems are only notified to the Android app, so in this case there is no way to know ...
Does it only happen downhill?
What level of assistance was set during the long descent?

Thanks for your response.
This only happened downhill and I was in level 1 (but also changed to level 2 and 3 when I noticed the problem.)

However - today, I rode a similar downhill path and I could not replicate the problem....
So, I agree that this could be also an electrical problem. I will check wiring again, monitor and report back if & when it happens again.

Otherwise still super-happy using your firm- & hardware setup
:thumb:
 
Hi,
Just received the PCB. 8)
Any advice on how to fix it on top of the controller? Is any electric insulation needed?
Thanks¡
 
I`m not familiar and have zero experience with ESP32, but can i use this circuit (w/o thermal sensor shown here)with latest software and how to flash ESP32 board?
 
endlessolli said:
Update: After a couple of reboots of the phone and various BT option toggles - it suddenly worked!
Amazing stuff, @mspider65!

(So far, the ESP32 (development board) is running standalone, as I am still waiting on the ESP board I am planning to use for the bike. Will update

Hi, same problem here. Can discover and connect via bluetooth to de ESP32 with the Android but no matter how many times I reboot the phone or toggle Bluetooth on and off I can´t manage to discover the device in the app :S
Any ideas?
 

Attachments

  • image.png
    image.png
    22.7 KB · Views: 102
Back
Top