BT Interface for TSDZ2 Open Source firmware - Work in progress

Electric Motors and Controllers
sp1n4d0   10 mW

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

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

Post by sp1n4d0 » Aug 14 2020 4:10am

edit: offtopic
Last edited by sp1n4d0 on Aug 17 2020 7:30am, edited 1 time in total.

vass   1 W

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

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

Post by vass » Aug 14 2020 4:17am

mspider65 wrote:
Aug 11 2020 6:28am
vass wrote:
Aug 10 2020 4:28pm
if in the future the source code for the app is also available i can try to code something.
All the source code is available on Github.
From the project main page https://github.com/TSDZ2-ESP32 you could browse all the repositories.

Nice, as soon has i have some time i will play with it, do you have "something" that can emulate the motor and the bluetooth connection to the App so one can code without the need for the real thing?

PandaYeti   1 mW

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

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

Post by PandaYeti » Aug 14 2020 9:36am

Since there seems to be quite few people interested in the pcb. I decided to also order 3 pcbs. If there is anyone interested in Germany or Europe, let me know.

vass   1 W

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

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

Post by vass » Aug 16 2020 3:49am

PandaYeti wrote:
Aug 14 2020 9:36am
Since there seems to be quite few people interested in the pcb. I decided to also order 3 pcbs. If there is anyone interested in Germany or Europe, let me know.
I can have one (I live in Portugal) :thumb:

mspider65   10 W

10 W
Posts: 70
Joined: Aug 04 2019 2:10pm

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

Post by mspider65 » Aug 16 2020 9:19am

Field weakening implementation is almost completed.

I have done many code optimizations and now the PWM control loop code takes only 30us and i was able to rise the PWM frequency from about 15.6KHz to 20KHz. This means that now it is possible to feed the motor with a correct sine wave signal up to a cadence of 120rpm.

Before releasing, I still prefer to do a couple more test rides to double check everything is okay.
In the meantime, I share some screenshots with the results of some tests.

The tests was done with a half charged battery (37.9V was the reading from my voltmeter) and with a fully charged battery the results should be better.
As you can see at a cadence of 110 rpm the motor absorbs about 300W and 250W at 120rpm.
In practice, the power gap at around 90rpm is no longer felt and the motor continues to push up to 110-120 rpm.
Power-110rpm.png
Power-110rpm.png (54.1 KiB) Viewed 983 times
Power-120rpm.jpg
Power-120rpm.jpg (48.41 KiB) Viewed 983 times
FWAngle-110rpm.png
FWAngle-110rpm.png (45.09 KiB) Viewed 983 times

Wimpy747   1 mW

1 mW
Posts: 14
Joined: Apr 25 2020 12:02pm

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

Post by Wimpy747 » Aug 16 2020 3:12pm

removed post
Last edited by Wimpy747 on Aug 31 2020 2:19am, edited 1 time in total.

mspider65   10 W

10 W
Posts: 70
Joined: Aug 04 2019 2:10pm

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

Post by mspider65 » Aug 16 2020 3:26pm

vass wrote:
Aug 14 2020 4:17am
Nice, as soon has i have some time i will play with it, do you have "something" that can emulate the motor and the bluetooth connection to the App so one can code without the need for the real thing?
To test i used two simulators running on the PC (LCD and Controller simulator) and an ESP32 DevKit board connected to the PC with a couple of FTDI adapters.
The simulators are the following.
https://github.com/mspider65/OSFControllerSimulator
https://github.com/mspider65/VLCD5Simulator

sp1n4d0   10 mW

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

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

Post by sp1n4d0 » Aug 16 2020 6:55pm

edit: offtopic
Last edited by sp1n4d0 on Aug 17 2020 7:30am, edited 1 time in total.

Wimpy747   1 mW

1 mW
Posts: 14
Joined: Apr 25 2020 12:02pm

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

Post by Wimpy747 » Aug 17 2020 1:53am

removed post
Last edited by Wimpy747 on Aug 31 2020 2:19am, edited 1 time in total.

mspider65   10 W

10 W
Posts: 70
Joined: Aug 04 2019 2:10pm

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

Post by mspider65 » Aug 17 2020 7:01am

Wimpy747 wrote:
Aug 16 2020 3:12pm
bart594 wrote:
Aug 13 2020 12:55pm
sp1n4d0 wrote:
Aug 09 2020 3:15pm


I was able to build using this "how to" https://makerdiary.com/blogs/news/how-t ... th-arm-gcc
and TSDZ2 Wiki https://github.com/OpenSource-EBike-fir ... evelopment
After building i run the script "release-SW102_ota" it successfully build an sw102-otaupdate.zip file to flash the display but when i try to flash this zip it gives me an error, i have no idea what´s wrong.
Image
(click this image to view full log)

