This article explains the unipolar stepper motor interfacing with LPC1768 microcontroller. The microcontroller is programmed in two ways one is to rotate the stepper motor in sweep mode (i.e front and back) and another is to control the speed of rotation of the stepper motor. For basic concepts and working of a stepper motor, refer the article on Stepper Motors. For setting up the Environment for the development of ARM cortex M3 is well discussed in this article.
Fig. 1: Stepper Motor Interface With LPC1768 Prototype
Stepper motor is one of the commonly used motors for precise angular movement. The advantage of using a stepper motor is that the angular position of the motor shaft can be controlled without any feedback mechanism. Stepper motors are widely used in industrial and commercial applications. They are also commonly used as in drive systems of autonomous robots. Stepper motor is a variable reluctance DC motor. When correct input sequence of signal is given to the motor, it starts rotation in steps.
(For more detail refer Unipolar Stepper motor interfacing with microcontroller AT89C51).
Stepper motor can be termed as digital motor because it operates on pulses. Unlike AC or DC motor that rotates continuously, stepper motor rotates in steps. It rotates in number of steps as per applied number of pulses. Stepper motor is used in many applications like:
-
Robotic application – to move robotic arm to specific position, to move robo-vehicle in specific direction at specific angle.
-
Disk drive application (CD drive, HDD) – to position reading head at specific position· Defence application – to fire a shell or to launch missile at perfect angle.
-
Domestic application – to open or close window shutter / curtain / blinds etc.
-
Communication application – to lock the position of satellite dish antenna at specific angle.
Rotation of stepper motor:
Let us start with how to rotate a stepper motor, as we learned from the previous articles we have to follow a sequence in input to the stepper input wires and also we have to use a current amplifier to amplify the current source to drive the stepper motor. Here we are going to use ULN2003. ULN2003 is high voltage, high current Darlington arrays each containing seven open collector Darlington pairs with common emitters. Here it is used as a current driving IC. For the input sequence we use a lookup table to place the values in the pins. Look up table used here is.
Code snippet:
uint8_t lookup_table[7][4] = {
{1,0,1,0},
{0,1,1,0},
{0,1,0,1},
{1,0,0,1}};
Once the circuit is connected as per the circuit diagram and the code given below is loaded, Stepper motor start sweeping in both direction.
For more details about the GPIO functions in the LPC1768 refer these articles.
Switch and Led interface with LPC1768.
Creating Library for LPC1768.
Speed control of stepper motor:
Here, a potentiometer is connected to the analog input 0 is used to control the speed of rotation of a stepper motor. LCD is also interfaced to show the speed in values from 0 to 100. ADC module of LPC1768 will convert the analog voltage to digital values which is used to determine the delay values of the stepper revolution, thus speed can be varied by rotating the POT.
For more details about the ADC module and LCD interface to the LPC1768 refer these articles.
LCD interface in 4bit mode with LPC1768.
ADC Programming in LPC1768.
Circuit Description:
In the circuit, Port P0 is defined as output port to provide the input sequence for the stepper motor. The motor leads are not directly interfaced with the microcontroller pins because stepper motor requires 60mA current while LPC1768 has the maximum current rating of 50mA. So ULN2003 is used to transfer signals from the microcontroller to the stepper wires. The POT is connected to the ADC input P1.31 for the speed control of the Stepper motor.
Create a project using Keil uvision4 for LPC1768 Microcontroller:
In this section, we will start creating a project in Keil MDK we have already installed Keil µVision and Co-MDK Plug-in + CoLinkEx Drivers required for the CoLinkEx programming adapter. You can start by downloading the project files and kick start your practical experiment.
Fig. 2: Stepper Motor Interface With LPC1768 Prototype Using Keil Software
Project Source Code
###The codes are linked in Description ###
Circuit Diagrams
Project Components
Filed Under: ARM
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.