• Howdy! we're looking for donations to finish custom knowledgebase software for this forum. Please see our Funding drive thread

EasyDIY OpenSource display for EVs: TSDZ2 and Bafang M500/M600 EBike motors

Finished my EasyDIY display, welcome screen 0.20.0 is shown and rgb leds blink red-orange-green then turn off.
All buttons work and I can access the settings menu with up-down combo also on-off = select are responding well.

MCP2515 can (with x-tal 8MHz) module tested fine with CanHacker but not with nRF.

Connections made between MCP & nRF:
Code:
Vcc = Vdd OUT (3V3)
Gnd = Gnd
CS  = CS2  = P0.31
SO  = MISO = P1.15
SI  = MOSI = P1.13
SCK = SCLK = P1.10
INT = nc

On my workbench, I would first try to send the required package (Tx with CanHacker). Before I wire everything back to the bike.
What can-massage(s) might/is the display waiting for?
 
Ggaljoen said:
Finished my EasyDIY display, welcome screen 0.20.0 is shown and rgb leds blink red-orange-green then turn off.
All buttons work and I can access the settings menu with up-down combo also on-off = select are responding well.

MCP2515 can (with x-tal 8MHz) module tested fine with CanHacker but not with nRF.

Connections made between MCP & nRF:
Code:
Vcc = Vdd OUT (3V3)
Gnd = Gnd
CS  = CS2  = P0.31
SO  = MISO = P1.15
SI  = MOSI = P1.13
SCK = SCLK = P1.10
INT = nc

On my workbench, I would first try to send the required package (Tx with CanHacker). Before I wire everything back to the bike.
What can-massage(s) might/is the display waiting for?
Look at the source code on GitHub - there is just few messages on can.c file.
 
casainho said:
Look at the source code on GitHub - there is just few messages on can.c file.

I digged into the github and found my workaround, now it is alive:
20220731_074846.jpg

Had to perform a nasty hack to get it going; UPDATE next (small printed) section is NOT correct. It was 'only' a power supply issue!
my suspicious thoughts about the MCP 250k init values in CANSPI.c were kind of confirmed.
Code:
MCP2515_WriteByte(MCP2515_CNF1, 0x00);
MCP2515_WriteByte(MCP2515_CNF2, 0xE5);
MCP2515_WriteByte(MCP2515_CNF3, 0x83);

Most (if not all) having these values:
Code:
#define MCP_8MHz_250kBPS_CFG1 (0x00)
#define MCP_8MHz_250kBPS_CFG2 (0xB1)
#define MCP_8MHz_250kBPS_CFG3 (0x85)

Workaround achieved:
  • nRF init display with oled and mcp connected => stuck at welcome screen
  • disconnected the MCP SPI bus from nRF, keep MCP powered
  • connect MCP SPI to CanHacker and sent the MCP init for 250k can
  • disconnected the MCP SPI bus from arduino, keep MCP powered
  • connect MCP to nRF
  • Success => can messages received and displayed

Power supply issue explained in my next post.

20220731_075812.jpg

Thank you casainho to make this possible!!!

Next on my list: setting up the development environment and dig further.
 
Could this display be used to show Motor and controller temperature? I would like to build something like this that can be used inline with the standard bafang display just to show Motor & Controller temperature. I have the skills to build the display, Understanding the firmware and canbus is quite new to me though.
 
EasyDIY display working fine now!

A power issue caused the workaround to function.
The MCP2515 init is not complete wrong; it is intended for 500kBPS with a 16Mhz X-tal; most modules are equiped with a 8Mhz thus suitable parameters for Bafang 250kBPS.

