QWIIC MOTOR Driver

#include “SparkFun_Qwiic_Step.h” //Click here to get the library: http://librarymanager/All#Qwiic_Step by SparkFun

QwiicStep motor;

void setup()

{

Serial.begin(115200);

Serial.println(“Qwiic step examples”);

Wire.begin();

motor.setI2Caddress(0x5d);

}

results in

21:30:43.480 → UFSR : 0

21:30:43.480 → DFSR : 0

21:30:43.480 → AFSR : 0

21:30:43.480 → BFAR : A300917C

21:30:43.480 → Mode : Thread

21:30:43.480 → Priv : Privileged

21:30:43.480 → Stack: PSP

21:30:43.480 →

21:30:43.480 → – MbedOS Fault Handler –

21:30:43.480 →

21:30:43.480 →

21:30:43.480 →

21:30:43.480 → ++ MbedOS Error Info ++

21:30:43.480 → Error Status: 0x80FF013D Code: 317 Module: 255

21:30:43.480 → Error Message: Fault exception

21:30:43.480 → Location: 0x106F4

21:30:43.480 → Error Value: 0x10005E38

21:30:43.480 → Current Thread: main Id: 0x10004250 Entry: 0x22E89 StackSize: 0x1000 StackMem: 0x10005E98 SP: 0x10006E60

21:30:43.525 → For more info, visit: https://mbed.com/s/error?error=0x80FF01 … RTEMIS_ATP

21:30:43.525 → – MbedOS Error Info –

Not sure what changes you had made BUT I gave it a try. (attached)

It compiles without errors BUT I can not test as I do not have this board, so look for your feedback.

You should not have to change any of the examples to use this.

Below is an overview of the changes I applied.

Changes SPI:

Set SPI default at 500Khz:

SPISettings DefaultSPISettings(500000, MSBFIRST, SPI_MODE0);

According to the datasheet the board can run on 1Mhz, but the original SPI setup was also for 500Khz.

Added a new optional call to change these settings from the sketch:

uint8_t beginSPI(SPISettings spiSettings = DefaultSPISettings)

It will update the spiSettings (if provided), set library for SPI and act in the same way as begin().

Between the SPI commands should be 20us delay according to the datasheet.

This delay is handled by a “loop-counter”. The default value was set by the original developer to 50 for 16Mhz processor. The Artemis runs on 48Mhz, so I have set it to 150. You can change that by changing: settings.LoopDelay = xx in the sketch.

On the Artemis Edge board is NO SPI interface. In the SCMD.h file you can exclude all the SPI references by commenting out line 44 : #define INCLUDE_SPI . It will then compile without errors.

Changes Wire:

Added selection for Wire1 next to Wire as the I2C interface

myMotorDriver.settings.commInterface = I2C_MODE; will use Wire

myMotorDriver.settings.commInterface = I2C_MODEW1; will use Wire1

If Wire1 is not defined or available on the current board, it will default to Wire.

SparkFun_Serial_Controlled_Motor_Driver_Arduino_Library-master_pvha.zip (34 KB)

I have a question about the same board but unrelated to OP. Feel free to re-categorize as necessary.

I am currently using this driver to control two coreless DC motors from another retailer.

When the motors are hooked up and the board is set to 0, there is a very slow spin still present. On my scope it appears that there are very short spikes still coming through at 1500us. The motor retailer suggested that I need to somehow center or zero the signal from the motor driver, is this possible to do on the QWIIC motor driver or do I need to replace it with something else? Thank you!