-
Notifications
You must be signed in to change notification settings - Fork 919
Debug Serial
Debug Serial can be enabled with DEBUG_SERIAL_USART parameter and will allow you to get information from the board as Human readable ASCII output to:
- Calibrate the battery voltage reading
- Calibrate the temperature reading
- See input Calibration results
- Debug
- Plot the results
Use a FTDI adapter or a Bluetooth module (eg. AT-09, HM-10, HC-06,...) and monitor the output data using the Web Tool tool or any serial monitor.
HC-06 works, connected to USART2 at 9600 bauds (define DEBUG_SERIAL_USART2 and USART2_BAUD=9600).
Use DEBUG_SERIAL_USART2 for the left cable or DEBUG_SERIAL_USART3 for the right cable.
Different variants can have it already enabled on a different cable depending on which cable is use by this variant by default.
- Connect GND and RX of a 3.3v FTDI adapter/Bluetooth module to the blue wire on left (DEBUG_SERIAL_USART2) or right sensor board cable (DEBUG_SERIAL_USART3) depending on config.h settings
⚠ Red wire from sensor cable delivers 15v !!!
Use a serial terminal/monitor to read the output at 115200 bauds (could be 38400 bauds if you use a previous version of the firmware).
DEBUG_SERIAL_ASCII output is:
in1:345 in2:1337 cmdR:0 cmdL:0 BatADC:0 BatV:0 TempADC:0 Temp:0
Field | Ouput |
---|---|
in1 | Input1 |
in2 | Input2 |
cmdR | Right Wheel Speed Command (not the measured speed) |
cmdL | Left Wheel Speed Command (not the measured speed) |
BatADC | Battery adc-value measured by mainboard |
BatV | Battery calibrated voltage multiplied by 100 for verifying battery voltage calibration |
TempADC | For board temperature calibration |
Temp | Temperature in celcius for verifying board temperature calibration |
The above is done in main.c
, see lines 440 and line 225 by using printf statements, wrapped in #if defined(DEBUG_SERIAL_USART2) || defined(DEBUG_SERIAL_USART3)
. More printf statements with same wrapping can be added in other places for monitoring purposes.
If enabled with parameter DEBUG_SERIAL_PROTOCOL in config.h, in combination with DEBUG_SERIAL_USART2 or DEBUG_SERIAL_USART3 for selecting the right cable, debug protocol lets you send Ascii commands.
Command | Usage | Description |
---|---|---|
$HELP | HELP HELP PPPP |
Prints all commands/parameters/variables available for the protocol If parameter/variable PPPP is provided, it will print individual help text |
$GET | GET GET PPPP |
Prints current value, initial value, minimum and maximum for all parameters/variables If parameter/variable PPPP is provided, it will print current value, initial value, minimum and maximum for parameter/variable |
$SET | SET PPPP VVVV | Sets parameter PPPP with Value VVVV if it's in the correct range |
$INIT | INIT PPPP | Initializes parameter PPPP to EEPROM value if available, config.h value otherwise |
$SAVE | SAVE | Saves all parameters that can be saved to EEPROM |
$WATCH | WATCH PPPP | Enables/disables output for parameter/variable. It will display 15 values at most |
All commands can be used for parameters, but variables cannot be Set,Initialized or Saved.
Values are being translated to external<>internal format automatically.
Type | Name | Description | Can be Set | Can be saved to EEPROM |
---|---|---|---|---|
Parameter | CTRL_MOD | Ctrl mode 1:Voltage 2:Speed 3:Torque | Yes | No |
Parameter | CTRL_TYP | Ctrl type 0:Commutation 1:Sinusoidal 2:FOC | Yes | No |
Parameter | I_MOT_MAX | Max phase current A | Yes | Yes |
Parameter | N_MOT_MAX | Max motor RPM | Yes | Yes |
Parameter | FI_WEAK_ENA | Enable field weak 0:OFF 1:ON | Yes | No |
Parameter | FI_WEAK_HI | Field weak high RPM | Yes | No |
Parameter | FI_WEAK_LO | Field weak low RPM | Yes | No |
Parameter | FI_WEAK_MAX | Field weak max current A(FOC only) | Yes | No |
Parameter | PHA_ADV_MAX | Max Phase Adv angle Deg(SIN only) | Yes | No |
Variable | IN1_RAW | Input1 raw value | No | No |
Parameter | IN1_TYP | Input1 type 0:Disabled, 1:Normal Pot, 2:Middle Resting Pot, 3:Auto-detect | Yes | Yes |
Parameter | IN1_MIN | Input1 minimum value | Yes | Yes |
Parameter | IN1_MID | Input1 middle value | Yes | Yes |
Parameter | IN1_MAX | Input1 maximum value | Yes | Yes |
Variable | IN1_CMD | Input1 command value | No | No |
Variable | IN2_RAW | Input2 raw value | No | No |
Parameter | IN2_TYP | Input2 type 0:Disabled, 1:Normal Pot, 2:Middle Resting Pot, 3:Auto-detect | Yes | Yes |
Parameter | IN2_MIN | Input2 minimum value | Yes | Yes |
Parameter | IN2_MID | Input2 middle value | Yes | Yes |
Parameter | IN2_MAX | Input2 maximum value | Yes | Yes |
Variable | IN2_CMD | Input2 command value | No | No |
Variable | DC_CURR | Total DC Link current A *100 | No | No |
Variable | LDC_CURR | Left DC Link current A *100 | No | No |
Variable | RDC_CURR | Right DC Link current A *100 | No | No |
Variable | CMDL | Left Motor Command RPM | No | No |
Variable | CMDR | Right Motor Command RPM | No | No |
Variable | SPD_AVG | Motor Measured Avg RPM | No | No |
Variable | SPDL | Left Motor Measured RPM | No | No |
Variable | SPDR | Right Motor Measured RPM | No | No |
Variable | RATE | Rate *10 | No | No |
Variable | SPD_COEF | Speed Coefficient *10 | No | No |
Variable | STR_COEF | Steer Coefficient *10 | No | No |
Variable | BATV | Calibrated Battery Voltage *100 | No | No |
Variable | TEMP | Calibrated Temperature °C *10 | No | No |
- Make sure the baud rate is 115200
- Make sure you are using the sensor cable(left=DEBUG_SERIAL_USART2 or right=DEBUG_SERIAL_USART3) selected in config.h
- TX can be defective on your mainboard, you can switch to other sensor cable if not used already in config.h
- On some boards the wire colors might differ, try switching the green wire
- Make sure the RX on your FTDI is working. You can connect the RX and TX on the FTDI and check if you received the commands you send in the Web Tool tool or any serial monitor