diff --git a/examples/SineWaveCAN/SineWaveCAN.ino b/examples/SineWaveCAN/SineWaveCAN.ino index cab7d9a..bc6dc28 100644 --- a/examples/SineWaveCAN/SineWaveCAN.ino +++ b/examples/SineWaveCAN/SineWaveCAN.ino @@ -244,6 +244,9 @@ void setup() { void loop() { pumpEvents(can_intf); // This is required on some platforms to handle incoming feedback CAN messages + // Note that on MCP2515-based platforms, this will delay for a fixed 10ms. + // This has been found to reduce the number of dropped messages, however it can be removed + // for applications requiring loop times over 100Hz. float SINE_PERIOD = 2.0f; // Period of the position command sine wave in seconds diff --git a/src/ODriveMCPCAN.hpp b/src/ODriveMCPCAN.hpp index 64dc562..6b2ee42 100644 --- a/src/ODriveMCPCAN.hpp +++ b/src/ODriveMCPCAN.hpp @@ -33,9 +33,12 @@ static void onReceive(const CanMsg& msg, ODriveCAN& odrive) { } static void pumpEvents(MCP2515Class& intf) { - // nothing to do - // TODO: maybe remove - delay(10); // not sure why this resulted in less dropped messages, could have been a twisted coincidence + // On other platforms, this polls and processes incoming CAN messages. + // However, this is not possible on MCP2515-based platforms. + + // A 10ms delay was found to reduce the number of dropped messages, however a + // specific root cause has not been identified, and may be a quirk in the MCP2515. + delay(10); } CREATE_CAN_INTF_WRAPPER(MCP2515Class)