BT Interface for TSDZ2 Open Source firmware - Work in progress

Electric Motors and Controllers
mspider65   100 W

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

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

Post by mspider65 » Apr 08 2022 1:52am

Beli wrote:
Apr 07 2022 4:45pm
Now I had a look at your resent changes and my question now: what is the idea behind your "torque smoothing"?
The idea is explained here: viewtopic.php?f=30&t=115535

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 » Apr 08 2022 2:03pm

mspider65 wrote:
Apr 08 2022 1:52am
The idea is explained here: viewtopic.php?f=30&t=115535
:bigthumb:
Thank you for anticipating that I would ask about that :lol:

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 » Apr 09 2022 1:34pm

I integrated the latest changes in my version and gave it a trial today (with activated torque smoothing).
I didn't notice significant differences - at least it is running smooth with no problems so far (so as intended).

mspider65   100 W

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

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

Post by mspider65 » Apr 10 2022 1:13pm

Beli wrote:
Apr 09 2022 1:34pm
I integrated the latest changes in my version and gave it a trial today (with activated torque smoothing).
I didn't notice significant differences - at least it is running smooth with no problems so far (so as intended).
Today I finally started riding the bike again and I was able to test the new modification well.

Certainly the impact on the riding experience is not huge but the impression I got was positive even if it is clearly a subjective judgment.
However, analyzing the graph of the stored data, it is objectively seen that, when the torque smooth is active, the current absorbed by the motor is more constant and the current graph is flatter.

Deadrabbit   1 mW

1 mW
Posts: 11
Joined: May 26 2019 9:51am

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

Post by Deadrabbit » Apr 12 2022 1:23am

Deadrabbit wrote:
Mar 30 2022 3:04am
thanks a lot again for your work. I've ordered five peaces of the board.
Pcbway send me pictures of the board.
In my point of view, i think there are some headers unsoldered.

Could someone with the knowledge check the pictures?

Thanks!
Attachments
IMG_20220412_081906.jpg
IMG_20220412_081906.jpg (2.45 MiB) Viewed 947 times
IMG_20220412_081909.jpg
IMG_20220412_081909.jpg (4.35 MiB) Viewed 947 times
确认座子方向.png
确认座子方向.png (1.29 MiB) Viewed 947 times

mspider65   100 W

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

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

Post by mspider65 » Apr 12 2022 5:21am

Deadrabbit wrote:
Apr 12 2022 1:23am
Deadrabbit wrote:
Mar 30 2022 3:04am
thanks a lot again for your work. I've ordered five peaces of the board.
Pcbway send me pictures of the board.
In my point of view, i think there are some headers unsoldered.

Could someone with the knowledge check the pictures?

Thanks!
Everything seems to be fine.
Headers will be soldered after confirming the correct placement of the components.

endlessolli   10 W

10 W
Posts: 68
Joined: Jul 31 2020 11:55am

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

Post by endlessolli » Apr 12 2022 7:53am

Where would I find the "Data Graph View" data shown in the App (after swiping up)?
Where is that stored on the phone / can I export that somehow?

mspider65   100 W

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

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

Post by mspider65 » Apr 12 2022 10:36am

endlessolli wrote:
Apr 12 2022 7:53am
Where would I find the "Data Graph View" data shown in the App (after swiping up)?
Yes
Where is that stored on the phone / can I export that somehow?
In the phone app private storage but the data cannot be exported.

mspider65   100 W

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

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

Post by mspider65 » Apr 22 2022 10:02am

New Version released:

Functional changes:
  • New Torque sensor setup screen
Architectural changes:
  • Bluetooth interface optimization (MTU change, all real-time data sent in only one notification)
  • ESP32/Controller protocol update

The new torque setting screen helps to configure and troubleshoot any torque sensor issues.
Screenshot_20220422-160526_TSDZ2_ESP32.png
Screenshot_20220422-160526_TSDZ2_ESP32.png (44.55 KiB) Viewed 814 times
About Torque smooth Thresholds i found satisfactory for Min ADC Threshold and Max ADC Threshod respectively about 4% and 9% of the max mesured ADC Delta.

N.B.!!!
Due to the new BT Interface, the ESP32 OTA update is triky:
Perform the update in the following order!

1) STM8 Controller Firmware
2) ESP32 Firmware (SEE THE FOLLOWING INSTRUCTIONS!)
3) Android App

ESP32 Firmware Update:
1) Run the normal OTA update from the Android app
2) At the end of the firmware upload, do not wait for the update end message but go back to the main screen and then exit from the Android App
3) Open System Settings, go to Bluetooth Settings and remove the ESP32 board from paired devices.
4) Install the new Android App
5) Open the new Android app and select "Bluetooth Setup" from the "Options Menu" and repeat the Bluetooth pairing process with the ESP32 board.
6) After pairing is complete, start the connection and then select "Firmware->Show Versions" from the "Options Menu". This last operation will confirm to the ESP32 that the new firmware is working correctly otherwise, when turned off, the ESP32 will revert to the previous firmware version.

