Tag Archives: Arduino

Interfacing Arduino with SMCC-547 Stepper Motor Controller

This week I received a package from my favourite electronic component supplier Futurlec. It contained a very inexpensive stepper motor controller unit called an SMCC-547, made by a company in Thailand. The motor is small, has very little torque, and it has 18° steps, which is quite coarse as stepper motors go. Since I have no experience with stepper motors, I bought it thinking that I would be able to wire it up quickly to an Arduino microcontroller and play with it using Arduino’s Stepper Library.

Unfortunately, the library does not work for this controller. I have not found anything online that shows how to connect this to an Arduino, so I’m documenting it here, as much a reminder for me in case I want to go back to it, as for anyone else who can use it.

Tom Igoe’s stepper motor circuits page shows most motors as requiring a certain sequence of pulses on the four control wires of the motor:

Step wire 1 wire 2 wire 3 wire 4
1 High low high low
2 low high high low
3 low high low high
4 high low low high

However, all this does on the SMCC-547 is make the motor wiggle nervously.

By successively bringing each input HIGH I was able to learn that the correct logic for this controller is to bring the ABCD inputs high in order to make the motor rotate clockwise: A-B-C-D, and to make the motor rotate clockwise, do the inverse: D-C-B-A.

This required writing an Arduino sketch (program) from nothing, but after an hour or so I had this demonstration circuit running. A light sensor is connected to analog pin 0 on the Arduino. In the demonstration sketch, if there is lots of light on the sensor, the motor turns clockwise, and if the sensor is shaded, the motor turns counterclockwise. The sketch is shown below:

/*
Stepper Motor Demonstration
for SMCC-547 Stepper Module

by Michael LeBlanc
NSCAD University
mleblanc@nscad.ca

It checks analogPin(0) and if it is higher than 512,
it rotates the motor clockwise, otherwise counterclockwise.

August 27, 2009
*/

/*
**************** N O T E **************************************
This unit does not work with the stepper.h library.
It works by setting one pin high and the others low.
To rotate clockwise, set inputs high in order A-B-C-D,
and D-C-B-A rotates counterclockwise.
***************************************************************
*/

int analogPin = 0;
int activePin = 1;
int outputPin[5] = {0,10,11,12,13};

void setup()
{
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
Serial.begin(9600);
}

void rotateLeft()  // rotate counterclockwise routine
{
if (activePin == 4)
{
activePin = 1;
digitalWrite(outputPin[4], LOW);
digitalWrite(outputPin[1], HIGH);
}
else
{
digitalWrite(outputPin[activePin], LOW);
activePin = activePin + 1;
digitalWrite(outputPin[activePin], HIGH);
}
}

void rotateRight()   // rotate clockwise routine
{

if (activePin == 1)
{
activePin = 4;
digitalWrite(outputPin[1], LOW);
digitalWrite(outputPin[4], HIGH);
}
else
{
digitalWrite(outputPin[activePin], LOW);
activePin = activePin - 1;
digitalWrite(outputPin[activePin], HIGH);
}
}

void loop()
{
int v;
v = analogRead(analogPin);
//Serial.println(activePin);  // for debugging
if (v > 512) //choose any number between 0 and 1023
{
rotateRight();
}
else
{
rotateLeft();
}
delay(200); // this sets the speed of the motor
}

This sketch is somewhat “brute force,” but it works. A much more elegant solution would be to populate the array with 4-bit binary values and use bitwise shifting and boolean ANDing to assign each output pin of the Arduino a HIGH or LOW state; I found an example of this technique in the Arduino Playground.

Creative Commons License
Stepper Motor Demonstration for SMCC-547 Stepper Module by Michael B LeBlanc is licensed under a Creative Commons Attribution-Noncommercial 2.5 Canada License.

What I did on my Summer Vacation

One of my projects, circa 1983

In 1980, just after I graduated from York University with an MFA, I took up electronics. I was working part-time at a private radio station about an hour’s drive from Toronto; this radio station was one of the first in the world to go fully automated in the early 1970’s. Today automation in broadcasting is a given, but at that time it was a big deal. My job was to “program” the machine they called “OTTO” so that it could run overnight without any human intervention. Programming involved selecting square aluminum wafers of different colours that were about 8cm square, with 5mm holes bored through them. One colour square represented a music selection, a different colour represented a commercial, and another represented a weather report. I had to stack these about a hundred high in a holder according to the station log, which determined what advertisement should go when. Heaven help you if you did not close the stack holder properly–the squares might land in a pile all over the floor.

I got curious about electronics because at the time the station converted OTTO from a mechanical system to an electronic system–which meant that instead of stacking squares of metal, you stood in front of OTTO and punched in the program using a keypad.

I was interested in electronics because I wanted to create interactive box/sculptures that changed with human presence. I dove into the subject and although I was in some ways greatly hampered by a lack of mathematical skills, I became quite a competent designer of digital gizmos. I even built several microcomputers, one using the RCA 1802. My first entree to programming was flipping switches on this single board computer to make an LED flash on and off.

When the Macintosh came along, my interests moved elsewhere, and for the past fifteen years, until this year, I have been largely focused on interactive media using the web. My electronics workshop remained in boxes from 1985 to this past July, when I set things up again, and bought some new gear and new parts.

One of the parts I purchased was a microprocessor called the Arduino. It’s an open source prototyping computing platform used by many artists and designers around the world.

I’m still interested in human interaction with computers; I want to try to meld old interfaces and traditional materials with computers. One thing that will help me in my quest is a new service called “Pachube” (pronounced ‘patch-bay’): Pachube is “a service that enables you to connect, tag and share real time sensor data from objects, devices, buildings and environments around the world. The key aim is to facilitate interaction between remote environments, both physical and virtual.”

In my current experiment, I have connected some sensors to an Arduino, and the Arduino sends the sensor data to my home computer, which uploads the data to Pachube, which makes it available to others online. In this case, a widget called PachuDial takes the data and makes a Flash-enabled dial, which updates every few minutes on this blog. I could Twitter this information, and I can plot it to my home virtually on a Google SketchUp model, and publish my virtual home online (if I wanted). To see the most advanced work from Pachube, view this YouTube video.