bafang-python
bafang-python copied to clipboard
Bafang Ultra 1000W communication?
Hi,
I am trying to make an Arduino that can read and write to the Bafang Ultra motor. It uses the DPC-18 display.
I have found out that the baudrate is 9600 and not 1200 (like on the BBS). I also listened to the communcation with my Bafang programming cable, and this is the results:
StopBits - 0 (1 stop bit) Parity - 0 (NO_PARITY) WordLength - 8
So it uses the 8,N,1 as the BBS. That means it should be 9600,8,N,1
I wrote this simple test to try to forward the serial communication between the motor and display and vice versa.
void setup() {
Serial2.begin(9600); // Display DP-C18 @TX16 RX17
Serial3.begin(9600); // Bafang Ultra Motor @TX14 RX15
}
void loop() {
readDisplay();
readController();
}
void readController() {
if (Serial3.available()) {
Serial2.write(Serial3.read());
}
}
void readDisplay() {
if (Serial2.available()) {
Serial3.write(Serial2.read());
}
}
The default serial parameter on Arduino is SERIAL_8N1, and I have it set to 9600 baud. Still, I get a Communication error from the Bafang display, showing me error code 30. Which means the serial forwarding doesn't work.
Do you have any idea to work this out?
Sorry, I cannot help here. I only had a "normal" BBS 250W and only tried the communication with the controller. Your code looks ok to me. Did you have any luck meanwhile?