Introduction: PWMSwizzling an Edison Arduino Breakout to Work With Grove Seeed Motor Shields

About: I've been building up gadgets from scraps and re-missioned tech since the days when a 555 was considered high function silicon. People doing such things weren't called "Makers", but that's what it wa…

This instructable explains the steps necessary to configure the hardware and software of an Intel Edison Arduino Breakout board so that it will communicate with a Grove Seeed Motor Shield. Examples of sketches for controlling a pair of DC motors, or a single stepper motor will be provided. The key to opening up the communication between the Edison and the Grove Seeed Motor Shield is to understand the way that the pulse width modulated (PWM) pins are managed between the Intel Edison and the associated Arduino Breakout Board. The breakout board's PWMSwizzler will be introduced.

What you'll need:



• Intel Edison Micro-controller
• Arduino Breakout Board for the Intel Edison
• Grove Seeed Motor Shield (V1 and/or V2)
• Two DC Motors
• One Stepper Motor

Step 1: Understanding Why It Doesn't Work Right Out of the Box

When a Grove Seeed Motor Shield is connected to an Intel Edison Arduino Breakout board that has its "out of the box" standard configuration, only one DC motor will be controllable by the standard motor demo Arduino sketches.

I observed that a reboot of the motor shield would result in a short spin of the second DC motor. It would only move once, despite the sketch loop repeatedly attempting to drive the motors in alternating directions.

Connecting a stepper motor and loading a stepper control sketch would result in no motor movement at all. I used an Arduino Uno to confirm that the motor shield, motors, and demo sketches were working on original Arduino hardware. The control problems were something specific to the Intel Edison Arduino emulation.

Given that only one of the two DC Motors was reacting to control inputs, I tried various sketch edits in an attempt to have the problem swap between the two motors. I adjusted the DC Motors control sketch to change the order in which enable pins were updated, and delays between assignments and use of pins. All to no avail.

I have a V1 and a V2 version of the Seeed Motor Control Shield. The V2 version was of more help in debugging the control problem. The V2 motor shield has LED indicators for the motor enable lines. The V1 does not have those indicators. Using the V2 shield I could see that one of the motor enable lines was never switching to active.

I invested a lot of time tracking down internet mentions of the incompatibility of the Grove Seeed Motor Shields with the Intel Edison. Descriptions of problems were found, but no references for solutions turned up. Some suggestions for adjusting GPIO pin timing were tried with no success.

It wasn't until I found the Edison Arduino Breakout board hardware guide that a bread crumb on the trail to the answer was found.

https://communities.intel.com/servlet/JiveServlet/...

The first clue was in the documentation for a block of jumpers marked PWM on the breakout board. This set of 10 pins with 4 2-pin jumpers is documented as the PWMSwizzler. It controls which 4 of the 6 standard Arduino PWM pins are active on the Edison Arduino Breakout board. Only 4 of the normal 6 PWM pins are available for any given hardware configuration of the breakout board. Even though there are PWM ~ marks silkscreened next to all 6 pins on the breakout board, not all of those pins can be active at the same time.

The factory configuration of the Arduino Breakout board enables PWM pins 3, 5, 6, and 9. The PWM 10 and 11 pins are inactive.

Review of the Grove Seeed Motor Shield data sheets reveals that the shields use pins D8 through D13.

http://www.seeedstudio.com/wiki/Motor_Shield_V1.0

http://www.seeedstudio.com/wiki/Motor_Shield_V2.0

It was becoming obvious that the default hardware configuration for the Arduino Breakout board would not talk to the Seeed Motor Shield because the D10 and D11 pins were not active.

Step 2: Configuring the PWMSwizzler Jumpers

The PWMSwizzler jumper block silkscreening on the breakout board does not a clearly identify which digital out pin number is controlled by which jumper pin. A table mapping the various active drivers to the pins for each digital output pin number can be found in the Edison Arduino Breakout hardware guide. I have included an image of the the pertinent section from the guide here.

There also is some information to be found in the Intel Edison Shield Testing Report document. Note that the shield testing guide has no mention of Grove Seeed Motor Shields. There are some tips for configuring the PWMSwizzler for other shields.

http://www.intel.com/support/motherboards/desktop/...

By using the jumpers on the Arduino Breakout board PWMSwizzler the D10 and D11 pins can be enabled for PWM. This is at the expense of disabling two of the other PWM pins. Given that the Grove Seeed Motor Shields use D8 through D13, I sacrificed the use of PWM 3 and PWM 5 to gain access to PWM 10 and PWM 11. A picture of the modified jumper settings is included here.

With the jumpers set, the hardware configuration to enable use of the Seeed Motor Shield is done.

Step 3: Invoking SetPwmSwizzler Function in Sketch Setup

The hardware jumper changes are a necessary, but not sufficient step in activating the higher PWM pin numbers.

A related change to the Arduino sketch must also be made to activate the pins during the compile, upload, and run of the sketch on the Edison.

When the default configuration of the swizzler jumpers has been changed, then the sketch using PWM must invoke an extra function call which could be placed in the setup function. To activate PWM on pins D6, D9, D10, and D11, as needed by the Grove Seeed Motor Shield, use the function call

setPwmSwizzler(6, 9, 10, 11);

This function is referenced in the Edison Board Shield Testing Report. An image containing an extract of the report is included, here.

http://www.intel.com/support/motherboards/desktop/...

Once the jumpers have been set, and the setPwmSwizzler call has been added to the sketch, then the PWM support for D10 and D11 will be enabled.

Step 4: Video Proof and Sample Sketches for DC and Stepper Motor Control

Two sample sketches are included.

One shows the control of two DC motors in alternating directions.

A section defining the pins, and invoking setPwmSwizzler is the following.

int pinI1=8;//define I1 interface
int pinI2=11;//define I2 interface

int speedpinA=9;//enable motor A

int speedpinB=10;//enable motor B

int pinI3=12;//define I3 interface

int pinI4=13;//define I4 interface

void setup() {

setPwmSwizzler(6, 9, 10, 11);

pinMode(pinI1,OUTPUT);

pinMode(pinI2,OUTPUT);

pinMode(speedpinA,OUTPUT);

pinMode(pinI3,OUTPUT);

pinMode(pinI4,OUTPUT);

pinMode(speedpinB,OUTPUT);

}

The other sketch shows the driving of stepper motor windings to sweep the stepper back and forth.

It is based on the example sketch found at this link,

http://41j.com/blog/2014/05/seeedstudio-motorshiel...

with an additional statement to invoke the setPwmSwizzler added to the setup procedure.

That concludes this instructable for how to get a Grove Seeed Motor Shield working with an Intel Edison Arduino Breakout board. I hope the time that I invested in figuring out how to make this work, and the time taken to document it for other Edison developers, has helped you get your motors running.