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

Electric Motors and Controllers
casainho   100 MW

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

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

Post by casainho » Dec 06 2018 6:40pm

buba wrote:
Dec 06 2018 5:59pm
jbalat wrote:
Dec 06 2018 5:43pm
dameri, could it be your flash cable is too long ?

buba, well done !!!.. How do you reset the trip meter, I think we had problems trying to come up with a button combination that hasnt been used yet.
Thank you so much!!! (And thanks for all the videos!)

When you are choosing to display the trip distance in the odometer field you can simply SHORT CLICK and then LONG HOLD the DOWN button. The same way you reset the odometer and the "distance since power on" by the way. The menu is as follows:

1.0 TRIP DISTANCE
1.1 DISTANCE SINCE POWER ON
1.2 ODOMETER

All is displayed in either miles (MIL) or kilometers (KM) depending on the setting you choose in the basic setup (imperial/metric).

Should I add so that you can set the trip distance to any value also or should that be "locked"? Feedback appreciated!
Hi Buba.

I did the main development of the firmware and I did the structure of LCD3 firmware, so I can guide you.
1.0 TRIP DISTANCE
1.1 DISTANCE SINCE POWER ON
1.2 ODOMETER
On current code, 1.1 and 1.2 are implemented but 1.2 ODOMETER is not. What I wanted to do but I didn't had time, was to store on EEPROM the last selected 1.x, so if user prefers to see for instance 1.1 DISTANCE SINCE POWER ON, the system will always start at 1.1 when users cycles over odometer fields. Is the same idea that odometer last field number is already stored on EEPROM and then the subfields would also need to be stored on EEPROM.

Do you plan to submit a pull request? I suggest you to make a pull request and then I all look and test it, then we can make a new release.
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.

buba   1 mW

1 mW
Posts: 12
Joined: Aug 31 2018 12:36am

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

Post by buba » Dec 06 2018 6:50pm

andyme wrote:
Dec 06 2018 6:31pm

i think it is really important that casainho get involved in this matter since endlesscadence seems not to be around. casainho is in the process of adapting the firmware to work with a color display and i think in order to stay compatible with the future development all changes should be integrated ideally into one piece of software only. So i would hope that you and casainho will agree on how to create files that satisfy his and your needs so that your changes can stay integrated in all future releases.
thineight, thanks! :thumb:

andyme, I would never want it to exist separate versions and would appreciate Casainhos input and feedback into implementing these functions officially. I do respect the time he, and others, have put into this firmware and would never want to request more. I hope someone sees the code to be approved for official use in further versions.

The code is merely updated on the display side and would not take much time to inspect and approve.

andyme   100 W

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

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

Post by andyme » Dec 06 2018 6:54pm

buba wrote:
Dec 06 2018 6:50pm
andyme wrote:
Dec 06 2018 6:31pm

i think it is really important that casainho get involved in this matter since endlesscadence seems not to be around. casainho is in the process of adapting the firmware to work with a color display and i think in order to stay compatible with the future development all changes should be integrated ideally into one piece of software only. So i would hope that you and casainho will agree on how to create files that satisfy his and your needs so that your changes can stay integrated in all future releases.
thineight, thanks! :thumb:

andyme, I would never want it to exist separate versions and would appreciate Casainhos input and feedback into implementing these functions officially. I do respect the time he, and others, have put into this firmware and would never want to request more. I hope someone sees the code to be approved for official use in further versions.

The code is merely updated on the display side and would not take much time to inspect and approve.
As i see it you got casainho already on your train... :) good luck! i think many of us have been looking for these features.

buba   1 mW

1 mW
Posts: 12
Joined: Aug 31 2018 12:36am

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

Post by buba » Dec 06 2018 6:59pm

On current code, 1.1 and 1.2 are implemented but 1.2 ODOMETER is not. What I wanted to do but I didn't had time, was to store on EEPROM the last selected 1.x, so if user prefers to see for instance 1.1 DISTANCE SINCE POWER ON, the system will always start at 1.1 when users cycles over odometer fields. Is the same idea that odometer last field number is already stored on EEPROM and then the subfields would also need to be stored on EEPROM.

Do you plan to submit a pull request? I suggest you to make a pull request and then I all look and test it, then we can make a new release.
Hi Casainho, and thank you for the reply!

I know what you mean and will try to fix it so that everything is stored on EEPROM and saved even when user power cycles! Good feedback!

Will try to add that also and then pull request so you can test it! Great!

casainho   100 MW

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

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

Post by casainho » Dec 06 2018 7:01pm

buba wrote:
Dec 06 2018 6:59pm
I know what you mean and will try to fix it so that everything is stored on EEPROM and saved even when user power cycles! Good feedback!

