BT Interface for TSDZ2 Open Source firmware - Work in progress

Electric Motors and Controllers
Post Reply
vass   1 W

1 W
Posts: 57
Joined: Jul 07 2020 3:57am

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by vass » Sep 14 2020 10:35am

mspider65 wrote:
Sep 03 2020 1:49am
Wimpy747 wrote:
Sep 02 2020 11:39am
I guess if I don't want to open the motor I can also place the board in the cable in a waterproof box, think this does not affect the behavior and functioning of the board?
Yes you can do it in this way too.
mspider65 do you think making the cable to the lcd5 longer will affect anything? (like controller cable -> 1m cable to pcb -> 1m oem cable to LC5.

i want also to have the pcb near the phone (inside a box on a phone holder for extra security) but dont want to splice the oem wiring (so i will have a damn big cable :) )

mspider65   100 W

100 W
Posts: 144
Joined: Aug 04 2019 2:10pm

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by mspider65 » Sep 14 2020 11:04am

vass wrote:
Sep 14 2020 10:35am
mspider65 do you think making the cable to the lcd5 longer will affect anything? (like controller cable -> 1m cable to pcb -> 1m oem cable to LC5.

i want also to have the pcb near the phone (inside a box on a phone holder for extra security) but dont want to splice the oem wiring (so i will have a damn big cable :) )
No problem at all, since serial connections are terminated on te ESP32 board.

PandaYeti   1 mW

1 mW
Posts: 13
Joined: Feb 10 2020 2:32pm

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by PandaYeti » Sep 15 2020 3:25am

mspider65 wrote:
Sep 10 2020 7:57am
It's really difficult to compare power consumption between two different firmware, there are really many parameters that affects the comparison. I have a 36V motor and my feeling is different and compared to the official 0.20beta i have detected a slightly lower consumption (about 5% less)
You could try to reduce the default motor inductance parameter in the android app (e.g. from 142 to 120 or 110), maybe with the current setup the FOC angle calculation for the 48V motor is too "aggressive".
Field weakening starts only above 85 rpm and only if you are using a high assistance factor. You could check if field weakening was active looking in the Graph view and selecting the "field weakening angle" parameter.
I am just working now on motor optimization (better rotor position estimation) and I hope to publish soon a new release that will provide a small further improvement.
Adjusting the value to 120 feels more robust. A little weaker, but I felt, like the motor started to stutter when using very high rpm and 142.
Is it possible to flash 0.20beta OTA in order to compare the firmwares? Most of the values should als show up fine in the app, right?
Yes, in the Android app you could set the torque offset parameter. Enable the checkbox and put the value you read on the "ADC torque" dashboard field when the your feets are not on pedals.
For some reason the torque sensor takes a long time to stabilize the signal and often the offset calculated at the startup is lower than the correct value.
:oops: That works perfektly, thank you!
Actually the only way is changing the setup on the OEM display. But I think it would also be useful to have the option to change it from the Android app. I will take this into account for the next release.
That would be great!! Thanks!

PandaYeti   1 mW

1 mW
Posts: 13
Joined: Feb 10 2020 2:32pm

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by PandaYeti » Sep 15 2020 3:28am

vass wrote:
Sep 14 2020 10:11am
E-bike lover wrote:
Sep 13 2020 12:02pm
Hi guys
I am interested in this pcb too but I have just found this post after searching for months. Probably others couldn't find this post too and will be better to add these kind of pages(optimisation for tsdz2) to github.
I have a idea to improve this pcb and that is by adding gps and sim function to it so that the bike could be traceable. Anyone has any idea how to make it?
Also, it would be nice if someone could sell me 1/2 pcb in a reasonable price in EU :D
hello, VelOtto has 2 pcbs, i was going to buy 2 but you can take one of them (PM him).
I also got 2 spare ones. I think I paid to much taxes though, which made them more expensive, still trying to figure out why.

mspider65   100 W

100 W
Posts: 144
Joined: Aug 04 2019 2:10pm

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by mspider65 » Sep 15 2020 4:26pm

PandaYeti wrote:
Sep 15 2020 3:25am
Is it possible to flash 0.20beta OTA in order to compare the firmwares? Most of the values should als show up fine in the app, right?
I don't quite remember if I changed anything in the protocol, but it should probably work. Try and let me know.
Also try the new version that I am publishing now. I am confident that the new release brings improvements.

mspider65   100 W

100 W
Posts: 144
Joined: Aug 04 2019 2:10pm

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by mspider65 » Sep 15 2020 4:40pm

