New "TSDZ2 Torque Sensor Central Motor"

jbalat said:
Casainho no this won’t work for everyone.
You need to read the (max for 1 second) torque adc upon startup of the controller and then add +2 to set as the minimum
I bet that’s what most torque sensing bikes do.

The torque calibration should only be accessed from a sub menu and not every time the motor starts up, ie go into a setup routine measure the adc value and then store it. The motor on power up then should access that value.

Perhaps every 100 starts you could put up a screen message to re calibrate if needed.
 
This is the way I plan to prototype the development for the motor temperature sensor firmware.

You see, the temperature sensor is very cheap bought on Ebay as also that STM8 prototype development board:

 
Waynemarlow said:
jbalat said:
Casainho no this won’t work for everyone.
You need to read the (max for 1 second) torque adc upon startup of the controller and then add +2 to set as the minimum
I bet that’s what most torque sensing bikes do.

The torque calibration should only be accessed from a sub menu and not every time the motor starts up, ie go into a setup routine measure the adc value and then store it. The motor on power up then should access that value.

Perhaps every 100 starts you could put up a screen message to re calibrate if needed.
I like much this idea of calibration start from the LCD3, maybe they are also doing this on factory production. Maybe user need to do only one time and user will need anyway to setup all the possible configuration values on LCD3 at the very first time.

Maybe user could on LCD3:
1. start auto calibration of ADC min value
2. set ADC max value
3. set value of ADC steps of 10kgs of force on the pedals (needed to calc the pedal human power)
 
jbalat said:
Walk mode yes long press down to turn on then press the button again to turn off should work well too
I think that can be very dangerous, let's say you are on the metro and you fall over your bicycle and the motor is running... You can't turn it off now and the wheel can cut your fingers, your air or something if you touch with them on the bicycle chain!! That can happen to you or other if they fall to over you bicycle.

I really prefer the turn off delay, as it minimizes that possible problems.
 
casainho said:
I like much this idea of calibration start from the LCD3, maybe they are also doing this on factory production. Maybe user need to do only one time and user will need anyway to setup all the possible configuration values on LCD3 at the very first time.

Maybe user could on LCD3:
1. start auto calibration of ADC min value
2. set ADC max value
3. set value of ADC steps of 10kgs of force on the pedals (needed to calc the pedal human power)

The one thing that has been a real pain in the time of owning the TDSZ2 engine was giving it to other riders and getting complaints back that it wasn't working, its just natural to keep one foot on a pedal as you start the power up, not sure why but it just seems natural to do and as soon as you stop and restart it without said foot on pedal, full Ebike power is restored. Almost certainly the factory engine re calibrates every time and I do wonder some times whether that gives odd readings as sometimes the motor can be more sensitive than at other times, you only need a bit of back tension on the motor and that will be the case.

Max value should be relatively easy, simple lock the brakes and stand on one pedal.

Not sure that we need to really be as precise as loading the pedals to obtain human power values, statistically the average person can produce at most X Watts of power, simply use a statistical theoretical value, it may not be precise but probably good enough for what we want. At some stage we will get riders on this thread that have been tested or who do ride with power meters and they should be able to fairly quickly work out what value gives a reasonably accurate figure.
 
Guys I’m all for calibrating adc from the menu rather than startup since there are other things you need to set up anyway, even just being able to manually adjust the min and max values would be great for now. Is this something you could implement as a priority since I can’t ride my bike like this any more

The only thing is that if we only do it once at setup and this value drifts over time or changes with temperature then potentially the bike could start up and go on its own !! That’s why it’s done every time you start. If the user is on the peddle at startup then this is still safe and he will learn the next time not to do it again.

Agree for setting the max value we could just read the adc when standing on the peddle and use that value. If we feel it’s too hard to peddle we can do it again with less pressure. To get the right setting for human power we could use a 10kg weight. This does not need to be automated. We could just read the adc and then adjust it manually.

