Can't get QWIIC Motor driver sketch to work with Redboard Turbo

I just got a new QWIIC Motor Driver for Christmas, and am attempting to get the Experiment #1 test sketch from the Hookup Guide working on my Redboard Turbo. I changed all references of Serial to SerialUSB, so that I could get output showing on my TeraTerm window. However, when I run the sketch, I don’t even get the beginning “Starting sketch.” string showing. What other modification is needed to get the code to run?

(TeraTerm is set to the com8 port that the Turbo board is on, and other sketches work fine with the Turbo board. The baud is 9600 too, I checked.)

Hi NotDavid4JustDavid,

I think the issue is with the motor driver initializing. Try adding a Wire.begin(); call in the Setup like this:

void setup()
{
  pinMode(8, INPUT_PULLUP); //Use to halt motor movement (ground)
  Wire.begin();
  Serial.begin(9600);
  Serial.println("Starting sketch.");

That should initialize the motor driver. If it still doesn’t work, try adding in the SDA and SCL pins into your Wire.begin(); call like this:

Wire.begin(20,21);

I hope this helps get your Qwiic Motor Driver working with your RedBoard Turbo. If you continue to have issues getting it working or have any other questions or issues with the board, let us know and we would be happy to help.

So I tried adding in the ‘wire.begin();’ statement as suggested. No go.

Just to be sure, I did the second variation you suggested as well:

#include <Arduino.h>

#include <stdint.h>

#include “SCMD.h”

#include “SCMD_config.h” //Contains #defines for common SCMD register names and values

#include “Wire.h”

//#define Serial SerialUSB

SCMD myMotorDriver; //This creates the main object of one motor driver and connected slaves.

void setup()

{

pinMode(8, INPUT_PULLUP); //Use to halt motor movement (ground)

Wire.begin(20,21);

SerialUSB.begin(9600);

SerialUSB.println(“Starting sketch.”);

This also failed to produce any output on the TeraTerm screen. (Although I do see the blue LED blinking on the Motor Driver board, as expected.) I did a reboot by the unplug-replug in the USB cable trick after the sketch was uploaded successfully. No change…/

I then tried commenting out the first pinMode statement. No change. I made sure my libraries were updated, and recompiled. No change. I’ve run out of the obvious tricks here that I know of.

I’ve got a quick update. I was able to test this with a RedBoard Turbo today and ran into the same issue. I’m not sure at the moment why the code is not running but I’m guessing it’s due to the Wire.begin call in the source files. I’ll do some more troubleshooting and see if I can identify and fix the problem and update you as soon as I can.

Okay, I’ve figured out the issue and have a fix that should get your Qwiic Motor Driver up and running on your Turbo. The problem is with the SCMD.begin function in the .cpp file for the library. That function is calling an I2C address (Wire.begin(settings.I2CAddress):wink: which, on AVR boards works fine, but on SAMD boards is used to indicate a slave device so the Turbo just sits there waiting for I2C commands from a master.

To fix this, you’ll need to modify that call in the source files [here. Just remove the “settings.I2CAddress” and leave the Wire.begin(); function there blank. If you’re not sure where to find that source file, it should be along a similar file path to this:

“C:\Users\mark\Documents\Arduino\libraries\Serial_Controlled_Motor_Driver\src”

You’ll need to open file named “SCMD.cpp” up and edit it with either a code editing software or just any text editor and then save it. After that, try re-uploading the code and it should run without any problems. Let me know if you have any questions about how to modify the library or if you’re still having trouble and I would be happy to help.](SparkFun_Serial_Controlled_Motor_Driver_Arduino_Library/src/SCMD.cpp at master · sparkfun/SparkFun_Serial_Controlled_Motor_Driver_Arduino_Library · GitHub)

On my Raspberry Pi 2B I used Geany to edit the .cpp file to remove the address in the wire.begin call. Nice to know I did the correct thing. Now to make a Qwiic SCMD Python pigpio module.

Dale

Yes, and No, and Yes. LOL. What that means is that I did have to make the exact change you recommended in line 95 of SCMD.cpp to be as follows:

case I2C_MODE:

Wire.begin();

break;

And that modification is definitely required to get this to work correctly for the Redboard Turbo. However, to also see the initial ‘println’ statement output in the Example sketch, I ended up having to add in a delay to the sketch, as follows:

void setup()

{

pinMode(8, INPUT_PULLUP); //Use to halt motor movement (ground)

Wire.begin();

SerialUSB.begin(9600);

delay(5000);

SerialUSB.println(“Starting sketch.”);

Once that extra delay was put in (Okay, it’s an overkill amount. I know.) the sketch started up fine and gave me output on TeraTerm like I was expecting to see:

Starting sketch.

ID matches 0xA9

Waiting for enumeration…Done.

Without the extra delay, all I got was the ‘Done’ string printed out. So it looks like the begin statements need some time to do their thing before we can start pressing their services into action.

Also, the C++ source for SCMD.cpp could probably wrap this particular ‘fix’ in an #ifdef statement for the SAMD boards. Otherwise I’m sure this will come up again.

Thank you for your patience and fast response! It’s working now, and that’s what we’re after.

After SerialUSB.bgim(115200); I do a while(!SerialUSB); on all sketches to give me time to start the monitor. Lots of code now includes it. I have also made a sketch outline with all my standard #defines and other stock code. I am also naming sketches with the processor, and main function type. This allows testing small parts that I can copy and paste together for bigger programs.

Dale