Skip to content

Commit 5b65c50

Browse files
committed
Fix hang while waiting for CAN heartbeat on multi-ODrive systems
When using the Teensy's built-in CAN peripheral, pumpEvents will effectively only process the 16 messages in the Teensy's CAN mailbox. This is in contrast to the MCP2515, which uses an interrupt, and the Arduino R4 CAN peripheral, which is dequeued to up to 100 messages. Previously, we delayed for 100ms after (unsuccessfully) processing incoming messages for a heartbeat message. As a result, when using systems with more than one ODrive, and/or an extremely high number of messages per second, the Teensy's mailbox will fill before the heartbeat is recieved, and thus discard future messages. This issue is exacerbated by the default 100ms period of the ODrive's heartbeat message -- in short, the ODrive would always send a heartbeat message at the same time relative to the Teensy reading the mailbox, so unless the timing was such that the heartbeat was in the first 16 messages during the delay, it would be missed. For most users, minute differences in the ODrive and Teensy's clock accuracy would cause a timing skew that would eventually bring correct this, however this could take up to 30 minutes, if not indefinitely long.
1 parent 5e8ecf7 commit 5b65c50

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# [0.10.8]
2+
- Removed delay while waiting for heartbeat message, causing infinite/nondeterministic delays on some Teensy-based systems with multiple ODrives.
3+
14
# [0.10.7]
25
- Fixed int overflow issue w/ Arduino Mega example
36

examples/SineWaveCAN/SineWaveCAN.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ void setup() {
224224
Serial.println("Waiting for ODrive...");
225225
while (!odrv0_user_data.received_heartbeat) {
226226
pumpEvents(can_intf);
227-
delay(100);
228227
}
229228

230229
Serial.println("found ODrive");

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# https://arduino.github.io/arduino-cli/0.33/library-specification/
22
name=ODriveArduino
3-
version=0.10.7
3+
version=0.10.8
44
author=ODrive Robotics Inc. <[email protected]>
55
maintainer=ODrive Robotics Inc. <[email protected]>
66
sentence=Library to control ODrive motor controllers

0 commit comments

Comments
 (0)