Skip to content

Commit

Permalink
Merge pull request #709 from odriverobotics/can_controller_error
Browse files Browse the repository at this point in the history
Add controller error message
  • Loading branch information
Wetmelon authored Sep 6, 2022
2 parents 3985bb7 + 317d09a commit 6131bc0
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ GUI/node_modules
GUI/build

docs/reStructuredText/_build/
tools/odrive-cansimple.ini
15 changes: 15 additions & 0 deletions Firmware/communication/can/can_simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ void CANSimple::do_command(Axis& axis, const can_Message_t& msg) {
case MSG_GET_ADC_VOLTAGE:
get_adc_voltage_callback(axis, msg);
break;
case MSG_GET_CONTROLLER_ERROR:
get_controller_error_callback(axis);
break;
default:
break;
}
Expand Down Expand Up @@ -203,6 +206,18 @@ bool CANSimple::get_sensorless_error_callback(const Axis& axis) {
return canbus_->send_message(txmsg);
}

bool CANSimple::get_controller_error_callback(const Axis& axis) {
can_Message_t txmsg;
txmsg.id = axis.config_.can.node_id << NUM_CMD_ID_BITS;
txmsg.id += MSG_GET_CONTROLLER_ERROR; // heartbeat ID
txmsg.isExt = axis.config_.can.is_extended;
txmsg.len = 8;

can_setSignal(txmsg, axis.controller_.error_, 0, 32, true);

return canbus_->send_message(txmsg);
}

void CANSimple::set_axis_nodeid_callback(Axis& axis, const can_Message_t& msg) {
axis.config_.can.node_id = can_getSignal<uint32_t>(msg, 0, 32, true);
}
Expand Down
1 change: 1 addition & 0 deletions Firmware/communication/can/can_simple.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class CANSimple {
MSG_SET_POS_GAIN,
MSG_SET_VEL_GAINS,
MSG_GET_ADC_VOLTAGE,
MSG_GET_CONTROLLER_ERROR,
MSG_CO_HEARTBEAT_CMD = 0x700, // CANOpen NMT Heartbeat SEND
};

Expand Down
1 change: 1 addition & 0 deletions docs/figures/can-protocol.csv
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,5 @@ IEEE 754 Float","32
1","0
0"
0x01C,Get ADC Voltage****,Master***,ADC Voltage,0,IEEE 754 Float,32,1,0
0x01D,Get Controller Error*,Axis,Controller Error,0,Unsigned Int,32,1,0
0x700,CANOpen Heartbeat Message**,Slave,-,-,-,-,-,-
9 changes: 8 additions & 1 deletion tools/create_can_dbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@
adcVoltage = cantools.database.can.Signal("ADC_Voltage", 0, 32, is_float=True)
getADCVoltageMsg = cantools.database.can.Message(0x01C, "Get_ADC_Voltage", 8, [adcVoltage])

# 0x01D - Controller Error
controllerError = cantools.database.can.Signal("Controller_Error", 0, 32)
controllerErrorMsg = cantools.database.can.Message(
0x01D, "Get_Controller_Error", 8, [controllerError]
)

db = cantools.database.can.Database(
[
heartbeatMsg,
Expand Down Expand Up @@ -189,7 +195,8 @@
setLinearCountMsg,
setPosGainMsg,
setVelGainsMsg,
getADCVoltageMsg
getADCVoltageMsg,
controllerErrorMsg,
]
)

Expand Down
7 changes: 7 additions & 0 deletions tools/odrive-cansimple.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,18 @@ BO_ 27 Set_Vel_gains: 8 Vector__XXX
SG_ Vel_Integrator_Gain : 32|32@1+ (1,0) [0|0] "" Vector__XXX
SG_ Vel_Gain : 0|32@1+ (1,0) [0|0] "" Vector__XXX

BO_ 28 Get_ADC_Voltage: 8 Vector__XXX
SG_ ADC_Voltage : 0|32@1+ (1,0) [0|0] "" Vector__XXX

BO_ 29 Get_Controller_Error: 8 Vector__XXX
SG_ Controller_Error : 0|32@1+ (1,0) [0|0] "" Vector__XXX





BA_DEF_ BO_ "GenMsgCycleTime" INT 0 65535;
BA_DEF_DEF_ "GenMsgCycleTime" 0;


SIG_VALTYPE_ 9 Pos_Estimate : 1;
Expand All @@ -153,5 +159,6 @@ SIG_VALTYPE_ 23 Vbus_Voltage : 1;
SIG_VALTYPE_ 26 Pos_Gain : 1;
SIG_VALTYPE_ 27 Vel_Gain : 1;
SIG_VALTYPE_ 27 Vel_Integrator_Gain : 1;
SIG_VALTYPE_ 28 ADC_Voltage : 1;


0 comments on commit 6131bc0

Please sign in to comment.