TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

buba said:
I have added so many functions and optimized so much space it is insane. But there is a limit. Trying to make the firmware react so good that we do not need Startup Boost and get some space back.

I definitely think Boost seems like a band-aid that can be discarded if you improve the responsiveness. Personally I would be very happy to see it dropped. It seems to be a frequent pattern with control systems that they accumulate band-aids to try to fix behavior where if you get back to the fundamentals you can avoid them altogether.

I'm assuming that you're also improving the slow-down responsiveness. In 0.19 the run-on is pretty strong, feels like ~1s after stopping pedaling, and to me at high assist even feels like a ramp up and then sudden stop. This is a problem for me with an internal gear hub, where gear shifts are very abrupt - unlike a derailleur when the chain ramps between cogs - I'm pretty sure if my shift comes through under power I'm really stressing that poor blue gear, but avoiding it means a very long, slow gearshift.

I'm also hoping whatever causes set-off to lag sometimes will go away. I'm not running a brake cut-off at present, and I'm not sure if that contributes, but a lot of times I get nothing much for the first revolution or two on set-off, and then a slow ramp-up. I think it's related to having a foot on the pedals when stationary.

I'm looking forward to your new beta - though I'll probably be on vacation.

What recommended sdcc version works for the codebase? I tried a few and got various SEGVs and other issues during compilation.

Thanks for your efforts!
 
flufferty said:
I may be completely out of the loop here, but why do we need the human power to be accurate?
It seems that all the TSDZ2-units have differently calibrated sensors, and perhaps the stock firmware is compensating for that (undocumented eeprom-data?), perhaps it isn't.

Couldn't we include a calibration routine that takes the resting value, and then records the highest torque value read, and uses that for dynamically applying the power-factor. (given we don't need real-watt human power, we only need a deterministic torque-sensor range)

The firmware could continuously save the highest torque recorded, and use that. So the harder you press your bike (torque sensor range allowing) the higher you'll raise the torque-range (until its saturated, or you cant push it more).
So given a "well-calibrated" physical torque sensor, you will get a larger/finer range, but someone with a badly calibrated physical torque sensor, will have the same range, but with worse resolution.

If needed, perhaps a new "weaker" person wants to use THAT motor, you reset the calibrated value in a menu-option.
With the above option of "dynamic" high-point, a child could ride the motor and enjoy it's full benefits, even without reaching the 40kg or so where the torque sensors seems to max out.

The things you describe actually define Torque Assist that will be released soon!

It all boils down to a desire to have the torque sensor perform the very best it can. The better it can interpret user input the better the response of the system. For the coming Torque Assist there is no problem at all as it is similar to the original firmware. The torque sensor will be calibrated during power on and establish a resting value. After this, the more you press on the pedals the more power you will get. Simple as that. And if you have some user having problems with applying enough force you simply adjust the assist level multipliers so it suits that user.

For Power Assist we need to calibrate the torque sensor so it gives us a correct conversion between the ADC value and real life force/torque. This enables us to accurately measure human power which can be a fun riding mode to be in. If we can make it work 100 % then it would be very natural and responsive. But the operating range and characteristics of the torque sensor in the TSDZ2 is setting the limit and it is this limit we are trying to push now.
 
jimmyfergus said:
buba said:
I have added so many functions and optimized so much space it is insane. But there is a limit. Trying to make the firmware react so good that we do not need Startup Boost and get some space back.

I definitely think Boost seems like a band-aid that can be discarded if you improve the responsiveness. Personally I would be very happy to see it dropped. It seems to be a frequent pattern with control systems that they accumulate band-aids to try to fix behavior where if you get back to the fundamentals you can avoid them altogether.

I am very thankful you commented and said that. We will see what the feedback is from the community when the next beta is released. Will do my best to jam as much as possible including Boost.



jimmyfergus said:
I'm assuming that you're also improving the slow-down responsiveness. In 0.19 the run-on is pretty strong, feels like ~1s after stopping pedaling, and to me at high assist even feels like a ramp up and then sudden stop. This is a problem for me with an internal gear hub, where gear shifts are very abrupt - unlike a derailleur when the chain ramps between cogs - I'm pretty sure if my shift comes through under power I'm really stressing that poor blue gear, but avoiding it means a very long, slow gearshift.

