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

Electric Motors and Controllers
casainho   100 MW

100 MW
Posts: 2668
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Nov 12 2018 5:50pm

jbalat wrote:
Nov 12 2018 5:47pm
maximusdm wrote:
Nov 12 2018 4:13pm
@ Cas
I run today 0.15 with current ramp for lag. In my opinion the fix is solid even when starting in 8th gear. Previously the lag was 2s +.

The power delivery is solid gold, bike is very responsive. I can hit 45km/h with 0.4 assist using 220w.
Max,
I couldnt find where to make the change so I just set the inverse ramp again down to 20 which works well for me...
I looked in motor.c and motor.h but couldnt find where to set the current ramp ?
Yeh I think the new assist levels work well, just need a bit of tweaking as they are too powerful for me :)
I think I did mention the current ramp configuration value is on config.h.

I wounder if the rate of 5 amps/second is fast enough. What would be the value for the guys that prefer torque/force? And for the others that prefer to save the gears?
Developer of the Flexible OpenSource firmware for EBike motor controllers (TSDZ2 and KT) and LCDs (KT-LCD3 and Bafang 850C color LCD).

If you like my work, you can 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
jbalat   10 kW

10 kW
Posts: 526
Joined: Nov 10 2012 11:50pm
Location: Melbourne, Australia

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

Post by jbalat » Nov 13 2018 12:38am

Hi Casainho I will have another look for it, but I have to say I really love the assist levels based on human power. It feels like you get rewarded when you peddle harder, I don’t know why but I also used less battery than normal.
Good Work :thumb:

Oh my speed sensor connection is really dodgy, I’m a bit scared to flash again... but I really need to fix the problem with leaning on the peddles and motor cutting out :(
I’m thinking about soldering the motor wires to the sensor cable but leave another connector which I can use just for flashing, do you think you can still flash while the sensor is connected ?
I wounder if the rate of 5 amps/second is fast enough. What would be the value for the guys that prefer torque/force? And for the others that prefer to save the gears?
It would be so cool if we could set this value in one of the config menus !!!
Please subscribe to my Youtube home page for Quadcopters, FPV and Bike Rides http://www.youtube.com/jbalatutube
My build log here http://endless-sphere.com/forums/viewto ... =6&t=55352
For some cool ebike talk join us on The Best ebike https://www.facebook.com/groups/193581737807033/
Tech talk TSDZ2 Opensource firmware viewtopic.php?f=30&t=93818&start=150

michih.   1 µW

1 µW
Posts: 3
Joined: Nov 11 2018 8:33am

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

Post by michih. » Nov 13 2018 12:59am

We need All this ramp 😲

Mfg Michael

maximusdm   100 mW

100 mW
Posts: 36
Joined: Sep 08 2018 12:51pm

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

Post by maximusdm » Nov 13 2018 4:12am

jbalat wrote:
Nov 12 2018 5:47pm
Max,
I couldnt find where to make the change so I just set the inverse ramp again down to 20 which works well for me...
I looked in motor.c and motor.h but couldnt find where to set the current ramp ?
Yeh I think the new assist levels work well, just need a bit of tweaking as they are too powerful for me :)
I used the already created branch(https://github.com/OpenSource-EBike-fir ... rrent_ramp) and made a manual release from it.

Yes, it works to flash with the speed sensor connected. Initially I made connections directly on the motor wires since my stlink did not work.

andyme   100 W

100 W
Posts: 174
Joined: Oct 04 2017 1:40pm

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

Post by andyme » Nov 13 2018 4:45am

maximusdm wrote:
Nov 13 2018 4:12am
jbalat wrote:
Nov 12 2018 5:47pm
Max,

I couldnt find where to make the change so I just set the inverse ramp again down to 20 which works well for me...
I looked in motor.c and motor.h but couldnt find where to set the current ramp ?
Yeh I think the new assist levels work well, just need a bit of tweaking as they are too powerful for me :)
@jbalat i am not sure if you mean what is also my impression: you can get "carried away" and reach power assist values that you actually would have wanted to avoid.