The new files are in https://github.com/TSDZ2-ESP32/TSDZ2-ES ... master/bin
- Android: TSDZ2_ESP32v2.1.12.apk
- ESP32: TSDZ2-ESP32-Mainv1.2.1.zip
- STM8: TSDZ2-v16.zip
Last edited by mspider65 on May 14 2022 10:27am, edited 1 time in total.

endlessolli   10 W

10 W
Posts: 68
Joined: Jul 31 2020 11:55am

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

Post by endlessolli » Apr 23 2022 4:29am

Hi @mspider65
Well, that update did unfortunately not work for me :( - I hope I did not brick it.....

I think I followed your instructions exactly:
1. updating the tsdz2 firmware worked
2. uploading the esp32 fw worked
3. unpairing bt worked
But then I got distracted (wife called....) and the tsdz2/esp went to timeout / power down

When I powered it up again, it get erratic blinking error E-08 and in sync the battery bar goes from full to empty.
(I have the small XH-18 display)

I can then go to the BT Setup menue of the new app, scan and also see the device, but when trying to pair it fails:
("Error: Pairing failed")

I then tried to reinstall the older app version (TSDZ2_ESP32v2.1.11); but also there pairing causes the above error.

Note: I still can initiate walk assist, so it seems not completely bricked...

Do you have an idea what I can do / troubleshoot now?

endlessolli   10 W

10 W
Posts: 68
Joined: Jul 31 2020 11:55am

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

Post by endlessolli » Apr 23 2022 5:05am

Never mind! It worked!!

This is really emberrassing.... I used the wrong pairing pin....... :oops:

Unfortunately, I can not test it in real live, because I had to travel back from where the bike is.
(But I took the tsdz2 with me :D )
Thanks again for this great setup, @mspider65 !

endlessolli   10 W

10 W
Posts: 68
Joined: Jul 31 2020 11:55am

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

Post by endlessolli » Apr 27 2022 10:26am

I can't believe why there is no further response to @mspider65 update of his firmware & App.
Just to reiterate:
Update is NO Problem!
(It was just stupid me who entered the wrong BT pin when connecting.... Hint: Default is: 123456 - it is even stated during the update process)

Thanks again to @mspider65 for creating this firmware & App and share his continous improvements.
(I like esp. the new App setting structure with the torque sensor having its on sub-menue)

Deadrabbit   1 mW

1 mW
Posts: 11
Joined: May 26 2019 9:51am

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

Post by Deadrabbit » Apr 27 2022 1:11pm

Hi,

i recieved my pcbs but i'm not able to pair with my phone. Flashing went fine, but there is no Bluetooth device which i can connect to.

I've tried scanning also with the android app nrf connect, but i can't see the device.

I've also tried different power sources: Via the pin headers @ 3,3 Volt and via the main connector @ 29 Volt.

If i connect via FTDI and putty to the esp, i get the following messages:

Code: Select all

Brownout detector was triggered

ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:4244
load:0x40078000,len:12740
ho 0 tail 12 room 4
load:0x40080400,len:3744
entry 0x40080620
I (46) cpu_start: Pro cpu up.
I (46) cpu_start: Application information:
I (46) cpu_start: Project name:     TSDZ2-ESP32-Main
I (48) cpu_start: App version:      1.2.1
I (53) cpu_start: Compile time:     Mar  7 2022 12:30:56
I (59) cpu_start: ELF file SHA256:  231775a46e0091bb...
I (65) cpu_start: ESP-IDF:          v4.1-dirty
I (70) cpu_start: Starting app cpu, entry point is 0x400813d8
I (61) cpu_start: App cpu up.
I (81) heap_init: Initializing. RAM available for dynamic allocation:
I (87) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (93) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
I (99) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (105) heap_init: At 3FFBDB5C len 00000004 (0 KiB): DRAM
I (111) heap_init: At 3FFCE5A0 len 00011A60 (70 KiB): DRAM
I (118) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (124) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (130) heap_init: At 4009CA68 len 00003598 (13 KiB): IRAM
I (136) cpu_start: Pro cpu start user code
I (155) spi_flash: detected chip: gd
I (155) spi_flash: flash io: qio
I (156) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (163) tsdz_main: NVS init ...
I (1343) tsdz_main: Read cfg ...
I (1343) tsdz_nvs: NVS KEY = 7
I (1343) tsdz_main: UART init ...
I (1343) tsdz_main: BT init ...
I (1343) BTDM_INIT: BT controller compile version [219866f]
I (1353) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
W (1363) phy_init: failed to load RF calibration data (0x1102), falling back to full calibration
These message is constantly repeated.

Edit: Some Update... It seems to be a problem with the power. I've replaced the FTDI with a 3,3 Volt Power Supply and i see the esp32 and i'm able to connect.

But if power the pcb with 42 Volt on the main input, i can only measure >2V on the jumper.
Attachments
s-l1600.jpg
s-l1600.jpg (89.39 KiB) Viewed 694 times

Deadrabbit   1 mW

1 mW
Posts: 11
Joined: May 26 2019 9:51am

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

Post by Deadrabbit » Apr 27 2022 2:23pm

Ok, now everything is working. I thought, that the esp32 is able to enable the motor via GPIO, but after reading the schematics, i've checked that the voltage regulator XL7005A is enabled via the display on.

If i power VBatt and PW_EN everything works fine.

I think in the next days i will build it into the tsdz2.

BW

mspider65   100 W

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

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

Post by mspider65 » Apr 28 2022 12:05pm

endlessolli wrote:
Apr 27 2022 10:26am
I can't believe why there is no further response to @mspider65 update of his firmware & App.
Just to reiterate:
Update is NO Problem!
(It was just stupid me who entered the wrong BT pin when connecting.... Hint: Default is: 123456 - it is even stated during the update process)

Thanks again to @mspider65 for creating this firmware & App and share his continous improvements.
(I like esp. the new App setting structure with the torque sensor having its on sub-menue)
Thank you!
often people post on the forum to complain about something wrong or to ask for help. So if there are not many messages for me it means everything is working fine :D :D. (Or that there are few people who use it). In any case, no problem at all.
Enjoy your rides.

andyb   10 mW

10 mW
Posts: 32
Joined: Oct 26 2021 3:42am

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

Post by andyb » May 13 2022 3:23am

Hello, I'm just about to install this and I was wondering, if I wish to try a different firmware (eg mbrusa's) at some point in the future, would I have to remove the board (I realise the Bluetooth app wouldn't work).

Thanks to everyone for all the brilliant help and support on this forum and mspider65 for keeping this firmware going.

Andy.

mspider65   100 W

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

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

Post by mspider65 » May 14 2022 4:49am

andyb wrote:
May 13 2022 3:23am
I was wondering, if I wish to try a different firmware (eg mbrusa's) at some point in the future, would I have to remove the board.
yes, you should remove the board.
To leave it you would need a special firmware that acts as a pass through on the connection between the controller and the display.

andyb   10 mW

10 mW
Posts: 32
Joined: Oct 26 2021 3:42am

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

Post by andyb » May 14 2022 9:31am

Thanks for the speedy reply. :bigthumb:

andyb   10 mW

10 mW
Posts: 32
Joined: Oct 26 2021 3:42am

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

Post by andyb » May 25 2022 2:44pm

:bolt: ITS ALIVE!!!!!! :bolt:

Very excited :D :D :D

I thought I would share my experience of flashing the board and getting the temp sensor sorted, it's all working but along the way I made some mistakes and I'm hoping by posting them others might be helped.

I used this to flash
flashing part 5.jpg
flashing part 5.jpg (213.28 KiB) Viewed 367 times
I got all the files in place as per the instructions, I renamed TSDZ2-ESP32-Mainv1.2.1.zip to TSDZ2-ESP32-Main.zip.

Don't miss this, I did and it's obvious and in bold :oops:
flashing part 3.jpg
flashing part 3.jpg (22.75 KiB) Viewed 367 times
When I tried to flash I got a warning message from windows and then it wouldn't flash (you know when it's working as you can see a script running). I had to change the execution policy to allow me to flash it. I ended up doing all of this in an admin powershell, this site helped me do it.

PLEASE NOTE Changing this setting might mean that your computer will run scripts that might damage it, have a good read of the below before changing it.

https://superuser.com/questions/106360/ ... ll-scripts

Please see attachments for more details of how I did it.

All working now except for the temperature sensor, I had messed up the wiring. :oops: The connectors wires are in a different order to the pins so the colours don't match
flashing part 4.jpg
flashing part 4.jpg (46.84 KiB) Viewed 367 times
All done now and thanks for all the help from everyone here, I can't wait to get it onto my bike.
Attachments
flashing part 1.jpg
flashing part 1.jpg (250.74 KiB) Viewed 367 times
flashing part 2.jpg
flashing part 2.jpg (170.82 KiB) Viewed 367 times
flashing ESP32.txt
(3.85 KiB) Downloaded 12 times

Admiralrofl   1 mW

1 mW
Posts: 17
Joined: Jan 26 2022 12:20am

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

Post by Admiralrofl » Jun 06 2022 12:15am

Hey everyone, Im really interested in this approach for the tsdz2, especially with a possbility of throttle and temp sensing. I wanted to see if it would be possible to run a no display setup with all of this, But I don't see anyone having tried nor anything in the wiki.

andyb   10 mW

10 mW
Posts: 32
Joined: Oct 26 2021 3:42am

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

Post by andyb » Jun 07 2022 3:39am

:bolt: It's Still alive :bolt: (Sort of)

(Sorry Admiralrofl, I don't know about running no display)

I have it all wired up and working (on one of the 2 boards I had there was a short between txl and gnd) the other one was fine.

I have a problem though.

It works brilliantly until I change gears and at that point it kind of stops working the connection with the phone drops out as well and then either provides no power or power in fits and starts. I then leave it for a while (a few minutes) and it works again then breaks again (when I change gear).
I have swapped out my LCD, same thing happens.
Lowered the max current.
The cables seem fine and as it works otherwise I don't think it's that.
I have tried it without the phone, put the phone on aeroplane mode, same thing.

Has anyone any ideas, my next things to do are:

Turn off Field weakening Assist without pedal rot, and lower the acceleration.

I will report back, but please if you have experienced this can you help.

Also does anyone know the wheel sizes I should use, VLCD6, I have used 230 (which should be 29" and so eMtb) but it gives me cadence mode, I will have a play with this and feed back if noone can help.

Thanks.

andyb   10 mW

10 mW
Posts: 32
Joined: Oct 26 2021 3:42am

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

Post by andyb » Jun 07 2022 12:16pm

mspider65 wrote:
May 14 2022 4:49am
andyb wrote:
May 13 2022 3:23am
I was wondering, if I wish to try a different firmware (eg mbrusa's) at some point in the future, would I have to remove the board.
yes, you should remove the board.
To leave it you would need a special firmware that acts as a pass through on the connection between the controller and the display.
Thanks, would shorting the tx and rx connections appropriately work, I could use a connector on the end of the current one.

Thanks (again)

mspider65   100 W

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

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

Post by mspider65 » Jun 08 2022 5:31am

Admiralrofl wrote:
Jun 06 2022 12:15am
Hey everyone, Im really interested in this approach for the tsdz2, especially with a possbility of throttle and temp sensing. I wanted to see if it would be possible to run a no display setup with all of this, But I don't see anyone having tried nor anything in the wiki.
It is not the purpose of this project.
In theory, however, it would be possible by modifying the firmware of the ESP32 board even if it would then be necessary to add some HW at least to turn the system on / off.

mspider65   100 W

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

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

Post by mspider65 » Jun 08 2022 5:45am

andyb wrote: It works brilliantly until I change gears and at that point it kind of stops working the connection with the phone drops out as well and then either provides no power or power in fits and starts. I then leave it for a while (a few minutes) and it works again then breaks again (when I change gear).
I don't see how gear shift can affect the ESP32 board operation.
Check the connections and the power supply, there must be some problem there.
andyb wrote: Also does anyone know the wheel sizes I should use, VLCD6, I have used 230 (which should be 29" and so eMtb) but it gives me cadence mode, I will have a play with this and feed back if noone can help.
The wheel circumference must be configured with the Android app.
The wheel diameter on the display is instead used to set the default assistance mode at start-up.
Read the Wiki.
andyb wrote: Thanks, would shorting the tx and rx connections appropriately work, I could use a connector on the end of the current one.
If you restore the connection of the TX/RX cables as before installing the board, obviously everything works as before.

andyb   10 mW

10 mW
Posts: 32
Joined: Oct 26 2021 3:42am

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

Post by andyb » Jun 08 2022 5:54pm

Thanks for getting back to me, I admit it looks a bit confusing. Can I go back to a previous version by flashing etc or would this not work?
mspider65 wrote:
Jun 08 2022 5:45am
andyb wrote: It works brilliantly until I change gears and at that point it kind of stops working the connection with the phone drops out as well and then either provides no power or power in fits and starts. I then leave it for a while (a few minutes) and it works again then breaks again (when I change gear).
I don't see how gear shift can affect the ESP32 board operation.
Check the connections and the power supply, there must be some problem there.

I don't either, i can only think that the change in torque is having some effect, it's not the actual gear change as the ESP wouldn't know I have changed gear, I will check it but as it is working then not working i'm unsure what it could be.
andyb wrote: Also does anyone know the wheel sizes I should use, VLCD6, I have used 230 (which should be 29" and so eMtb) but it gives me cadence mode, I will have a play with this and feed back if noone can help.
The wheel circumference must be configured with the Android app.
The wheel diameter on the display is instead used to set the default assistance mode at start-up.
Read the Wiki.

Yes, but I have been changing the wheel size on the LCD not the App and 230cm 29" doesn't give me eMtb, which is what has confused me.
andyb wrote: Thanks, would shorting the tx and rx connections appropriately work, I could use a connector on the end of the current one.
If you restore the connection of the TX/RX cables as before installing the board, obviously everything works as before.
Thanks, just wanted to be sure.

Post Reply