TSDZ2 EBike wireless standard (like Specialized Turbo Levo) - OpenSource

Spent the entire day just trying to get my watch code running on top of a softdevice on the X9, who would of thought it'd be so difficult :shock:. Anyway I've got the lvgl graphics library hooked in now, got the button controls working so just need to hook in the ANT code and it'll be mostly good to go.

On a side note @casainho if you need to know how to get full debugging working on the NRF chipsets (i.e. chip registers, etc) I now know how to set that up (was trying to debug why softdevice wasn't working, turns out a bootloader is mandatory with a softdevice) and I'm also now fairly well versed with building the bootloader and application settings so I guess it wasn't a complete waste of the day
 
bobreece20 said:
Anyway I've got the lvgl graphics library hooked in now, got the button controls working so just need to hook in the ANT code and it'll be mostly good to go.

I'm also now fairly well versed with building the bootloader and application settings so I guess it wasn't a complete waste of the day
Good advance!! Share pictures please.

If you can, please update / write documentation page about everything you think is useful for developers.

About the boot loader, do you want to develop it? I would say we want to use the button to enter on it as also have it running in parallel to our firmware / app, so we can go to the nrf app and always be able to update without the need to touch again on the button.

The firmware you develop for the watch, I can use for my LCD. I guess only the display size on my LCD is a bit bigger. I don't think I will have energy to fully develop firmware for my display.
 
Yeah I'll get around to writing to documentation soon.

Not much to see atm really. Lvgl provides a lot of nice widgets but a single button was enough to prove the concept and graphics renderering
IMG_20200726_202848_2.jpg

Helpfully Lvgl also comes with simulator for the PC so I can mock up the UI without having to bother with the hardware.
IMG_20200801_210043.jpg

This X9 really does have terrible screen resolution though... Will have to put some thought into how to make the UI scale for the different devices we want to target (may have to design a small (x9 Pro), medium (Pinetime) and large (bike LCD) UI)
 
bobreece20 said:
This X9 really does have terrible screen resolution though... Will have to put some thought into how to make the UI scale for the different devices we want to target (may have to design a small (x9 Pro), medium (Pinetime) and large (bike LCD) UI)
Yes, a PC simulator is very nice to important and also having that library with widjets. When I started the 850C firmware I tried to make Lvgl to work but I could not and so it was for sure hard to develop current widjets, that it was not me after all to develop them, was other developer as I miss the knowledge.

With all that work on different screens, what are your expectations for the final firmware? Mine, as I told, is just the same as 860C firmware + user HR received by ANT+ or Bluetooth. I do not expect to try replace a Gain Edge!!

And why don't you simplify and develop only for Primetime as it seems the only one that will maybe be available to buy on medium/long term?
 
casainho said:
With all that work on different screens, what are your expectations for the final firmware? Mine, as I told, is just the same as 860C firmware + user HR received by ANT+ or Bluetooth. I do not expect to try replace a Gain Edge!!

And why don't you simplify and develop only for Primetime as it seems the only one that will maybe be available to buy on medium/long term?

My expectations (for now) is to be able to use the watch to monitor the bike and control it. Currently I'm not thinking about HR or anything like that. A simple small device to control is all I wish for now. Obviously I've no objections to working towards a Garmin Edge like device but I want to start off small xD

The X9 is useful for me atm whilst I'm still in prototyping/learning stage as if I break it, it's £9 and a two day wait for another. With a suitable HAL there shouldn't be much effort to switch to PineTime anyway (and the longer I leave the PineTime the more likely all the hardware drivers will of been figured out and available).

Anyway, just tested the DFU bootloader. All you have to do have the following two lines:
```
NRF_POWER->GPREGRET = BOOTLOADER_DFU_START;
NVIC_SystemReset();
```
and this define:
```
#define BOOTLOADER_DFU_START 0xB1
```
in and it'll cause the device to reboot into the dfu bootloader. The dfu bootloader can then be connected to from nRF Connect on Android to pass new firmware to the device. I've not tested actually producing a firmware zip yet but I assume it'll work fine (and it looks fairly simple https://devzone.nordicsemi.com/nordic/short-range-guides/b/software-development-kit/posts/getting-started-with-nordics-secure-dfu-bootloader#h30sjziadf6hpjsiv7m17imj1jfgvi). As for getting out of the DFU Bootloader, I believe there is an abort code but I'm unsure how to use that from nRF Connect so you have to wait for the 2 min inactivity timer on the bootloader to trigger before it returns back to the current application.
 
bobreece20 said:
casainho said:
With all that work on different screens, what are your expectations for the final firmware? Mine, as I told, is just the same as 860C firmware + user HR received by ANT+ or Bluetooth. I do not expect to try replace a Gain Edge!!

And why don't you simplify and develop only for Primetime as it seems the only one that will maybe be available to buy on medium/long term?

My expectations (for now) is to be able to use the watch to monitor the bike and control it. Currently I'm not thinking about HR or anything like that. A simple small device to control is all I wish for now. Obviously I've no objections to working towards a Garmin Edge like device but I want to start off small xD

The X9 is useful for me atm whilst I'm still in prototyping/learning stage as if I break it, it's £9 and a two day wait for another. With a suitable HAL there shouldn't be much effort to switch to PineTime anyway (and the longer I leave the PineTime the more likely all the hardware drivers will of been figured out and available).

Anyway, just tested the DFU bootloader. All you have to do have the following two lines:
```
NRF_POWER->GPREGRET = BOOTLOADER_DFU_START;
NVIC_SystemReset();
```
and this define:
```
#define BOOTLOADER_DFU_START 0xB1
```
in and it'll cause the device to reboot into the dfu bootloader. The dfu bootloader can then be connected to from nRF Connect on Android to pass new firmware to the device. I've not tested actually producing a firmware zip yet but I assume it'll work fine (and it looks fairly simple https://devzone.nordicsemi.com/nordic/short-range-guides/b/software-development-kit/posts/getting-started-with-nordics-secure-dfu-bootloader#h30sjziadf6hpjsiv7m17imj1jfgvi). As for getting out of the DFU Bootloader, I believe there is an abort code but I'm unsure how to use that from nRF Connect so you have to wait for the 2 min inactivity timer on the bootloader to trigger before it returns back to the current application.
There is even a better and more advanced option for the bootloader that is it be fully running in parallel with our firmware, meaning the user can go to the mobile app and flash a new firmware without touch any physical button.
 
Because I could not 3D design with success a remote button to reuse the VLCD5 remote parts, I decided to move forward and keep outside the wireless board. And I have the very first firmware working (I think there is room to improve the buttons reaction).

Next step is to add the coil cell and develop the firmware to be optimized for very lower power usage so the coin cell can work for at least 1 year:

[youtube]AhgU8M5qEPg[/youtube]

image.png
 
Wow! Great progress. Congratulations!
Would the new firmware be able to support wahoo devices?
I don't think the edge remote will work on the wahoo elemnt series.
Perhaps implement an ANT connection to the elemnt series something like the Shimano Di2 that would allow for both paging and configurable button control:
https://m.youtube.com/watch?v=pgGITe1_OQ0

More info from wahoo:
https://support.wahoofitness.com/hc/en-us/articles/115000460504-What-Are-the-Functions-of-the-Di2-Hood-Buttons-When-Paired-to-an-ELEMNT-
 
I did finish the very first version of the firmware and is perfectly usable:

[youtube]O67TSVkCuRM[/youtube]

Repository: https://github.com/OpenSource-EBike-firmware/ebike_wireless_remote

The board is powered with a coin cell CR2032 that I hope will work for at least 1 year - I implemented on the firmware all the ultra low power features possible:

-------------------------------------------------------
• wakeup
☑ any button press (from low power)
☑ any button press (from ultra low power)
-------------------------------------------------------
• enter low power
☑ every time it is not reacting to buttons or rx/tx ANT
☐ every time it is not reading battery voltage
-------------------------------------------------------
• enter ultra low power
☑ if no master / display found (takes about 30 seconds for this detection)
☑ if no button press for 1 hour
-------------------------------------------------------
 
casainho said:
I did finish the very first version of the firmware and is perfectly usable:

[youtube]O67TSVkCuRM[/youtube]

Repository: https://github.com/OpenSource-EBike-firmware/ebike_wireless_remote

The board is powered with a coin cell CR2032 that I hope will work for at least 1 year - I implemented on the firmware all the ultra low power features possible:

-------------------------------------------------------
• wakeup
☑ any button press (from low power)
☑ any button press (from ultra low power)
-------------------------------------------------------
• enter low power
☑ every time it is not reacting to buttons or rx/tx ANT
☐ every time it is not reading battery voltage
-------------------------------------------------------
• enter ultra low power
☑ if no master / display found (takes about 30 seconds for this detection)
☑ if no button press for 1 hour
-------------------------------------------------------

First of all thank you casainho for your great and hard work.
Just to understand, will it also be possible to use this project with kunteng controllers?
 
fabus said:
Just to understand, will it also be possible to use this project with kunteng controllers?
Since the project is OpenSource, everything is possible while there are developers available to do it. I am not using Kunteng motor controllers anymore, there are no reason for me to develop it.
 
I updated the repository with the schematic, with minimal notes for replication: https://github.com/OpenSource-EBike-firmware/ebike_wireless_remote

ebike_remote_wireless-v1.png
 
casainho said:
fabus said:
Just to understand, will it also be possible to use this project with kunteng controllers?
Since the project is OpenSource, everything is possible while there are developers available to do it. I am not using Kunteng motor controllers anymore, there are no reason for me to develop it.

Knowing Tsdz2 uses controllers from kunteng , i thought project was possible even with an external controller kt
 
casainho said:
I updated the repository with the schematic, with minimal notes for replication: https://github.com/OpenSource-EBike-firmware/ebike_wireless_remote

ebike_remote_wireless-v1.png

Sounds very interesting casainho.
I am trying to figure out if I am potentially ready with my current hardware. I already have the ST clone programmer as I am a long time follower of this project.
I have:
- A spare vlcd5 keypad
- a Garmin fenix 3 watch (capable of installing the small apps)
If I buy the wireless board and the button battery, am I ready to try the newest firmware or do I need to buy additional stuff?

I currently have not fully understood the full system connection (motor to control keypad)..

The last question is: if I use the garmin watch for ebike control, will it be able to record the GPS log at the same time? I currently use it to log my bike activity, I wander if it can handle both activities...
Thanks
 
thineight said:
casainho said:
I updated the repository with the schematic, with minimal notes for replication: https://github.com/OpenSource-EBike-firmware/ebike_wireless_remote

ebike_remote_wireless-v1.png

Sounds very interesting casainho.
I am trying to figure out if I am potentially ready with my current hardware. I already have the ST clone programmer as I am a long time follower of this project.
I have:
- A spare vlcd5 keypad
- a Garmin fenix 3 watch (capable of installing the small apps)
If I buy the wireless board and the button battery, am I ready to try the newest firmware or do I need to buy additional stuff?

I currently have not fully understood the full system connection (motor to control keypad)..
[youtube][/youtube]
The last question is: if I use the garmin watch for ebike control, will it be able to record the GPS log at the same time? I currently use it to log my bike activity, I wander if it can handle both activities...
Thanks
1. The project is far from be finished. The idea is to be modular and use standards, so, apps and hardware done by others will work and we do not need to develop it - because we simple can't, it would be a TO BIG project!!

2. The OpenSource EBike Remote Wireless is just a wireless remote but OpenSource, meaning we can customize it and make one remote for our custom needs like with extra buttons (other than the standard EBike buttons).
This extra buttons can maybe be configured for control of your music on your smartphone or something like that!!

3. On this current version, the firmware sends only value 0 and 1, when clicking button UP and button DOWN. This works on Garmin Edge for change no next and previous page. I did not yet test other values over 1 so I did not discover what other values are possible.

4. For ebike control, the standard is to use an Edge that supports ANT+ LEV profile. I think none watches support ANT+ LEV from factory, but yes, there are custom apps from other developers that do that. For now, is better to stick what comes from factory because I don't think anyone in the community is available to develop such apps.

5. To better understand wireless EBike mode on the Edge, see this video I recorded:
1. First I did pair my wireless EBike (that wireless board) on the Edge
2. There is a page specific for EBike, were we can see battery status and assist level. We can also change assist level on the touch screen, clicking on the + and - buttons. BUT, with a wireless remote, we can change the assist level without need to touch on the display, also, we can change the page on the remote, so, the idea is to use the remote to change between different pages with different data as also the EBike page - JUST LIKE on 860C and SW102!!

[youtube]YYaG6Zjt1xo[/youtube]

6. The activities are recorded on the Edge as usual. And there are data from the motor that goes to the Edge like the motor power that I think can be automatically recorded on the activity.

So to resume:
1. our OpenSource remote is developed. In future I need to try the values needed to be sent to Edge for change the assist level but every developer can help on this, even because there is a simulator for PC to ANT+ where this values can be tested.

2. TSDZ2 Ebike wireless board. the EBike firmware part that is the new only thing is implemented and tested as seen on the video. Hardware is ready and tested. What is missing is the firmware acting as a virtual display, like using 860C display firmware and ignore all the parts about display data on the LCD. I started but I was trying to make it integrated with V1.0.0 of 860C and SW102 firmware but it was to much for me... I was stuck and not capable to advance... soon I will just fork V1.0.0 and start a specific project for wireless TSDZ2 Ebike.

And note that although is not tested yet, there is planned to test a version of the wireless remote where the brake sensors can be connected -- but we don't know yet if the wireless connection to TSDZ2 will be fast enough for detect the brake signal to stop the motor:

file.php
 
casainho said:
1. The project is far from be finished. The idea is to be modular and use standards, so, apps and hardware done by others will work and we do not need to develop it - because we simple can't, it would be a TO BIG project!!

2. The OpenSource EBike Remote Wireless is just a wireless remote but OpenSource, meaning we can customize it and make one remote for our custom needs like with extra buttons (other than the standard EBike buttons).
This extra buttons can maybe be configured for control of your music on your smartphone or something like that!!

3. On this current version, the firmware sends only value 0 and 1, when clicking button UP and button DOWN. This works on Garmin Edge for change no next and previous page. I did not yet test other values over 1 so I did not discover what other values are possible.

4. For ebike control, the standard is to use an Edge that supports ANT+ LEV profile. I think none watches support ANT+ LEV from factory, but yes, there are custom apps from other developers that do that. For now, is better to stick what comes from factory because I don't think anyone in the community is available to develop such apps.

5. To better understand wireless EBike mode on the Edge, see this video I recorded:
1. First I did pair my wireless EBike (that wireless board) on the Edge
2. There is a page specific for EBike, were we can see battery status and assist level. We can also change assist level on the touch screen, clicking on the + and - buttons. BUT, with a wireless remote, we can change the assist level without need to touch on the display, also, we can change the page on the remote, so, the idea is to use the remote to change between different pages with different data as also the EBike page - JUST LIKE on 860C and SW102!!

[youtube]YYaG6Zjt1xo[/youtube]

6. The activities are recorded on the Edge as usual. And there are data from the motor that goes to the Edge like the motor power that I think can be automatically recorded on the activity.

So to resume:
1. our OpenSource remote is developed. In future I need to try the values needed to be sent to Edge for change the assist level but every developer can help on this, even because there is a simulator for PC to ANT+ where this values can be tested.

2. TSDZ2 Ebike wireless board. the EBike firmware part that is the new only thing is implemented and tested as seen on the video. Hardware is ready and tested. What is missing is the firmware acting as a virtual display, like using 860C display firmware and ignore all the parts about display data on the LCD. I started but I was trying to make it integrated with V1.0.0 of 860C and SW102 firmware but it was to much for me... I was stuck and not capable to advance... soon I will just fork V1.0.0 and start a specific project for wireless TSDZ2 Ebike.

And note that although is not tested yet, there is planned to test a version of the wireless remote where the brake sensors can be connected -- but we don't know yet if the wireless connection to TSDZ2 will be fast enough for detect the brake signal to stop the motor:

file.php

Thanks for the detailed info.
I was thinking at this watch app when I asked the question, that looks compatible with the fenix3 watch and many others device.
https://apps.garmin.com/it-IT/apps/1532f0d9-fd19-4b63-b038-435d8fd670a4#0
 
thineight said:
Thanks for the detailed info.
I was thinking at this watch app when I asked the question, that looks compatible with the fenix3 watch and many others device.
https://apps.garmin.com/it-IT/apps/1532f0d9-fd19-4b63-b038-435d8fd670a4#0
I already tested the app and it seems it just shows information but don´t let you change the assist level, which is a MUST.

I think a app of the wireless remote must let as minimum to change the assist level. I also think it should let turn on/off the system but maybe that must be done with a physical switch on the ebike and never on the GPS display or on the watch.
 
TarrenceRobertson said:
Why NEVER on the watch? I'm generally interested in being able to manage everything on the watch. And the best option is voice control. Do you think this is possible?
maybe the reason is as described above.
1. The project is far from being finished. The idea is to be modular and use standards, so, apps and hardware done by others will work and we do not need to develop it - because we simple can't, it would be a TO BIG project!!

When the remote is finished everybody can fill it's own needs.
 
I received the Bluetooth button and it has some issues for EBike application:
- does not work on my Garmin GPS (works ok on my Android)
- the support for the button does not work on a bicycle handle bar, the size is instead for the bigger size of a car handlebar
- does not have a tactile feedback, meaning you will need to look at it to make sure you clicked on the right button
- it is not water prof
- is big, I expect to have something small no my bicycle handle bar

01.jpg


02.jpg


03.jpg
 
I found the button battery discharged after 1 week only... I think the only option is because the hardware is using power as I think the firmware is running always at ultra low power. I decided to "cut" the path for the 3.3V voltage DC-DC converter and for that a resistor must be removed, so, the battery voltage goes directly to the NRF52. I also removed the RGB LED and I think it may also being using some power.

After removing the resistor, the battery + wire need to be soldered to a capacitor (the biggest pad / place I found the be possible to solder the wire). Let's see for how long the new battery will work:

board.jpg
 
casainho said:
I found the button battery discharged after 1 week only... I think the only option is because the hardware is using power as I think the firmware is running always at ultra low power. I decided to "cut" the path for the 3.3V voltage DC-DC converter and for that a resistor must be removed, so, the battery voltage goes directly to the NRF52. I also removed the RGB LED and I think it may also being using some power.

After removing the resistor, the battery + wire need to be soldered to a capacitor (the biggest pad / place I found the be possible to solder the wire). Let's see for how long the new battery will work:

board.jpg

Not sure if these links are of any help:
https://devzone.nordicsemi.com/f/nordic-q-a/49572/what-is-lowest-power-consumption-template-code-for-nrf52840-dongle

https://devzone.nordicsemi.com/f/nordic-q-a/60041/nrf52840-power-consumption-with-increased-voltage-for-peripherals

https://devzone.nordicsemi.com/f/nordic-q-a/56270/nrf52840-dongle-draws-more-current-on-vddh-than-vdd
 
casainho said:
Maybe we should keep talking about this development on the specific thread: https://endless-sphere.com/forums/viewtopic.php?f=28&t=106346
I've started playing around with the FreeCAD Surface function. :)
The 3D printing result looks quite rough, which is due to the z-resolution of the cheap 3D printer...

regards
stancecoke

3D Test Print.JPG
 
stancecoke said:
casainho said:
Maybe we should keep talking about this development on the specific thread: https://endless-sphere.com/forums/viewtopic.php?f=28&t=106346
I've started playing around with the FreeCAD Surface function. :)
The 3D printing result looks quite rough, which is due to the z-resolution of the cheap 3D printer...
Nice. I will try to find a video tutorial on FreeCAD Surface function.

I know you do not use TSDZ2, only hub motors. Also you do not use a display but prefer only a mobile app. On this project we can go as low as also not using a display and using a mobile app only - we will need a mobile app. The app you are using with KT controller is a candidate? is it OpenSource?
 
casainho said:
Also you do not use a display but prefer only a mobile app.
I only use the mobile phone for logging debug data with blueterm. I don't use the BlueOsec-App of @Xnyle.

casainho said:
The app you are using with KT controller is a candidate? is it OpenSource?
Sadly it is not open source, @Xnyle has only published the APK-file:
https://github.com/Xnyle/bluosec-apk/

I still do not need any display. The Keypad could be used for switching the system on/off and changing the assist level. I would be happy with short blinks of a LED or short buzzer beeps as a feedback for successfully pressed buttons...
eg. short LED-flash every 5 seconds for system switched on, e.g. 5 blinks/beeps for one time for level 5 after pressing up/down button.... This should not stress the button cell too much....

regards
stancecoke
 
stancecoke said:
I still do not need any display. The Keypad could be used for switching the system on/off and changing the assist level. I would be happy with short blinks of a LED or short buzzer beeps as a feedback for successfully pressed buttons...
eg. short LED-flash every 5 seconds for system switched on, e.g. 5 blinks/beeps for one time for level 5 after pressing up/down button.... This should not stress the button cell too much....
Yes, I see this happening like you say. Mobile app would need to be used only for a first time configuration and as optional at anytime for configuration and see real time status and data.

For the ones with a watch like me, with a battery that holds charge for 20 days, one could use the watch as a remote and so the bicycle handlebar would be even more clean -- but this is something for future, for now, only that remote button I did show on the video, is working.

With LED only and not a buzzer as I suspect it would take to much energy. At least an LED is used the commercial wireless remote buttons:

image.png
 
Back
Top