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.