Multiple serial lines from teensy to odrive


Trying to get to grips with setting up communication between 3 odrives and a teensy. Initially i’m just trying to read voltages from each odrive, connected via serial through a ISO7731 (the same as the recommended ISO7762F from the docs with fewer channels).

I’ve attached my code below and this works great to read the voltage from one odrive. Similarly, if I comment out all the serial3 lines and uncomment either the serial1 or serial2 lines, I can successfully read the voltages from the indevidual odrive. However, when uncommenting more than one serial line, the voltages returned are rubbish - mostly zeros, and they are coming back at irregular time intervals.

// includes
#include <HardwareSerial.h>
#include <ODriveArduino.h>

// Printing with stream operator helper functions
template<class T> inline Print& operator <<(Print &obj,     T arg) { obj.print(arg);    return obj; }
template<>        inline Print& operator <<(Print &obj, float arg) { obj.print(arg, 4); return obj; }

// ODrive objects
//ODriveArduino odrive1(Serial1);
//ODriveArduino odrive2(Serial2);
ODriveArduino odrive3(Serial3);

// delay value
int d = 200;

void setup() {
  // ODrive uses 115200 baud
//  Serial1.begin(115200);
//  Serial2.begin(115200);
  // Serial to PC
  while (!Serial) ; // wait for Arduino Serial Monitor to open


void loop() {
  // put your main code here, to run repeatedly:
//  Serial1 << "r vbus_voltage\n";
//  Serial << "Odrive on serial 1 - Vbus voltage: " << odrive1.readFloat() << '\n';
//  delay(d);
//  Serial2 << "r vbus_voltage\n";
//  Serial << "Odrive on serial 2 - Vbus voltage: " << odrive2.readFloat() << '\n';
//  delay(d);

  Serial3 << "r vbus_voltage\n";
  Serial << "Odrive on serial 3 - Vbus voltage: " << odrive3.readFloat() << '\n';


Any help would be greatly appreciated!


Looks right, from a code point of view.


Not sure if this was the only problem, but Vcc1 and Vcc2 have to be the same levels on the ISO7731 chip. I was running Vcc2 at 5v from the the same source that is powering the teensy and Vcc1 from the 3.3v from the odrive. Now running Vcc2 from 3.3v from the teensy and seems to be working!

Are there actually any guidelines on how low the delay can be in this code? Is there a risk of overloading the serial lines if the delay is close to 0?

We handle the entire UART buffer at 8kHz, which is 125micro seconds. To transfer a single ASCII character (8 bit) at 115200baud, it takes 69 microseconds. So you can only send ~ 2 characters in a single cycle. There’s no way you’ll overload the buffer unless you increase the bit rate.