add current feedback

This commit is contained in:
interfisch 2019-12-28 14:35:55 +01:00
parent ec4d6714c5
commit d8afc9682f
2 changed files with 15 additions and 2 deletions

View File

@ -7,6 +7,15 @@
//to flash set boot0 (the one further away from reset button) to 1 and press reset, flash, program executes immediately
//set boot0 back to 0 to run program on powerup
//Flashing the hoverbrett controller:
/*
* connect uart adapter to serial port cable (the one with more red heatshrink)
* (disconnect xt30 power connector)
* set jumper on usb uart adapter to output 5V
* hold boot0 button (black, the outermost) while powering up (or restarting with small button next to it)
* flash
*/
//PA2 may be defective on my bluepill
#define SERIAL_CONTROL_BAUD 38400 // [-] Baud rate for HoverSerial (used to communicate with the hoverboard)
@ -187,6 +196,8 @@ typedef struct{
int16_t speedL_meas;
int16_t batVoltage;
int16_t boardTemp;
int16_t curL_DC;
int16_t curR_DC;
int16_t checksum;
} SerialFeedback;
SerialFeedback Feedback;
@ -654,7 +665,7 @@ void ReceiveSerial2()
if (idx == sizeof(SerialFeedback)) {
uint16_t checksum;
checksum = (uint16_t)(NewFeedback.start ^ NewFeedback.cmd1 ^ NewFeedback.cmd2 ^ NewFeedback.speedR ^ NewFeedback.speedL
^ NewFeedback.speedR_meas ^ NewFeedback.speedL_meas ^ NewFeedback.batVoltage ^ NewFeedback.boardTemp);
^ NewFeedback.speedR_meas ^ NewFeedback.speedL_meas ^ NewFeedback.batVoltage ^ NewFeedback.boardTemp ^ NewFeedback.curL_DC ^ NewFeedback.curR_DC);
// Check validity of the new data
if (NewFeedback.start == START_FRAME && checksum == NewFeedback.checksum) {
@ -670,6 +681,8 @@ void ReceiveSerial2()
Serial.print(" 6: "); Serial.print(Feedback.speedL_meas);
Serial.print(" 7: "); Serial.print(Feedback.batVoltage);
Serial.print(" 8: "); Serial.println(Feedback.boardTemp);
Serial.print(" 9: "); Serial.print(Feedback.curL_DC); //in mA (100mA resolution), in hoverbrett negative sign for forward
Serial.print(" 10: "); Serial.println(Feedback.curR_DC); //in mA (100mA resolution), in hoverbrett negative sign for forward
} else {
Serial.println("Non-valid data skipped");
}

@ -1 +1 @@
Subproject commit 1d9843a26c1d76f6fa997315a490db089c48ec57
Subproject commit d62793f9a2d6d04a1e8681fbcffbc6ccb309f8f4