Totally understand you. My goal with this next version is to improve everything but can already say that it will be impossible to do everything perfect from the very first beta. But just releasing it will be a big step. After it is released I will listen for much needed feedback from the community and make improvements based on that feedback.

It will be over 4000 lines of code added/changed/improved when the new beta arrives. 1 % time spent on new riding modes, 9 % time spent on feeling and response, 90 % time spend for preparation of handling many riding modes, creating a modular system, safety, easier future development, future display support and so on.



jimmyfergus said:
I'm also hoping whatever causes set-off to lag sometimes will go away. I'm not running a brake cut-off at present, and I'm not sure if that contributes, but a lot of times I get nothing much for the first revolution or two on set-off, and then a slow ramp-up. I think it's related to having a foot on the pedals when stationary.

I'm looking forward to your new beta - though I'll probably be on vacation.

What recommended sdcc version works for the codebase? I tried a few and got various SEGVs and other issues during compilation.

Thanks for your efforts!

Look forward to you testing the new beta and of course your feedback! As I said, it will not be perfect but the foundation will be rock solid.

I use SDCC 3.8.0.

Appreciate it!
 
buba said:
The torque sensor will be calibrated during power on and establish a resting value. After this, the more you press on the pedals the more power you will get. Simple as that. And if you have some user having problems with applying enough force you simply adjust the assist level multipliers so it suits that user.
There is an issue here. My torque sensor could measure only 10 kgs and after that was very not linear.

So, the first 5 kgs was my legs resting than just another 5 kgs for measure user actual leg force, which is almost nothing, so user will simple not get any assistance by putting more force on the pedals because the sensor saturates very early -- it is like if sensor is faulty.
 
casainho said:
buba said:
The torque sensor will be calibrated during power on and establish a resting value. After this, the more you press on the pedals the more power you will get. Simple as that. And if you have some user having problems with applying enough force you simply adjust the assist level multipliers so it suits that user.
There is an issue here. My torque sensor could measure only 10 kgs and after that was very not linear.

So, the first 5 kgs was my legs resting than just another 5 kgs for measure user actual leg force, which is almost nothing, so user will simple not get any assistance by putting more force on the pedals because the sensor saturates very early -- it is like if sensor is faulty.

Correct, for that case I have added an error code warning users that something might be wrong with the torque resolution. The new wiki explains that the user should:

1. Not press the pedals during calibration

2. Follow your tutorial and adjust the torque sensor as it needs to be calibrated

So if the resting torque is higher than 64 (value can be changed, just chose 64 for now) it is due to the user applying force on the pedals or the torque sensor simply needs calibration. I think we should advise users in the wiki to check their sensor if they feel that the response is lacking. And if it is above a certain level (probably higher than 64) the sensor should be calibrated.

What do you think?
 
buba said:
casainho said:
buba said:
The torque sensor will be calibrated during power on and establish a resting value. After this, the more you press on the pedals the more power you will get. Simple as that. And if you have some user having problems with applying enough force you simply adjust the assist level multipliers so it suits that user.
There is an issue here. My torque sensor could measure only 10 kgs and after that was very not linear.

So, the first 5 kgs was my legs resting than just another 5 kgs for measure user actual leg force, which is almost nothing, so user will simple not get any assistance by putting more force on the pedals because the sensor saturates very early -- it is like if sensor is faulty.

Correct, for that case I have added an error code warning users that something might be wrong with the torque resolution. The new wiki explains that the user should:

1. Not press the pedals during calibration

2. Follow your tutorial and adjust the torque sensor as it needs to be calibrated

So if the resting torque is higher than 64 (value can be changed, just chose 64 for now) it is due to the user applying force on the pedals or the torque sensor simply needs calibration. I think we should advise users in the wiki to check their sensor if they feel that the response is lacking. And if it is above a certain level (probably higher than 64) the sensor should be calibrated.

What do you think?
This is a difficult situation as a bad calibrated torque sensor is more like a fault torque sensor, or almost as if does not exist. In this case, I think a human power controller or PAS controller is better than a torque sensor controller. The previous wrong code for reading human power was acting more like a PAS controller and it worked so well that we didn't discover the wrong code until we started to measure the human power with care.
 
