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

agphil said:
Are you sure that the cadence is not the 4th graph and the weight the 3rd one?

Thanks!! You were right and here another log now with correct variables labels.

What I see clearly wrong are peaks of calculated weight on the pedals. This peaks are way more than the values regarded to the ADC, I mean, the ADC value is the input to the calculation and the weight the output, and this output is clearly over what should be, so, I will look at the code to try find the issue. This error peaks are bigger at low cadence and reduce to almost zero at higher cadence like 80 and 90 RPM.





bikelpl said:
You can use app named "Arduino Centrale Free" it is universal serial plotter.
It can show up to 10 values on one graph in different colors.
It can also log received data as CSV.
Thanks!! That would be nice for me to use right now but I tested and It could not connect. Many Android apps can not connect because SW102 is Bluetooth Low Energy - I tested many and I found only 2 that can connect.
 
I don't know but I think at low cadence the weight on the pedal is high when you push on the pedal, and low when the pedals are in the dead zone. When you increase the cadence you get inertia and the weight is constant through the rotation.
I don't think there is anything wrong with your graph.

casainho said:
agphil said:
Are you sure that the cadence is not the 4th graph and the weight the 3rd one?

What I see clearly wrong are peaks of calculated weight on the pedals. This peaks are way more than the values regarded to the ADC, I mean, the ADC value is the input to the calculation and the weight the output, and this output is clearly over what should be, so, I will look at the code to try find the issue. This error peaks are bigger at low cadence and reduce to almost zero at higher cadence like 80 and 90 RPM.
 
For example, if you would do the same measurements when climbing standing on the pedals at 50rpm, I would expect huge peaks in the weight graph.

agphil said:
I don't know but I think at low cadence the weight on the pedal is high when you push on the pedal, and low when the pedals are in the dead zone. When you increase the cadence you get inertia and the weight is constant through the rotation.
I don't think there is anything wrong with your graph.

casainho said:
agphil said:
Are you sure that the cadence is not the 4th graph and the weight the 3rd one?

What I see clearly wrong are peaks of calculated weight on the pedals. This peaks are way more than the values regarded to the ADC, I mean, the ADC value is the input to the calculation and the weight the output, and this output is clearly over what should be, so, I will look at the code to try find the issue. This error peaks are bigger at low cadence and reduce to almost zero at higher cadence like 80 and 90 RPM.
 
mspider65 said:
benno said:
Yes i think that make sense, also for the rx interrupt.

The rx interrupt should run with higher priority to avoid overrun problems.
The tx interrupt instead could run slower without issues.
Beno, please go ahead and make the pull request.

And I just changed the ADC to be running at bellow 6MHZ and not at 8MHZ, as someone suggested (sorry, I forgot the message where I saw this information).
I also changed the battery current read to be on the correct registers as Benno explained and he is correct.
Thanks everyone for this contribution.

agphil said:
I don't know but I think at low cadence the weight on the pedal is high when you push on the pedal, and low when the pedals are in the dead zone. When you increase the cadence you get inertia and the weight is constant through the rotation.
I don't think there is anything wrong with your graph.
I think I understand you you mean. The issue I see is that, for instance, I see peaks of calculated 60 kgs while the ADC input values should only give values of 40 kgs. First I will take care of this error and then we will see how it goes.
 
nassal said:
Martin555 said:
nassal said:
Any idea why no pedal assist? Thanks

Maybe the pre-set battery cut-off voltage is above the current battery voltage? Is the walk mode working?

Yes walk mode works!!. Will check the configuration. Thanks
I had the problem where only walk mode works, and it was my fully charged Japanese cell battery was too good for the cheap Chinese controller/firmware.
I ran the battery down to 90% and everything started working again.
 
Mr.Flibble said:
nassal said:
Martin555 said:
nassal said:
Any idea why no pedal assist? Thanks

Maybe the pre-set battery cut-off voltage is above the current battery voltage? Is the walk mode working?