New Release:
All the layers (STM8 Bike Controller, ESP32 board and Android App) should be updated.
As usual all the files could be downloaded from https://github.com/TSDZ2-ESP32/TSDZ2-ES ... master/bin
Tour1.jpg
Tour1.jpg (256.36 KiB) Viewed 1350 times
The main new features are:

Motor optimizations:
+ PWM Freq at 19Khz
+ better rotor interpolation (Hall sensor detection runs at 38Khz, twice the PWM freq) -> better field alignment and less current ripple.
+ Updated motor svm_table according to new PWM frequency and to upper bound of TIM1 counter
+ Variable Max Field Weakening angle based on motor speed
+ Higher Power Assist multiplier resolution (2% instead of 10%)

Android App:
+ Override Street mode (long press Street Mode icon on main dashboard)
+ New Max speed cfg parameters
+ New Power assist multipliers

E-bike lover   1 mW

1 mW
Posts: 17
Joined: Jul 27 2020 3:44pm

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by E-bike lover » Sep 15 2020 6:08pm

PandaYeti wrote:
Sep 15 2020 3:28am
vass wrote:
Sep 14 2020 10:11am
E-bike lover wrote:
Sep 13 2020 12:02pm
Hi guys
I am interested in this pcb too but I have just found this post after searching for months. Probably others couldn't find this post too and will be better to add these kind of pages(optimisation for tsdz2) to github.
I have a idea to improve this pcb and that is by adding gps and sim function to it so that the bike could be traceable. Anyone has any idea how to make it?
Also, it would be nice if someone could sell me 1/2 pcb in a reasonable price in EU :D
hello, VelOtto has 2 pcbs, i was going to buy 2 but you can take one of them (PM him).
I also got 2 spare ones. I think I paid to much taxes though, which made them more expensive, still trying to figure out why.
Are u living in Europe? If yes, then u don't have to paid tax under 150euro. U only have to paid the shipping fee and it should ost u around 5euro only. How much did u paid for the pcb in total?(should be under 50usd)

vass   1 W

1 W
Posts: 57
Joined: Jul 07 2020 3:57am

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by vass » Sep 16 2020 8:04am

E-bike lover wrote:
Sep 15 2020 6:08pm
PandaYeti wrote:
Sep 15 2020 3:28am
vass wrote:
Sep 14 2020 10:11am
E-bike lover wrote:
Sep 13 2020 12:02pm
Hi guys
I am interested in this pcb too but I have just found this post after searching for months. Probably others couldn't find this post too and will be better to add these kind of pages(optimisation for tsdz2) to github.
I have a idea to improve this pcb and that is by adding gps and sim function to it so that the bike could be traceable. Anyone has any idea how to make it?
Also, it would be nice if someone could sell me 1/2 pcb in a reasonable price in EU :D
hello, VelOtto has 2 pcbs, i was going to buy 2 but you can take one of them (PM him).
I also got 2 spare ones. I think I paid to much taxes though, which made them more expensive, still trying to figure out why.
Are u living in Europe? If yes, then u don't have to paid tax under 150euro. U only have to paid the shipping fee and it should ost u around 5euro only. How much did u paid for the pcb in total?(should be under 50usd)
If they came from outside Europe you should have to pay, here in Portugal i would pay 25% over the price of the item+shipping (yeah its stupid like hell to combine postage costs...)

vass   1 W

1 W
Posts: 57
Joined: Jul 07 2020 3:57am

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by vass » Sep 16 2020 8:06am

mspider65 wrote:
Sep 15 2020 4:40pm
New Release:
All the layers (STM8 Bike Controller, ESP32 board and Android App) should be updated.
As usual all the files could be downloaded from https://github.com/TSDZ2-ESP32/TSDZ2-ES ... master/bin
Tour1.jpg

The main new features are:

Motor optimizations:
+ PWM Freq at 19Khz
+ better rotor interpolation (Hall sensor detection runs at 38Khz, twice the PWM freq) -> better field alignment and less current ripple.
+ Updated motor svm_table according to new PWM frequency and to upper bound of TIM1 counter
+ Variable Max Field Weakening angle based on motor speed
+ Higher Power Assist multiplier resolution (2% instead of 10%)

Android App:
+ Override Street mode (long press Street Mode icon on main dashboard)
+ New Max speed cfg parameters
+ New Power assist multipliers
Niceeeee, also nice ride and view :)

sp1n4d0   10 mW

10 mW
Posts: 33
Joined: Jun 13 2019 6:49pm

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by sp1n4d0 » Sep 16 2020 3:18pm