For the walk mode I agree with you that it maybe a bit unsafe waiting for the second button press to turn off since anything can happen.
 
Ok Part 3 is up if anyone is interested. This is just about making up the cable to connect from the stlink to the motor and reading the existing firmware on the motor so we can make a backup
[youtube]zChf_2K8rW8[/youtube]
 
Discovered something interesting on torque sensor calibration using the coaster brake version of the TSDZ2. Since the coaster brake version does not freewheel pedaling backward but engages the chainring in reverse like a normal bike, if you have a coaster brake you can apply backward torque while starting the motor. This has the effect of increasing motor watts at a given torque while pedaling. We are actually using this on hand cycles for handicapped riders where their arm strength is less than leg strength. If they apply reverse torque while starting the motor they can get much more power from the motor with less actual human effort. I have done a few coaster brake bikes for older riders that benefit from doing this as well. What Jbalat is describing as very tiring is what these riders experience with a regular factory version of the TSDZ2 firmware. It is very tiring to get the motor to apply power. We now have this kludge workaround with coaster brake versions of the motor by applying force in reverse while powering up.

Being able to adjust the amount of power at different ranges of torque would be a great feature for the open source firmware project. Weaker riders whether from age or disability can then get the full benefit of the electric assist without strenuous effort and it would work on regular TSDZ2's as well as coaster brake versions.
 
Rydon said:
Discovered something interesting on torque sensor calibration using the coaster brake version of the TSDZ2. Since the coaster brake version does not freewheel pedaling backward but engages the chainring in reverse like a normal bike, if you have a coaster brake you can apply backward torque while starting the motor. This has the effect of increasing motor watts at a given torque while pedaling. We are actually using this on hand cycles for handicapped riders where their arm strength is less than leg strength. If they apply reverse torque while starting the motor they can get much more power from the motor with less actual human effort. I have done a few coaster brake bikes for older riders that benefit from doing this as well. What Jbalat is describing as very tiring is what these riders experience with a regular factory version of the TSDZ2 firmware. It is very tiring to get the motor to apply power. We now have this kludge workaround with coaster brake versions of the motor by applying force in reverse while powering up.

Being able to adjust the amount of power at different ranges of torque would be a great feature for the open source firmware project. Weaker riders whether from age or disability can then get the full benefit of the electric assist without strenuous effort and it would work on regular TSDZ2's as well as coaster brake versions.

Very nice! One thing to take into consideration though, is when the motor is working alone at higher power, this is going to exponentially increase the failure rate... one reason the throttle is governed.... Some people may want to consider the LingBei or BBS series if they require this, but I understand they may still want to apply force and have the torque sensing bicycle experience, just a little easier, so this still is a super cool trick! Thanks for sharing
 
Rydon said:
Being able to adjust the amount of power at different ranges of torque would be a great feature for the open source firmware project. Weaker riders whether from age or disability can then get the full benefit of the electric assist without strenuous effort and it would work on regular TSDZ2's as well as coaster brake versions.
I really love to see that kind of use of technology!! I am happy to think that my work can help that kind of users needs.

The assist level value that scales the human power is configured on config.h and I am using this values (anyone can change them for other values):

#define ASSIST_LEVEL_0 0.0
#define ASSIST_LEVEL_1 1.0
#define ASSIST_LEVEL_2 2.0
#define ASSIST_LEVEL_3 3.0
#define ASSIST_LEVEL_4 6.0
#define ASSIST_LEVEL_5 9.0

Also I plan to make this values to be configurable on the LCD3, so no need to build and flash the firmware everytime you want to change them.

Also, on LCD3 right now you can see the real time value of calculated and scalled human power, so this way is easy to debug/verify the calculated value (the value starts at 0 and goes up to 255, were 255 is like 100%).

Also, our firmware implements constant power control, that can be interesting compared to original firmware, because user can get constant help of a fixed power (like say 300W) and not something that keeps changing....
 
