V3.6 allows me to control two BOTWHEELs, but I would like to use two S1s to control two BOTWHEELs.
I use ARDUINO as my development environment.
In V3.6, I can easily control two BOTWHEELs using odrive0 or odrive1, but because I have connected each BOTWHEEL to two S1s, the ARDUINO program has become complicated and I am having trouble.
Is there a better way?
Can I control two S1’s with one serial (ODRIVE serial)?
Hi! Sorry, what is MultiUART? You can’t have two S1 with a single serial, but you can have two S1s (up to 63, in fact) on a single CAN bus, which we generally recommend. However, it should be fairly simple to have two S1s connected to a single Arduino. What Arduino is this – Arduino Uno? Mega? Something else? You need to use SoftwareSerial if using an Arduino Uno, otherwise this code looks generally correct. What’s the issue you’re having with it?
1 Like
Thank you. I am using Arduino UNO. I was able to control two S1s using software serial.
(Multiple software serials can be used with multiUART as well)
SoftwareSerial odrive_serial(3, 4);
SoftwareSerial odrive_serial2(8, 9);
ODriveArduino odrive(odrive_serial);
ODriveArduino odrive2(odrive_serial2);
odrive_serial.begin(baudrate);
odrive_serial2.begin(baudrate);
Is the following sketch sufficient for speed control?
Please let me know if there are any other simple ways to write it.
if(!odrive2.run_state(0, AXIS_STATE_CLOSED_LOOP_CONTROL, false )) return;
if(!odrive.run_state(0, AXIS_STATE_CLOSED_LOOP_CONTROL, false )) return;
odrive_serial << “w axis” << 0 << ".controller.input_vel " << -2 << ‘\n’;
odrive_serial2 << “w axis” 0 << ".controller.input_vel " << 2 << ‘\n’;
That looks generally good! But you don’t need to do the raw serial writes for those last two lines, you could just do:
odrive.setVelocity(-2);
odrive2.setVelocity(2);
You should check out the docs here: Controlling ODrive from an Arduino via UART — ODrive Documentation 0.6.10 documentation
1 Like
Thank you for your reply.
I tried it but I got an error.
case1)
odrive.setVelocity(-2);
odrive2.setVelocity(2);
(error)
exit status 1
‘class ODriveArduino’ has no member named ‘setVelocity’; did you mean ‘SetVelocity’?
case2)
odrive.SetVelocity(-2);
odrive2.SetVelocity(2);
(error)
exit status 1
no matching function for call to ‘ODriveArduino::SetVelocity(int)’
Is the S1 library different?
Oh - please use the ODriveUART class instead of ODriveArduino and make sure your library is up to date: Controlling ODrive from an Arduino via UART — ODrive Documentation 0.6.10 documentation