TSDZ2 mid drive and 850C and SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Electric Motors and Controllers
djwlindenaar   1 µW

1 µW
Posts: 2
Joined: Feb 17 2019 10:51am

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

Post by djwlindenaar » Feb 25 2019 4:38pm

Showing off my lighting solution on my bike. It's powered from the TSDZ2 and with a small fix, it works with this firmware.

The front is the original light supplied with the motor. The rear is a waterproof USB led strip from AliExpress https://s.click.aliexpress.com/e/VSnGOxPd1
IMG_20190225_191935.jpg

casainho   1.21 GW

1.21 GW
Posts: 3906
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Feb 25 2019 4:46pm

djwlindenaar wrote:
Feb 25 2019 4:38pm
Showing off my lighting solution on my bike. It's powered from the TSDZ2 and with a small fix, it works with this firmware.

The front is the original light supplied with the motor. The rear is a waterproof USB led strip from AliExpress https://s.click.aliexpress.com/e/VSnGOxPd1

IMG_20190225_191935.jpg
I am really happy that you found the issue and solved it. Can you please submit a pull request so we can add to next version?

Thanks for sharing that picture, seems great that idea of the LED strip. Would like to add to wiki that picture and a bit more details in how to buy and install that LED strip??
- 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.

User avatar
gaber   10 W

10 W
Posts: 69
Joined: Sep 22 2017 8:56am
Location: Grand Rapids, MI

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

Post by gaber » Feb 25 2019 5:23pm

djwlindenaar wrote:
Feb 25 2019 4:38pm
Showing off my lighting solution on my bike. It's powered from the TSDZ2 and with a small fix, it works with this firmware.

The front is the original light supplied with the motor. The rear is a waterproof USB led strip from AliExpress https://s.click.aliexpress.com/e/VSnGOxPd1

IMG_20190225_191935.jpg
Nice! Yes, very interested in a walk through of your wiring (or a wiring diagram). Looks like endlesscadence's diagrams from a few months ago are down (from whatever hosting source they were at).
sometimes you eat the bear, and sometimes, well, he eats you.

haiyi911   1 W

1 W
Posts: 58
Joined: Oct 13 2017 5:35am

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

Post by haiyi911 » Feb 26 2019 4:39am

Hi casainho ,
Could you tell me the relationship between Phase A(SPWM) with Phase Asv(SVPWM)?and how to calculate them?

the numbers in ‘Phase Asv ’column are different with the firmware,are they be suitable for use?
Attachments
spwm-svpwm.jpg
spwm-svpwm.jpg (9.79 KiB) Viewed 1573 times
svm.jpg
svm.jpg (6.84 KiB) Viewed 1573 times
as.jpg
as.jpg (10.71 KiB) Viewed 1573 times

casainho   1.21 GW

1.21 GW
Posts: 3906
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Feb 26 2019 4:43am

haiyi911 wrote:
Feb 26 2019 4:39am
Hi casainho ,
Could you tell me the relationship between Phase A(SPWM) with Phase Asv(SVPWM)?and how to calculate them?

the numbers in ‘Phase Asv ’column are different with the firmware,are they be suitable for use?
Sorry, I don't remember now how I got the values. I did read in a few sources. I shared most my relevant sources, you can find if you search on google for KT motor controller firmware.
- 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.

mctubster   100 W

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

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

Post by mctubster » Feb 26 2019 5:18am

casainho wrote:
Feb 25 2019 6:01am

1. when lag occurs because of some fail on power boost, I quick hit the brakes and power boost starts immediately. This is a workaround.

2. I always use "Motor assistance startup without pedal rotation" = 1 so I do not have that issue. If you acan, give a look at the code to try understand what may be causing that issue.
Thanks for the feedback. I'm guessing your brakes have a cutout and they "restart" the boost code?

I will try Motor assistance startup without pedal rotation also ... though without the brake cutout might be too much at lights etc. My brakes have the wiring, but I was trying to cut down on it!

I had a quick look at the code, I'm not a C programmer but will sit down and try to make sense of the boost function at least ... are there any timeouts or resets in the order of a 2-3 seconds that come to mind?

Also I have a 60FPS camera - will setup by the motor and at least get a better sense of when it happens ... seems random to me, but there could be a good pattern.

Cheers

casainho   1.21 GW

1.21 GW
Posts: 3906
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Feb 26 2019 5:28am

mctubster wrote:
Feb 26 2019 5:18am
are there any timeouts or resets in the order of a 2-3 seconds that come to mind?
Yes, look at the code and you will find the time of power boost (boost time + fadeout time).
- 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   1.21 GW

