TSDZ2 OSF for 860C - combining 0.20C and v12

Blacklite

100 W
Joined
Jan 29, 2019
Messages
194
Location
Brisbane
Absolutely have loved trying out mbrusa's new 20.1C fork... particularly hybrid mode! Thanks mbrusa and all the other OSF developers.

I've had a few days off so had a play with bringing the mbrusa 20.1C changes to mspider65's v12, so I could try out v12 with an 860C display and no bluetooth module.

https://github.com/iamblacklite/TSDZ2-Smart-Ebike-860C-V12

The display firmware is still v20.1C from mbrusa for 860C.

I started with v12, and implemented the changes that were made by mbrusa to v7. There is no facility to perform the hall sensor calibration, the values are just the hardcoded defaults. Adding this would require a lot of additions to the display code, and then some additions to the display communications protocol. mspider65's defaults are very close to the average of all the reported hall calibrations from his thread so hopefully not losing too much at this stage.

Only had one ride with it, but seems quieter and slightly more powerful.

Definitely have not tested everything, so use at your own risk.
 
Only in 860c i have a 850c :(


the tsdz2 .hex is the same from 850c and 860c. shouldn't it work then?
st visual tells me an error in line 7. did i download the wrong one?


MFG Michael
 
It should work with 850C as the display protocol is the same. I haven’t tested it though.

The file to use should be TSDZ2-v20.1C.V12.hex

I have only done a little bit of testing, so while it flashed and ran ok for me, there’s every chance there are hidden issues.
 
Thanks a lot! it runs. I will see if it makes mistakes. I didn't notice anything negative during a short drive. only positive. :thumb:

mfg michael
 
Blacklite said:
https://github.com/iamblacklite/TSDZ2-Smart-Ebike-860C-V12
Hello, It seems there is a new release in your GitHub. Is it new functionality or bug fixing? In case there were any issues, what should we be careful about?
 
plpetrov said:
Hello, It seems there is a new release in your GitHub. Is it new functionality or bug fixing? In case there were any issues, what should we be careful about?

Just some bug fixes.

After a long ride yesterday I can only find one issue. There is a little twitch in the motor, doesn't happen often, and only lasts for maybe a quarter of a second. It's like a tiny moment that feels like the sprag clutch is slipping. michih has confirmed it is the software. Unfortunately it seems completely random.
 
The twitch issue is solved courtesy of mspider65's bugfix in the V13.

Many other changes in this version attached. Everything is on github for those that want to see the code. A lot of it is an experiment to get myself back into coding a little, I'm happy with using it for myself, but others might find something useful here.

It's an amalgam of mbrusa's 20.1C, mspider's V12 and some of mspider's V13 (not including the reduction in PWM speed or ADC right align changes), and the tweaks of mbrusa's 20.1Cv2. There is also bits of the v1.1.1 from casainho in the motor controller file. The 860C display code is very close to the mbrusa 20.1Cv2 with the only changes being a reworking of the comms data packet to try and save a few bytes, and changing back to 9600 baud transmission rate - the interface is exactly the same and all of the documentation applies.

Mainly I tried to increase execution speed by pre-computing some of the maths used, and limiting the range of some variables so as to be able to use STM8 single instructions rather than SDCC library functions eg. eliminating the slow map_ui16 function, and reducing the complexity of calculation in the old motor_controller function so it doesn't call any library maths functions and can exist in the TIM4 ISR directly.

It's not heavily tested, but seems to work quietly and efficiently for what I've tried so far. Of course as usual use at your own risk.
 

Attachments

  • TSDZ2-20.1C.V12.13.zip
    207.4 KB · Views: 39
I’ve been playing for months with the code and have a new version that I quite like up. It’s mainly my own tweaks, more as an experiment for myself than anything else. But a couple of features I quite like. I’ve added the ability to filter the torque sensor value, using an exponentially weighted moving average. Setting from 0 to 5 in the display - 100%, 80%, 66%, 50%, 33%, 20% respectively for the percentage of the new value used - I think this may have existed in Casainho’s build? There’s also a second motor acceleration parameter that times out after a certain number of cycles after a brake sensor event, to try and smooth out my gear changes with a gear sensor.
 
Back
Top