Will try to add that also and then pull request so you can test it! Great!
Well, but the idea would be to store all subfields last state, not only the subfiled for 1.x. I hope that while you are at it, you can structure and implementation that works for all the subfields.
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.

dameri   10 mW

10 mW
Posts: 24
Joined: Sep 20 2018 10:57am

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

Post by dameri » Dec 07 2018 4:06am

jbalat wrote:
Dec 06 2018 5:43pm
dameri, could it be your flash cable is too long ?
Is this cable too long?
St-linkCable.JPG
St-linkCable.JPG (146.71 KiB) Viewed 253 times

User avatar
jbalat   10 kW

10 kW
Posts: 523
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 » Dec 07 2018 6:45am

Nah looks fine to me.. hmmm, other issues people have had is markings on their stlink was not the same as default but then you would get different errors, also not enough power on the USB port, maybe try another laptop ?
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

andyme   100 W

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

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

Post by andyme » Dec 07 2018 8:44am

DPC-18 hmmmm...glue, glue, glue...and i think very different from the 850C

one thing before i start:

this UART thing....could that mean that it could be programmed without the need to open it?

ok, so i opened it...different case/housing as the 850C...there is no frame, etc...so the cover glass is glued in directly into the case. it is from real glass. I think it would be very difficult to remove it without breaking it. I broke mine into pieces. However: it could always be replaced by some piece of acrylic glass for a few cents. so that must not necessarily be the stop mark yet.

after the glass is gone, the display comes out immediately. the board is held in place by 2 small screws AND: glue....the part you want to get to is the bottom side, in order to get there you will also need to remove the USB which is, you guess it, also glued in..

