-
Notifications
You must be signed in to change notification settings - Fork 979
Variant USART
This variant can be used to control the board from another board(e.g. Arduino, ESP32, ESP8266,RASPBERRY PI) or a computer via a serial protocol.
The example Arduino sketch will send commands and process the feedback.
You can also test this variant with following Web Tool, it let's you control the board and trace feedback values.
This issue has another example to control the firmware with Python code.
- Connect blue wire to RX, green wire to TX and black wire to GND of Arduino on right sensor cable(shorter)
⚠ Red wire from sensor cable delivers 15v !!!
The default baud rate is 115200.
Commands are send as binary frames with following structure:
- Start frame(unsigned int16) : 0xABCD
- Steer(signed int16) : Steer with range -1000 to 1000
- Speed(signed int16) : Speed with range -1000 to 1000
- Checksum(unsigned int16) : XOR checksum
The least significant byte comes first (little endian).
The FOC firmware will discard frames if:
- Command length is not correct
- Start frame is not correct
- Checksum is not correct
- 1 character inactivity on RX line while receiving the frame (Idle Line Detection)
A timeout will be triggered if no correct frame is received during the time specified with parameter SERIAL_TIMEOUT in config.h (160ms by default).
Calibration is not required with USART control, but can be done if you use an input devices(e.g. Joystick or Throttle handle) on the Arduino and are not taking care of calibrating center value and min/max range there.
Following feedback is sent:
- Start frame(unsigned int16) : 0xABCD
- Cmd1(signed int16) : Steer or Brake(hovercar) after normalizing and mixing
- Cmd2(signed int16) : Speed or Throttle(hovercar) after normalizing and mixing
- SpeedR(signed int16) : Measured right wheel speed in RPM
- SpeedL(signed int16) : Measured left wheel speed in RPM
- Battery Voltage(signed int16) : Calibrated Battery Voltage *100
- Temperature(signed int16) : Temperature in °C *10
- Led(unsigned int16) : Used to control the leds on the sideboard
- Checksum(unsigned int16) : XOR checksum
The least significant byte comes first (little endian).
If the board is beeping
- Make sure the baud rate is 115200
- Make sure you are using the sensor cable(left=USART2 or right=USART3) selected in config.h
- On some boards the wire colors might differ, try switching blue and green wires
- Your Arduino TX might not be working, you can verify that by trying with and FTDI and the Web tool to confirm the mainboard/firmware is not the issue