New TSDZ2 Open Source firmware with Bluetooth interface

mspider65 said:
Yes a reistor voltage divider works well, but in the other direction, a 5v buffer/driver is useful not only for safety reason but also to have a better connection reliability.
The cable that goes to the display is quite long an the noise margin using a 3.3v driver and a 5v receiver is small and, even though the cable going to the controller is short, it is still in a noisy environment with quite high currents switching at PWM frequency.

Hi; just wanted to report back:
I got it to work! Great, great project @mspider65!

As stated, I build it off available parts. (A bare ESP32Wroom, a tiny DC-DC Step Down Module 6-55V to 5V plus AMS1117 3.3V regulator, stacked ontop of each other.) But you and @Beli were correct in that my intended level shifter circiut (TXB0108) did NOT work! (The communication to the motor-controller did work, but not towards the display - lots of CRC errors in debug seen.
So I tried for the Rx side direct connection and the Tx side a Ohm voltage divider (both for controller & LCD). That works so far. I still need to see, if it works reliably. I cross my fingers it does, as my setup is outside of the controller / motor case.
I am happy how I got the individual parts squeezed together into a small enclosure, which will hide somewhere ontop of the motor. (Although direct soldering of the bare ESP module is tricky...)
Thanks again for sharing this, @mspider. Especially, the hall optimization, the great App and the entire concept of the 'man-in-the-middle approach'!
IMG_1657.JPG
 

Attachments

  • IMG_1658.JPG
    IMG_1658.JPG
    2.3 MB · Views: 1,711
endlessolli said:
Hi; just wanted to report back:
I got it to work! Great, great project @mspider65!

As stated, I build it off available parts. (A bare ESP32Wroom, a tiny DC-DC Step Down Module 6-55V to 5V plus AMS1117 3.3V regulator, stacked ontop of each other.) But you and @Beli were correct in that my intended level shifter circiut (TXB0108) did NOT work! (The communication to the motor-controller did work, but not towards the display - lots of CRC errors in debug seen.
So I tried for the Rx side direct connection and the Tx side a Ohm voltage divider (both for controller & LCD). That works so far. I still need to see, if it works reliably. I cross my fingers it does, as my setup is outside of the controller / motor case.
I am happy how I got the individual parts squeezed together into a small enclosure, which will hide somewhere ontop of the motor. (Although direct soldering of the bare ESP module is tricky...)
Thanks again for sharing this, @mspider. Especially, the hall optimization, the great App and the entire concept of the 'man-in-the-middle approach'!
IMG_1657.JPG

Hi, I'm glad to see everything worked out well.
At first I also used a solution like yours.
I guess it is not easy to solder the bare ESP32 Wroom module. Others have successfully used the ESP32 DevKit board which is bigger and easier to solder but clearly then you need a slightly bigger case than yours.
 
May i suggest another approach to an android app? Why not use the wifi of the esp32 as a hotspot, and use a browser based display?
 
Hey Guys, have my bike running with the esp32 for 2 years now but I would like it to start up in power mode iso torque mode.
Does anyone know how to get this done?
 
mspider65 said:
Wimpy747 said:
Hey Guys, have my bike running with the esp32 for 2 years now but I would like it to start up in power mode iso torque mode.
Does anyone know how to get this done?

Everything is in the wiki.

sorry!

But thanks for the answer!
 
Hi,

Really great work!

I would need some advise ordering the board.
pcbway told me, that there are some parts not available.

Please see the attached calc sheet.

Can i replace item #20 with the suggested? Are there alternatives for item #1?
 

Attachments

  • Question T-M7W43264A-5sets-BOM_TSDZ2-ESP32-v4(2022-03-26).xls
    108.5 KB · Views: 36
Deadrabbit said:
Hi,

Really great work!

I would need some advise ordering the board.
pcbway told me, that there are some parts not available.

Please see the attached calc sheet.

Can i replace item #20 with the suggested? Are there alternatives for item #1?

For Item #20 the replacement is OK (it is just a header)
For Item #1 an alternative could be BZX584C5V1. But there are many other 5.1V Zener diodes with SOD-523 footprint.
 
Hi,

thanks a lot again for your work. I've ordered five peaces of the board.

Are there plans, to adapt the firmware also for the 860c Display?

As i understand, the ESP32 works only with the stock displays.
 
The 860c is for Bafang motors. Therefore it should use a different protocoll than the Tongsheng motor.

This leads me to conclude, that it would not work with the ESP32.

Is this correct?
 
Just wanted to say thanks again to @mspider65
Over the wintertime, I built a system according to the Github instructions (a bare bone version; see my earlier posts from Dec) - but I never had the chance to actually use it, as my bike was in a different location.
Now I am where the bike is and today I swapped the TSDZ2 (running mbrusas 1-20.1B OSF) to an 'upgraded' one running mspider's soft- & hardware. (complete and easy swap, as I had a backup TSDZ2)

Really, really cool! I could not test it throughly yet, but everything works as expected, the motor sounds even smoother than before and is very responsive, the App is working lag-free and has a clear layout.

-> Thanks again!!!
 
.... now that I tested it a bit more, I am wondering how / if I can do a torque calibration through your App?
(I have the small xh-18 display, so no calibration possible there, as far as I know)
The reason I am wondering: I get on the right side roughly only half the torque than on hte left side (for equel pressure).
I think for that reason I get fluktuating support within 1 pedal rotation,
(That is also whay I am very interested in the frimware updates you discussed in another thread here on ES)
But 1st I would get the sensor calibrated - i.e. having roughly the same reading for left & right pedal pressure.
 
endlessolli said:
.... now that I tested it a bit more, I am wondering how / if I can do a torque calibration through your App?
(I have the small xh-18 display, so no calibration possible there, as far as I know)
The reason I am wondering: I get on the right side roughly only half the torque than on hte left side (for equel pressure).
I think for that reason I get fluktuating support within 1 pedal rotation,
(That is also whay I am very interested in the frimware updates you discussed in another thread here on ES)
But 1st I would get the sensor calibrated - i.e. having roughly the same reading for left & right pedal pressure.

No way to solve this problem with the calibration.
Calibration is only the definition of a function which, given the ADC value of the Torque sensor, provides the real Torque value (Nm).
The SW doesn't have a reference position of the pedals (the PAS sensor doesn't provide a 0 reference position) and for this reason the SW is not able to adjust the torque value according to the pedal position.

Probably the axle, in addition to torsion (which is normal), is subject to bending.
Try to fix the problem at the hardware level.
1) Check the axle carefully if it doesn't have any small cracks
2) Try adding a bearing. (Especially if you have an axle extension for a wider bottom bracket).
3) The axle is not symmetrical along 360 degrees; try to disassemble and reassemble the cranks by turning them +/-90 degrees.
 