eyebyesickle said:
Very nice! One thing to take into consideration though, is when the motor is working alone at higher power, this is going to exponentially increase the failure rate... one reason the throttle is governed....
I hope that the motor temperature sensor firmware that I am developing will avoid that failures.
 
casainho said:
eyebyesickle said:
Very nice! One thing to take into consideration though, is when the motor is working alone at higher power, this is going to exponentially increase the failure rate... one reason the throttle is governed....
I hope that the motor temperature sensor firmware that I am developing will avoid that failures.

NICE, yeah I was thinking about that after I posted in the other thread, I had totally forgot about the temp sensor.
 
Also good to know that if the minimum adc is set below the no load adc then the bike isn’t going to run away. It must also use pas to determine whether to apply power or not
 
jbalat said:
Also good to know that if the minimum adc is set below the no load adc then the bike isn’t going to run away. It must also use pas to determine whether to apply power or not
Motor run away is dangerous!! That happened to me many times during development and that is why I think using brake sensors is really important, because the run away when you turn on the ebike is really bad.

So, if user do not apply 'negative" torque to pedals, the automatic calibration should not fail even because we use an offset value for security to avoid that run away. Also, from my experience, values drifiting do not happen but I hope you guys can also keep looking at the ADC values so we learn about this.

About using PAS to not apply power to motor if pedals are stopped, I don't agree with that. Yes, seems that original firmware sometimes do that, I press the pedals but I get no assistance untill the pedals rotate :-(
You see that on our firmware you get assistance as soon you apply torque to pedalss, I think that is the biggest advantage of the torque sensor over using PAS only!!!
But also, I see now that this torque sensor outputs constantly a value if I put my weight on on pedal and keep there... so it is a way to fake the system, my soon did that cheat 1 year ago on the KT torque sensor untill I did filter out that like this and I plan to do it also for TSDZ2:
- if bicycle wheel is stopped (if wheel speed is equal to 0), use torque sensor signal even if pedal cadence is 0 (we will get assistance from a stop point)
- if bicycle wheel is rotating, use torque sensor signal only if pedal cadence > 20 (this filters out that cheating and is also secure because I like to rest on the pedals and I don't want motor assistance/motor run away on that time)
 
There's a bit of value in having rotation before the torque sensor cuts in. I've got into the habit of easing right back on my power each time I change gear, ie stop pedaling and then slowly rotate just as I change gear, once into gear I then pedal as per normal. I get very clean gear changes this way particularly if I'm changing into the larger 42T gear I have to sometimes use.

The other way we could do this is to ramp up the power from say a cadence of 20, I think Bafang does this as I seem to remember fiddling with the ramp up settings to get a much more even and progressive feel to the motor.
 
Hmm very interesting dilemma, we just want the bike to feel as natural as possible but also safe.

when I ride slowly with low torque I need it to be more sensitive so I have a higher resolution of control of power. I guess the max adc can be reduced to give more sensitivity and the power can also be reduced to compensate.

If I sit at lights waiting and rest my foot on peddle I don’t won’t it to take off on me. No cadence should give no power. If there are 24 magnets then you need to wait for 30degree rotation from rest

If I want to take off from start I don’t want it to surge to 600 watts it should ramp up from zero based on speed

When I accelerate at more than cadence of 60 I don’t want the power to drop away, I actually want more power. Low cadence should be lower power to prevent breaking your chain or chain slipping and high cadence should give more power since chain won’t slip. This firmware causes my chain to slip many times compared to the original firmware.

I really need to understand how the code works so I can start tweaking
 
jbalat said:
Hmm very interesting dilemma, we just want the bike to feel as natural as possible but also safe.

when I ride slowly with low torque I need it to be more sensitive so I have a higher resolution of control of power. I guess the max adc can be reduced to give more sensitivity and the power can also be reduced to compensate.

If I sit at lights waiting and rest my foot on peddle I don’t won’t it to take off on me. No cadence should give no power. If there are 24 magnets then you need to wait for 30degree rotation from rest

If I want to take off from start I don’t want it to surge to 600 watts it should ramp up from zero based on speed

When I accelerate at more than cadence of 60 I don’t want the power to drop away, I actually want more power. Low cadence should be lower power to prevent breaking your chain or chain slipping and high cadence should give more power since chain won’t slip. This firmware causes my chain to slip many times compared to the original firmware.

I really need to understand how the code works so I can start tweaking
I have brakes installed so I rest on pedals while keep brakes active, this is perfect for me like that.

Yes, please try to understand and I can help you understand if you ask questions. After you can try and feel in practice what makes sense or not.

You want to look at ebike_app.c file, on function: ebike_control_motor ()
 
I changed the torque min and max adc values and did a hot compile and flash in eclipse, good news is that the bike is now responsive again. Thanks Casainho.
That gets me going again but really need a good solution for all
 
casainho said:
Maybe user could on LCD3:
1. start auto calibration of ADC min value
2. set ADC max value
3. set value of ADC steps of 10kgs of force on the pedals (needed to calc the pedal human power)
Thinking more about all of this, I don't like the idea of adding more tecnhical options on LCD3 and maybe it better to put all this more automatic, even if may need some more attention from the user like the ADC min value autocalibration at startup of the system.

New idea:
1. Torque sensor ADC min value: auto calibration happens always at startup -- should work very well but user can't press the pedals at startup, just like on original firmware.
2. Torque sensor ADC max value: start with a value of ADC min value + 20 and will be increased every time the ADC get's an higher value -- this way only on first step on pedals the user will feel the max assistance. Will this work?? what will be the feeling of the user at the very first time???
3. Torque sensor ADC steps for 10kgs of force: This is needed to calc the pedal human power in watts (only needed to show to user!) and will be needed to setup on LCD3. If user do not calibrate, no issue, only maybe the show value may be a bit incorrect. This value depends only from 1. and not from 2.

I think I will implement like that and let's see what happens :)
 
Thanks Casainho this will make the firmware usable for everyone

i dont know about changing the max adc all the time. If you need to climb a hill then max adc might go to 180 and all of a sudden when riding on flat road it will feel much more difficult than before...

Maybe just add a fixed amount like +32 to the min adc

Ideas for future version ???
====================
1. max adc = min adc + f(assist level)
so at lower power it has more sensitivity...
For assist level 1 add +20
And for assist level 5 add +45

BTW I noticed you already add extra power for higher cadence so I’m happy with that.

Would like to hear anyone else's opinion on this ?
 
jbalat said:
i dont know about changing the max adc all the time. If you need to climb a hill then max adc might go to 180 and all of a sudden when riding on flat road it will feel much more difficult than before...

Maybe just add a fixed amount like +32 to the min adc
Even when riding a flat road, I think that at very first pedal impulse we can hit near the max value of torque sensor.

About the max value, seems that for your TSDZ2 you have a delta of 20 units, while for mine I have 32. Can you please confirm again your values????? if you have also near 32 and only the ADC min value change between TSDZ2, that would be better.

jbalat said:
Ideas for future version ???
====================
1. max adc = min adc + f(assist level)
so at lower power it has more sensitivity...
For assist level 1 add +20
And for assist level 5 add +45

BTW I noticed you already add extra power for higher cadence so I’m happy with that.
So you and others can better understand what I did.

First, torque sensor value is mapped from the ADC_TORQUE_SENSOR_MIN_VALUE and ADC_TORQUE_SENSOR_MAX_VALUE to 0 and 255. I am using 255 because is 8 bits max value and is easier to make calculation in 8 bits with shift operations, like divide or multiply by 256.
Here happens the mapping of the ADC value of the torque sensor and the output stays in variable ui8_torque_sensor_value_filtered (yes, it says filtered but there is no filtering -- that is a name from KT firmware, I will improve this later). UI8_ADC_TORQUE_SENSOR is the address from STM8 that torque sensor ADC value is read:

Code:
void torque_sensor_read (void)
{
  // map value from 0 up to 255
  ui8_torque_sensor_value = (uint8_t) (map (
      UI8_ADC_TORQUE_SENSOR,
      (uint8_t) ADC_TORQUE_SENSOR_MIN_VALUE,
      (uint8_t) ADC_TORQUE_SENSOR_MAX_VALUE,
      (uint8_t) 0,
      (uint8_t) 255));

  ui8_torque_sensor_value_filtered = ui8_torque_sensor_value;
}

So, after having torque sensor ADC value in the range o 0 to 255, we multiply it with the pedal cadence and this way we get the human power on the pedals. The output value of this stage is stored on the ui8_pedal_human_power variable, that again in range of 0 to 255.
f_get_assist_level () is the value sent by LCD and is the value defined on main.h of firmware -- for instance, on assist level 4 is 6.0. See that I keep limiting to value 255.

And yes, when cadence is less than 25 (at a startup), we use directly the torque sensor value to get assistance as soon we press the pedals (unlike on original firmware).

Code:
  // cadence percentage (in x256)
  ui16_temp = (ui8_pas_cadence_rpm * 256) / (PAS_MAX_CADENCE_RPM);
  // limit the calculated value to be no more than PAS_MAX_CADENCE_RPM x256
  if (ui8_pas_cadence_rpm > PAS_MAX_CADENCE_RPM)
  {
    ui16_temp = PAS_MAX_CADENCE_RPM * 256;
  }

  // human power: pedal torque * pedal cadence
  // do not apply human power with lower cadence
  if (ui8_pas_cadence_rpm > 25)
  {
    // calc human power
    ui8_pedal_human_power = ui8_torque_sensor_value_filtered * ui16_temp) / 256;

    // now scale human power with assist level
    f_temp = ui8_pedal_human_power * f_get_assist_level ();
    if (f_temp > 255)
      f_temp = 255;

    ui8_pedal_human_power = f_temp;
  }
  else
  {
    ui8_pedal_human_power = ui8_torque_sensor_value_filtered;
  }