i managed to remove all that (it is not really a problem, frankly spoken.

So please find attached the pics. first one is an open 850C so you can see that i was able to open that one with no issue... :lol:
Attachments
20181207_141921.jpg
20181207_142028.jpg
20181207_141951.jpg
20181207_142002.jpg

casainho   100 MW

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

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

Post by casainho » Dec 07 2018 9:08am

andyme wrote:
Dec 07 2018 8:44am
this UART thing....could that mean that it could be programmed without the need to open it?
850C also is updated by UART but it is encrypted, it uses an encrypted bootloader that I bet is the same for the DPC18. They both use the same STM32, I bet they both use UART bootloader with encryption so using UART to update is not an option.

That STM32F205RC is an Arm Cortex-M3 MCU with 256 Kbytes Flash, 120 MHz CPU and the one on 850C has 512 Kbytes Flash, 128 MHz CPU. So I would say in terms of processing and memory for implement advanced features, the 850C is good.

That board of DPC18, I can't see pads where we can connect the STLinkV2 for flashing while on 850C they are conveniently placed on top right, like on KT-LCD3 and so is easy to open a hole on the case to accommodate the programming header pins.
Also, as you say, it seems more destructive the process to open DPC18 when compared to 850C. And also since hardware is different, microcontroller reference, probably a different LCD (no LCD reference), etc, would take a lot of time and money to start develop for DPC-18 and so I am discarding that possibility.

About the remote buttons, I see 5 wires on the board: black, green, yellow, blue and red. Can you please open the remote and see how the buttons are wired?? how it has 5 buttons with only 5 wires?? Because maybe we can learn and who knows if we can do the same for 850C and it has on the board 5 pads for 5 wires from a remote...
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.

andyme   100 W

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

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

Post by andyme » Dec 07 2018 9:16am

casainho wrote:
Dec 07 2018 9:08am
andyme wrote:
Dec 07 2018 8:44am
this UART thing....could that mean that it could be programmed without the need to open it?
850C also is updated by UART but it is encrypted, it uses an encrypted bootloader that I bet is the same for the DPC18. They both use the same STM32, I bet they both use UART bootloader with encryption so using UART to update is not an option.

That STM32F205RC is an Arm Cortex-M3 MCU with 256 Kbytes Flash, 120 MHz CPU and the one on 850C has 512 Kbytes Flash, 128 MHz CPU. So I would say in terms of processing and memory for implement advanced features, the 850C is good.

That board of DPC18, I can't see pads where we can connect the STLinkV2 for flashing while on 850C they are conveniently placed on top right, like on KT-LCD3 and so is easy to open a hole on the case to accommodate the programming header pins.
Also, as you say, it seems more destructive the process to open DPC18 when compared to 850C. And also since hardware is different, microcontroller reference, probably a different LCD (no LCD reference), etc, would take a lot of time and money to start develop for DPC-18 and so I am discarding that possibility.

About the remote buttons, I see 5 wires on the board: black, green, yellow, blue and red. Can you please open the remote and see how the buttons are wired?? how it has 5 buttons with only 5 wires?? Because maybe we can learn and who knows if we can do the same for 850C and it has on the board 5 pads for 5 wires from a remote...
Gotcha...i will be doing this in about 8-9 hours from now

casainho   100 MW

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

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

Post by casainho » Dec 07 2018 9:17am

casainho wrote:
Dec 07 2018 9:08am
andyme wrote:
Dec 07 2018 8:44am
this UART thing....could that mean that it could be programmed without the need to open it?
850C also is updated by UART but it is encrypted, it uses an encrypted bootloader that I bet is the same for the DPC18. They both use the same STM32, I bet they both use UART bootloader with encryption so using UART to update is not an option.
With encrypted bootloader, they own the firmware and seems they sell specific firmware versions for OEMs, sometimes as we see, the only thing is placing an image banner with the brand of the OEM -- that is why I am being contacted by some OEMs/EBike sellers asking for me to place the brand on the LCD -- that must have value for them!!

I believe Bafang (and other producers) earn money by customizing their original LCD firmware for OEMs, that is why they want to lock the system and that is why this project could represent some problems to this part of their business model -- but, open the LCDs and solder pins is DIY so I guess OEMs will still prefer to pay them and buy batch of LCDs ready and with guarantee.
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.

andyme   100 W

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

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

Post by andyme » Dec 07 2018 6:19pm

andyme wrote:
Dec 07 2018 9:16am
casainho wrote:
Dec 07 2018 9:08am
andyme wrote:
Dec 07 2018 8:44am
this UART thing....could that mean that it could be programmed without the need to open it?


Gotcha...i will be doing this in about 8-9 hours from now
I need more time to look into this. PCB is 2 sided black is supposed to be ground. Maybe there are some combinations of wires that are being activated? I will try to measure this, no idea of i will be successful. I will be back with more ...
20181208_001223~01.jpg
20181208_001214~01.jpg

Rafe   10 mW

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

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

Post by Rafe » Dec 07 2018 6:22pm

Phew. I'm glad I decided not to try and open the front of my DPC18 Andyme that is one very expensive look and see you just did. :shock:

linklemming   1 mW

1 mW
Posts: 18
Joined: Aug 25 2011 12:55pm

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

Post by linklemming » Dec 08 2018 1:46am

Is the high cadence mode only applicable to the 36V motor because the parameters used for this mode are for the 36V motor?

I can now build my own software so Im willing to try stuff for 48V motor if someone could let me know what parameters to try. Im also literate in software/firmware as its my profession and I spend all day analyzing and testing code (spent 20 years prior in coding/development).

The high human power values, still confuse me, I have been thru all the code/calculations and all looks good. Basically it just seems twice as high as it should. Just out of curiosity...from researching torques sensors like those available thru grin technologies, it appears that some only measure one pedals force and some measure from both pedals. Could this somehow be the issue?

In the end, I dont think it really matters as the power calculation is measuring work, if its off by a factor of x, thats fine. The possible issue is that the default assist multipliers seem to try be very close to those of the bosch unit but could be off if the actual power is not the same as what the bosch is measuring. From todays ride analysis, I think I am going to try lower assist multipliers like jbalat has recommended. Im basically going to just cut them(defaults) in half and see how that works. The default values just seem too 'all or nothing'. I can definately feel difference between assist 1(0.5) and 2(1.0) but 3-5(1.5,2.0,2.5) seem the same unless I intentionally barely use the pedals (low cadence, low pressure). Some might like that but it seems off to me and nothing like my brose equipped bike.

Just ordered an 850C, hoping to get that running next week

casainho   100 MW

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

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

Post by casainho » Dec 08 2018 5:15am

andyme wrote:
Dec 07 2018 6:19pm
I need more time to look into this. PCB is 2 sided black is supposed to be ground. Maybe there are some combinations of wires that are being activated? I will try to measure this, no idea of i will be successful. I will be back with more ..
Try to make the schematic of that board, can be on a paper and then you take a picture.
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.

dameri   10 mW

10 mW
Posts: 24
Joined: Sep 20 2018 10:57am

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

Post by dameri » Dec 08 2018 6:54am

jbalat wrote:
Dec 07 2018 6:45am
Nah looks fine to me.. hmmm, other issues people have had is markings on their stlink was not the same as default but then you would get different errors, also not enough power on the USB port, maybe try another laptop ?
I don’t know what is the problen. I think my laptop have enough power on usb port. ST-link is not regocnized in usb3 port. I have tried also desktop computer with usb extension cable, and no luck.

Maby I have wrong cable. There is different colors than wiki page. https://github.com/OpenSource-EBike-fir ... e-on-TSDZ2

Picture colors from up to down.

Black, green orange, purple, brown and white
SpeedCable.jpg
SpeedCable.jpg (348.39 KiB) Viewed 153 times

Rafe   10 mW

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

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

Post by Rafe » Dec 08 2018 8:27am

dameri wrote:
Dec 08 2018 6:54am
jbalat wrote:
Dec 07 2018 6:45am
Nah looks fine to me.. hmmm, other issues people have had is markings on their stlink was not the same as default but then you would get different errors, also not enough power on the USB port, maybe try another laptop ?
I don’t know what is the problen. I think my laptop have enough power on usb port. ST-link is not regocnized in usb3 port. I have tried also desktop computer with usb extension cable, and no luck.

Maby I have wrong cable. There is different colors than wiki page. https://github.com/OpenSource-EBike-fir ... e-on-TSDZ2

Picture colors from up to down.

Black, green orange, purple, brown and white
SpeedCable.jpg


Wiring colours on that link are the same as your cable.

You should have Purple to RST, Black to SWIM, Orange to GND, and Brown to 5V. White and Green not used

To check your wiring with a multimeter here's the pin out photo https://github.com/hurzhurz/tsdz2/blob/master/pinout.md

Your ST Link Dongle is labeled slightly differently to mine The two GNDs swap places with SWIM and SWDIO but I've no idea if changing wires would cause damage. Like this:
https://github.com/OpenSource-EBike-fir ... stlink.jpg


You may find this page helpful too
https://www.eco-ebike.com/blogs/eco-cyc ... romscratch
Last edited by Rafe on Dec 08 2018 8:37am, edited 1 time in total.

dameri   10 mW

10 mW
Posts: 24
Joined: Sep 20 2018 10:57am

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

Post by dameri » Dec 08 2018 8:36am

Thanks Rafe.

My ST-LINK is propably not working. When I try to read tabs the light goes out of device. Is this normal? I have to unplug device and connect again and light comes on.

Where you have ordered (working) ST-LINK device? Is there sellers in europe? When order from china it takes ages to come.

Rafe   10 mW

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

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

Post by Rafe » Dec 08 2018 8:42am

In the UK you can order from what are listed as UK sellers on Ebay at a premium price so I assume that must be the same elsewhere. The one caveat is that many of them are actually in China using faster mail.


Rafe   10 mW

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

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

Post by Rafe » Dec 08 2018 9:46am

Just reading back through your posts Dameri you seem to be doing everything properly. Logically if the ST Link works on LCD3 and not on the motor controller then it has to be the wiring to the controller and that usually is the wires are too long but in your case they could not be shorter. So I would suggest checking your wiring from the ST link to the plug again because if the length of wiring is critical then a poor connection would also have the same effect. Taking out the soldering iron and re-doing it all again may just pay dividends.
Last edited by Rafe on Dec 08 2018 11:57am, edited 4 times in total.

dameri   10 mW

10 mW
Posts: 24
Joined: Sep 20 2018 10:57am

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

Post by dameri » Dec 08 2018 9:59am

Thank's again Rafe, I have been triple check wires and solder again wires. I think I go to buy new dongle from local dealer on monday. It's quite expensive compared to ebay but I don't have to wait.

Now I'm going to watch snooker.

Rafe   10 mW

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

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

Post by Rafe » Dec 08 2018 10:00am

Yes I think I would try another link too then. Enjoy the snooker, :D These cheap Chinese clones are probably a false economy.


like you I could not programme the controller from the lap top but could the LCD3 and also like you managed to read the controller a few times. I then moved over to the PC and that was still iffy so I then used the USB socket on on a memory card reader that is plugged directly into a USB riser on the motherboard with no other USB devices loading the connection and hey presto it worked. That was via a USB extension lead from PC to ST Link too but it was the second one I tried, it did not work properly on first extension lead.

angusinalberta   1 mW

1 mW
Posts: 13
Joined: Jun 18 2018 8:57pm
Location: alberta

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

Post by angusinalberta » Dec 08 2018 12:40pm

linklemming writes
I can definately feel difference between assist 1(0.5) and 2(1.0) but 3-5(1.5,2.0,2.5) seem the same unless I intentionally barely use the pedals (low cadence, low pressure)
The stock firmware uses torque assist levels of 0.4, 0.75, 1.5, and 3.0
Note the progression, each step is double. Try something like that.

andyme   100 W

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

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

Post by andyme » Dec 08 2018 12:58pm

casainho wrote:
Dec 08 2018 5:15am
andyme wrote:
Dec 07 2018 6:19pm
I need more time to look into this. PCB is 2 sided black is supposed to be ground. Maybe there are some combinations of wires that are being activated? I will try to measure this, no idea of i will be successful. I will be back with more ..
Try to make the schematic of that board, can be on a paper and then you take a picture.
ok, so it goes like this:

wire combination: "button name"

yellow and black: "plus"
green and black : "minus"
yellow and red : "info symbol"
green and red : "light symbol"
blue and red : "power symbol"

Labels:

blue: L1
green: L2
yellow: L3
red: R1
black: GND

Post Reply