BT Interface for TSDZ2 Open Source firmware - Work in progress

Electric Motors and Controllers
mspider65   100 W

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

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

Post by mspider65 » Apr 30 2021 9:23am

Blacklite wrote:
Apr 30 2021 9:03am
Im wondering what the reasoning for the reduce to 18kHz PWM is? Is it timing given the extra instructions to read the ADC in the PWM interrupt?
Switching frequency is a tradeoff between motor speed and efficency.
The Mosfet of the TSDZ2 controller aren't so fast, and i think 18KHz colud be a good compromise to have good efficiency and at the same time to guarantee good operation when you need to use a high cadence.

huan   10 µW

10 µW
Posts: 6
Joined: Apr 09 2021 9:38am

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

Post by huan » May 05 2021 11:14am

About 2 weeks ago installed the esp32 board successfully.
Thanks for your work mspider.
New firmware v13 was interesting for me. Im getting controller communications error in app. With xh 18 its error code e03. First i thought my engine runs to hot. But it happens always at around 43 degress and after once happend it stays until engine is around 37 degress. Happens always in short intervals for half a second. Deactivate temp control doesnt helped me. Im sure its something with tx rx line, bad connection or maybe to long cables? Have to check it. My fault.
New firmware did not change this behavior for your information.
Attachments
20210505_184957.jpg
20210505_184957.jpg (117.36 KiB) Viewed 1412 times

mspider65   100 W

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

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

Post by mspider65 » May 05 2021 12:53pm

huan wrote:
May 05 2021 11:14am
About 2 weeks ago installed the esp32 board successfully.
Thanks for your work mspider.
New firmware v13 was interesting for me. Im getting controller communications error in app. With xh 18 its error code e03. First i thought my engine runs to hot. But it happens always at around 43 degress and after once happend it stays until engine is around 37 degress. Happens always in short intervals for half a second. Deactivate temp control doesnt helped me. Im sure its something with tx rx line, bad connection or maybe to long cables? Have to check it. My fault.
New firmware did not change this behavior for your information.
Check the wiring between ESP32 and controller, check also the solder points on the ESP32 board in particular the 3 small integrated circuits close to the 4 pin serial connector.

huan   10 µW

10 µW
Posts: 6
Joined: Apr 09 2021 9:38am

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

Post by huan » May 14 2021 12:09pm

Ive could fix my problem. Today i could put my motor to 66 degress without communcation error.
Cadence mode for my is like cruise mode without having it enabled. Motor stops to spin only with a lot of pedal pressure backwards or i change assistance mode to 0.

gfmoore   100 W

100 W
Posts: 165
Joined: May 01 2021 4:48pm
Location: Stoke-on-Trent, UK

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

Post by gfmoore » May 15 2021 9:38am

Hi,

I've not been able to side load the apk. I use a Note 4.0 running Android 9, but it isn't the Samsung firmware, it's ViperOS.

Anyhow. I have copied the apk to the downloads directory on the phone, used X-plore to locate it, clicked? on it. It says Open with Package installer and it says: "There was a problem whilst parsing the package?"

I have allowed Unknown Apps (And I have Developer options enabled)

Any ideas? I will probably download Android Studio and try using the sources.


As a totally separate theme. What is the the model of ESP 32 that you use or doesn't it matter and what toolchain are you using to develop?

edit: for instance does this do the job? https://www.ebay.co.uk/itm/224378202490 ... SwL0pgRkCn

Great work by the way. I can't wait to get my motor and try out these mods.

Gordon
Known purveyor of useless questions :roll:

gfmoore   100 W

100 W
Posts: 165
Joined: May 01 2021 4:48pm
Location: Stoke-on-Trent, UK

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

Post by gfmoore » May 15 2021 10:33am

How odd, the source builds and then runs on my phone fine using Android Studio (Man it takes ages to download and get that ide running and updated.) So don't know what gives.

Gordon
Known purveyor of useless questions :roll:

gfmoore   100 W

100 W
Posts: 165
Joined: May 01 2021 4:48pm
Location: Stoke-on-Trent, UK

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

