OpenSourceEBike / TSDZ2-Smart-EBike

Flexible OpenSource firmware for TongSheng TSDZ2 mid drive ebike motor
GNU General Public License v3.0
251 stars 130 forks source link

I broke my cadence sensor, workaround in software #129

Open djwlindenaar opened 4 years ago

djwlindenaar commented 4 years ago

So my cadence sensor broke (in a similar way as here )

I'm now on 0.20.0-beta1, so I thought I could still run the motor in Torque mode, since the torque sensor is still working fine. Only, I needed to adapt the code to ignore the cadence signal. I got that working fine (still need to test on a longer drive, but it seems OK during the test drive).

Actually this got me wondering whether we really need the candence sensor. OK, when it's there it is quite nice and allows for quick response to stopping the pedaling. On the other hand, if it is broken, the other sensors (torque and motor speed) should still allow for estimation of the cadence as follows:

if (Torque > 0) // maybe plus some offset to make it more stable
  cadence = motor_cadence * transmission_ratio
else
  cadence = 0

Am I missing something? If you all think this could work, we can implement a setting which would allow anyone with a broken cadence sensor to keep using the bike. Simply by enabling that setting...