Motor firmware, bart594 have another repo with it: https://github.com/bart594/TSDZ2-Smart-EBike
i think you need to open it up and flash the "hard" way
https://github.com/OpenSource-EBike-fir ... re-install
i don't think that unlocked bootloader makes the difference here
Or have you already flashed casainho's official 1.0.0 version ?

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
Very anxious to use these, the main.hex is to flash the motor?
However the .apk file fails to install on any device I have, I'm running android 9 and 10.
Any idea what the problem can be?

If you want to discuss about the bart594 project fork, please open a new discussion.

I would like to keep this discussion clean, otherwise the reader does not understand what we are talking about.

sp1n4d0   10 mW

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

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

Post by sp1n4d0 » Aug 17 2020 7:29am

You are right, sorry about that!
I will remove my posts to avoid confusion.

Wimpy747   1 mW

1 mW
Posts: 14
Joined: Apr 25 2020 12:02pm

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

Post by Wimpy747 » Aug 31 2020 2:24am

Also removed my posts, I do love the project but would like to be able to use it with the sw102 display, because i actually like this display and also pefer the .20 firmware as the osf 1.0.0 is way to 'big' for me, do not need 20 assist levels for example.

In the first post you were refering to this in the future, so I guess I will have to wait.
Will order the board in the meantime, thanks for the nice work

PandaYeti   1 mW

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

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

Post by PandaYeti » Sep 01 2020 11:53am

Hi guys,

I fiddeled around a bit with the PCB and have the following Problem, which I don't know how to solve:
When I connect to the PCB via bluetooth, without connecting an antenna to the IPEX port, it works perfectly. As soon as I connect the antenna and try to connect, it does not work. Connecting the antenna while beeing connected via bluetooth, works. I checked the antenna physically according to 2,4 Ghz spec, and it seemss correct. Does anyone have an idea what could be the problem?

mspider65   10 W

10 W
Posts: 70
Joined: Aug 04 2019 2:10pm

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

Post by mspider65 » Sep 01 2020 3:12pm

New Release:
After several days spent on holiday in a mountain hut away from technology, today I finally published the new version with Field Weakening.
Panorama.jpg
Panorama.jpg (207.69 KiB) Viewed 761 times
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

mspider65   10 W

10 W
Posts: 70
Joined: Aug 04 2019 2:10pm

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

Post by mspider65 » Sep 01 2020 4:44pm

Wimpy747 wrote:
Aug 31 2020 2:24am
Also removed my posts, I do love the project but would like to be able to use it with the sw102 display, because i actually like this display and also pefer the .20 firmware as the osf 1.0.0 is way to 'big' for me, do not need 20 assist levels for example.

In the first post you were refering to this in the future, so I guess I will have to wait.
Will order the board in the meantime, thanks for the nice work
A user reported that the SW102 display sold by EcoCycles, works fine with the current release
pgwguk wrote:
Jun 05 2020 8:14am
As well as testing the VLCD5 which worked great, I also tested the SW102 from EcoCycles.
This mini display has TSDZ2 compatible firmware pre-loaded, so my hope was it'd be compatible with the ESP32 setup.
The great news is, it does! All the functionality of the SW102 appears active, power level and power mode selection also works!

mspider65   10 W

10 W
Posts: 70
Joined: Aug 04 2019 2:10pm

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

Post by mspider65 » Sep 02 2020 1:31am

PandaYeti wrote:
Sep 01 2020 11:53am
Hi guys,

I fiddeled around a bit with the PCB and have the following Problem, which I don't know how to solve:
When I connect to the PCB via bluetooth, without connecting an antenna to the IPEX port, it works perfectly. As soon as I connect the antenna and try to connect, it does not work. Connecting the antenna while beeing connected via bluetooth, works. I checked the antenna physically according to 2,4 Ghz spec, and it seemss correct. Does anyone have an idea what could be the problem?
It's strange behavior, do you have another antenna to try?
Check if the ground and antenna wire are not shorted

Wimpy747   1 mW

1 mW
Posts: 14
Joined: Apr 25 2020 12:02pm

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

Post by Wimpy747 » Sep 02 2020 11:39am

mspider65 wrote:
Sep 01 2020 4:44pm
Wimpy747 wrote:
Aug 31 2020 2:24am
Also removed my posts, I do love the project but would like to be able to use it with the sw102 display, because i actually like this display and also pefer the .20 firmware as the osf 1.0.0 is way to 'big' for me, do not need 20 assist levels for example.