Hello everyone,
this morning I borrowed a digital luggage scale and I made some quick tests on the force/sensor response.

It has a sort of hook, therefore I put the bike upright in normal position with the brake pressed, pedal horizontal (no laser level though :wink:) and force applied upwards on the pedal at the back (right).
I flipped the bike, rotated the pedals 180° and repeated the measurements on the left pedal just to have 2 sets of values.
The precision may not be that accurate but I think it gives the idea.

My rest value, read from menu 9.2, is about 50. To be noted that it was 48-49 few weeks ago when buba asked the first time.

Here below my chart, i think I can conclude that it can linearly appreciate about 20 kg.
force vs torque.png

Hope more data helps the development.
Cheers
 
fi7ippo said:
dameri said:
fi7ippo said:
I am very happy that you like the idea, but I was thinking, and I believe that if it is not too much trouble, and there is enough memory space, the ideal would be to have two parameters that can be changed by the user:

1- User calibration weight available with an approximation of 0.1 or 0.5 kg (this is because it would be difficult for everyone to have an identical weight to be applied for the ADC reading);

Excuse me for coming to this technical discussion. How does the driver's weight work? At least I sit in the saddle practically every time I cycle. So I don't push my pedal at full weight almost ever. And I think many others do the same when driving on an electric bike.

Hi Dameri, maybe I didn't express myself correctly!
The fact is that to calibrate the torque sensor (assuming it is now linear) we need at least 2 points. The first is the value at rest detected during power on, we must enter the second which apparently varies from sensor to sensor.

Now, we can perform an ADC reading with a defined weight applied to the crank (example 20 - 30kg), or, since it would not be easy for everyone to have the same calibration weight to apply at the crank to perform the second reading, we can have 2 parameters to configure, the weight applied during calibration and the ADC reading with applied weight! In this way, since a straight line passes only by two points each one would have its own sensor perfectly calibrated regardless of the weight used for calibration!

Thank you for explanation.
 
Hello casainho, i've just updated the wiki for the brake sensor installation
https://github.com/OpenSource-EBike-firmware/TSDZ2_wiki/wiki/How-to-install-brake-sensors
I am not sure I did the procedure correctly, anyway I added the note on top to pay attention during the boot to make sure the brake sensors are correctly installed and working, in addition I added the schematic with a good solution to keep the sensor disconnectable.

Unfortunately I think I cannot add pictures on the wiki, therefore I kindly ask you to add the following one to your wiki in order to complete the explaination.
Many thanks.

brake_sensor_schematic.png
 
thineight said:
Hello casainho, i've just updated the wiki for the brake sensor installation
https://github.com/OpenSource-EBike-firmware/TSDZ2_wiki/wiki/How-to-install-brake-sensors
I am not sure I did the procedure correctly, anyway I added the note on top to pay attention during the boot to make sure the brake sensors are correctly installed and working, in addition I added the schematic with a good solution to keep the sensor disconnectable.

Unfortunately I think I cannot add pictures on the wiki, therefore I kindly ask you to add the following one to your wiki in order to complete the explaination.
Many thanks.

brake_sensor_schematic.png
Done, the file is here: https://github.com/OpenSource-EBike-firmware/TSDZ2_wiki

Yes, files need to be upload to other place and works differently.
 
casainho said:
Done, the file is here: https://github.com/OpenSource-EBike-firmware/TSDZ2_wiki

Yes, files need to be upload to other place and works differently.

I think I've done. Please double check as I never used github before. :wink:
 
Hello good afternoon Buba, finished riding an engine with Throttle, I confirm that the Throttle does not work with version v.19 beta8 I have tested with previous versions example version Throttle v0.16.0 working, thank you very much for your work.
 
I am new to this, and I'm wondering: is the Open Source firmware compatible with the 850c colors display, or is it only with the KT-LCD3? Are there any plans to make the 850c compatible with it?
 
skestans said:
I am new to this, and I'm wondering: is the Open Source firmware compatible with the 850c colors display, or is it only with the KT-LCD3? Are there any plans to make the 850c compatible with it?
I hope to release in a few days a first version for 850C, here is a picture I took recently from the one I am riding in my bicycle:

IMG-20190710-200545-3.jpg
 
