STEPPER MOTOR USING PIC MICROCONTROLLER,In this tutorial, you will learn to interface a stepper motor with PIC16F877A microcontroller. A stepper motor is a kind of a motor that converts electrical pulses into mechanical movement. Unlike all conventional motors, a stepper motor advances in steps. These steps of the motor are measured in degrees and can vary as per its application. It takes one step at the time and the size of each step is equal to the other.
There are three excitation modes of a stepper motor;wave drive, full driveand half drive. In wave drive mode, only one winding is energized at a given time, whereas in full drive mode, two phases are energized at the same time. The number of steps, however, are same in both wave and full drive modes. Half drive mode combines both wave drive and full drive i.e. it energizes one and two phase alternatively. TASK
To drive a stepper motor using PIC microcontroller
CIRCUIT DIAGRAM FOR STEPPER MOTOR USING PIC microcontroller :
Circuit diagram of stepper motor interfacing with pic16f877a microcontroller is given below:
The easiest way of interfacing a stepper motor with a microcontroller is via ULN2003 transistor array chip. This IC has seven Darlington transistor drivers and is used for high current torque motors. In the circuit diagram, the four input pins (1B, 2B, 3B, 4B) of ULN2003 are connected to the lower significant bits of PORTD of the microcontroller and the output pins (1C, 2C, 3C, 4C) are connected to the ‘live’ pins of the stepper motor as shown above.
The ‘common’ pins of the stepper motor, together with ‘COM’ pin of ULN2003 are hooked up to a 12V battery supply.
Stepper motor speed
The speed of the stepper motor can be increased or decreased via Proteus as well. For this purpose, right click on the stepper motor and select ‘Edit Properties. The window on the right will appear on the screen.
For a 200 step motor, a complete rotation (360°) is divided into 200 steps. This gives the size of a single step which is equal to 1.8°. You can vary the number ofsteps as well as the step angle using Proteus, the effects of which will be visible during simulation.
C-CODE FOR STEPPER MOTOR INTERFACING WITH PIC MICROCONTROLLER
Write the following code in the mikroC code editor window:
- void main()
- TRISD = 0b0000000; // PORT D as output port
- PORTD = 0b1111111;
- PORTD = 0b00000011; // energizing two phases at a time
- Delay_ms(500); // delay of 0.5s
- PORTD = 0b00000110;
- PORTD = 0b00001100;
- PORTD = 0b00001001;
- }while(1); // loop executed infinite times
The above code represents the working of a stepper motor in full drive mode. For wave drive and half drive modes, slight changes will be required in the above code. The circuit diagram, however, remains the same. The PORTD of the controller has been declared as an output port which is fed to the driver IC ULN2003. The combination of bits from PORTD of the controller is transferred to the input pins of the IC, which enables it to switch the different coils of the motor on and off.
Stepper motors are used immensely in our daily life. They are used in automobiles, digital photocopiers, computer printers, to move the print head carriage, and other home appliances. Stepper motors are also used in industrial machines, security and medical equipments.
To dowload circuit diagram and code of stepper motor control using pic microcontroller click on following link :
you can help us and others by sharing this article with your friends. Thanks 🙂
You may also like to read:
- Stepper Motor Control with L293D Motor Driver IC and Arduino
- DC Motor Speed and Direction Control with L293D Driver IC and Arduino
- ESP8266 NodeMCU with Stepper Motor (28BYJ-48 and ULN2003 Motor Driver)
- ESP32 Interface with Stepper Motor (28BYJ-48 and ULN2003 Motor Driver)
- Stepper Motor Interfacing with TM4C123 Tiva Launchpad