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

Electric Motors and Controllers
User avatar
Bourtin   1 µW

1 µW
Posts: 3
Joined: Nov 19 2019 12:07pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by Bourtin » Dec 08 2019 10:32am

After 1300 km with the original firmware, I installed version 0.19 with display 850c and version 5 beta7.
It's great, it seems to me that the engine is less noisy, very versatile for both settings and information.
The distance trip and the odometer are reset to zero when I turn off the display. Is this normal operation?
I like toting the mileage on an entire battery discharge.
Surly Ogre Tsdz2 48v.

casainho   10 GW

10 GW
Posts: 4430
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » Dec 08 2019 10:35am

Bourtin wrote:
Dec 08 2019 10:32am
After 1300 km with the original firmware, I installed version 0.19 with display 850c and version 5 beta7.
It's great, it seems to me that the engine is less noisy, very versatile for both settings and information.
The distance trip and the odometer are reset to zero when I turn off the display. Is this normal operation?
I like toting the mileage on an entire battery discharge.
Trip is considered to start at every system boot.

Odometer has that issue you say. Will probably make an option on configuration to see and edit (like reset) this value.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

Uturn   1 W

1 W
Posts: 58
Joined: Jun 06 2018 10:09am

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by Uturn » Dec 09 2019 2:03am

casainho wrote:
Dec 07 2019 9:13am
Are you able to do it??
rather not... as an architect I am ok with drawings but no specific GitHub knowledge here.

famichiki   100 W

100 W
Posts: 131
Joined: Jul 12 2019 9:00am

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by famichiki » Dec 10 2019 5:58pm

Apart from issues with secondary functions or plans to add any additional features, is the motor control of 0.20 considered reliable yet?

mctubster   100 W

100 W
Posts: 231
Joined: Feb 26 2018 6:21am

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by mctubster » Dec 10 2019 8:09pm

famichiki wrote:
Dec 10 2019 5:58pm
Apart from issues with secondary functions or plans to add any additional features, is the motor control of 0.20 considered reliable yet?
I have been running for a few months, zero issues for me (using KT-LCD3) It's great!

famichiki   100 W

100 W
Posts: 131
Joined: Jul 12 2019 9:00am

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by famichiki » Dec 11 2019 3:34am

Can anyone please explain to me what these settings are for, what the delay is referring to and why bigger is bad?

Thanks!

Code: Select all

#define READ_BATTERY_CURRENT_FILTER_COEFFICIENT                   2
#define READ_BATTERY_VOLTAGE_FILTER_COEFFICIENT                   2

/*---------------------------------------------------------
  NOTE: regarding ADC battery current measurement and 
  filter coefficients 

  Possible values: 0, 1, 2, 3, 4, 5, 6
  0 equals to no filtering and no delay, higher values 
  will increase filtering but will also add a bigger delay.
---------------------------------------------------------*/

obcd   100 W

100 W
Posts: 158
Joined: Jul 16 2019 3:45pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by obcd » Dec 11 2019 4:26am

Without studying and knowing the code, I would expect it to do some filtering and averaging of the battery voltage.
Let's assume you read the voltage every second. If you take the average of 2 readings, you only have the result 2 seconds later.
Without averaging, you will have the result after a second. Battery voltage depends upon current draw due to battery internal resistance and cable resistances. If you average your readings, you will get a more stable reading that lags a bit behind. As your battery voltage isn't suposed to suddenly jump below it's minimum treshold, this shouldn't be a problem for most, unless you really want to see how much the voltage drops if you load the battery.

SuperSl0w   1 mW

1 mW
Posts: 14
Joined: Dec 22 2018 11:48am

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by SuperSl0w » Dec 11 2019 4:29am

I'm still waiting for my 48v battery to arrive, but i'm already do some pre-work when the battery arrives..

- downloaded STVP-STM32 from https://www.st.com/en/development-tools/stvp-stm32.html
- installed STVP-STM32 software
- plugged the ST Link v2 mini to a free usb port: https://i.imgur.com/Io1ev0I.png
- configured stm32 with this settings: https://i.imgur.com/llRif19.png
- load TSDZ2-v0.20.0-beta.1.hex file https://i.imgur.com/LjhcMeC.png
- which button need a push to flash the fw? And how to save the original fw ?

famichiki   100 W

100 W
Posts: 131
Joined: Jul 12 2019 9:00am

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by famichiki » Dec 11 2019 3:50pm

obcd wrote:
Dec 11 2019 4:26am
Without studying and knowing the code, I would expect it to do some filtering and averaging of the battery voltage.
Let's assume you read the voltage every second. If you take the average of 2 readings, you only have the result 2 seconds later.
Without averaging, you will have the result after a second. Battery voltage depends upon current draw due to battery internal resistance and cable resistances. If you average your readings, you will get a more stable reading that lags a bit behind. As your battery voltage isn't suposed to suddenly jump below it's minimum treshold, this shouldn't be a problem for most, unless you really want to see how much the voltage drops if you load the battery.
Thanks for the the info. Do you think this is purely for the battery level display, or could it also have some effect on motor operation?

