I had Gemini Deep Research AI-Generate this report on the display protocol. Seems to be useful:
Bafang Display Protocol
Bafang Display Protocol
This only describes the programming mode. That doesn't help, as we only need the normal working mode. But your first log will help, I'll take a deeper look at the weekend!Seems to be useful:
Which display are you using exactly?but I also get Err 30
Hm, your display sends a lot of unknown commands. We would need an original Bafang controller, to see, what is answered on this commands to emulate the "right" answers.I'll take a deeper look at the weekend!
The most complete list of commands seems to be in the Bafang firmware of Daniel Nilsson.Controller just replies in weird ways... no checksum as far as I can tell, but either just the same value twice or with 0x20 added)
| Command | Number of messages sent | Meaning of the command |
| 0x08 | 10 | CMD_PEDAL_MOV |
| 0x0A | 8 | CMD_AMPS |
| 0x0B | 8 | CMD_PAS_LEVEL |
| 0x11 | 8 | CMD_BATT_SOC |
| 0x1A | 4 | BF_CMD_LIGHT |
| 0x1F | 4 | BF_CMD_WHEELDIAM |
| 0x20 | 9 | CMD_WHEEL_RPM |
| 0x21 | 8 | unknown |
| 0x22 | 8 | OPCODE_BAFANG_DISPLAY_READ_RANGE |
| 0x30 | 8 | unknown |
| 0x31 | 8 | CMD_MOVING |
| 0x60 | 2 | unknown |
| 0x62 | 2 | unknown |
| 0x63 | 2 | unknown |
| 0x64 | 2 | unknown |
| 0x65 | 2 | unknown |
| 0x66 | 2 | unknown |
| 0x67 | 2 | unknown |
| 0x90 | 2 | CMD_VERSION |
Sorry for the delay: had to get a logic analyzer to be sure, and I found out what the problem was in case you are still interested: the series resistors on my spintend rx and tx line proved faulty, which made uart erratic. So nothing to do with your codeIt is save to flash by the STLink, the hex/bin files include the bootloader.
But make sure, that you make a "full chip erase" with the STM32 Utility (or other tools), to clean the pages, that are used as EEPROM. Otherwise the old setting will still be there.
Not with this code, since it uses the luna uart file. You need to write your own vesc script for that. The good news is that vesc has native can support, and since luna also implementated a CAN version of bafang display, it shouldn't be too hard to transcribe into a lispBM script, or simply keep the C version and adapt Stancecoke's fork.Hello, can I connect the display from Bafang with CAN protocol to the paddle. Thanks
Dp C244 display model
It's still difficult for me, but I found the firmware for the KT lcd, I'll put it in! Thank you!Not with this code, since it uses the luna uart file. You need to write your own vesc script for that. The good news is that vesc has native can support, and since luna also implementated a CAN version of bafang display, it shouldn't be too hard to transcribe into a lispBM script, or simply keep the C version and adapt Stancecoke's fork.
What should be the advantage? If you neither want to use a Bafang UART display nor a torquesensor, then this project is not suited for you.but I'm wondering do I get any advance from flashing this firmware for my e-bike
endless-sphere.com
built for bldc_sc>git clone GitHub - stancecoke/VESC_BLDC: The VESC motor control firmwareThe Flipsky 75100 is available at a very reasonable price and in a pedelec-compatible housing. However, the VESC is hardly suitable for e-bikes due to the lack of display and torque sensor support. This has challenged my tinkering instinct
Luna Cycle has already implemented the Bafang protocol for its BBSHD controller, so I “only” had to port it to the Flipsky hardware.
For the torque sensor I put the PAS signal on the servo input and the torque signal on ADC2.
The VESC tool still works for setting up the motor, but the app setting must not be done with the VESC tool at the moment, as it does not (yet) know the new functions.
Currently it only runs on the test bench, the torque sensor signals are emulated by a blackpill board.
Next I have to install the controller in my tinker bike and do a real test ride
Commits · stancecoke/VESC_BLDC
![]()
A little teaser on Youtube:
regards
stancecoke
16 1f 03 1b 53If you have a USB-UART converter, please listen to the tx data stream of the display (1200 BAUD) with your laptop first.
If the messages are valid, we can do further steps.
The tx stream (in hex representation) should look like this:
Code:11 0A 11 11 16 1A F0 20 11 08 16 0B 00 21 11 0A 11 11 16 1A F0 11 20 11 08 16 1F 03 1B 53 11 0A
where the 0x11 is a request to the controller and the 0x16 is an information to the controller.
11 11 --> get battery soc
11 0A --> get amps
11 20 --> get speed
.....
16 1A F0 --> light off (not implemented in Luna code)
16 0B 00 21 --> PAS level 0
16 1F 03 1B 53 --> wheel diameter (not implemented in Luna code)
....
https://github.com/stancecoke/VESC_...bfde/hwconf/flipsky/luna_display_serial.c#L38
The library in the "Forumscontroller" project has more parameters implemented than the Luna Cycle, but in decimal representation:
https://github.com/jenkie/Arduino-P...r/Arduino_Pedelec_Controller/display_bafang.h
regards
stancecoke
That's a matter of the display, not of the Luna UART implementation. I'm not an expert on Bafang UART, you would have to listen to the communication on a working Display-Controller combination to check if there is something new. I don't know exactly, but I think there was a report somewhere, that the communication runs on 9600 BAUD sometimes.....no 11s
After many iterations with the tweaks and re-flash I got the following output (vs code serial monitor) from startup; works for a second, then err30, then err30 disappears briefly and then comes back.That's a matter of the display, not of the Luna UART implementation. I'm not an expert on Bafang UART, you would have to listen to the communication on a working Display-Controller combination to check if there is something new. I don't know exactly, but I think there was a report somewhere, that the communication runs on 9600 BAUD sometimes.....
See #59this VESC Tool version
I started by trying to get your VESC branch from GitHub - stancecoke/VESC_BLDC: The VESC motor control firmware to work with EKD01 and Flipsky V6 MK5. Cloned branch; fixed build errors and built for flipsky_60_mk5, then started trying to understand why it didn't seem to work; thus the terminal output.See #59
I have no idea, what you are doing...
Are you trying to port the Luna Cycle UART implementation to another hardware?!
thanks for the info; I did setup the openOCD debugger in VS Code and successfully hit some breakpoints a while back but didn't know exactly what to look for. Will look for unanswered requests. Also will work on setting it up in CubeIde to compare debugging capabilities.You will have to look for requests from the display, that are not answered by the luna implementation. The display shows E30 if it gets no answer. I remember some commands were commented out and maybe your display sends some additional requests, that are not implemented in the Luna code yet.
You can start a multithread debug session from the CubeIDE and set some breakpoints to see if the code is executed as planned:
https://endless-sphere.com/sphere/t...ering-and-firmware-making.127833/post-1876244
It's crazy, how many threads are running in parallel on the VESC
![]()
No, this things are completely independent.requires torque or pas sensor and/or motor to be connected for the controller to send response or maybe it will throw err30?
Will you commit your code to GitHub? Would be great to see what went wrong and how you fixed it!I got the err30 resolved
yes but first testing the rest of it and doing some cleanupWill you commit your code to GitHub? Would be great to see what went wrong and how you fixed it!
I have most of changes from master branch locally merged with the stancecoke branch andyes but first testing the rest of it and doing some cleanup
issues I am currently dealing with for some hours: build produces "Could not deserialize motor configuration. This probably means that something is wrong with your firmware, or this VESC Tool version." so, although the display works without err30, I can't use the VESC tool to configure the motor.
I am looking at merging the changes from my EKD01 build into the master branch, whichdoes not produce that errordidn't but now does after some merging. I thought I saw somewhere some required settings in VESC tool for this to work with VESC tool, but now I can't find that.
Recommendations?
If you look at the generic VESC schematic in Benjamins repo, you will find pins PB11 and PC7 for UART Rx, both are 5V tolerant.is the flipsky 5v tolerant on the RX pin


