# Learn Embedded Programming [Step by Step]

## Unipolar Stepper Motor Interfacing With PIC Microcontroller (PIC18F2550) in Proteus [step by step]

### Unipolar Stepper Motor

 animation source :wikipedia

### Stepper Motors and It's Working Principles :

In this tutorial I will show , how to interface stepper motor with microcontroller and in this case I will use pic18f2550 microcontroller .Basically stepper motor works step by step .It can rotate 360 degree by the movements of equal steps.They are available stepper motor with steps 200, 180, 144, 72, 24 with rotation angles 1.8°, 2°, 2.5°, 5°, 15° respectively. Stepper motor moves each step at a time where every steps are equal .
Generally stepper motor works on the principle of electromagnetic induction. A internal rotor is surrounded by electromagnetic stators where rotor and stator like to be stable by achieving different poles.In this way the stepper motor rotate .If one stator gets power , thetab stator attracts the rotor .At this situation the rotor rotates so that the stable state can be achieved .If next stator is on and others are off .The motor will complete the next step .

#### Generally Stepper Motors are Divided into Three Types :

1.Hybrid Stepper Motor
2.Permanent Magnet Stepper Motor
3.Variable Reluctance  Stepper Motor

1.Unipolar Motor
2.Bipolar Motor

#### Unipolar :

This type of stepper motor is very popular and  most preferable for the hobbyists .Unipolar stepper motor contains centre tapped  windings inside .In this case coils are connected through a common wire and the poles can be changed without changing the direction of current .That's why the commutation circuit is very simple for unipolar stepper motor .

#### Bipolar :

This types of motor have no centre taped windings .For achieving reverse magnetic poles the current should be reversed in direction .In order to control this motor we need L293D ic because it is more complex to control .Basically L293D is used  as the alternative of H-bridge circuit .H-bridge circuit is also used to controlling dc motor.

#### Driving Operation of Stepper Motor :

Wave drive Operation (One becomes On at a time) :
In this case each stator gets power at a time and the rotation continues to the next .

 Bipolar Stepper Motor Interfacing With PIC Microcontroller (PIC18F2550) in Proteus [step by step]

Full Step Drive Operation(Two  become On at a time) :
In this case two stators get power at a time and the rotation continues to the next .This is very popular method .

Half Drive Operation(One or Two  become On at a Time) :

In this case one or two stators get power and this makes the rotation of  half drive operation .
 Unipolar Stepper Motor Interfacing With PIC Microcontroller (PIC18F2550) in Proteus [step by step]

Now at this situation , we have got necessary information  to create a Project .

### Proteus Circuit :

Please Complete the circuit as Given below . This Circuit is for Unipolar Stepper Motor
 Unipolar Stepper Motor Interfacing With PIC Microcontroller (PIC18F2550) in Proteus [step by step]

Now Create a Project in MikroC .If you are a beginner , you can follow the instruction :

### MikroC Code :

#### Source Code :

#Wave Drive :

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

void main() {
CMCON = 0x07;
Trisb=0x00;
while(1){
PORTB.F0=0;
PORTB.F1=0;
PORTB.F2=0;
PORTB.F3=1;
delay_ms(1000);
PORTB.F0=0;
PORTB.F1=0;
PORTB.F2=1;
PORTB.F3=0;
delay_ms(1000);
PORTB.F0=0;
PORTB.F1=1;
PORTB.F2=0;
PORTB.F3=0;
delay_ms(1000);
PORTB.F0=1;
PORTB.F1=0;
PORTB.F2=0;
PORTB.F3=0;
delay_ms(1000);
}
}

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

#Full Drive :

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void main() {
CMCON = 0x07; // To turn off comparators
Trisb=0x00;
delay_ms(1000);
while(1){
PORTB.F0=0;
PORTB.F1=0;
PORTB.F2=1;
PORTB.F3=1;
delay_ms(1000);
PORTB.F0=0;
PORTB.F1=1;
PORTB.F2=1;
PORTB.F3=0;
delay_ms(1000);
PORTB.F0=1;
PORTB.F1=1;
PORTB.F2=0;
PORTB.F3=0;
delay_ms(1000);
PORTB.F0=1;
PORTB.F1=0;
PORTB.F2=0;
PORTB.F3=1;
delay_ms(1000);
}
}

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

#Half Drive :

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void main() {
CMCON = 0x07; // To turn off comparators
Trisb=0x00;
delay_ms(1000);
while(1){
PORTB.F0=0;
PORTB.F1=0;
PORTB.F2=0;
PORTB.F3=1;
delay_ms(1000);
PORTB.F0=0;
PORTB.F1=0;
PORTB.F2=1;
PORTB.F3=1;
delay_ms(1000);
PORTB.F0=0;
PORTB.F1=0;
PORTB.F2=1;
PORTB.F3=0;
delay_ms(1000);
PORTB.F0=0;
PORTB.F1=1;
PORTB.F2=1;
PORTB.F3=0;
delay_ms(1000);
PORTB.F0=0;
PORTB.F1=1;
PORTB.F2=0;
PORTB.F3=0;
delay_ms(1000);
PORTB.F0=1;
PORTB.F1=1;
PORTB.F2=0;
PORTB.F3=0;
delay_ms(1000);
PORTB.F0=1;
PORTB.F1=0;
PORTB.F2=0;
PORTB.F3=0;
delay_ms(1000);
PORTB.F0=1;
PORTB.F1=0;
PORTB.F2=0;
PORTB.F3=1;
delay_ms(1000);
}
}

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
How to run the MikroC and save hex file .

Now go to the proteus circuit to load the hex file
Run the Project

#### Result :

 Full Drive

 Wave Drive
 Half Drive

Thank You !

#### 1 comment:

1. Thanks for sharing this complete guide. also check my website

Ain't getting any visitors!

## Tags

: (1) 18F2550 (1) 36KHz (3) and (1) arduino (1) Based (1) battery (1) Bipolar (1) Blinking (1) blinks (1) Bluetooth (1) button (1) circuit (1) clock (1) control (1) Db9 (1) DC Motor (2) digital (2) display (2) DS1307 (1) electronic (1) flash (1) flashing (1) HC-06 (1) home (1) how (1) How to (10) i2c tutorial (1) in (1) indicator (1) interface (8) interfacing (3) Interrupt (3) Introduction (1) IR Receiver (4) key pad (1) keyboard (1) keypad (1) lavel (1) Lcd 16x2 (2) lcd 2x16 (2) led (1) lm35 (2) LPG (1) machine (1) make (1) making (1) matrix (1) max232 (1) meter (2) microchip (4) microchips (3) mikroC (5) musical (1) NEC Protocol (4) pcb (5) PIC (3) pic controller (11) pic proteus (1) Pic Tutorial (12) pic18 (2) pic18f2550 (11) picRFモジュール (1) proteus (6) push (1) push button (1) PWM (1) real (1) Rs 232 (1) Rs232 (1) scroll (1) scrolling (1) Serial Port (1) simulation (2) step by step (7) step bystep (1) text (2) time (1) timer (4) timer0 (4) tone (1) tutorial (2) Unipolar (1) USB (1) usb 1.0 (1) USB HID (1) using (9) voltmeter (1) voting (1) with (2) work (1)

## Traffic Feed

Live Traffic Feed
Visitor Tracking