casainho   10 GW

10 GW
Posts: 4430
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » Dec 12 2019 10:55am

850C display new firmware

Here is the latest version and I think 90% of the firmware is done - I don´t expect to add much more on the firmware, at least new configurations should be added that depends on the motor controller firmware development.

Download here: https://github.com/OpenSource-EBike-fir ... 5.0-beta.8

Changelog beta.8:
- graphs: graphs now show the variables up to a time of 15m, 1h or 4h
- graphs: added customization for each graph variable of X axis of 15m, 1h, 4h or automatic, where automatic the X axis scale starts at 15m and increases with the time
- more options configurations on the battery graph and text
- increased the configuration cell number up to 15 as seems a user is testing a 15S battery with success
- odometer: corrected issue where odometer value was not saved
- odometer: value is show on configurations and can be edited (to be reset for instance)

Image Image
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

mikec1953   10 µW

10 µW
Posts: 5
Joined: Sep 11 2011 12:31pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by mikec1953 » Dec 12 2019 4:42pm

Still cannot consistently get to Configuration Menu with new release 850C_v0.5.0-beta.8. Using the steps of 1) short click of Power Button followed by 2) long press 0f Power Button, it works about 1 out of 20 attempts. The rest of the time the display turns off.

redwater   10 mW

10 mW
Posts: 30
Joined: Oct 18 2019 12:36pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by redwater » Dec 13 2019 2:52am

mikec1953 wrote:
Dec 12 2019 4:42pm
Still cannot consistently get to Configuration Menu with new release 850C_v0.5.0-beta.8. Using the steps of 1) short click of Power Button followed by 2) long press 0f Power Button, it works about 1 out of 20 attempts. The rest of the time the display turns off.
Try do it very fast.

redwater   10 mW

10 mW
Posts: 30
Joined: Oct 18 2019 12:36pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by redwater » Dec 13 2019 2:54am

casainho wrote:
Dec 12 2019 10:55am
850C display new firmware

Here is the latest version and I think 90% of the firmware is done - I don´t expect to add much more on the firmware, at least new configurations should be added that depends on the motor controller firmware development.

Download here: https://github.com/OpenSource-EBike-fir ... 5.0-beta.8

Changelog beta.8:
- graphs: graphs now show the variables up to a time of 15m, 1h or 4h
- graphs: added customization for each graph variable of X axis of 15m, 1h, 4h or automatic, where automatic the X axis scale starts at 15m and increases with the time
- more options configurations on the battery graph and text
- increased the configuration cell number up to 15 as seems a user is testing a 15S battery with success
- odometer: corrected issue where odometer value was not saved
- odometer: value is show on configurations and can be edited (to be reset for instance)

Image Image
Odometer works ! :bigthumb:

casainho   10 GW

10 GW
Posts: 4430
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » Dec 13 2019 4:34am

mikec1953 wrote:
Dec 12 2019 4:42pm
Still cannot consistently get to Configuration Menu with new release 850C_v0.5.0-beta.8. Using the steps of 1) short click of Power Button followed by 2) long press 0f Power Button, it works about 1 out of 20 attempts. The rest of the time the display turns off.
So it means the short click is not being detected. You need to make a very fast click and immediately followed of the long press.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

redwater   10 mW

10 mW
Posts: 30
Joined: Oct 18 2019 12:36pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by redwater » Dec 13 2019 4:41am

Is that possible to do multiple trip times and distance cancelled by user, not reseting when power off display ? Some like Trip 1, Trip 2, Trip 3 .

casainho   10 GW

10 GW
Posts: 4430
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » Dec 13 2019 4:45am

redwater wrote:
Dec 13 2019 4:41am
Is that possible to do multiple trip times and distance cancelled by user, not reseting when power off display ? Some like Trip 1, Trip 2, Trip 3 .
Yes it is. Please put your suggestions on github issue tracker so they will not be forgotten.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

Powerhour   100 mW

100 mW
Posts: 40
Joined: Sep 08 2019 11:33am

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by Powerhour » Dec 13 2019 3:10pm

Does beta8 work on the .20 beta?

Minatauro   10 mW

10 mW
Posts: 23
Joined: Dec 22 2018 5:59am

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by Minatauro » Dec 14 2019 1:21pm

Hi,
I just swapped out a broken torque sensor for a brand new one, however, there is no assistance from the motor now when peddling. The vlcd5 is fine and has no error codes. I tried the walk assist to test the motor and that is not working. If the display is working does that mean the controller is ok? The torque sensor is new and the wires seem to be ok on it. I can't figure out why it's not giving assistance. Had anyone experienced this before?

redwater   10 mW