casainho said:
skestans said:
I am new to this, and I'm wondering: is the Open Source firmware compatible with the 850c colors display, or is it only with the KT-LCD3? Are there any plans to make the 850c compatible with it?
I hope to release in a few days a first version for 850C, here is a picture I took recently from the one I am riding in my bicycle:

IMG-20190710-200545-3.jpg

Amazing, thank you so much for your work! I have never owned an e-bike but your project has made me very excited to build my first one!
 
thineight said:
Hello everyone,
this morning I borrowed a digital luggage scale and I made some quick tests on the force/sensor response.

It has a sort of hook, therefore I put the bike upright in normal position with the brake pressed, pedal horizontal (no laser level though :wink:) and force applied upwards on the pedal at the back (right).
I flipped the bike, rotated the pedals 180° and repeated the measurements on the left pedal just to have 2 sets of values.
The precision may not be that accurate but I think it gives the idea.

My rest value, read from menu 9.2, is about 50. To be noted that it was 48-49 few weeks ago when buba asked the first time.

Here below my chart, i think I can conclude that it can linearly appreciate about 20 kg.

Hope more data helps the development.
Cheers

Just want to thank you for the extra data and taking the time to test! :bigthumb:

The more we have the better we can model the behavior of the torque sensor. It is interesting that you tested both sides as well! Also, it seems your torque sensor suffers "aging" if the resting value has increased over time. This would explain why it always calibrates when powering on the system in the original firmware. They know that with time it will change. We also calibrate in the same way but not as long as they do. In the new version it will calibrate longer and be much more accurate though.

EDIT: Nice work on the brake sensor tutorial and pictures! I think it will be much appreciated by the whole community!
 
Popo15 said:
Hello good afternoon Buba, finished riding an engine with Throttle, I confirm that the Throttle does not work with version v.19 beta8 I have tested with previous versions example version Throttle v0.16.0 working, thank you very much for your work.

Hello Popo15,

Have you enabled the throttle in the Configuration Menu under the Motor Controller Setup?

https://github.com/OpenSource-EBike-firmware/TSDZ2_wiki/wiki/Features-and-configurations-for-version-0.19.X#7_Motor_Controller_Setup
 
I got my torque sensor well calibrated and even saved the max value of each pedal rotation and then applied the sinewave average factor, so, I hope this value is correct.

I had a bug on 850C that took me some days to solve... but finally the graph shows correctly the pedal human power and with that white line as a contour.

I had to sweat to get that 300W peak!! I had to put all my body of 100 kgs on the pedals and pedal hard up to get some decent cadence. Since now my torque sensor measures only up to 40 kgs and there is not yet an exploitation of the non linear zone, I guess the peak should be more like double of that value... Anyway, for pedaling seated, I think the values are correct. I can do between 100 to 150 watts continuous for maybe like 30 minutes.
I changed the gears and even if my cadence increase or decrease, the power measured were almost the same as I was trying to keep it the same, feeling that I was doing the same effort/work, so I think it really works well.

Note that black vertical lines are due to the mobile camera recording frequency.
2019-07-12-11-53-48-1.jpg


Buba, I have the code ready to move to your code.

Maybe you are wasting time doing all that optimizations on LCD3, I guess it will not handle the options for torque sensor calibration (including the non linear range).
 
casainho said:
I got my torque sensor well calibrated and even saved the max value of each pedal rotation and then applied the sinewave average factor, so, I hope this value is correct.

I had a bug on 850C that took me some days to solve... but finally the graph shows correctly the pedal human power and with that white line as a contour.

I had to sweat to get that 300W peak!! I had to put all my body of 100 kgs on the pedals and pedal hard up to get some decent cadence. Since now my torque sensor measures only up to 40 kgs and there is not yet an exploitation of the non linear zone, I guess the peak should be more like double of that value... Anyway, for pedaling seated, I think the values are correct. I can do between 100 to 150 watts continuous for maybe like 30 minutes.
I changed the gears and even if my cadence increase or decrease, the power measured were almost the same as I was trying to keep it the same, feeling that I was doing the same effort/work, so I think it really works well.

Note that black vertical lines are due to the mobile camera recording frequency.
2019-07-12-11-53-48-1.jpg