Yes walk mode works!!. Will check the configuration. Thanks
I had the problem where only walk mode works, and it was my fully charged Japanese cell battery was too good for the cheap Chinese controller/firmware.
I ran the battery down to 90% and everything started working again.
Unlike on original firmware, there is no limitation at all on our developed firmware for battery max voltage, so, this should not apply.
 
Have just replaced KT-LCD3(v20) with 850C(Alpha 4) and have to say with the field awakening it is another league. Many thanks to Casainho and all other contributors. :bigthumb:
But let me also say that Power Assist based on Cadence and Torque is not for me the best option for the MTB trails with quick uphill and downhill changes.
It gives low support at low cadence (like at beginning of uphill ride) and gives high assist at high cadence (when going downhill) and exact opposite is expected therefore Torque Assist or eMTB mode would be much better option.
In comparison with v20 I also miss some main display values like Max/Average speed and consumed Wh but that's not as important.

Let me also report 2 issues :
Battery SOC
With 52V (14S) battery I get incorrect readings like 92% SOC at 52V which should be much less like 65%. I don't understand how the SOC is now calculated without parameter which indicates number of cells in series. Could you briefly explain ?

Field awakening and Torque sensor Calibration settings

When activating field awakening in config menu also Torque sensor Calibration gets activated in the background and it works vice versa when deactivating Torque sensor Calibration also field awakening is deactivated automatically. Is it a bug or purposely ?
 
casainho said:
nassal said:
I have checked the configuration according ti instruction. The only thing works is walk mode. Have flash the latest version alpha.4, it didn’t make different, virtual throttle doesn’t work. Tried stock firmware, no pedal assist again but throttle works. I can’t use throttle with OSF as I used the wire for heat sensor. Any clue?
If walk assist work then the motor is ok.

Note that you must put assist level > 0 for virtual throttle to work. And it must work. Also reset the configurations to default values and check again. Virtual throttle does not depend on torque sensor nor on cadence sensor, so, it must work unless some incorrect configuration is done.

I have checked the Configuration and checked agin. have reset default value, on assist level 0 still virtual throttle doesn’t work. I have flashed the firmware again and no different. Only thing is works is walk assist. Any more advise?? Thanks 😰
 
nassal said:
casainho said:
nassal said:
I have checked the configuration according ti instruction. The only thing works is walk mode. Have flash the latest version alpha.4, it didn’t make different, virtual throttle doesn’t work. Tried stock firmware, no pedal assist again but throttle works. I can’t use throttle with OSF as I used the wire for heat sensor. Any clue?
If walk assist work then the motor is ok.

Note that you must put assist level > 0 for virtual throttle to work. And it must work. Also reset the configurations to default values and check again. Virtual throttle does not depend on torque sensor nor on cadence sensor, so, it must work unless some incorrect configuration is done.

I have checked the Configuration and checked agin. have reset default value, on assist level 0 still virtual throttle doesn’t work. I have flashed the firmware again and no different. Only thing is works is walk assist. Any more advise?? Thanks [emoji27]
Assist level has to be greater than 0 for the virtual throttle to work. Then a long press on up button to activate it.


Sent from my iPad using Tapatalk Pro
 
andrewgateway said:
nassal said:
casainho said:
nassal said:
I have checked the configuration according ti instruction. The only thing works is walk mode. Have flash the latest version alpha.4, it didn’t make different, virtual throttle doesn’t work. Tried stock firmware, no pedal assist again but throttle works. I can’t use throttle with OSF as I used the wire for heat sensor. Any clue?
If walk assist work then the motor is ok.

Note that you must put assist level > 0 for virtual throttle to work. And it must work. Also reset the configurations to default values and check again. Virtual throttle does not depend on torque sensor nor on cadence sensor, so, it must work unless some incorrect configuration is done.

I have checked the Configuration and checked agin. have reset default value, on assist level 0 still virtual throttle doesn’t work. I have flashed the firmware again and no different. Only thing is works is walk assist. Any more advise?? Thanks [emoji27]
Assist level has to be greater than 0 for the virtual throttle to work. Then a long press on up button to activate it.