Hi!
I installed this PCB today, running with last firmware (esp32 v1.1.2 and controller v7) and android app v2.1.3
I have 48v motor and 48v battery (13s5p).
I can´t set Battery cell overvoltage and Battery cell all bars, it does not save the values that i input in the app, it revert to mutch lower values and the display shows E08 - battery overvoltage.
Can someone confirm this error?

sp1n4d0   10 mW

10 mW
Posts: 33
Joined: Jun 13 2019 6:49pm

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by sp1n4d0 » Sep 17 2020 4:04am

Already see that this is a bug with 2.1.2 and 2.1.3 Android app.
With Android app 2.1.1 I was able to introduce the correct values for Battery cell overvoltage, it should be around 4.2V or 420 mV x 10, but with latest App it is out of the range, looks like it is expecting a overvoltage value for the pack, which is around 54.6V (Vx10=546) for 13S battery.
Same behavior with Battery cell All bars field.

mspider65   100 W

100 W
Posts: 144
Joined: Aug 04 2019 2:10pm

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by mspider65 » Sep 17 2020 5:25am

sp1n4d0 wrote:
Sep 17 2020 4:04am
Already see that this is a bug with 2.1.2 and 2.1.3 Android app.
With Android app 2.1.1 I was able to introduce the correct values for Battery cell overvoltage, it should be around 4.2V or 420 mV x 10, but with latest App it is out of the range, looks like it is expecting a overvoltage value for the pack, which is around 54.6V (Vx10=546) for 13S battery.
Same behavior with Battery cell All bars field.
Yes, there is a bug introduced in the v2.1.2.
I have released a new version v2.1.4 with the fix.
https://github.com/TSDZ2-ESP32/TSDZ2-ES ... v2.1.4.apk

sp1n4d0   10 mW

10 mW
Posts: 33
Joined: Jun 13 2019 6:49pm

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by sp1n4d0 » Sep 17 2020 6:47am

mspider65 wrote:
sp1n4d0 wrote:
Sep 17 2020 4:04am
Already see that this is a bug with 2.1.2 and 2.1.3 Android app.
With Android app 2.1.1 I was able to introduce the correct values for Battery cell overvoltage, it should be around 4.2V or 420 mV x 10, but with latest App it is out of the range, looks like it is expecting a overvoltage value for the pack, which is around 54.6V (Vx10=546) for 13S battery.
Same behavior with Battery cell All bars field.
Yes, there is a bug introduced in the v2.1.2.
I have released a new version v2.1.4 with the fix.
https://github.com/TSDZ2-ESP32/TSDZ2-ES ... v2.1.4.apk
wow that was fast Image, thank you!
I'll test ride it this weekend.

daenny   10 mW

10 mW
Posts: 22
Joined: Sep 24 2015 1:30pm

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by daenny » Sep 21 2020 4:07pm

@bart594 I sent you a PM. It would be nice to start a new thread with your changes to the color LCD
bart594 wrote:
Aug 13 2020 12:55pm
here you will find compiled firmware files (lcd and controller) with compatible android app
https://github.com/bart594/Color_LCD/re ... ag/20.1.15
@mspider: I would be interested in adjusting your code to make the ESP32 compatible with the SW102. Bart made it such that he did not use the ESP32 at all (as far as I understood). I.e. I would like to make the ESP32 "talk" to the SW102 display. I think it should be not too difficult, seeing that the protocol is the same as the motor actually uses. But not knowing your code, it's somewhat difficult to start, would you be willing to help?

Also I would be interested in a board, if someone still has one available in Europe (NL). Otherwise, I could order another batch.
Current build:
GSM Woosh Middrive, with VESC controller, color LCD Display and Teensy ForumsController:
https://endless-sphere.com/forums/viewtopic.php?t=84042

mspider65   100 W

100 W
Posts: 144
Joined: Aug 04 2019 2:10pm

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by mspider65 » Sep 22 2020 5:22am

daenny wrote:
Sep 21 2020 4:07pm
@mspider: I would be interested in adjusting your code to make the ESP32 compatible with the SW102. Bart made it such that he did not use the ESP32 at all (as far as I understood). I.e. I would like to make the ESP32 "talk" to the SW102 display. I think it should be not too difficult, seeing that the protocol is the same as the motor actually uses. But not knowing your code, it's somewhat difficult to start, would you be willing to help?
Hi daenny,
i don't have a SW102 and i don't have in plan to buy one, but it shouldn't be difficult to make the SW compatible with the SW102.
Actually the ESP32 uses the 0.20beta protocol to talk to the motor and on the LCD side, uses the OEM LCD protocol (really similar to the 0.20beta LCD protocol).
You should look into tsdz_data.c and tsdz_uart.c source files.
The raw protocol is managed by the tsdz_uart.c. The main function is tsdz_uart_task that receive and sends the raw data from the serial lines. The function processLcdMessage is called when a correct LCD message is received and the getLcdMessage function is called when a new LCD message should be sent to the LCD.

