I was looking at the code for the X2 libraries and couldn’t find what the return value from x2_get_motor_current() relates to to. The VNH2SP30 description states that a register holds the value corresponding to 0.13V/A. So: does this return value mean that I should handle the function like this?
float current = x2_get_motor_current(0) * 0.13; /* to get current on motor 0 in amps?? */
// Get the running current average for the specified motor
// Note: measuring current is only possible on Orangutan X2s with VNH2SP30
// motor drivers. The VNH3SP30 does not support current sense feedback.
unsigned char OrangutanX2::getMotorCurrent(unsigned char motor)
{
unsigned char cmd = CMD_GET_M1_CURRENT;
if (motor == MOTOR2)
cmd = CMD_GET_M2_CURRENT;
OrangutanSPIMaster::transmitAndDelay(cmd, 3);
return OrangutanSPIMaster::transmit(0);