element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Blog [Christmas Wreath of Things] Internet of Holiday Lights: part 6 - Stepper Motor works
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 26 Dec 2014 11:56 PM Date Created
  • Views 2548 views
  • Likes 3 likes
  • Comments 7 comments
  • wreath_of_things
  • iot_holidaylights
  • internet-of-things
  • iot
  • motor
  • arduino
  • stepper_motors
Related
Recommended

[Christmas Wreath of Things] Internet of Holiday Lights: part 6 - Stepper Motor works

Jan Cumps
Jan Cumps
26 Dec 2014

My entry for the Internet of Holiday Lights is an electro-mechanical wreath.

My first blog post was a brain dump of possibilities.

In my second post I made a paper prototype.

My third post was about getting the Arduino Yun up and running.

In the fourth post I used the Linux part of the Yun to get at the current date and time.

In the fifth post I scavenged a stepper motor from a flatbed scanner.


I have that motor working now.


You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image





The motor driver kit

In my previous post I blogged about driving the motor with a 4 transistor H-bridge, and how I goofed that up. So I ended up dragging home a Velleman MOTOR & POWER SHIELD VOOR ARDUINO.

That shield's design is very similar to the Arduino Circuit for Bipolar Stepper Motor (the two pins example). Here's the two schematics side by side:

bipolar_stepper_two_pins2.png  image


Velleman and myself have one particular thing in common. We're both from Belgium.
The last time I've built a kit from them must have been somewhere in the late 80's. So I was quite excited to spend an evening of my Christmas holidays building up the kit.
There was one unpleasant thingy though. The smd ic was packaged in bubble wrap with tape around it. And someone in the kit assembly department must have been too strong for that job:

image

No real harm done, I could straighten the pins without too much effort. Still, I'm expecting better...


Building the kit


That was not too difficult. There's only one smd component. In stead of soldering it with a fine tip pin by pin at the end - as advised by Velleman - I put that one up first.

I used solder paste and hot air. At my age, your eyes are happy that the don't have to stare at the 20 tiny pins while hand soldering each of them.

 

solder station

My solder station is an Aoyue 968A+. I've bought that with a voucher my company gave me earlier this year as a present. Because I'm a cheapskate, I searched for the lowest price (shipping included). That was on Amazon America.

The pleasant surprise came a week later when the Belgian tax authorities charged me an import tax that was lifting it way up above buying local. Go figure.

image

 

I'm rather fond on that solder station. Works well for me.


The other thing that I did different than Velleman's instructions is using flux. I'm soldering lead-free, and flux is more than welcome in that situation.
The kit is complete, and the instructions are easy to follow. And since it's been a while since I did that, it was quite an entertaining exercise.



image



The software


I want to use the Arduino Stepper library. In this contest, one of my goals is to stick close to the nature of the devices.
image


Since there isn't too much difference in design between Velleman's kit and Arduino's example, it shouldn't be too hard. And it isn't.

For the moment, I've left all the jumpers on my kit in their default position.

  • enable coil A on digital3
  • direction coil A on digital 2
  • enable coil B on digital 9
  • direction coil B on digital 8


I could use the Ardiono Shield example libraries with these changes:


in the constructor and setup(), I switched the output pins to reflect the jumpers on my shield, and enabled the enable (sic) pins.

#define STEPA 2
#define STEPB 8
#define ENAA 3
#define ENAB 9
#define BUTTON_CTRL 4
// ...
Stepper myStepper(stepsPerRevolution, STEPA, STEPB);