Sent from my iPad using Tapatalk Pro
Just tried it on assist level 1, 2, 10, no throttle. I tried up button long press, up and down button long press.
 
casainho said:
New firmware: TSDZ2 cadence increase from 90 to 120 RPM as also motor power "amplification" on this same high cadence

You guys get ready for the most advanced and powerful TSDZ2 firmware!!

The big new feature on this version 1.0.0 is the "amplification" of cadence and motor power in the range from 80 to 120RPM!! previous, the motor power would start to decrease at around cadence 80 and be zero at 90, meaning no motor assistance at all over cadence 90RPM. Now, you will get assistance all way up to cadence 120RPM.
Note that this considers a battery with the same voltage as the motor, like a 36V battery with a 36V motor or 48V battery with 48V motor. Even in the cases of using a 48V battery with 36V motor, the cadence is still increased up to 120RPM with most possible optimized efficiency.

This is the first time I made the version as 1.0.0 because all major features about TSDZ2 motor control are now implemented like FOC and Field Weakening. Also on the display side, I don't plan any new big changes.
There certainly features that can be added in future versions like 1.1.0 and polish the current ones, and I plan to do that.

Changelog from previous stable release v0.8.0:
- increase motor assistance as also pedal cadence up to 120RPM (previous limit was around 85RPM) and for this was need to:
-- UART communications frequency is increased twice to save the processing time needed to implement following points
-- increased PWM frequency from 15.6kHz to 19 kHz
-- implement Field Weakening
-- configuration to enable/disable Field Weakening as it brings a loss of efficiency at high cadence value over 90RPM, possible a loss of 25%
- added coast brake ADC sensitivity configuration: the TSDZ2 coast brake version should now fully work on this firmware version
- added configuration for cadence fast stop mode, which is enabled by default. Enable for regular bicycles and disable for some full suspension bicycles
- ebike control loop now runs at twice the frequency in the hope to make system a bit more responsive (tested by vshitikov)
- added Wh/km variable to be shown on custom fields and also on the graph

Download and follow the full instructions here: https://github.com/OpenSource-EBike-firmware/Color_LCD/releases/tag/860C_850C_SW102_v1.0.0-alpha.4

I just tried the new Alpha 4 on my wife's bike with her 850C.
I have to say it's the best firmware we've ever used on an 850C!
 
I'm waiting for parts to arrive from China (860c and another battery) then I am looking forward to trying this on my 8 speed hub gear machine. Bored of riding my single speed around now :)
 
andrewgateway said:
I have checked the Configuration and checked agin. have reset default value, on assist level 0 still virtual throttle doesn’t work. I have flashed the firmware again and no different. Only thing is works is walk assist. Any more advise?? Thanks [emoji27]
Virtual throttle only works if assist level > 0.

There are configurations that will disable motor assist, maybe some of them are wrong on your configurations:
- max wheel speed
- battery max current
- battery low cut off voltage
- motor max current
- torque sensor calibration: keep it disable to make sure there is no issue with your torque sensor calibration
- assist level factors
- motor temperature: keep it disabled to make sure you did not a wrong configuration
- keep street mode disabled
- max power: configure on main screen the max power for something higher than 1000

elfnino said:
Let me also report 2 issues :
1. Battery SOC
With 52V (14S) battery I get incorrect readings like 92% SOC at 52V which should be much less like 65%. I don't understand how the SOC is now calculated without parameter which indicates number of cells in series. Could you briefly explain ?
2.
Field awakening and Torque sensor Calibration settings

When activating field awakening in config menu also Torque sensor Calibration gets activated in the background and it works vice versa when deactivating Torque sensor Calibration also field awakening is deactivated automatically. Is it a bug or purposely ?
1. Seems you didn't your work of reading the configurations wiki page. After doing so, then put your questions here.

2. I will check. thanks.
 