mspider65 said:
endlessolli said:
....
The reason I am wondering: I get on the right side only roughly half the torque than on the left side (for equal pressure).
I think for that reason I get fluctuating support within 1 pedal rotation,
(That is also why I am very interested in the firmware updates you discussed in another thread here on ES)
...

No way to solve this problem with the calibration.
Calibration is only the definition of a function which, given the ADC value of the Torque sensor, provides the real Torque value (Nm).
The SW doesn't have a reference position of the pedals (the PAS sensor doesn't provide a 0 reference position) and for this reason the SW is not able to adjust the torque value according to the pedal position.

Probably the axle, in addition to torsion (which is normal), is subject to bending.
Try to fix the problem at the hardware level.
1) Check the axle carefully if it doesn't have any small cracks
2) Try adding a bearing. (Especially if you have an axle extension for a wider bottom bracket).
3) The axle is not symmetrical along 360 degrees; try to disassemble and reassemble the cranks by turning them +/-90 degrees.

Thanks for the feedback!
(I thought that if I could make the steepness of the calibration curve double on the right side compared to the left side, I could compensate the difference in sensitivity? But in any case a clean hardware fix as you suggested would be much better.) ->

Reg. 1) This is a brand new replacement axle / torquesensor unit, so it should not have cracks
Reg. 2) I have already extra bearings on both sides (3 in total)
reg. 3) I did not think about this non-symmetry (sensor vs pedal orientation)! Thanks for that suggestion - I will try that & report back!
 
hmmm - the more I investigate, the more confused I am....

So, rotating the Pedals by 90deg DOES makes a difference - but the bigger difference comes from in which Pedal-Position I turn the system on (-> Zeroing the torque-value):
Looking at the 'raw' ADC values, they range from 195 to 215 depending on what the Pedal Position (angle) is (- all without weight on the Pedals).So, this gives already a variation of '20'.

The next strange thing: Putting my max weight (100kg) on either pedal, I only achieve a max ADC value of 250.

So, the ADC range from 'no weight' (195 to 215) to 'max weight' (250) is pretty small - is that normal / an acceptable range??

Also: How does your software know which ADC range it can expect?

(I am asking all this, because I have the feeling that I do not get good support from the motor currently.
Pls note that I think that this is looks like a hardware problem not related to your Software / Firmware. Unfortunately, this motor never ran with a different Firmware...)
 
endlessolli said:
hmmm - the more I investigate, the more confused I am....

So, rotating the Pedals by 90deg DOES makes a difference - but the bigger difference comes from in which Pedal-Position I turn the system on (-> Zeroing the torque-value):
Looking at the 'raw' ADC values, they range from 195 to 215 depending on what the Pedal Position (angle) is (- all without weight on the Pedals).So, this gives already a variation of '20'.

The next strange thing: Putting my max weight (100kg) on either pedal, I only achieve a max ADC value of 250.

So, the ADC range from 'no weight' (195 to 215) to 'max weight' (250) is pretty small - is that normal / an acceptable range??

Also: How does your software know which ADC range it can expect?

(I am asking all this, because I have the feeling that I do not get good support from the motor currently.
Pls note that I think that this is looks like a hardware problem not related to your Software / Firmware. Unfortunately, this motor never ran with a different Firmware...)

If the raw torque ADC value without any weight on pedals changes with the position of the pedals, the problem should be electrical not mechanical.
Perhaps the two discs of the torque sensor are not perfectly matched? Are the springs correctly positioned?