that is why i imagine that introducing configurable upper limits per assist level individually would help in this matter. because there may be siutations where you need or want 500 W assistance, so you can assign these or no limit at all to e.g just level 4 or 5, and e.g. limit all the others to 300.

in my specific case i have a rather long hill to climb up to get home. i need as much assistance as possible then. but in most of the other situations i would not mind/prefer to set an upper limit.

andyme   100 W

100 W
Posts: 174
Joined: Oct 04 2017 1:40pm

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

Post by andyme » Nov 13 2018 8:13am

gaber wrote:
Nov 07 2018 9:44pm
How have you guys wired in your brake wires? I understand how to do it schematically (thanks to the wiki), but am curious where you’ve spliced them in and with what connectors. Looking to capitalize on the group think instead of reinventing the wheel.
sorry, i just read this now.

my original display's cable (XS18?) in integrated in the upper tube of the bike. I did not want to remove it, so therefore i cut the old display's cable shortly after the top. I added the brake sensor and i soldered everything together. I did not make any connectors here, but it would not be a problem to add that if needed, obviously.
WhatsApp Image 2018-11-13 at 14.10.12(2).jpeg
WhatsApp Image 2018-11-13 at 14.10.12(1).jpeg
WhatsApp Image 2018-11-13 at 14.10.12.jpeg

nbdriver   10 mW

10 mW
Posts: 32
Joined: Jul 31 2015 4:38am
Location: Belgium

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

Post by nbdriver » Nov 13 2018 9:07am

Sorry to ask but what is stalled wheel protection ?
and what is exactly the problem reported by EndlessCadence regarding this functionality.

I'm about to flash 0.15.0 but if this problem ist fixed in 0.15.1 i may just wait a few days :D

Thank you,

User avatar
gaber   1 W

1 W
Posts: 59
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 » Nov 13 2018 9:35am

andyme wrote:
Nov 13 2018 8:13am
my original display's cable (XS18?) in integrated in the upper tube of the bike. I did not want to remove it, so therefore i cut the old display's cable shortly after the top. I added the brake sensor and i soldered everything together. I did not make any connectors here, but it would not be a problem to add that if needed, obviously.

No worries - thanks Andy! I'm going down a very similar path. VLCD5 display cable cut around the same spot. Planning on running a couple of pigtail wires (for GND and Brake wires) out of the solder bundle and add connectors to those and the end of the wires coming from the brake lever. Will hopefully be a clean and modular solution.

Just to double check, I only need to wire into Brake and GND on the motor side, correct? Nothing needs to be wired into the LCD3 side for brakes to work?
sometimes you eat the bear, and sometimes, well, he eats you.

andyme   100 W

100 W
Posts: 174
Joined: Oct 04 2017 1:40pm

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

Post by andyme » Nov 13 2018 10:28am

gaber wrote:
Nov 13 2018 9:35am
andyme wrote:
Nov 13 2018 8:13am


Just to double check, I only need to wire into Brake and GND on the motor side, correct? Nothing needs to be wired into the LCD3 side for brakes to work?
Yes!

User avatar
gaber   1 W

1 W
Posts: 59
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 » Nov 13 2018 11:27am

andyme wrote:
Nov 13 2018 10:28am
gaber wrote:
Nov 13 2018 9:35am
Just to double check, I only need to wire into Brake and GND on the motor side, correct? Nothing needs to be wired into the LCD3 side for brakes to work?
Yes!
Sweet, thanks man! I'll see if I can't help clarify some of the wiki documentation when I get this finished up.
sometimes you eat the bear, and sometimes, well, he eats you.

Rafe   10 mW

10 mW
Posts: 29
Joined: Oct 16 2018 5:56pm

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

Post by Rafe » Nov 13 2018 12:19pm

Delete superseded by new firmware
Last edited by Rafe on Nov 13 2018 5:33pm, edited 4 times in total.

maximusdm   100 mW

100 mW
Posts: 36
Joined: Sep 08 2018 12:51pm

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

Post by maximusdm » Nov 13 2018 1:32pm

