Merge pull request #712 from odriverobotics/can_sync

Update vbus_voltage message to match Pro
This commit is contained in:
Paul Guenette
2022-09-07 08:46:54 -07:00
committed by GitHub
5 changed files with 26 additions and 16 deletions

View File

@@ -135,9 +135,9 @@ void CANSimple::do_command(Axis& axis, const can_Message_t& msg) {
case MSG_RESET_ODRIVE:
NVIC_SystemReset();
break;
case MSG_GET_VBUS_VOLTAGE:
case MSG_GET_BUS_VOLTAGE_CURRENT:
if (msg.rtr || msg.len == 0)
get_vbus_voltage_callback(axis);
get_bus_voltage_current_callback(axis);
break;
case MSG_CLEAR_ERRORS:
clear_errors_callback(axis, msg);
@@ -348,17 +348,18 @@ bool CANSimple::get_iq_callback(const Axis& axis) {
return canbus_->send_message(txmsg);
}
bool CANSimple::get_vbus_voltage_callback(const Axis& axis) {
bool CANSimple::get_bus_voltage_current_callback(const Axis& axis) {
can_Message_t txmsg;
txmsg.id = axis.config_.can.node_id << NUM_CMD_ID_BITS;
txmsg.id += MSG_GET_VBUS_VOLTAGE;
txmsg.id += MSG_GET_BUS_VOLTAGE_CURRENT;
txmsg.isExt = axis.config_.can.is_extended;
txmsg.len = 8;
uint32_t floatBytes;
static_assert(sizeof(vbus_voltage) == sizeof(floatBytes));
static_assert(sizeof(float) == sizeof(vbus_voltage));
static_assert(sizeof(float) == sizeof(ibus_));
can_setSignal<float>(txmsg, vbus_voltage, 0, 32, true);
can_setSignal<float>(txmsg, ibus_, 32, 32, true);
return canbus_->send_message(txmsg);
}

View File

@@ -30,7 +30,7 @@ class CANSimple {
MSG_GET_IQ,
MSG_GET_SENSORLESS_ESTIMATES,
MSG_RESET_ODRIVE,
MSG_GET_VBUS_VOLTAGE,
MSG_GET_BUS_VOLTAGE_CURRENT,
MSG_CLEAR_ERRORS,
MSG_SET_LINEAR_COUNT,
MSG_SET_POS_GAIN,
@@ -63,7 +63,7 @@ class CANSimple {
bool get_encoder_count_callback(const Axis& axis);
bool get_iq_callback(const Axis& axis);
bool get_sensorless_estimates_callback(const Axis& axis);
bool get_vbus_voltage_callback(const Axis& axis);
bool get_bus_voltage_current_callback(const Axis& axis);
// msg.rtr bit must NOT be set
bool get_adc_voltage_callback(const Axis& axis, const can_Message_t& msg);

View File

@@ -93,7 +93,13 @@ IEEE 754 Float","32
1","0
0"
0x016,Reboot ODrive,Master***,-,-,-,-,-,-
0x017,Get Vbus Voltage,Master***,Vbus Voltage,0,IEEE 754 Float,32,1,0
0x017,Get Bus Voltage and Current,Master***,"Bus Voltage
Bus Current","0
4","IEEE 754 Float
IEEE 754 Float","32
32","1
1","0
0"
0x018,Clear Errors,Master,-,-,-,-,-,-
0x019,Set Linear Count,Master,Position,0,Signed Int,32,1,0
0x01A,Set Position Gain,Master,Pos Gain,0,IEEE 754 Float,32,1,0
1 CMD ID Name Sender Signals Start byte Signal Type Bits Factor Offset
93
94
95
96
97
98
99
100
101
102
103
104
105

View File

@@ -137,9 +137,10 @@ getSensorlessEstMsg = cantools.database.can.Message(
# 0x016 - Reboot ODrive
rebootMsg = cantools.database.can.Message(0x016, "Reboot", 0, [])
# 0x017 - Get vbus Voltage
vbusVoltage = cantools.database.can.Signal("Vbus_Voltage", 0, 32, is_float=True)
getVbusVMsg = cantools.database.can.Message(0x017, "Get_Vbus_Voltage", 8, [vbusVoltage])
# 0x017 - Get vbus Voltage and Current
busVoltage = cantools.database.can.Signal("Bus_Voltage", 0, 32, is_float=True)
busCurrent = cantools.database.can.Signal("Bus_Current", 32, 32, is_float=True)
getVbusVCMsg = cantools.database.can.Message(0x017, "Get_Bus_Voltage_Current", 8, [busVoltage, busCurrent])
# 0x018 - Clear Errors
clearErrorsMsg = cantools.database.can.Message(0x018, "Clear_Errors", 0, [])
@@ -190,7 +191,7 @@ db = cantools.database.can.Database(
getIqMsg,
getSensorlessEstMsg,
rebootMsg,
getVbusVMsg,
getVbusVCMsg,
clearErrorsMsg,
setLinearCountMsg,
setPosGainMsg,

View File

@@ -110,8 +110,9 @@ BO_ 21 Get_Sensorless_Estimates: 8 Vector__XXX
BO_ 22 Reboot: 0 Vector__XXX
BO_ 23 Get_Vbus_Voltage: 8 Vector__XXX
SG_ Vbus_Voltage : 0|32@1+ (1,0) [0|0] "" Vector__XXX
BO_ 23 Get_Bus_Voltage_Current: 8 Vector__XXX
SG_ Bus_Current : 32|32@1+ (1,0) [0|0] "" Vector__XXX
SG_ Bus_Voltage : 0|32@1+ (1,0) [0|0] "" Vector__XXX
BO_ 24 Clear_Errors: 0 Vector__XXX
@@ -155,7 +156,8 @@ SIG_VALTYPE_ 20 Iq_Setpoint : 1;
SIG_VALTYPE_ 20 Iq_Measured : 1;
SIG_VALTYPE_ 21 Sensorless_Pos_Estimate : 1;
SIG_VALTYPE_ 21 Sensorless_Vel_Estimate : 1;
SIG_VALTYPE_ 23 Vbus_Voltage : 1;
SIG_VALTYPE_ 23 Bus_Voltage : 1;
SIG_VALTYPE_ 23 Bus_Current : 1;
SIG_VALTYPE_ 26 Pos_Gain : 1;
SIG_VALTYPE_ 27 Vel_Gain : 1;
SIG_VALTYPE_ 27 Vel_Integrator_Gain : 1;