PandaYeti   1 mW

1 mW
Posts: 13
Joined: Feb 10 2020 2:32pm

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by PandaYeti » Sep 22 2020 9:37am

mspider65 wrote:
Sep 15 2020 4:26pm

I don't quite remember if I changed anything in the protocol, but it should probably work. Try and let me know.
Also try the new version that I am publishing now. I am confident that the new release brings improvements.
Just tried the new firmware. It's awesome!! Couldn't take it to the real test yet (regarding heat) but it fells great!
Thanks for implementing the override Street mode by the way ;)

PandaYeti   1 mW

1 mW
Posts: 13
Joined: Feb 10 2020 2:32pm

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by PandaYeti » Sep 22 2020 9:41am

E-bike lover wrote:
Sep 15 2020 6:08pm

Are u living in Europe? If yes, then u don't have to paid tax under 150euro. U only have to paid the shipping fee and it should ost u around 5euro only. How much did u paid for the pcb in total?(should be under 50usd)
Yeah, had to pay 16% tax and I had to pay DHL an extra 12,5 Eur because they payed the tax upfront....
Total is 37eur /pcb. Still got one left in case someone is interested!

shaddi   1 W

1 W
Posts: 50
Joined: May 30 2018 3:20pm

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by shaddi » Sep 25 2020 5:40am

does anybody in germany/europe has spare PCBs for sale?

daenny   10 mW

10 mW
Posts: 22
Joined: Sep 24 2015 1:30pm

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by daenny » Sep 27 2020 7:52am

mspider65 wrote:
Sep 22 2020 5:22am
Hi daenny,
i don't have a SW102 and i don't have in plan to buy one, but it shouldn't be difficult to make the SW compatible with the SW102.
Actually the ESP32 uses the 0.20beta protocol to talk to the motor and on the LCD side, uses the OEM LCD protocol (really similar to the 0.20beta LCD protocol).
You should look into tsdz_data.c and tsdz_uart.c source files.
The raw protocol is managed by the tsdz_uart.c. The main function is tsdz_uart_task that receive and sends the raw data from the serial lines. The function processLcdMessage is called when a correct LCD message is received and the getLcdMessage function is called when a new LCD message should be sent to the LCD.
Thanks for your hints. I managed to reproduce at least having the display directly attached to the motor and get the first values out of it. However it's using the forks that @bart made himself for the controller. It seems he changed the protocol. Also his fork of the app is not working on my phone.
So my plan would be to adjust only the SW102 code and make that compatible with your app and your controller code. So then people having the SW102 would not need the esp32.
Current build:
GSM Woosh Middrive, with VESC controller, color LCD Display and Teensy ForumsController:
https://endless-sphere.com/forums/viewtopic.php?t=84042

casainho   100 GW

100 GW
Posts: 5499
Joined: Feb 14 2011 2:43pm

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by casainho » Sep 27 2020 11:19am

daenny wrote:
Sep 27 2020 7:52am
So my plan be to adjust only the SW102 code and make that compatible with your app and your controller code. So then people having the SW102 would not need the esp32.
This is a good idea, I always wanted SW102 with a mobile app and since it has Bluetooth.

For wireless EBike standard I am developing, I use the same Bluetooth microcontroller of SW102, so, if you do this mean in future I will be able to reuse and use this mobile app, Wich would be great!!
- TSDZ2 and OpenSource EV display: 128x64 OLED display, easy to build as DIY, Bluetooth and ANT, OTA wireless updates, easy to repair and customize for other EVs.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: OpenSource EV display, Wireless EBike standard ANT+ and Bluetooth, TSDZ2 OpenSource firmware, KT motor controllers and displays.

Please consider a donation to help developments: paypal.me/jorgecasa

mspider65   100 W

100 W
Posts: 144
Joined: Aug 04 2019 2:10pm

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by mspider65 » Sep 27 2020 12:54pm

casainho wrote:
Sep 27 2020 11:19am
daenny wrote:
Sep 27 2020 7:52am
So my plan be to adjust only the SW102 code and make that compatible with your app and your controller code. So then people having the SW102 would not need the esp32.
This is a good idea, I always wanted SW102 with a mobile app and since it has Bluetooth.