agphil said:
For example, if you would do the same measurements when climbing standing on the pedals at 50rpm, I would expect huge peaks in the weight graph.
I was testing again the code that calculates the weight on the pedals and it is ok. So then I started to make 2 different readings of the torque sensor signal:
1. regular measurement every 50ms independent of the pedal position
2. measurement every moment the pedals are in horizontal position (2 times per each 1 RPM)

Than I mix the signal 1. and 2. in a proportion defined on configuration "torque sensor filter", from 0 to 100%. Where 25 is 75% of the signal for 1. and 25% of signal 2..
I could not test for long rides but seems to me that a value between 20 and 40 is somehow good. On a value of 60% I note a lot of delay... here are logs of the signals I took:

Filter = 0. Note peaks of weight of 80 and 110 kgs (green line), these are correct because is was pedaling out of the saddle - these measurements are only possible with torque sensor calibration otherwise the torque sensor will never measure them:




Filter = 20. Maybe this is a good value:




Filter = 40:




Filter = 60, no good, we feel a lot of delay on the motor response:

 
Hi, why is motor set to max 750W on FW1.0.0-alfa4 ? Also parameters like battery current and field weakening not changes after exit from menu. Battery is set always on 16A, and field weakening is always disable after power off/on.
 
redwater said:
Hi, why is motor set to max 750W on FW1.0.0-alfa4 ? Also parameters like battery current and field weakening not changes after exit from menu. Battery is set always on 16A, and field weakening is always disable after power off/on.
Field weakening configuration had an issue and I just corrected on next 1.0.0-alpha.5.
Battery current, I don't know, seems to work for me.
 
New firmware release v1.0.0-alpha.5
https://github.com/OpenSource-EBike-firmware/Color_LCD/releases/tag/860C_850C_SW102_v1.0.0-alpha.5

News:
- added torque sensor filter with configuration (only works if torque sensor calibration is enable): find the filter configuration on the torque sensor configuration menu. I hadn't much time for testing but I think a high value like 80 is the best for me because if not, I feel a lot oscillation of motor assist power at high assist levels, I think this is due to erratic high torque sensor measurements when the cranks are not horizontal - this are limitations / issues on this torque sensor. As the filter measures only when the cranks are horizontal, then an high filter value will help on this issue. Also my torque sensor has really bad sensitivity after the 30 kgs (and this is a new torque sensor installed this week and have the same bad sensitivity as the old one) which probably makes worst this issue.

- SW102: added Bluetooth UART with pairing and currently sends some variables only to help debug: this makes the firmware ready to develop connection to a Bluetooth app like this: https://github.com/TSDZ2-ESP32/TSDZ2-Android , https://github.com/TSDZ2-ESP32/TSDZ2-ESP32-Wiki/wiki

- corrected ADC frequency
- corrected Field awakening incorrect configuration
 
Why not implementing a simple digital filter or a moving average on all the measurements?
something like weight = A*weight(n-1) + B*weight(n) with A+B=1
or for example a moving average with 3 points: weight = (weight(n-2) + weight(n-1) + weight(n))/3

Your single sample when the pedal is horizontal seems to introduce a lot of noise in your calculation.

casainho said:
agphil said:
For example, if you would do the same measurements when climbing standing on the pedals at 50rpm, I would expect huge peaks in the weight graph.

Than I mix the signal 1. and 2. in a proportion defined on configuration "torque sensor filter", from 0 to 100%. Where 25 is 75% of the signal for 1. and 25% of signal 2..
I could not test for long rides but seems to me that a value between 20 and 40 is somehow good. On a value of 60% I note a lot of
 
casainho said:
New firmware release v1.0.0-alpha.5
https://github.com/OpenSource-EBike-firmware/Color_LCD/releases/tag/860C_850C_SW102_v1.0.0-alpha.5

News:
- added torque sensor filter with configuration (only works if torque sensor calibration is enable): find the filter configuration on the torque sensor configuration menu. I hadn't much time for testing but I think a high value like 80 is the best for me because if not, I feel a lot oscillation of motor assist power at high assist levels, I think this is due to erratic high torque sensor measurements when the cranks are not horizontal - this are limitations / issues on this torque sensor. As the filter measures only when the cranks are horizontal, then an high filter value will help on this issue. Also my torque sensor has really bad sensitivity after the 30 kgs (and this is a new torque sensor installed this week and have the same bad sensitivity as the old one) which probably makes worst this issue.