Post by gfmoore » May 15 2021 11:08am

Anyone got a board for sale? (I'm in UK)

Gordon
Known purveyor of useless questions :roll:

michih.   100 W

100 W
Posts: 103
Joined: Nov 11 2018 8:33am

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

Post by michih. » May 15 2021 11:39am

have 2 here. am from Germany


MFG Michael

gfmoore   100 W

100 W
Posts: 165
Joined: May 01 2021 4:48pm
Location: Stoke-on-Trent, UK

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

Post by gfmoore » May 15 2021 11:49am

@michih pm sent :)
Known purveyor of useless questions :roll:

Beli   1 W

1 W
Posts: 55
Joined: Dec 07 2020 5:08pm

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

Post by Beli » May 15 2021 2:09pm

gfmoore wrote:
May 15 2021 9:38am
I've not been able to side load the apk. I use a Note 4.0 running Android 9, but it isn't the Samsung firmware, it's ViperOS.
Anyhow. I have copied the apk to the downloads directory on the phone, used X-plore to locate it, clicked? on it. It says Open with Package installer and it says: "There was a problem whilst parsing the package?"
I once noticed the same with a custom rom on a Samsung tablet. Could have been Viper too.

I probably need to change and make the apk myself too. Hints or even a howto would be welcomed :)
gfmoore wrote:
May 15 2021 9:38am
As a totally separate theme. What is the the model of ESP 32 that you use or doesn't it matter and what toolchain are you using to develop?
On the developed PCB there is an ESP32 Pico which includes memory on chip. It just saves space. You should be able to take every ESP32 board with at least 4MB memory (= standard size).
Toolchain you could find at espressif - ESP-IDF, I'm using the current v4.2.1, additionally esp-idf-tools. You could use VSCode, Eclipse...
gfmoore wrote:
May 15 2021 9:38am
edit: for instance does this do the job? https://www.ebay.co.uk/itm/224378202490 ... SwL0pgRkCn
It will work.
Of course you additionally would need a DC/DC converter for power supply and a level shifter for the serial ports (ESP32 ports working at 3.3V, TSDZ2 at 5V).

casainho   100 GW

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

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

Post by casainho » May 15 2021 2:22pm

Beli wrote:
May 15 2021 2:09pm
Of course you additionally would need a DC/DC converter for power supply and a level shifter for the serial ports (ESP32 ports working at 3.3V, TSDZ2 at 5V).
We are using ONLY a very small DC-DC and 2 MOSFETs for turn on/off the motor controller and no level shifter at all!! The circuit is very simple, only 5 extra wires to solder other than the displays wires: https://opensourceebike.github.io/ebike ... oller.html

Image

Image

Image

The final device is very small:
Image
- 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.

Beli   1 W

1 W
Posts: 55
Joined: Dec 07 2020 5:08pm

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

Post by Beli » May 15 2021 2:31pm

casainho wrote:
May 15 2021 2:22pm
We are using ONLY a very small DC-DC and 2 MOSFETs for turn on/off the motor controller and no level shifter at all!!
ESP32 has no protection at the IO ports and can't be used without level shifters!

casainho   100 GW

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

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

Post by casainho » May 15 2021 2:35pm

Beli wrote:
May 15 2021 2:31pm
casainho wrote:
May 15 2021 2:22pm
We are using ONLY a very small DC-DC and 2 MOSFETs for turn on/off the motor controller and no level shifter at all!!
ESP32 has no protection at the IO ports and can't be used without level shifters!
Are you sure? Because I see that protections on the motor controller side. 850C, 860C, SW102 displays are all 3.3V as also our wireless board, all of them work perfectly.
- 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.

Beli   1 W

1 W
Posts: 55
Joined: Dec 07 2020 5:08pm

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

Post by Beli » May 15 2021 2:45pm

casainho wrote:
May 15 2021 2:35pm
Are you sure?
Yes:
https://esp32.com/viewtopic.php?t=877#p56956

casainho   100 GW

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

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