For wireless EBike standard I am developing, I use the same Bluetooth microcontroller of SW102, so, if you do this mean in future I will be able to reuse and use this mobile app, Wich would be great!!
Yes, it whould be nice to have the possibility to use directly the SW102 for those who do not want to do hardware modifications to the motor controller.
It will be also fine if the Android app could be used for your project.

vass   1 W

1 W
Posts: 57
Joined: Jul 07 2020 3:57am

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by vass » Sep 28 2020 3:16am

damn Casainho and mspider on the same place :). Tongsheng should just get you guys onboard and do a tsdz3 with your ideias and code (and some mods for thermal stuff) and have a damn nice motor from factory (a factory could do this with 50 euros or less i would say)

casainho   100 GW

100 GW
Posts: 5499
Joined: Feb 14 2011 2:43pm

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by casainho » Sep 28 2020 3:35am

vass wrote:
Sep 28 2020 3:16am
damn Casainho and mspider on the same place :). Tongsheng should just get you guys onboard and do a tsdz3 with your ideias and code (and some mods for thermal stuff) and have a damn nice motor from factory (a factory could do this with 50 euros or less i would say)
Wireless EBike standard will be ready to implement on any other motor. I wish others brands could make a better mid drive torque sensor motor, relatively cheap and with cheap repair parts also, yes, like TSDZ2 but with belts to be more silent. I would prefer even a less powerful motor to be smaller and lighter. And also a bigger version, maybe with 1.5Kw.
- TSDZ2 and OpenSource EV display: 128x64 OLED display, easy to build as DIY, Bluetooth and ANT, OTA wireless updates, easy to repair and customize for other EVs.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: OpenSource EV display, Wireless EBike standard ANT+ and Bluetooth, TSDZ2 OpenSource firmware, KT motor controllers and displays.

Please consider a donation to help developments: paypal.me/jorgecasa

vass   1 W

1 W
Posts: 57
Joined: Jul 07 2020 3:57am

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by vass » Sep 28 2020 3:43am

casainho wrote:
Sep 28 2020 3:35am
vass wrote:
Sep 28 2020 3:16am
damn Casainho and mspider on the same place :). Tongsheng should just get you guys onboard and do a tsdz3 with your ideias and code (and some mods for thermal stuff) and have a damn nice motor from factory (a factory could do this with 50 euros or less i would say)
Wireless EBike standard will be ready to implement on any other motor. I wish others brands could make a better mid drive torque sensor motor, relatively cheap and with cheap repair parts also, yes, like TSDZ2 but with belts to be more silent. I would prefer even a less powerful motor to be smaller and lighter. And also a bigger version, maybe with 1.5Kw.
Yeah, a BBSHD with torque sensor, altough expensive could be a good thing (basicaly an ultra for diy), maybe the Lightest ebike kit will be good enough.
But tongsheng could do it very easly with the help off you guys, some thermal pads and a temperature sensor and a pcb with bluetooth would make the motor way better from factory.

Wimpy747   10 mW

10 mW
Posts: 22
Joined: Apr 25 2020 12:02pm

Re: BT Interface for TSDZ2 Open Source firmware - Work in progress

Post by Wimpy747 » Sep 29 2020 6:32am

daenny wrote:
Sep 27 2020 7:52am
mspider65 wrote:
Sep 22 2020 5:22am
Hi daenny,
i don't have a SW102 and i don't have in plan to buy one, but it shouldn't be difficult to make the SW compatible with the SW102.
Actually the ESP32 uses the 0.20beta protocol to talk to the motor and on the LCD side, uses the OEM LCD protocol (really similar to the 0.20beta LCD protocol).
You should look into tsdz_data.c and tsdz_uart.c source files.
The raw protocol is managed by the tsdz_uart.c. The main function is tsdz_uart_task that receive and sends the raw data from the serial lines. The function processLcdMessage is called when a correct LCD message is received and the getLcdMessage function is called when a new LCD message should be sent to the LCD.
Thanks for your hints. I managed to reproduce at least having the display directly attached to the motor and get the first values out of it. However it's using the forks that @bart made himself for the controller. It seems he changed the protocol. Also his fork of the app is not working on my phone.
So my plan would be to adjust only the SW102 code and make that compatible with your app and your controller code. So then people having the SW102 would not need the esp32.
The 'bart' app is not signed so you have to install the app on your phone with adb

Post Reply