Application Note
March 2009
Stepper motor speed control By: Wong Jih Kian HK2006-5159
Abstract This application note is for novices who want a general guide showing how to control a stepper motor speed. There is a great deal of information available about how these motors work and how to use them to control the speed. Also, this application note is focus on stepper motors speed that can be driven by microcontrollers with basic circuit added. This document includes basic information needed to get started quickly that is simple and easy to implement. Keyword: Stepper motor, microcontroller, speed control.
Introduction
A stepper motor is a brushless, synchronous electric motor that converts digital pulses into mechanical shaft rotation from electrical current driven into the motor. Current pulses are applied to the motor, and this generates discrete rotation of the motor shaft. Every revolution of the stepper motor is divided into a discrete number of steps and the motor must be sent a separate pulse for each step. The stepper motor can only take one step at a time and each step is the same size which each pulse causes the motor to rotate a precise angle typically 1.8°, and the motor's position can be controlled without any feedback mechanism. As the digital pulses increase in frequency, the step movement changes into continuous rotation, with the speed of rotation directly proportional to the frequency of the pulses.
pdfMachine - is a pdf writer that produces quality PDF files with ease! Get yours now! “Thank you very much! I can use Acrobat Distiller or the Acrobat PDFWriter but I consider your product a lot easier to use and much preferable to Adobe's" A.Sarras - USA
Speed control circuit diagram This is a basic circuit diagram that controls the stepper motor speed with voltage regulator 7805 and potential meter shown in figure 1. When vary the potential meter will produce the analogue signal from 0.1V until 5V into microcontroller. In the microcontroller, ADC converter will convert the analogue input to digital output in order to decide the steeper motor speed. Figure 2 showing the output of the speed control circuit when varied the potential meter.
Figure 1: Speed control circuit for stepper motor
Figure 2: Oscilloscope show the output of speed control
pdfMachine - is a pdf writer that produces quality PDF files with ease! Get yours now! “Thank you very much! I can use Acrobat Distiller or the Acrobat PDFWriter but I consider your product a lot easier to use and much preferable to Adobe's" A.Sarras - USA
Connection between speed control circuit with microcontroller The speed control circuit connected to PIN 2 of PIC16F877A that the analogue signal 05V sends into microcontroller in order to convert to digital signal. The eight LED connected from the PIN 33 to PIN 40 of PIC which will indicate the digital signal changing from 00000000 to 11111111 when the potential meter was varied. The stepper motor will connected to the PIN 19, PIN 20 and PIN 6 of PIC. Further more, stepper motor MO-STEP-17PM-K508 work with stepper driver SD02A.
Figure 3: Connection between speed control circuit with microcontroller
pdfMachine - is a pdf writer that produces quality PDF files with ease! Get yours now! “Thank you very much! I can use Acrobat Distiller or the Acrobat PDFWriter but I consider your product a lot easier to use and much preferable to Adobe's" A.Sarras - USA
Microcontroller Assemble code for Analogue to Digital Converter (ADC) According an example below of a program that performs of ADC can be used to drive a stepper motor. Simply cycling through the states sequentially and placing the state values on port pins will cause a stepper motor to move. This is written in C.
SETUP_ADC MOVLW
B'10000000'
;FOSC/32 ;CHANNEL 0 ;ADC NOT ACTIVE ;ADC OFF
MOVWF CALL MOVLW
ADCON0 BANK1 B'01000100'
MOVWF CALL RETURN
ADCON1 BANK0
CALL MOVLW MOVWF MOVLW MOVWF DECFSZ GOTO BSF BTFSC GOTO MOVF BCF RETURN
BANK0 B'10000001' ;CONFIGURE TO AN0 ADCON0 D'50' X1 X1 $-1 ;DELAY A WHILE ADCON0,2 ;START CONVERSION ADCON0,2 ;WAIT UNTIL ADC COMPLETED $-1 ADRESH,W ;MOVE ADC VALUE TO WORKING REGISTER ADCON0,ADON ;OFF ADC MODULE
CALL MOVLW MOVWF MOVLW MOVWF DECFSZ GOTO BSF BTFSC GOTO MOVF BCF RETURN
BANK0 B'10001001' ;CONFIGURE TO AN1 ADCON0 D'50' X1 X1 $-1 ;DELAY A WHILE ADCON0,2 ;START CONVERSION ADCON0,2 ;WAIT UNTIL ADC COMPLETED $-1 ADRESH,W ;MOVE ADC VALUE TO WORKING REGISTER ADCON0,ADON ;OFF ADC MODULE
CALL MOVLW MOVWF MOVLW MOVWF DECFSZ GOTO BSF BTFSC GOTO MOVF BCF RETURN
BANK0 B'10011001' ;CONFIGURE TO AN3 ADCON0 D'50' X1 X1 $-1 ;DELAY A WHILE ADCON0,2 ;START CONVERSION ADCON0,2 ;WAIT UNTIL ADC COMPLETED $-1 ADRESH,W ;MOVE ADC VALUE TO WORKING REGISTER ADCON0,ADON ;OFF ADC MODULE
;LEFT JUSTIFIED ;RA0, RA1, RA3 AS ADC
READ_ADC1
READ_ADC2
READ_ADC3
pdfMachine - is a pdf writer that produces quality PDF files with ease! Get yours now! “Thank you very much! I can use Acrobat Distiller or the Acrobat PDFWriter but I consider your product a lot easier to use and much preferable to Adobe's" A.Sarras - USA
Conclusion Stepper motors speed control can be attributed in part to the various ways the motor can be driven because of its compatibility with digital systems. Figure 4 below shows an example block diagram of a system with stepper motors speed control, microcontroller, stepper motor, and feedback. The feedback is not always needed but can still be provided for precision assistance compare with DC motors because they have a harder time making precision movements. Hence, it requires a circuit that can compensate for the risk of drifting or overshooting a target position. Steppers can be found in printers, disk drives, toys, cars, and other applications or products. It worked well in factories and assembly environments applications such as robotic arms and precision assembly controls.
Figure 4: Example System with Speed control, Microcontroller, Stepper Motor and Feedback
References 1. Microchip, PIC16F87XA Data Sheet, 28/40/44-Pin Enhanced Flash Microcontrollers 2. Matthew Grant, 16-Bit Automotive Applications, Microcontroller Division, Freescale Semiconductor Application Note, Quick Start for Beginners to Drive a Stepper Motor, AN2974 Rev. 1, 06/2005. 3.
Clive L. Dym, Patrick Little, Engineering Design, Second Edition, John Wiley & Sons Inc
pdfMachine - is a pdf writer that produces quality PDF files with ease! Get yours now! “Thank you very much! I can use Acrobat Distiller or the Acrobat PDFWriter but I consider your product a lot easier to use and much preferable to Adobe's" A.Sarras - USA