On LCD3, you can see on real time the value of ui8_pedal_human_power!!

So, if you want to add more sensitivity, I think you should change ui8_pedal_human_power.
Also see that if you are keep doing max torque on pedals (255), as soon pedals cadence increase this means you are effectively increasing the human power!! because if cadence increases means the increased human power now accelerates the ebike.
And if suddenly you go to a downhill, the cadence will increase but you will be doing less torque so the human power reduces as expected.

Well, to resume, the current firmware implementation works very well to me. I think the best we can do is to use full torque sensor resolution / ADC range.
 
Bought a second hand engine which the owner seems to think the torque sensor has failed, any body have any checks to verify this before I buy a new torque unit.

Thanks
 
Waynemarlow said:
Bought a second hand engine which the owner seems to think the torque sensor has failed, any body have any checks to verify this before I buy a new torque unit.
Use LCD3 to see in real time the value of torque sensor ADC. A not working torque sensor will show 0 value or other constant value while you change the force on the pedals.
 
casainho said:
About the max value, seems that for your TSDZ2 you have a delta of 20 units, while for mine I have 32. Can you please confirm again your values????? if you have also near 32 and only the ADC min value change between TSDZ2, that would be better.

Yes I am also using +32
my rest adc is 40 so I'm using 42 min and 74 Max
This feels really good !!!
 
Waynemarlow said:
Bought a second hand engine which the owner seems to think the torque sensor has failed, any body have any checks to verify this before I buy a new torque unit.

Thanks

Do you have a VLCD-5 to hook up to it? You can access the torque signal diagnostic from the hidden menu
 
Back
Top