Buba, I have the code ready to move to your code.

Maybe you are wasting time doing all that optimizations on LCD3, I guess it will not handle the options for torque sensor calibration (including the non linear range).

Nice work!

One alternative is that you do not commit your changes and do not accept my pull request yet. I can add your changes in my branch and then you can accept the entire pull request when everything is finished. This would be the best for me as I then have more time to finish my development. And when I am finished you can accept the pull request and immediately test my changes in combination with your changes. Everything will work! Can we do that? I can add the changes you have done in the branch: pedal_power_average in the coming days.

If that works with you I would be very grateful!
 
buba said:
EDIT: One alternative is that you do not commit your changes and do not accept my pull request yet. I can add your changes in my branch and then you can accept the entire pull request when everything is finsihed. This would be the best for me as I then have more time to finish my development. And when I am finished you can accept the pull request and immediately test my changes in combination with your changes. Everything will work! Can we do that? I can add the changes you have done in the branch: pedal_power_average in the coming days.

If that works with you I would be very grateful!
yes, I put my latest code on that branch. Get it from there.

Some notes:
- I decided to calculate in parallel the human pedal power value to be shown on LCD as the one used to control the motor do works well and I didn't to risky what is working well
- the calibration value is for my girlfriend bicycle, that seams to have a double sensitivity torque compared to others

I want to release today firmware version for 850C LCD, for motor controller firmware version 0.19.0.
 
casainho said:
I want to release today firmware version for 850C LCD, for motor controller firmware version 0.19.0.

Great to hear this is almost ready to Beta Casainho, Are there any flashing instructions for this screen. I have a spare screen waiting to be tested that I have opened and added programming pins, but I'm note sure of the flashing process?
 
casainho said:
buba said:
EDIT: One alternative is that you do not commit your changes and do not accept my pull request yet. I can add your changes in my branch and then you can accept the entire pull request when everything is finsihed. This would be the best for me as I then have more time to finish my development. And when I am finished you can accept the pull request and immediately test my changes in combination with your changes. Everything will work! Can we do that? I can add the changes you have done in the branch: pedal_power_average in the coming days.

If that works with you I would be very grateful!
yes, I put my latest code on that branch. Get it from there.

Some notes:
- I decided to calculate in parallel the human pedal power value to be shown on LCD as the one used to control the motor do works well and I didn't to risky what is working well
- the calibration value is for my girlfriend bicycle, that seams to have a double sensitivity torque compared to others

Very nice and I highly appreciate that you asked as this greatly simplifies the development process. I will finish what I have started and then add your changes! Look forward to test the result the coming days! This is so perfect!!

Thanks for the notes!


casainho said:
I want to release today firmware version for 850C LCD, for motor controller firmware version 0.19.0.

Very cool! :bigthumb:
 
buba said:
Popo15 said:
Hello good afternoon Buba, finished riding an engine with Throttle, I confirm that the Throttle does not work with version v.19 beta8 I have tested with previous versions example version Throttle v0.16.0 working, thank you very much for your work.

Hello Popo15,

Have you enabled the throttle in the Configuration Menu under the Motor Controller Setup?

https://github.com/OpenSource-EBike-firmware/TSDZ2_wiki/wiki/Features-and-configurations-for-version-0.19.X#7_Motor_Controller_Setup
good morning, if enabled and it does not work, thank you very much.
 
Popo15 said:
buba said:
Popo15 said:
Hello good afternoon Buba, finished riding an engine with Throttle, I confirm that the Throttle does not work with version v.19 beta8 I have tested with previous versions example version Throttle v0.16.0 working, thank you very much for your work.

Hello Popo15,

Have you enabled the throttle in the Configuration Menu under the Motor Controller Setup?

https://github.com/OpenSource-EBike-firmware/TSDZ2_wiki/wiki/Features-and-configurations-for-version-0.19.X#7_Motor_Controller_Setup
good morning, if enabled and it does not work, thank you very much.

Have you set the number to ”2”?

- Motor Controller Setup, Submenu 4

Set to ”2” for the Throttle funtion

(Set to ”1” for Motor Temperature function)

(Set to “0” for no optional function)

And can you check the:

- Advanced Technical Data, submenu 0

... to see if the throttle value changes?
 
Back
Top