Regarding the torque calculation, the SW at startup reads the ADC value of the torque sensor and saves this value as a zero reference value (this is the reason why you shouldn't put your feet on the pedal during power up).
it is also possible not to have the zero reference calculated at startup by specifying its value directly in the configuration parameters.
Then the SW calculates the difference between the actual ADC value and the zero reference value (torque ADC Delta).
For power mode then the SW multiplies the torque ADC delta by the config. parameter "Torque ADC factor" to calculate the actual torque in Nm.
Then, if you have a limited torque ADC range you should increase this parameter.
For Torque mode instead, the delta is multiplied by the current torque level assist factor.
Again, limited torque range ‐> increase the torque mode assist factors.
 
mspider65 said:
If the raw torque ADC value without any weight on pedals changes with the position of the pedals, the problem should be electrical not mechanical.
Perhaps the two discs of the torque sensor are not perfectly matched? Are the springs correctly positioned?

Regarding the torque calculation, the SW at startup reads the ADC value of the torque sensor and saves this value as a zero reference value (this is the reason why you shouldn't put your feet on the pedal during power up).
it is also possible not to have the zero reference calculated at startup by specifying its value directly in the configuration parameters.
Then the SW calculates the difference between the actual ADC value and the zero reference value (torque ADC Delta).
For power mode then the SW multiplies the torque ADC delta by the config. parameter "Torque ADC factor" to calculate the actual torque in Nm.
Then, if you have a limited torque ADC range you should increase this parameter.
For Torque mode instead, the delta is multiplied by the current torque level assist factor.
Again, limited torque range ‐> increase the torque mode assist factors.

Thanks for your help on this!
It could be that the disks have a 'wobble' causing the fluctuation of the raw ADC baseline (I bought this broken motor and repaired it - there was some mistreatment on one of the disks, if I remember correctly... )

Now to the compensation of my limited torque range in power mode (my preferred mode):
When you state to adjust
'the config. parameter "Torque ADC factor"' - is that the "Torque sensor ADC step" Parameter
(w/ default value of 67) in the "System" menu of "Bike Configuration" in your App?

Thanks again for your help on this!

(Also - is there an outlook when your new firmware version might be ready? If I understand correctly, you are averaging torque data form a complete pedal rotation; that could me help a lot with the fluctuation I am seeing, I guess.)
 
endlessolli said:
Thanks for your help on this!
It could be that the disks have a 'wobble' causing the fluctuation of the raw ADC baseline (I bought this broken motor and repaired it - there was some mistreatment on one of the disks, if I remember correctly... )

Now to the compensation of my limited torque range in power mode (my preferred mode):
When you state to adjust
'the config. parameter "Torque ADC factor"' - is that the "Torque sensor ADC step" Parameter
(w/ default value of 67) in the "System" menu of "Bike Configuration" in your App?

Thanks again for your help on this!

(Also - is there an outlook when your new firmware version might be ready? If I understand correctly, you are averaging torque data form a complete pedal rotation; that could me help a lot with the fluctuation I am seeing, I guess.)

Yes, for Power Mode you have to increase the "Torque Sensor ADC Step" and you have to manually enter in the configuration the Torque ADC Offset (the zero torque ADC reference), but if you have a maximum range of 40 and a fluctuation of 20, I think you can't satisfactorily solve the problem with the software.

Regarding the new version, unfortunately at the moment I am not able to use the bike, but soon I will be able to start again and therefore I should be able to test the new version well.
 
mspider65 said:
Yes, for Power Mode you have to increase the "Torque Sensor ADC Step" and you have to manually enter in the configuration the Torque ADC Offset (the zero torque ADC reference), but if you have a maximum range of 40 and a fluctuation of 20, I think you can't satisfactorily solve the problem with the software.

Regarding the new version, unfortunately at the moment I am not able to use the bike, but soon I will be able to start again and therefore I should be able to test the new version well.

... with Torque Sensor ADC Step = 100 and setting T ADC Offeset = 205 (mean of baseline min and max) I get a decent reaction.
Thanks - again! (Also I finally understand now, what these parameters mean / do)
I will ride with these values for now - until I have time to dismantle the unit.

Other than that: I cross my fingers for your firmware-testing!
 
Hi. I'm looking at getting some of these boards made.
The DDZ9689T-7 Zener Diode 5.1V SOD523 is out of stock.
Would anyone be able to suggest an alternative part?
 
kyej said:
Hi. I'm looking at getting some of these boards made.
The DDZ9689T-7 Zener Diode 5.1V SOD523 is out of stock.
Would anyone be able to suggest an alternative part?

This was already asked and answered by @mspider65 a couple of entries up in this thread:
"...alternative [for DDZ9689T-7] could be BZX584C5V1. But there are many other 5.1V Zener diodes with SOD-523 footprint."
Hope this helps.
 
@mspider65

I was just about to implement some changes in my adapted ESP32 LCD version concerning torque (my earlier recorded Torque/'Newton table to get reasonable human power values and connected to that I was wondering if it would make sense to linearize the torque values like it was done for other displays before).
Now I had a look at your resent changes and my question now: what is the idea behind your "torque smoothing"?
 
Back
Top