I also noticed an oscillation when I was playing with calibration and I had to disable it. I think it comes from the fact that the pedal rotation with the round chain-ring gives unequal torque and motor follows the torque.

So I guess I'm ready not to try your new 1.0.0 version with the filter! Do I loose the calibration coefficients after uploading the FW in the display?
 
Yes, you must do complete configuration new
 
I have created a pull request for the uart_tx_interrupt improvement. I think its a good idea
to set the software priority to the second highest level as mspider65 suggested.

mspider65 said:
It is also better to add the following call at the end of the uart_init() function in order to run the TX interrupt with lower priority than the other interrupts.
ITC_SetSoftwarePriority(UART2_TX_IRQHANDLER, 0x02);

casainho said:
And I just changed the ADC to be running at bellow 6MHZ and not at 8MHZ, as someone suggested (sorry, I forgot the message where I saw this information).
Its written in an application note (ST AN2658 Using the analog to digital converter of the STM8S microcontroller) page 8 at the bottom.

@casainho

I have a question about the field weakening you implemented. I studied the code but could not really see
how the field weakening is controlled.
According to what rule do you decide how much you advance the angle?
 
benno said:
I have created a pull request for the uart_tx_interrupt improvement. I think its a good idea
to set the software priority to the second highest level as mspider65 suggested.

mspider65 said:
It is also better to add the following call at the end of the uart_init() function in order to run the TX interrupt with lower priority than the other interrupts.
ITC_SetSoftwarePriority(UART2_TX_IRQHANDLER, 0x02);

casainho said:
And I just changed the ADC to be running at bellow 6MHZ and not at 8MHZ, as someone suggested (sorry, I forgot the message where I saw this information).
Its written in an application note (ST AN2658 Using the analog to digital converter of the STM8S microcontroller) page 8 at the bottom.

@casainho

I have a question about the field weakening you implemented. I studied the code but could not really see
how the field weakening is controlled.
According to what rule do you decide how much you advance the angle?
I will see later, on next week, the pull request - I have to test it first. Thanks!!

The ADC frequency is done.
The battery current measurement on PWM interrupt, didn't work!! Since it is not a priority, I just left admit was before.

Well, the idea is to keep controlling the motor current / torque on Field Weakening and I found on some simple tests it is about x1.25 more current to have the same torque. Then, I just increase the angle to control the current and no special controller, only specific different timings for specific things like I expect the motor speed to be slower to change than current or when braking, etc - I am pretty sure you did understand this on the code. I did some tests on all this.
 
casainho said:
andrewgateway said:
I have checked the Configuration and checked agin. have reset default value, on assist level 0 still virtual throttle doesn’t work. I have flashed the firmware again and no different. Only thing is works is walk assist. Any more advise?? Thanks [emoji27]
Virtual throttle only works if assist level > 0.

There are configurations that will disable motor assist, maybe some of them are wrong on your configurations:
- max wheel speed
- battery max current
- battery low cut off voltage
- motor max current
- torque sensor calibration: keep it disable to make sure there is no issue with your torque sensor calibration
- assist level factors
- motor temperature: keep it disabled to make sure you did not a wrong configuration
- keep street mode disabled
- max power: configure on main screen the max power for something higher than 1000

I have checked all above, all Is correct. still only thing works is walk assist.
I have flashed the alpha5, checked all above and the configuration https://github.com/OpenSource-EBike-firmware/TSDZ2_wiki/wiki/Features-and-configurations-on-display
Still not working.
The only thing I didn’t understand is
“ max power: configure on main screen the max power for something higher than 1000”
Many thanks
 
nassal said:
The only thing I didn’t understand is
“ max power: configure on main screen the max power
Read the features and configurations wiki page.
 
Back
Top