1.21 GW
Posts: 3906
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Feb 26 2019 5:42am

I just put this code on master:

Correct pedal human power #74

Users did report that pedal human power is about 2x more.

@casainho had the idea to evaluate the torque sensor peak signal (measuring peak signal every pedal rotation) as being a sinewave and so the average would be:

> [Average value = 0.637 × maximum or peak value, Vpk](https://www.electronics-tutorials.ws/ac ... ltage.html)

For a quick hack, we can just reduce actual value to 0.637.
- 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.

User avatar
elem   100 W

100 W
Posts: 135
Joined: May 26 2017 4:27pm
Location: alpes maritimes
Contact:

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

Post by elem » Feb 26 2019 11:09am

it feel good, champion like indurain are about 500/600w in explosif mode, a friend who run marathon ( but 63 year old ) and many bicycle ( road without assit and MTb assisted with me ) made an " effort test " and was mesured a 230W peak,
i saw i was sometimes more than 400 w peak with V0.16 open source LCD3 and i m pretty sure my max power must be about 200w ( never tested in a medical or sport center but will do it ) may be 250w in explosif mode but probably less ...

Soo, 0.637 seems to be good value .
RockRider 9.1 TSDZ2 open source firmware .

casainho   1.21 GW

1.21 GW
Posts: 3906
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Feb 26 2019 11:23am

elem wrote:
Feb 26 2019 11:09am
it feel good, champion like indurain are about 500/600w in explosif mode, a friend who run marathon ( but 63 year old ) and many bicycle ( road without assit and MTb assisted with me ) made an " effort test " and was mesured a 230W peak,
i saw i was sometimes more than 400 w peak with V0.16 open source LCD3 and i m pretty sure my max power must be about 200w ( never tested in a medical or sport center but will do it ) may be 250w in explosif mode but probably less ...

Soo, 0.637 seems to be good value .
Thanks for reporting.

This as also the side benefit to increase a bit the resolution of assist levels, as 0.1 factor that is the min LCD3 can handle, was to much when I need to increase next assist level only by 50% what would be 0.15 but LCD3 just handle 0.2. Now, with about half of human power measure, I can setup assist level 1 as 0.2 and assist level 2 as 0.3 and so on. But in feature maybe we should try increase resolution, on color LCD will be much easier to show numbers like 0.01.
- 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   1.21 GW

1.21 GW
Posts: 3906
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Feb 26 2019 4:27pm

A question for @Buba (Buba is the only active developer other than me) and others:

I think that we need higher resolution on the assist level factor. I think a lower value that a user can do is like 25W (previous would be about 50W but with last change I did, should be half). If user want to have max power assist of 1000W (on a 52V battery, charged at 56V, where max charged is 58.8V) on the smallest power he does, max assist possible will be: 25 * 25.5 = 637.5 W, far from the target 1000W. We are using 8 bits for assist level factor variable, hence the max of 25.5. I think we should also have resolution like 0.025 while now we have only 0.1. So, I think we would need to change LCD3 assist level code...

My question is: since code is full, what do you think is better to do, 1. keep current LCD3 firmware closed to this changes and add this changes only to 850C LCD? or 2. you will work to make this changes on LCD3 (I understand should be hard and you may not be motivated to do this). This questions apply to other possible needed changes for maintenance of current features. Also, I think it is desirable to have other features that I think LCD3 will never have space for it, like password at startup (LCD3 original firmware has that feature and also 850C LCD, maybe every LCD...) -- what should we do for future LCDs that can have more features???

If was now, I would let some free space on LCD3 so it would be possible to make small changes/maintenance on current features.
- 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.

emyr666   10 µW

10 µW
Posts: 5
Joined: Feb 26 2019 5:31pm

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

Post by emyr666 » Feb 26 2019 5:35pm

I have ordered a TSDZ2 kit and LCD3 with a view to installing this firmware. I am a software developer and am interested in the code. I had a look at github and see the term "ERPS" mentioned a lot. I can't find an explanation of this anywhere. Can someone tell me what ERPS stands for?

mark5   100 kW

100 kW
Posts: 1317
Joined: Dec 28 2011 9:26pm
Location: USA

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

Post by mark5 » Feb 26 2019 5:54pm

emyr666 wrote:
Feb 26 2019 5:35pm
... I had a look at github and see the term "ERPS" mentioned a lot. I can't find an explanation of this anywhere. Can someone tell me what ERPS stands for?
casainho wrote:
Oct 31 2018 8:33am
ERPS: electric revoltuino per second: https://en.wikipedia.org/wiki/Revolutions_per_minute
casainho wrote:
Nov 01 2018 6:35pm
ERPS

Image

Motor rotor has 16 magnets. Each pair makes 1 ERPS, so the rotor rotates at 8 ERPS if it rotates 1 RPS.

Hall sensor detects 1 ERPS, because each magnet pair has both north and south magnetic field (360 degrees).

Rydon   100 W

100 W
Posts: 246
Joined: Aug 11 2016 5:26pm

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

Post by Rydon » Feb 26 2019 8:17pm

casainho wrote:
Feb 26 2019 4:27pm
A question for @Buba (Buba is the only active developer other than me) and others:
...
My question is: since code is full, what do you think is better to do, 1. keep current LCD3 firmware closed to this changes and add this changes only to 850C LCD? or 2. you will work to make this changes on LCD3 ...

If was now, I would let some free space on LCD3 so it would be possible to make small changes/maintenance on current features.
I have a few thoughts on this. I agree with Casainho that having this higher resolution on assist is important. Are there perhaps little-used features that take up a lot of code space? If so perhaps it should have its own fork like the OEM display effort. My other thought is, are their functions that are common to all displays that could be moved to the controller firmware instead of the LCD3? I know this might require too much effort to be possible with existing resources but it is a question worth asking. I defer, of course, to those actually doing the development.

vscope   100 mW

100 mW
Posts: 43
Joined: Jun 19 2018 5:42am

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

Post by vscope » Feb 27 2019 6:49am

Hi guys,
Since my KT LCD3 died, is it possible to enable the TSDZ2 by simply connecting
"green|P+|battery voltage" to "white|Vin|ground when LCD disabled and P+ (battery voltage) when LCD is enabled"?

https://github.com/OpenSource-EBike-fir ... 3-to-TSDZ2

cheers
vscope

shaddi   100 mW

100 mW
Posts: 43
Joined: May 30 2018 3:20pm

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

Post by shaddi » Feb 27 2019 10:16am

vscope wrote:
Feb 27 2019 6:49am
Since my KT LCD3 died, is it possible to enable the TSDZ2 by simply connecting
"green|P+|battery voltage" to "white|Vin|ground when LCD disabled and P+ (battery voltage) when LCD is enabled"?

https://github.com/OpenSource-EBike-fir ... 3-to-TSDZ2
I think it does not work. A lot of variables are not filled with data so the controller is waiting for them via serial. As i suggested, there should be some config-vars and runtime-vars splitted in the code and everything "non-critical" could be filled with default values.
https://github.com/OpenSource-EBike-fir ... /issues/30

vscope   100 mW

100 mW
Posts: 43
Joined: Jun 19 2018 5:42am

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

Post by vscope » Feb 27 2019 10:23am

shaddi wrote:
Feb 27 2019 10:16am
I think it does not work. A lot of variables are not filled with data so the controller is waiting for them via serial. As i suggested, there should be some config-vars and runtime-vars splitted in the code and everything "non-critical" could be filled with default values.
https://github.com/OpenSource-EBike-fir ... /issues/30
thx for the info!

buba   10 kW

10 kW
Posts: 587
Joined: Aug 31 2018 12:36am

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

Post by buba » Feb 27 2019 12:47pm

Long time, no write...

I have been buried in work the last two weeks and worked every single day. I literally had no time to read and update myself on all the updates posted here. But hopefully things will slow down a bit in the coming days and I will have some more time.

Anyway, fun to see that the thread is so full of life and that this great community is growing!
casainho wrote:
Feb 26 2019 4:27pm
A question for @Buba (Buba is the only active developer other than me) and others:

I think that we need higher resolution on the assist level factor. I think a lower value that a user can do is like 25W (previous would be about 50W but with last change I did, should be half). If user want to have max power assist of 1000W (on a 52V battery, charged at 56V, where max charged is 58.8V) on the smallest power he does, max assist possible will be: 25 * 25.5 = 637.5 W, far from the target 1000W. We are using 8 bits for assist level factor variable, hence the max of 25.5. I think we should also have resolution like 0.025 while now we have only 0.1. So, I think we would need to change LCD3 assist level code...

My question is: since code is full, what do you think is better to do, 1. keep current LCD3 firmware closed to this changes and add this changes only to 850C LCD? or 2. you will work to make this changes on LCD3 (I understand should be hard and you may not be motivated to do this). This questions apply to other possible needed changes for maintenance of current features. Also, I think it is desirable to have other features that I think LCD3 will never have space for it, like password at startup (LCD3 original firmware has that feature and also 850C LCD, maybe every LCD...) -- what should we do for future LCDs that can have more features???

If was now, I would let some free space on LCD3 so it would be possible to make small changes/maintenance on current features.
I have a couple of ideas that will optimize the code for space. After this it will maybe be possible to implement a higher resolution. I will try to increase the resolution, optimize in regard to size and also submit a pull request for you all to test!
GitHub: https://github.com/leon927
PayPal: leonstor at bredband.net

NIPSEN   100 mW

100 mW
Posts: 38
Joined: Feb 26 2019 5:14pm

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

Post by NIPSEN » Feb 27 2019 1:48pm

Hi TSDZ2 open firware community, thanks for all your great job, you decided me to buy this motor.
I try to get as much information as possible so as not to pollute the discussions with trivia, but I can't find an answer to the following question:
Is the open source firmware of the 850C LCD compatible with the latest version of the your controller firmware?

casainho   1.21 GW

1.21 GW
Posts: 3906
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Feb 27 2019 1:55pm

NIPSEN wrote:
Feb 27 2019 1:48pm
Hi TSDZ2 open firware community, thanks for all your great job, you decided me to buy this motor.
I try to get as much information as possible so as not to pollute the discussions with trivia, but I can't find an answer to the following question:
Is the open source firmware of the 850C LCD compatible with the latest version of the your controller firmware?
No it is not. That firmware is far from being stable, I am using in my bicycle and it give me a lot of troubles -- I am not finding time to improve this firmware.
- 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.

NIPSEN   100 mW

100 mW
Posts: 38
Joined: Feb 26 2019 5:14pm

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

Post by NIPSEN » Feb 27 2019 2:04pm

casainho wrote:
Feb 27 2019 1:55pm
No it is not. That firmware is far from being stable, I am using in my bicycle and it give me a lot of troubles -- I am not finding time to improve this firmware.
Thx for your answer, I hope you will find more time or that you will choose to prioritize the development of the 850C at the expense of the LCD3 (which is quite limited in memory).

In any case, I will probably buy both screens to help you with your tests.

NIPSEN   100 mW

100 mW
Posts: 38
Joined: Feb 26 2019 5:14pm

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

Post by NIPSEN » Feb 27 2019 3:23pm

FYI, I just found a TSDZ2 sell with 850C LCD :

https://fr.aliexpress.com/store/product ... 70861.html

Probably a custom firmware.

Rydon   100 W

100 W
Posts: 246
Joined: Aug 11 2016 5:26pm

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

Post by Rydon » Feb 28 2019 1:25am

NIPSEN wrote:
Feb 27 2019 3:23pm
FYI, I just found a TSDZ2 sell with 850C LCD :

https://fr.aliexpress.com/store/product ... 70861.html

Probably a custom firmware.
If you buy that motor you might be interested to know that I had some KT-LCD3 displays custom made specifically for the open source firmware project that are plug compatible with the 850C available here (my shop). We also have that same motor with the 850C or KT-LCD3 (found here) but we have to charge a little more because of support, tariffs, etc. We will also be making a small (~$50) donation to the developers as a token thank you for all their hard work (and fried controllers, displays, etc. :) ).

rmnlsn   1 µW

1 µW
Posts: 2
Joined: Feb 21 2019 10:41am

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

Post by rmnlsn » Feb 28 2019 7:24am

Hello everybody,
I'm working on Windows 10,
the installed SDCC is at version mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 3.8.0 #10562 (MINGW64),
the STVP is at versione 1.8.0.0.

When I compile the files in the src folder on master branch of Flexible OpenSource firmware for TongSheng TSDZ2 mid drive ebike motor with SDCC i get an ihx file.
Which are the next step to get the hex file for the STVP? How can I be sure that the my hex and the TSDZ2-v0.18.2.hex are the same if I didn't modify any src file?

Can someone help me?

Bash1303   1 mW

1 mW
Posts: 19
Joined: Oct 01 2018 1:45am

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

Post by Bash1303 » Feb 28 2019 7:55am

Hello every one

The inner motor seems to have given upp :(
I manager to order a replacement that Will take some time.

My question is: if i connect my old hub motor 36v 350w (hall sensor) to the controller. Will it run normal or i Will be damaging the controller?

I am running the open source firmware V 17

Best regards

Post Reply