Post by casainho » May 15 2021 3:00pm

Beli wrote:
May 15 2021 2:45pm
casainho wrote:
May 15 2021 2:35pm
Are you sure?
Yes:
https://esp32.com/viewtopic.php?t=877#p56956
Ok, I would no expect that "weakness" from a modern microcontroller as ESP.
Thank you for the clarification.
- 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.

Beli   1 W

1 W
Posts: 55
Joined: Dec 07 2020 5:08pm

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

Post by Beli » May 15 2021 3:20pm

I was surprised about that too. Especially because most cheap microcontrollers tolerate 5V.
But as also mentioned at the end of the linked side: maybe it's because the ESP is so modern and highly integrated the chip die is not build to deal with higher voltages at all.

mspider65   100 W

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

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

Post by mspider65 » May 16 2021 1:20am

Beli wrote:
May 15 2021 3:20pm
I was surprised about that too. Especially because most cheap microcontrollers tolerate 5V.
But as also mentioned at the end of the linked side: maybe it's because the ESP is so modern and highly integrated the chip die is not build to deal with higher voltages at all.
The quick and dirty solution could be to put something like a 10k resistor in series to the 3.3v ESP32 input or better a voltage divider with two resistors. Not what I would use for production or something you need to depend on but should work.
About the DC-DC converter it would be better to use one with a Power Enable input and use the Power line coming from the LCD ON/OFF signal as enable. The DC-DC converter, when switched on, acts as a short circuit due to the large input capacitors and it is easy to burn the LCD mosfet. Another possibility is to use a 100/200 Ohm resistor in series to the DC-DC converter input or use an external mosfet switch.

casainho   100 GW

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

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

Post by casainho » May 16 2021 6:20am

mspider65 wrote:
May 16 2021 1:20am
Beli wrote:
May 15 2021 3:20pm
I was surprised about that too. Especially because most cheap microcontrollers tolerate 5V.
But as also mentioned at the end of the linked side: maybe it's because the ESP is so modern and highly integrated the chip die is not build to deal with higher voltages at all.
The quick and dirty solution could be to put something like a 10k resistor in series to the 3.3v ESP32 input or better a voltage divider with two resistors. Not what I would use for production or something you need to depend on but should work.
If that could the a solution, then it is what is used inside TSDZ2 motor controller. So, what are all that displays doing are correct.
- 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.

mspider65   100 W

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

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

Post by mspider65 » May 20 2021 6:33am

New version released.
Everything should be updated, Android App, ESP32 and Controller.

The files are on Github: https://github.com/TSDZ2-ESP32/TSDZ2-ES ... master/bin
- Android: TSDZ2_ESP32v2.1.10.apk
- ESP32: TSDZ2-ESP32-Mainv1.1.8.zip
- STM8: TSDZ2-v14.zip

This version improves the motor efficiency under high loads.

In particular, the code that calculates the "Advance Angle" (FOC angle) has changed.
The old algorithm gave an underestimated value. Now the algorithm has changed and the value is calculated once every electrical revolution within the fast PWM interrupt.
I did some tests on a reference climb with the motor constantly at 400/450Watt and with the new version the motor warms up much less.

Important note:
After the update it is necessary to change the motor configuration.
There is a new parameter "FOC angle multipl." which replaces the "motor inductance" parameter.
In the Android app select: "Bike Configuration" -> System and select 36V or 48V according to your motor.
The parameter can also be entered manually in the range 0-50. If you want to experiment you can increase/decrease by 3 or 4 each time to see if you get further improvements.
MotorSetup.png
MotorSetup.png (11.9 KiB) Viewed 1060 times
As you can see from the screenshot I also added the possibility to disable the "Field Weakening"

Last note:
The update disables the "Torque Offset Fix", and whoever had it enabled will have to enable it again after the update.

Beli   1 W

1 W
Posts: 55
Joined: Dec 07 2020 5:08pm

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

Post by Beli » May 20 2021 3:36pm

Thanks for the new version. I thought I could relax because you don't plan to do updates during the next months but just use your bike? :lol:

