In this blog there are several posts talking about bipolar stepper motor and how to drive it. The bipolar stepper motor has two windings and 4 wires and to drive this windings 2 H-bridge circuits are needed. L293D motor driver chip is a good choice for driving this type of motor because it’s low cost and easy to use.
This post shows how to drive a cd-rom bipolar stepper motor using Microchip PIC12F1822 microcontroller and L293D motor driver IC.
To understand how this motor works read the following post:
Bipolar stepper motor control with PIC16F877A microcontroller
Bipolar stepper motor control using PIC12F1822 and L293D circuit:
Hardware Required:
- PIC12F1822 microcontroller —> datasheet
- L293D motor driver —> datasheet
- Bipolar stepper motor
- 2 x push button
- Breadboard and jumper wires
- PIC microcontroller programmer (PICkit 3, PICkit 4 …)
The two push buttons for moving the motor in direction 1 or direction 2.
PIC12F1822 internal oscillator is used and internal pull-ups are enabled for the 2 inputs.
The stepper motor voltage is 5V which is the same as the L293D chip VS and VSS.
Bipolar stepper motor control using PIC12F1822 and L293D CCS C code:
In this project the speed of the stepper motor is fixed by a variable called speed_delay = 10. If that number changed the speed of the motor will also change, if you increase that number the motor speed will decrease and if you decrease it the speed will increase.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | // Bipolar stepper Motor control using PIC12F1822 and L293D CCS C code // http://simple-circuit.com/ #include <12F1822.h> #fuses NOMCLR INTRC_IO PLL_SW #use delay(clock=32000000) #use fast_io(A) unsigned int8 step_number = 0, speed_delay = 10; void stepper(int8 step){ switch(step){ case 0: output_a(0b010010); break; case 1: output_a(0b010001); break; case 2: output_a(0b100001); break; case 3: output_a(0b100010); break; } } void main() { setup_oscillator(OSC_8MHZ | OSC_PLL_ON); // Set internal oscillator to 32MHz (8MHz and PLL) output_a(0); set_tris_a(0x0C); // Configure RA2 & RA3 as inputs port_a_pullups(0x0C); // Enable internal pull-ups for pins RA2 & RA3 while(TRUE){ output_a(0); while(!input(PIN_A2)){ // If RA2 button pressed step_number++; if(step_number > 3) step_number = 0; stepper(step_number); delay_ms(speed_delay); } while(!input(PIN_A3)){ // If RA3 button pressed if(step_number < 1) step_number = 4; step_number--; stepper(step_number); delay_ms(speed_delay); } } } |
Bipolar stepper motor control using PIC12F1822 and L293D video:
Project hardware video….
Discover more from Simple Circuit
Subscribe to get the latest posts sent to your email.
friend congratulations for all those beautiful projects I want to ask you the favor of if you can do this project with a pic12f615 what happens is that here you can’t get the pic12f1822 and I have some but they are pic12f615 I thank you immediately for a hug