What was causing the problem: MCP2515 Vcc was picky about the too low 3V VddOUT of the nRF and neither happy with clean 5V USB (don't ask my why too high?).
But when I put a 1N4148 inline from nRF Vusb to the MCP Vcc it worked = around 4,2V

Lachymx said:
Could this display be used to show Motor and controller temperature? I would like to build something like this that can be used inline with the standard bafang display just to show Motor & Controller temperature. I have the skills to build the display, Understanding the firmware and canbus is quite new to me though.

Yes, both motor and controller information (and everything else too) is available on the canbus.
At the moment the firmware is not ready to co-exist with the original display, at least to my findings: original has strange behaviour.
Nothing that can not be fixed in the future.
 
Ggaljoen said:
EasyDIY display working fine now!

A power issue caused the workaround to function.
The MCP2515 init is not complete wrong; it is intended for 500kBPS with a 16Mhz X-tal; most modules are equiped with a 8Mhz thus suitable parameters for Bafang 250kBPS.

What was causing the problem: MCP2515 Vcc was picky about the too low 3V VddOUT of the nRF and neither happy with clean 5V USB (don't ask my why too high?).
But when I put a 1N4148 inline from nRF Vusb to the MCP Vcc it worked = around 4,2V
Congratulations and please share pictures of the final build on your EBike.

So, what can you suggest to improve the project so next users will not have the same issue??
 
Lachymx said:
Could this display be used to show Motor and controller temperature? I would like to build something like this that can be used inline with the standard bafang display just to show Motor & Controller temperature. I have the skills to build the display, Understanding the firmware and canbus is quite new to me though.
I think Bafang M500/M600 only puts the motor temperature on the CAN BUS, not the controller temperature.

And yes, the display shows the motor temperature and that is very important to control, see here my recent experience:

------

Other thing I forgot to mention is that my motor got hot, because I had a lot of hills and the weather was like 35, I could feel the motor burning and I could not keep my hand on it. The display was saying like about 72 and so I kept and eye on the display and I stooped like 10 different times to wait for temperature decrease up to 50 or 55 degrees.

Even if the motor controller firmware should protect the motor, I was afraid and get near the fatal motor demagnetization I already had on TSDZ2 at begin when I did not know about this -- read here all the details of motor fatal demagnetization due to high temperatures: https://github.com/OpenSourceEBike/TSDZ2_wiki/wiki/TSDZ2-motor-demagnetized-due-to-overheating

Example when my motor had demagnetized due to high temperatures:
TSDZ2_demagnetized_motor-05.jpg


casainho said:
Yesterday I went to the mountains and I did cycle 140kms and it was hard. That gave me the opportunity to real test my EBike with M500 and I would like to share what I found:

1. 52V battery with a M500 48V motor: My M500 was bought as a 48V battery but soon I found it would start to limit the motor power very soon when the battery was like at 50% SOC. Since I built my own battery, I decided to add more 1 series from 48V 13 to 52V 14S, as recommended by one user, so the motor power limitation would start later. And this worked very well!! The SOC on the display was 99% for a long time, because the M500 was calculation the SOC for a 48V battery. I also could see that at 40% SOC, the motor was limiting my motor power at up like 220W, which is not bad since now the 40% SOC it is for sure a real lower SOC than 40%.

Now I need to fully implement the SOC Coulomb counting on our EasyDIY display, because the original SOC of M500 is totally wrong.

2. Walk assist does not work: I mean the motor rotates but at very slow speed like 2 km/h and has very low torque meaning that it even can not push at all the ebike on the hills, the motor just stops on the hills that is when I really need walk assist.

3. Electronics gears are perfect not related to this motors because they are modular (unlike the electronic gears just released by Shimano that only works for their electric motors), the SRAM AXS, worked flawlessly, perfectly, while my previous mechanical gears would always missing some gear and that was frustrating because I want to pedal as smooth as possible. The M500 works very well, so the external gears need to be on pair with the motor.

 
casainho said:
Congratulations and please share pictures of the final build on your EBike.

So, what can you suggest to improve the project so next users will not have the same issue??

Pictures will follow after a made a (semi)permanent mount for it. First I would like to tinker with the firmware.

From what I could reproduce; the voltage for the MCP is better of with Vusb minus voltagedrop over 1N4148 ~= 4V2

casainho said:
Lachymx said:
Could this display be used to show Motor and controller temperature? I would like to build something like this that can be used inline with the standard bafang display just to show Motor & Controller temperature.
I think Bafang M500/M600 only puts the motor temperature on the CAN BUS, not the controller temperature.

Might be more information; https://github.com/OpenSourceEBike/Bafang_M500_M600/tree/main/CANBUS#controller-speedcurrentvoltagetemperature-informations

Code:
Controller Speed/Current/Voltage/Temperature Informations
	Temp. Control. 
	Temp. Motor
 
Ggaljoen said:
casainho said:
Congratulations and please share pictures of the final build on your EBike.

So, what can you suggest to improve the project so next users will not have the same issue??

Pictures will follow after a made a (semi)permanent mount for it. First I would like to tinker with the firmware.

From what I could reproduce; the voltage for the MCP is better of with Vusb minus voltagedrop over 1N4148 ~= 4V2
Ok, so I should add this note to the build page.


Ggaljoen said:
casainho said:
Lachymx said:
Could this display be used to show Motor and controller temperature? I would like to build something like this that can be used inline with the standard bafang display just to show Motor & Controller temperature.
I think Bafang M500/M600 only puts the motor temperature on the CAN BUS, not the controller temperature.

Might be more information; https://github.com/OpenSourceEBike/Bafang_M500_M600/tree/main/CANBUS#controller-speedcurrentvoltagetemperature-informations

Code:
Controller Speed/Current/Voltage/Temperature Informations
	Temp. Control. 
	Temp. Motor
Did not know!! So maybe that can be a feature you can add and submit later a pull request with it? I mean, check if current display motor temperature is correct and read the controller temperature and add it, just like current motor temperature (You would need to add an extra field to show that new variable).
 
casainho said:
Did not know!! So maybe that can be a feature you can add and submit later a pull request with it? I mean, check if current display motor temperature is correct and read the controller temperature and add it, just like current motor temperature (You would need to add an extra field to show that new variable).

Managed, after a long search, to find the item references for the mainscreen 1-2-3 in the eeprom settings:
20220807_201334.jpg
Code:
ID: 02F83201
Temp. Control. Byte 6
Temp. Motor Byte 7
 
Ggaljoen said:
casainho said:
Did not know!! So maybe that can be a feature you can add and submit later a pull request with it? I mean, check if current display motor temperature is correct and read the controller temperature and add it, just like current motor temperature (You would need to add an extra field to show that new variable).

Managed, after a long search, to find the item references for the mainscreen 1-2-3 in the eeprom settings:
20220807_201334.jpg
Code:
ID: 02F83201
Temp. Control. Byte 6
Temp. Motor Byte 7

Nice to see you got it. Do not forget that user can change each data field variable to show, so it is customizable by user which variable to show on that 2 data fields, on each main page.

I hope you can contribute with the adding of controller temperature, by submitting a pull request.
 
FYI
According to the datasheet, the nRF62840 is not 5V logic tolerant, so it is not possible to connect it directly as the TSDZ2 motor-controller's STM8S105 processor runs at 5V logic.
 
Hello friends. I have a breakthrough for the STLinkV2 firmware issue. PROBLEM: The safety bit is set on newer versions of the NRF52 board and command nrf52_recover is not available in this state. Some have recommended J-link but this is not required as long as you have a newer version (J24 ) of STLinkV2.

https://stackoverflow.com/a/52723152 - the comment on this post is the solution.

"Moreover, ST-Link/V2 supports DAP-direct operations starting from version J24 and OpenOCD also supports that. If you run it as follows: openocd -f "interface/stlink-dap.cfg" -c "transport select dapdirect_swd; source [find target/nrf52.cfg]; init" you will be able to connect to Telnet on port 4444 and use all low-level DAP operations, including nrf52_recover, which fully recovers the chip."

So the solution is simply to run stlink program with dap configuration. This allowed me to run nrf52_recover and update the bootloader firmware. For reference I did this on MacOS.

:mrgreen: :mrgreen: :mrgreen:
 
dodox said:
FYI
According to the datasheet, the nRF62840 is not 5V logic tolerant, so it is not possible to connect it directly as the TSDZ2 motor-controller's STM8S105 processor runs at 5V logic.
it is right and the lifespan will be better with a 5V-3.3V level shifter
0J5318.599.jpg

v1sn.jpg
 
Hi all!

I recently built this display using a 1.3'' SPI display with SHH1106 chip and the latest firmware doesn't work, just black screen.

I then tried the v0.10.0, which worked fine, except for the 2 pixel shift. After much trial and error I managed to compile new version that had the correct byte changed from 0 to 2 to fix the pixel shift.

Just letting you know that v0.20.0 doesn't work with SHH1106 chips.
 
OnuPets said:
Hi all!

I recently built this display using a 1.3'' SPI display with SHH1106 chip and the latest firmware doesn't work, just black screen.

I then tried the v0.10.0, which worked fine, except for the 2 pixel shift. After much trial and error I managed to compile new version that had the correct byte changed from 0 to 2 to fix the pixel shift.

Just letting you know that v0.20.0 doesn't work with SHH1106 chips.
Great work to find and solve the issue!!

So you mean this firmware files are not working?
- firmware_ota-BAFANG_M500_M600-OLED_1.3_SPI-0.20.0.zip
- firmware_ota-TSDZ2-OLED_1.3_I2C-0.20.0.zip
- firmware_ota-TSDZ2-OLED_1.3_SPI-0.20.0.zip

Do you think would be possible for me to add a change on the firmware and make a new release like v0.20.1 just to correct this issue and if so, could you test it?

I am being away of development, many things going on on my life but anyway I am doing more and more sports - I keep riding my MTB EBike for events of 80 kms on mountains, but I also now have a road / kind of gravel bike (no motor and love the silent!) and I like to ride it. I am also doing trail runs and some swimming - that is why I do not have free time but at the same time am getting better fit with better health and not needing so much a motor.

Just a warning, I recently had an accident at slow speed on my EBike, when doing an MTB event, where I did brake by instinct when something got in front of me. I went with my mouth directly to the road, I lost one teeth, I have problems on other tooth, got some problems on my mouth and face. I will take months to fully recover and It will be very expensive!
Here is my new helmet, this time it will be a full face one - just be aware that this accidents happen and we now have full face helmets that are light and good for pedaling on the trails:
 
dodox said:
Is this a usable version for this display?
https://github.com/emmebrusa/TSDZ2-Smart-EBike-860C

I think this is quite relevant...
firmware code for the motor firmware from casainho has not changed after then OpenSource display started.
So it looks like it uses code compatible with the 850C/860C and SW102

But I don't see any reference to motor firmware in the OpenSource display guides at all...
 
ornias said:
dodox said:
Is this a usable version for this display?
https://github.com/emmebrusa/TSDZ2-Smart-EBike-860C

I think this is quite relevant...
firmware code for the motor firmware from casainho has not changed after then OpenSource display started.
So it looks like it uses code compatible with the 850C/860C and SW102

But I don't see any reference to motor firmware in the OpenSource display guides at all...
Because that comercial displays have different hardware versions and the firmware does not work for them anymore. That displays hardware is changed by the manufacturer when they want and there is no guarantee that the firmware will work. That is why the only recomend display is the DIY that has a stable hardware, which is under our control.
 
casainho said:
ornias said:
dodox said:
Is this a usable version for this display?
https://github.com/emmebrusa/TSDZ2-Smart-EBike-860C

I think this is quite relevant...
firmware code for the motor firmware from casainho has not changed after then OpenSource display started.
So it looks like it uses code compatible with the 850C/860C and SW102

But I don't see any reference to motor firmware in the OpenSource display guides at all...
Because that comercial displays have different hardware versions and the firmware does not work for them anymore. That displays hardware is changed by the manufacturer when they want and there is no guarantee that the firmware will work. That is why the only recomend display is the DIY that has a stable hardware, which is under our control.

That's not an answer to the question, please read the question carefully.
User was asking about ebrusa's firmware, is the communication from his firmware compatible with the displays or not?
 
ornias said:
That's not an answer to the question, please read the question carefully.
User was asking about ebrusa's firmware, is the communication from his firmware compatible with the displays or not?
Ah, I see, it was very quick read.

I don't know. The user needs to ask that question to ebrusa.
 
casainho said:
ornias said:
That's not an answer to the question, please read the question carefully.
User was asking about ebrusa's firmware, is the communication from his firmware compatible with the displays or not?
Ah, I see, it was very quick read.

I don't know. The user needs to ask that question to ebrusa.

Understandable, i've the same issue at times as well ;)

Lets phrase it differently:
Is the communication between an (older) 860C display and the motor, always the same for every firmware or not?
 
ornias said:
Lets phrase it differently:
Is the communication between an (older) 860C display and the motor, always the same for every firmware or not?
I only tested this DIY display with motor TSDZ2 V1 motor controller running my latest firmware version, as also on my motor Bafang M500 running is original firmware. I do not know about other combinations but I expect everything is different.
 
Hello Casainho, i've found this NRF52840 dongle on Aliexpress. I successfully flashed it but i noticed that the pinout is different from Nordic's, so i don't know how to connect properly to the display, the keypad and the motor cable. Did i make a wrong purchase or not?
Thank you in advance for the reply.
 

Attachments

  • DONGLE.jpg
    DONGLE.jpg
    438.3 KB · Views: 188
Arepo said:
Hello Casainho, i've found this NRF52840 dongle on Aliexpress. I successfully flashed it but i noticed that the pinout is different from Nordic's, so i don't know how to connect properly to the display, the keypad and the motor cable. Did i make a wrong purchase or not?
Thank you in advance for the reply.
That one is totally different. The only tested board is the one as seen on the site.
 
Hello everyone, I need your help. I studied in detail the instructions on how to build this display, but I can't flash the bootloader with stlink v2 (V2.J40.S7)
I suspect that I can't get in because "Warn : target nrf52.cpu examination failed"
nrf52840 (PCA10059 , 2.1.0 , 2022.9)
I also don't know how to proceed with telnet communication and whether stlink v2 needs to be modified or is it enough if I have stock firmware
 

Attachments

  • Komentár 2023-01-17 082536.png
    Komentár 2023-01-17 082536.png
    37.2 KB · Views: 54
Back
Top