Getting Bus Voltage and Encoder Position with ODriveArduino

Alright, I’m running my ODrive from an Arduino. Of course I am using the ODriveArduino library. I have also been fallowing James Bruton’s OpenDog project since there is a lot of similarities in what he and I are doing. The first of his videos and the first time I used an Arduino to work the ODrive I was using commands like GetParameters and SetParameters. I assume that these are gone now because when I try to compile these now I get error messages like " ‘class ODrive Arduino’ has no member named ’ GetParameters’ ". Is this the case?

There are also these little bits of code I found Oskar had written on GitHub:

for (int motor = 0; motor < 2; ++motor) {
odrive_serial << “r axis” << motor << “.encoder.pos_estimate\n”;
Serial << odrive.readFloat() << ‘\t’;

and:

// Read bus voltage
if (c == ‘b’) {
odrive_serial << “r vbus_voltage\n”;
Serial << "Vbus voltage: " << odrive.readFloat() << ‘\n’;

I am more interested in the second one now as I am trying to monitor the bus voltage. (Side note. Is there a way to set a voltage cutoff in firmware on the ODrive? I accidentally fried my LiPo pack by discharging them too much. Would like to have a safety in place for this.) But I would also like to get the encoder position eventually.

My main question is how exactly is the best way to ask for the voltage or encoder position and add it to an int? I also would like to know what is going on in this code, I cant for the life of me figure out why you are passing ASCII with a bitshift?? This doesn’t make any since to me and I can’t find much about it online. I am not an amazing programer and a little explanation on what is going on here would be very appreciated.

Thanks.

Hi Dylan,

I’m not sure I’m following the description of your problem.
However, I know why you are confused about the bit shift operators: they are also used as the “stream insertion operator”. You can read more here.

1 Like