At least you still left me bits of case 1 ui8_rx_buffer[6] for initialising OTA updates using WWDG_SWReset() :wink:

mspider65   100 W

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

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

Post by mspider65 » May 21 2021 1:41am

Beli wrote:
May 20 2021 3:36pm
I thought I could relax because you don't plan to do updates during the next months but just use your bike? :lol:
it's true!
But here it continued to get cold and bad weather and there is still snow in the mountains. So I had some more free time.
And then there were still a couple of things that bothered me to fix :)
At least you still left me bits of case 1 ui8_rx_buffer[6] for initialising OTA updates using WWDG_SWReset() :wink:
Probably this will be the next ;)

Beli   1 W

1 W
Posts: 55
Joined: Dec 07 2020 5:08pm

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

Post by Beli » May 21 2021 9:23am

mspider65 wrote:
May 21 2021 1:41am
But here it continued to get cold and bad weather and there is still snow in the mountains.
So your weather is not much better than north of the Alps...
On the other hand we can be happy that you continue your work :) :thumb:

Applied the (small ESP32) changes to my display version. Tests have to wait till better weather...

huan   10 µW

10 µW
Posts: 6
Joined: Apr 09 2021 9:38am

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

Post by huan » May 27 2021 4:29am

huan wrote:
May 14 2021 12:09pm
Cadence mode for my is like cruise mode without having it enabled. Motor stops to spin only with a lot of pedal pressure backwards or i change assistance mode to 0.
Anybody else with this problem?
I played around with pedal without rotation setting.
Recommended is 10 to 15. I get a nice start with a setting of 100. Seems not right but works for me.

Elektroid   1 µW

1 µW
Posts: 1
Joined: May 27 2021 12:08pm

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

Post by Elektroid » May 27 2021 12:11pm

Thanks for a useful app! Looking at the list of permissions it all looks legit, but I only wonder why does it require WRITE_SECURE_SETTINGS permission?

gfmoore   100 W

100 W
Posts: 165
Joined: May 01 2021 4:48pm
Location: Stoke-on-Trent, UK

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

Post by gfmoore » May 28 2021 12:11am

Beli wrote:
May 15 2021 2:09pm
gfmoore wrote:
May 15 2021 9:38am
I've not been able to side load the apk. I use a Note 4.0 running Android 9, but it isn't the Samsung firmware, it's ViperOS.
Anyhow. I have copied the apk to the downloads directory on the phone, used X-plore to locate it, clicked? on it. It says Open with Package installer and it says: "There was a problem whilst parsing the package?"
I once noticed the same with a custom rom on a Samsung tablet. Could have been Viper too.

I probably need to change and make the apk myself too. Hints or even a howto would be welcomed :)
gfmoore wrote:
May 15 2021 9:38am
As a totally separate theme. What is the the model of ESP 32 that you use or doesn't it matter and what toolchain are you using to develop?
On the developed PCB there is an ESP32 Pico which includes memory on chip. It just saves space. You should be able to take every ESP32 board with at least 4MB memory (= standard size).
Toolchain you could find at espressif - ESP-IDF, I'm using the current v4.2.1, additionally esp-idf-tools. You could use VSCode, Eclipse...
gfmoore wrote:
May 15 2021 9:38am
edit: for instance does this do the job? https://www.ebay.co.uk/itm/224378202490 ... SwL0pgRkCn
It will work.
Of course you additionally would need a DC/DC converter for power supply and a level shifter for the serial ports (ESP32 ports working at 3.3V, TSDZ2 at 5V).
Sorry for the late response I hadn't enabled replies. Thanks Beli et al for the reply, very helpful. My motor has now arrived and I think my board is due any day. Just need a battery :) Yes, I'll have to look at how to create an apk, now that I have Android Studio up and running. Once I have done it, I'll post the steps, but may be a couple of weeks.

I'll probably just have a few rides "as is" to see how it feels and then do the mods. Hopefully summer may start any day now... :wink:

Gordon
Known purveyor of useless questions :roll:

Post Reply