Driving a Unipolar stepper motor using ULN2803 + PIC16F887

1 minute read

Recently I dissembled an old Canon S200SP printer to get some motors. I found a unipolar stepper motor with 5 wires on it. But the model number is unclear as the motor is bit rusted. I tried to give a try.

First thing you have to do it check the resistance between the wires. You will find a wire which has lowest resistance with other wires. This is the centre tap. In my case,it is the red wire and in most cases this wire will be red.

Electronics-diy.com has a good article on stepper motor basics and about windings. I’m not going to tell those again and you can refer to that page.

I simply modified my general ULN2803 driver circuit to drive the stepper motor in single stepping mode (powering up single coil at a time) . I connected stepper motor to ULN2803 as loads according to the 2nd picture.

DSCF5576_800x600

DSCF5608_800x600

Now,It is time to do the coding,I simply edited previous MickroC code and same configuration bits were selected Winking smileThe bolded code is for single stepping mode Open-mouthed smile


void main() {


    osccon = 0x70;
    ansel  = 0;
    anselh  = 0;
    trisa = 0;
    trisb = 0;
    trisc = 0;
    trisd = 0;
  
  for(;;){
  portd.f4=1;
 
  porta.f7=1;
  porta.f6=0;
  portc.f0=0;
  portc.f1=0;

  delay_ms(10);

  porta.f7=0;
  porta.f6=1;
  portc.f0=0;
  portc.f1=0;
 
  delay_ms(10);
 
  porta.f7=0;
  porta.f6=0;
  portc.f0=1;
  portc.f1=0;

  delay_ms(10);
 
  porta.f7=0;
  porta.f6=0;
  portc.f0=0;
  portc.f1=1;

  portd.f4=0;
  delay_ms(10);
 
 
  delay_ms(2000);
  }
   
}

Capture

Let’s check the working circuit Winking smile

DSCF5594_800x600

If everything is correctly done,Your motor will be in continuous run Open-mouthed smile I’m going to get some angle measurements and to add a LCD to this project. Stay tuned and follow me on twitter Winking smile @incrediblediy Open-mouthed smile

Comments