In the first post you were refering to this in the future, so I guess I will have to wait.
Will order the board in the meantime, thanks for the nice work
A user reported that the SW102 display sold by EcoCycles, works fine with the current release
pgwguk wrote:
Jun 05 2020 8:14am
As well as testing the VLCD5 which worked great, I also tested the SW102 from EcoCycles.
This mini display has TSDZ2 compatible firmware pre-loaded, so my hope was it'd be compatible with the ESP32 setup.
The great news is, it does! All the functionality of the SW102 appears active, power level and power mode selection also works!
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?

PandaYeti   1 mW

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

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

Post by PandaYeti » Sep 02 2020 2:13pm

mspider65 wrote:
Sep 02 2020 1:31am
PandaYeti wrote:
Sep 01 2020 11:53am
Hi guys,

I fiddeled around a bit with the PCB and have the following Problem, which I don't know how to solve:
When I connect to the PCB via bluetooth, without connecting an antenna to the IPEX port, it works perfectly. As soon as I connect the antenna and try to connect, it does not work. Connecting the antenna while beeing connected via bluetooth, works. I checked the antenna physically according to 2,4 Ghz spec, and it seemss correct. Does anyone have an idea what could be the problem?
It's strange behavior, do you have another antenna to try?
Check if the ground and antenna wire are not shorted
I tried another antenna which lead to the same behavior. Then I connected it to another 3,3V power source and everything worked as expected, so I guess something is not quite right with my FTDI. Very strange.
Thanks for the hints, and for the update, btw! Can't wait to connect the PCB to the motor and take if for a spin!

mspider65   10 W

10 W
Posts: 70
Joined: Aug 04 2019 2:10pm

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

Post by mspider65 » 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   10 W

10 W
Posts: 70
Joined: Aug 04 2019 2:10pm

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

Post by mspider65 » Sep 03 2020 1:54am

PandaYeti wrote:
Sep 02 2020 2:13pm
I tried another antenna which lead to the same behavior. Then I connected it to another 3,3V power source and everything worked as expected, so I guess something is not quite right with my FTDI. Very strange.
Thanks for the hints, and for the update, btw! Can't wait to connect the PCB to the motor and take if for a spin!
Probably your FTDI adapter is not able to source enough current during the comnection transient.

Wimpy747   1 mW

1 mW
Posts: 14
Joined: Apr 25 2020 12:02pm

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

Post by Wimpy747 » Sep 03 2020 6:10am

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.
Thanks I will go for this, so I will have to order the sw102 from eco bikes , or try to figger out what kind of firmware they put on this perticular sw102.
Nice work man!

PandaYeti   1 mW

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

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

Post by PandaYeti » Sep 10 2020 5:39am

Hi,
so I connected the pcb and tested it with ne new firmware for a couple of days. I love the instant response when starting to peddle and the overall agility! Also the field weakening works great (48v motor here) Best firmware I tried so far!
I also have a couple of issues:
- I feel like the motor is getting way hotter and it drains the battery faster than for example mebrusa's firmware, even if I do not use the high cadence boost. Might field weakening have anything to do with this anyway?
- my torque sensor seems to have a very bad stock calibration. It shows 20, without any weight on the pedals. Any way to calibrate it with this firmware?
- the above point and the quick response when starting to pedal results in the motor starting to assist, although it is not necessary, for example when I just turn the pedals in order to shift down.
- is there any way to switch street mode using the android app? I tried setting the respective entry in the config, but it did not work. I liked the way it was implemented in mebrusa's firmware, being able to easily switch to off-road when powering up the display, but by default just going into street mode.

Thanks in advance!

mspider65   10 W

10 W
Posts: 70
Joined: Aug 04 2019 2:10pm

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

Post by mspider65 » Sep 10 2020 7:57am

PandaYeti wrote:
Sep 10 2020 5:39am
Hi,
so I connected the pcb and tested it with ne new firmware for a couple of days. I love the instant response when starting to peddle and the overall agility! Also the field weakening works great (48v motor here) Best firmware I tried so far!
I also have a couple of issues:
- I feel like the motor is getting way hotter and it drains the battery faster than for example mebrusa's firmware, even if I do not use the high cadence boost. Might field weakening have anything to do with this anyway?
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.
- my torque sensor seems to have a very bad stock calibration. It shows 20, without any weight on the pedals. Any way to calibrate it with this firmware?
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.
- is there any way to switch street mode using the android app? I tried setting the respective entry in the config, but it did not work. I liked the way it was implemented in mebrusa's firmware, being able to easily switch to off-road when powering up the display, but by default just going into street mode.
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.

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 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

vass   1 W

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

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

Post by vass » 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).

Post Reply