Pial's (We)blog
I will try to update this blog mostly with my hobby projects.

Arduino and stepper motor test.

July 3, 2010 04:06 by pial



Recently I collected a broken hard drive to experiment on making a POV clock that I found on the web. After taking the hard drive apart, my first idea was to drive the stepper motor in the hard drive using Arduino. I looked around the web for writeup and tutorials about the principles of driving stepper motors. I particularly found this resource very useful: http://www.cs.uiowa.edu/~jones/step/. Reading this tutorial I found out the type of stepper motor the hard drive had, as there are couple of types of stepper motors available in the market. This hard drive had a Variable Reluctance Stepper Motor and the internal construction of it is like the figure below.


. . . . . . . .
1 ---/\/\/\-  .            1
| . .      2   X   3
2 ---/\/\/\-|-- C        Y o Y
|          3   X   2
3 ---/\/\/\-               1
The motor has 4 pins, the common pin is usually connected to the positive power supply and the three other pins are required to be supplied negative voltage in a sequence to get the stepper motor moving. The logic is visualized in the figure below:



Now that I understood the logic of driving the motor, I wrote up the code for Arduino. The code uses 3 arduino digital pins in output mode (Pin 2,3,4) to drive the 3 coils of the stepper motor. However the arduino digital I/O pins does not produce enough current to drive the motor coils. Therefore power transistors or Darlington array chips (ULN2003 etc.) or H-Bridge motor drive chip (L293D etc.) are required to successfully drive the motor. For the experiment I used couple of regular NPN switching transistors (2N3904). These transistors yield quite low current (around 150-200mA), so I couldn't drive the motor beyond a certain speed. I wrote the code that will start spinning the motor at a lower speed and then gradually speed up. You can play with the steppingDealy value to control the speed of the motor.

Here is the arduino code:


int pinA = 2;
int pinB = 3;
int pinC = 4;
int steppingDelay = 100;

void setup() {
  pinMode(pinA, OUTPUT);
  pinMode(pinB, OUTPUT);
  pinMode(pinC, OUTPUT);

  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);  
}

void loop() {
  stepping(1);
  delay(steppingDelay);
  stepping(2);
  delay(steppingDelay);  
  stepping(3);
  delay(steppingDelay);
  if(steppingDelay > 10)
  {
    steppingDelay--;
  }
}

void stepping(int stage)
{
  switch(stage)
  {
  case 1:
    digitalWrite(pinA, LOW);
    digitalWrite(pinB, HIGH);
    digitalWrite(pinC, HIGH);
    break;
  case 2:
    digitalWrite(pinA, HIGH);
    digitalWrite(pinB, LOW);
    digitalWrite(pinC, HIGH);
    break;
  default:
    digitalWrite(pinA, HIGH);
    digitalWrite(pinB, HIGH);
    digitalWrite(pinC, LOW);
    break;
  } 
}

Download the sketch file:

StepperTest.pde (829.00 bytes)


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Arduino and Nokia 3310 display module

May 22, 2010 02:55 by pial

This is a experiment with arduino and nokia 3310 display module. I downloaded the library from http://www.nuelectronics.com/estore/index.php?main_page=product_info&products_id=12. I got the display modules from eBay and made my own simple breakout board. This demo shows the time reading from a DS1307 time keeping chip. Also demonstrates how to display a graphic image and animation on the display using the library.

Here is how it looks:

Here is a video clip:

 

Here is the arduino sketch:

Nokia3310_Clock.pde (5.80 kb)

pacman.h (5.87 kb)


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Arduino controlling a 4 digit seven segment display.

May 19, 2010 06:40 by pial

I recently wrote some code to drive a 4 digit seven segment display using the arduino and 74HC595 shift register chip. The display is a seven segment common anode display with decimal dots. The pin configuration can be found here. I have connected a DS18S20 temparature sensor to read the temparature and display the reading on the seven segment display.

Here is how it looks:




Here is the arduino sketch:

Download the sketch from the link below: 

SevenSegmentTest.pde (2.27 kb)

If you have any questions, please feel free to ask me via the contact link.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Arduino project: The clock

March 4, 2010 01:45 by pial

I have been working on this for a while and finally it has been perfected. Here the arduino reads data from DS1307 RTC chip using I2C protocol and displays the time in english and bengali digits on a dot matrix display. The dot matrix display is connected to the arduino through 74HC595 shift register chips to expand the I/O pins of arduino. Here is how the prototype looks:

Photos:





Video:

Arduino Real Time Clock using I2C and Dot Matrix Display from Pial on Vimeo.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5