jbalat wrote:
Nov 13 2018 12:38am
Oh my speed sensor connection is really dodgy, I’m a bit scared to flash again... but I really need to fix the problem with leaning on the peddles and motor cutting out :(
I’m thinking about soldering the motor wires to the sensor cable but leave another connector which I can use just for flashing, do you think you can still flash while the sensor is connected ?
I ordered some waterproof cables with connectors from aliexpress. They are quite cheap and should arrive fast to Australia.
https://www.aliexpress.com/item/40cm-2- ... 4c4dWWsO6C.
You can make the connection from motor to speed sensor with them and still write firmware.

Hope it help :)

EndlessCadence   100 W

100 W
Posts: 217
Joined: Aug 22 2018 4:31am

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

Post by EndlessCadence » Nov 13 2018 3:11pm

jbalat wrote:
Nov 13 2018 12:38am
Oh my speed sensor connection is really dodgy, I’m a bit scared to flash again... but I really need to fix the problem with leaning on the peddles and motor cutting out :(
I’m thinking about soldering the motor wires to the sensor cable but leave another connector which I can use just for flashing, do you think you can still flash while the sensor is connected ?
That sucks mate! Yes, it should work fine.

EndlessCadence   100 W

100 W
Posts: 217
Joined: Aug 22 2018 4:31am

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

Post by EndlessCadence » Nov 13 2018 3:14pm

:!:

I've released two new versions. Thanks casainho!

0.15.1 which fixes the stall protection issue (blinking 1 on display).
https://github.com/OpenSource-EBike-fir ... ag/v0.15.1

0.16.0 which also includes the new battery current ramp feature:
https://github.com/OpenSource-EBike-fir ... ag/v0.16.0

This way you can decide which one you want. I didn't try 0.16.0 myself yet.
It isn't necessary to reset your configuration to factory defaults or flash the display again if you were using version 0.15.0 already.

Enjoy! :D

vailbiker   1 µW

1 µW
Posts: 4
Joined: Nov 08 2018 5:45pm

Re: Flashing LCD3 Swim Errors

Post by vailbiker » Nov 13 2018 3:24pm

[/quote]

Hi,

I had similar problems when I tried to flash the open source firmware to my bike. :wink:

First of all, I have to say that the imaging in the wiki is partly incomplete and that you have to look at the plug layout carefully from several videos and sources together to get all the connections working - and maybe this is your problem as well. I do not know how complete your information is. Then it was a problem that the v2 clone was not working well. After I bought another one and tried another dealer too, I've got a different clon, that is different with the swim/gnd pin assignment. Maybe the pin assignment printing from the first clone is wrong - I've not checked it so far - just some cheap chinese scrap to throw it into trash..

I hope this helps you any further.
[/quote]


Thank you! This was helpful. I have what appears to be an identical STLink V2 clone as the one pictured by Casainho on the Github page. I put on my reading glasses and looked closely on the housing and sure enough the SWIM and GND pins are opposite on my STLink. I swapped the two wires and was able to flash the LCD3 without any issues. Apologies for taking up bandwidth for such an obvious mistake!

User avatar
gaber   1 W

1 W
Posts: 59
Joined: Sep 22 2017 8:56am
Location: Grand Rapids, MI

Re: Flashing LCD3 Swim Errors

Post by gaber » Nov 13 2018 3:35pm

vailbiker wrote:
Nov 13 2018 3:24pm

Hi,

I had similar problems when I tried to flash the open source firmware to my bike. :wink:

First of all, I have to say that the imaging in the wiki is partly incomplete and that you have to look at the plug layout carefully from several videos and sources together to get all the connections working - and maybe this is your problem as well. I do not know how complete your information is. Then it was a problem that the v2 clone was not working well. After I bought another one and tried another dealer too, I've got a different clon, that is different with the swim/gnd pin assignment. Maybe the pin assignment printing from the first clone is wrong - I've not checked it so far - just some cheap chinese scrap to throw it into trash..

I hope this helps you any further.
In an effort to clarify some things - here are the portion of my raw prep notes pertaining to creation of the ST link cable, as well as the soldering of the female side of the speed sensor extension cable directly to the LCD3 pins to make for easier flashing.

*Create ST Link flash cable by cutting ST Link ribbon cable (fairly short) and soldering appropriate wires to (fairly short) female connector from speed ext cable
* Whole thing should be ~10cm
* Stagger wire cuts so solder points don’t stack up, will be good practice for display to motor connection
* Drill hole in back of LCD 3 and solder female speed extension cable directly to LCD3 pins for easy programming
* LCD 3 J7 pins (left to right looking at display front) > ST Link pin connections
* LCD3 pin1: (display cable brown) connect to (grey ST cable) STLinkV2 5V pin
* LCD3 pin2: (display cable black) connect to (black ST cable) STLinkV2 SWIM pin
* LCD3 pin3: (display cable orange) connect to (white ST cable) STLinkV2 GND pin
* LCD4 pin4: (display cable purple) connect to (purple ST cable) STLinkV2 RST pin

Does that make sense to other people? If it does, I would be happy to it clean up, add some photos and submit to the wiki.
sometimes you eat the bear, and sometimes, well, he eats you.

michih.   1 µW

1 µW
Posts: 3
Joined: Nov 11 2018 8:33am

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

Post by michih. » Nov 13 2018 3:45pm

0.16.0 is Absolutely awesome :bigthumb:

Mfg Michael

nbdriver   10 mW

10 mW
Posts: 32
Joined: Jul 31 2015 4:38am
Location: Belgium

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

Post by nbdriver » Nov 13 2018 4:58pm

Oh what a cadence of releases :D
I just flashed the 0.15 version this afternoon and already a new version.

Feels great on 0.15 but :
I also noticed buttons being unresponsive in Config when pressed too long.
I started to play with off-road mode, and couldn’t figure out how to activate power limit with power and up keys, and enable soc display in temperature field when off-road mode feature is enabled. Because this combinations are used to enable and disable off-road mode. I had to disable off-road mode function to use on-off and down to show SOC in temperature field, and after re enable it.

Could you help me ?

And what precisely does the new ramp code ? I hesitate between flashing 0.15.1 and 0.16.

Not having to flash the display again is her great thing.

Thank you all for your wonderful work.

andyme   100 W

100 W
Posts: 174
Joined: Oct 04 2017 1:40pm

Re: Flashing LCD3 Swim Errors

Post by andyme » Nov 13 2018 5:09pm

gaber wrote:
Nov 13 2018 3:35pm
vailbiker wrote:
Nov 13 2018 3:24pm

Hi,

I had similar problems when I tried to flash the open source firmware to my bike. :wink:

First of all, I have to say that the imaging in the wiki is partly incomplete and that you have to look at the plug layout carefully from several videos and sources together to get all the connections working - and maybe this is your problem as well. I do not know how complete your information is. Then it was a problem that the v2 clone was not working well. After I bought another one and tried another dealer too, I've got a different clon, that is different with the swim/gnd pin assignment. Maybe the pin assignment printing from the first clone is wrong - I've not checked it so far - just some cheap chinese scrap to throw it into trash..

I hope this helps you any further.
In an effort to clarify some things - here are the portion of my raw prep notes pertaining to creation of the ST link cable, as well as the soldering of the female side of the speed sensor extension cable directly to the LCD3 pins to make for easier flashing.

*Create ST Link flash cable by cutting ST Link ribbon cable (fairly short) and soldering appropriate wires to (fairly short) female connector from speed ext cable
* Whole thing should be ~10cm
* Stagger wire cuts so solder points don’t stack up, will be good practice for display to motor connection
* Drill hole in back of LCD 3 and solder female speed extension cable directly to LCD3 pins for easy programming
* LCD 3 J7 pins (left to right looking at display front) > ST Link pin connections
* LCD3 pin1: (display cable brown) connect to (grey ST cable) STLinkV2 5V pin
* LCD3 pin2: (display cable black) connect to (black ST cable) STLinkV2 SWIM pin
* LCD3 pin3: (display cable orange) connect to (white ST cable) STLinkV2 GND pin
* LCD4 pin4: (display cable purple) connect to (purple ST cable) STLinkV2 RST pin

Does that make sense to other people? If it does, I would be happy to it clean up, add some photos and submit to the wiki.
I just want to say that the colors of STLink cables are arbitrary...it can be about anything depending on the maker.

And why would you solder the speed sensor cable to the pins? (edit: oh, so you can use the cable from the motor flash...i did as on the pic attached and i have one dedicated st-link for the motor and one for the display
WhatsApp Image 2018-11-13 at 23.08.08.jpeg
Last edited by andyme on Nov 13 2018 5:22pm, edited 1 time in total.

andrea_104kg   10 mW

10 mW
Posts: 27
Joined: Mar 05 2018 5:51pm

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

Post by andrea_104kg » Nov 13 2018 5:09pm

Sorry, my english it's bad, i do not undestand the difference betwine throttle version and no throttle version. The fist it's ONLY for throttle or work also whith torque sensor?
A motor whithout throttle works whith throttle version?

andyme   100 W

100 W
Posts: 174
Joined: Oct 04 2017 1:40pm

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

Post by andyme » Nov 13 2018 5:17pm

andrea_104kg wrote:
Nov 13 2018 5:09pm
Sorry, my english it's bad, i do not undestand the difference betwine throttle version and no throttle version. The fist it's ONLY for throttle or work also whith torque sensor?
A motor whithout throttle works whith throttle version?
Hi, you know what throttle is, yes? it is thumb gaz switch, so you can ride the bike like a motorcycle.

so: if you have this version, you use the throttle file, if you do not have it, you use the other one.

User avatar
gaber   1 W

1 W
Posts: 59
Joined: Sep 22 2017 8:56am
Location: Grand Rapids, MI

Re: Flashing LCD3 Swim Errors

Post by gaber » Nov 13 2018 5:21pm

andyme wrote:
Nov 13 2018 5:09pm

I just want to say that the colors of STLink cables are arbitrary...it can be about anything depending on the maker
They’re not important in general, but i wanted my prep to be very prescriptive and thought out so i just had to execute when soldering time came. That said, great point that those specifics vary and should be removed before posting to wiki.
andyme wrote:
Nov 13 2018 5:09pm

And why would you solder the speed sensor cable to the pins? i did as on the pic attachedWhatsApp Image 2018-11-13 at 23.08.08.jpeg
To match up with the male end of the speed sensor > STLink cable i made to flash the motor. This isn’t necessary, but is an option and (IMHO) provides the cleanest and easiest method for future flashing of both the motor and LCD. Some photos would be worth all the above words, I’ll work on getting some.
sometimes you eat the bear, and sometimes, well, he eats you.

andrea_104kg   10 mW

10 mW
Posts: 27
Joined: Mar 05 2018 5:51pm

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

Post by andrea_104kg » Nov 13 2018 5:37pm

andyme wrote:
Nov 13 2018 5:17pm
andrea_104kg wrote:
Nov 13 2018 5:09pm
Sorry, my english it's bad, i do not undestand the difference betwine throttle version and no throttle version. The fist it's ONLY for throttle or work also whith torque sensor?
A motor whithout throttle works whith throttle version?
Hi, you know what throttle is, yes? it is thumb gaz switch, so you can ride the bike like a motorcycle.

so: if you have this version, you use the throttle file, if you do not have it, you use the other one.
but if i have throtte version and do not use throtte, it works?
Actually no problem i have a 36v no throttle, but i will buy a 48v for another bike, and i planned to buy throttle version. But only for rare use of throttle.

EndlessCadence   100 W

100 W
Posts: 217
Joined: Aug 22 2018 4:31am

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

Post by EndlessCadence » Nov 13 2018 6:43pm

nbdriver wrote:
Nov 13 2018 4:58pm
And what precisely does the new ramp code ? I hesitate between flashing 0.15.1 and 0.16.
Go with 0.15.1 for now, will solve the possible error on display (blinking 1) and is just an awesome version. The button issue has already been reported and is a low priority for me.

andyme   100 W

100 W
Posts: 174
Joined: Oct 04 2017 1:40pm

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

Post by andyme » Nov 13 2018 7:03pm

nbdriver wrote:
Nov 13 2018 4:58pm


And what precisely does the new ramp code ?
This is something I also really would like to know.

Maybe someone from those who know could be so kind to explain what it does and how that improves the behavior.

I am sure everyone here does his best to follow up but we simply do not all have the same knowledge...

Thanks...

Post Reply