10 mW
Posts: 30
Joined: Oct 18 2019 12:36pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by redwater » Dec 14 2019 4:52pm

Someting strangle. I ride tomorrow 30 km, and till 29 km display shows always 53V, when reset display , shows 47,5V on the rest, when I ride again showing voltage 53V, when motor stop working show 47V, and when again working show 53V. Its strangle.

hefest   100 W

100 W
Posts: 145
Joined: Jan 11 2019 4:55am

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by hefest » Dec 15 2019 2:25pm

casainho wrote:
Dec 07 2019 9:13am
Uturn wrote:
Dec 07 2019 6:29am
Would be great to have some convenient menu in github to point us to current versions of stuff and to bleeding edge versions of stuff easily.
Good idea. It should be a wiki page pointing to the download/release of github. Are you able to do it??
I offered sometime ago to setup automatic builds with CI integration (e.g. TravisCI) for this project. Releases could be built on creating tags in Git repo. If devs are interested we could elaborate a bit more on git branching strategy used at the moment and finding something to make the job for the devs simpler and for the whole release process.

casainho   10 GW

10 GW
Posts: 4430
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » Dec 16 2019 7:39am

hefest wrote:
Dec 15 2019 2:25pm
casainho wrote:
Dec 07 2019 9:13am
Uturn wrote:
Dec 07 2019 6:29am
Would be great to have some convenient menu in github to point us to current versions of stuff and to bleeding edge versions of stuff easily.
Good idea. It should be a wiki page pointing to the download/release of github. Are you able to do it??
I offered sometime ago to setup automatic builds with CI integration (e.g. TravisCI) for this project. Releases could be built on creating tags in Git repo. If devs are interested we could elaborate a bit more on git branching strategy used at the moment and finding something to make the job for the devs simpler and for the whole release process.
I am ignorant about CI integration so it is hard to me to understand the value as also as it is naturally, I am reluctant to changes. Other developers already mention such topic, we discuss on github issue tracker and gittter. The developers are discussing development on gitter channel and this forum thread is more for feedback between users and developers, join the channel here: https://gitter.im/OpenSource-EBike/community
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

casainho   10 GW

10 GW
Posts: 4430
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » Dec 16 2019 7:47am

Just to let you guys know, that as being discussed between the developers here and on gitter channel, I am start working for the new improved protocol, mainly because the need of increased configurations size due to the new feature of full torque sensor calibration, that is ready once the calibration values can be setup on the display.

The notes I wrote for developers:

I am being thinking and writing the new improved protocol, see here: https://github.com/OpenSource-EBike-fir ... s-protocol
the new things are 2 commands: configurations and get motor controller firmware version
this 2 commands and his data associated only need to be exchanged at very specific moments like at startup or when user exit the configurations
all the other data needs to be sent every 100ms because it is needed to real time calculations
I am adding new data for real time
motor phase current (6 bits)
next firmware version, the pedal human power should control motor phase current and not the battery current, still both will be limited to max values
hall sensors state (3 bits) + pedal position
because this way user can debug faulty hall sensors has did happened to me and led me to burn a motor
and pedal position to debug/validate the pedal position needed to the torque sensor calibration
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

famichiki   100 W

100 W
Posts: 131
Joined: Jul 12 2019 9:00am

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by famichiki » Dec 16 2019 9:30pm

famichiki wrote:
Dec 11 2019 3:34am
Can anyone please explain to me what these settings are for, what the delay is referring to and why bigger is bad?

Code: Select all

#define READ_BATTERY_CURRENT_FILTER_COEFFICIENT                   2
#define READ_BATTERY_VOLTAGE_FILTER_COEFFICIENT                   2
obcd wrote:
Dec 11 2019 4:26am
Without studying and knowing the code, I would expect it to do some filtering and averaging of the battery voltage.
Could someone please tell me if this is purely for the battery level display, or will changing these settings also have some effect on motor operation?

I have 20+ seconds startup time while the battery bars are progressively being displayed (using Demion's branch default settings of voltage 6 & current 4) and I really want to reduce that.

Is this what will be causing that delay?

Is it OK to start riding before the battery bars are fully displayed?

casainho   10 GW

10 GW
Posts: 4430
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » Dec 17 2019 12:59am

famichiki wrote:
Dec 16 2019 9:30pm
Is it OK to start riding before the battery bars are fully displayed?
Yes, you can ride as soon you see the main screen which is almost immediately.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

redwater   10 mW

10 mW
Posts: 30
Joined: Oct 18 2019 12:36pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by redwater » Dec 17 2019 10:58am

redwater wrote:
Dec 14 2019 4:52pm
Someting strangle. I ride tomorrow 30 km, and till 29 km display shows always 53V, when reset display , shows 47,5V on the rest, when I ride again showing voltage 53V, when motor stop working show 47V, and when again working show 53V. Its strangle.
It was my fault, I write wrong battery resistance parameter to display. Now works well.

Post Reply