void setup() {
  pinMode(ENAA, OUTPUT);  //Set control pins to be outputs
  pinMode(ENAB, OUTPUT);
  digitalWrite(ENAA, LOW);
  digitalWrite(ENAB, LOW);
// ...
// set the speed at 60 rpm:
  myStepper.setSpeed(60);
   // initialize the serial port:
  Serial.begin(9600);

// ...



in the loop(), I took advantage of the enable capability of my shield:

void loop() {
  // step one revolution  in one direction:
// ...    
    Serial.println("clockwise");

    digitalWrite(ENAA, HIGH);
    digitalWrite(ENAB, HIGH);
    myStepper.step(100*stepsPerGearRevolution);  //  yes, I'm testing 100 full turns of the slowest wheel in my gearbox top test the resolution :) -- too lazy to count the cogs and ratios in my gearbox
    digitalWrite(ENAA, LOW);
    digitalWrite(ENAB, LOW);
    delay(500);
  }



I've successfuly tested the following examples on my stepper motor / shield combination:


image

I haven't tried the other Stepper examples. I have no reason why they shouldn't work too.


Motor and gearbox resolution


I've measured the motor resolution by adapting the stepper_oneRevolution example.

I found info on my motor (the Neocene 2T3542146) on the manufacturer's site. The step angle is 3,75°. 3,75°per Step = 96 steps per rotation.

I have verified that by running this adapted example:

#include <Stepper.h>


const int stepsPerRevolution = 96;  // change this to fit the number of steps per revolution
// for your motor


// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 2);


int stepCount = 0;         // number of steps the motor has taken


void setup() {
  // initialize the serial port:
  Serial.begin(9600);
  pinMode(3, OUTPUT);  //Set control pins to be outputs
  pinMode(9, OUTPUT);
  digitalWrite(3, HIGH);
  digitalWrite(9, HIGH);

}


void loop() {
  // step one step:
  myStepper.step(1);
  Serial.print("steps:" );
  Serial.println(stepCount);
  stepCount++;
  delay(25);
}



To measure the full resolution, I marked one cog of the slowest gear in the reduction. Then I activated the motor and counted how many rotations of the motor where needed for one full rotation of that last gear in the reduction.

I came at approx 29.5 rotations.

Then I made the following sketch to fine tune. It waits for a button press and then takes what I think are the right amount of steps to make the slowest gear go around 100 times.

That should give me enough resolution to survive the advent weeks.

/*
Stepper Motor Control - one revolution


This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 - 11 of the Arduino.


The motor should revolve one revolution in one direction, then
one revolution in the other direction.




Created 11 Mar. 2007
Modified 30 Nov. 2009
by Tom Igoe  (adapted by jc for the Internet of Holiday Lights - Velleman KA03 motor driver with Neocene 2T3542xmotor


*/


#include <Stepper.h>


#define STEPA 2
#define STEPB 8
#define ENAA 3
#define ENAB 9
#define BUTTON_CTRL 4




const int stepsPerRevolution = 96;


const int stepsPerGearRevolution = 30*stepsPerRevolution-32;  // change this to fit the number of steps per revolution


Stepper myStepper(stepsPerRevolution, STEPA, STEPB);


void setup() {
  pinMode(ENAA, OUTPUT);  //Set control pins to be outputs
  pinMode(ENAB, OUTPUT);
  digitalWrite(ENAA, LOW);
  digitalWrite(ENAB, LOW);


  pinMode(BUTTON_CTRL, INPUT);




  // set the speed at 30 rpm:
  myStepper.setSpeed(30);

  // initialize the serial port:
  Serial.begin(9600);
}


void loop() {
  // step one revolution  in one direction:
  if (! digitalRead(BUTTON_CTRL) ) {
    Serial.println("clockwise");
  //  myStepper.step(stepsPerRevolution);
    digitalWrite(ENAA, HIGH);
    digitalWrite(ENAB, HIGH);
    myStepper.step(100*stepsPerGearRevolution);
    digitalWrite(ENAA, LOW);
    digitalWrite(ENAB, LOW);
    delay(500);
  }

}

 

assorted scribbles:

image

  • Sign in to reply

Top Comments

  • mcb1
    mcb1 over 10 years ago in reply to Jan Cumps +3
    Jan Cumps It is a TTL device, and yes not so static sensitive as CMOS devices, but still not a good practice. Selloptape generates thousands of volts and with quite a bit of energy (We measured it years…
  • shabaz
    shabaz over 10 years ago in reply to mcb1 +3
    I agree. If it has semiconductor, personally I always place it into anti-static or static dissipative storage - and then it is one less thing to worry about. I also keep any empty card (for passives) or…
  • gadget.iom
    gadget.iom over 10 years ago +1
    An excellent article as always
  • shabaz
    shabaz over 10 years ago in reply to mcb1

    I agree. If it has semiconductor, personally I always place it into anti-static or static dissipative storage - and then it is one less thing to worry about. I also keep any empty card (for passives) or metal containers and save money : )

    A friend got me some wooden cigar boxes - I use them for capacitors : )

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 10 years ago in reply to Jan Cumps

    Jan Cumps

    It is a TTL device, and yes not so static sensitive as CMOS devices, but still not a good practice.

    Selloptape generates thousands of volts and with quite a bit of energy (We measured it years ago but I can't recall the figure)

     

    The bent pins showed it either didn't protect it, or was damaged during packaging, so you have to ask why bother.?

     

    Mark

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 10 years ago

    Nice.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 10 years ago in reply to mcb1

    It seems that static isn't an issue for this paricular IC. The datasheet doesn't warn you like they do for sensitive components.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 10 years ago

    Well done.

    Pity Mr Velleman doesn't understand about static electricity ...especially since they are an electronics company.  image

    Not only is the standard poly-bubble bad enough, but the act of pulling tape off a roll creates a HUGE static voltage.

     

    Mark

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube