First, the general introduction:
Stepping motor is an open-loop control element stepping electric part which transforms electric pulse signal into angular displacement or line displacement. In the case of non-overloading, the speed of the motor, the position of the stop only depends on the frequency of the pulse signal and the number of pulses, and is not affected by the load changes, when the stepper driver receives a pulse signal, it will drive the stepper motor in the direction set to rotate a fixed angle, called "Step Angle", Its rotation is run at a fixed angle step-by-step. The angular displacement can be controlled by controlling the number of pulses to achieve accurate positioning, and the speed and acceleration of motor rotation can be controlled by controlling the pulse frequency to achieve the purpose of speed regulation.
Fig. 1 Several common stepper motors
Figure 2 Stepper motor and ULN2003 combined
Second, commonly used terminology
1, Phase number: produces different pairs of polar N, s magnetic field of the excitation coil logarithm. Common m representation. 2. Number of Beats: the number of pulses required to complete a periodic change of the magnetic field or the conduction state with N, or the motor to turn over a tooth angle of the required number of pulses, four-phase motor as an example, four-phase four-beat mode of operation is Ab-bc-cd-da-ab, four-phase eight beat operation mode is A-ab-b-bc-c-cd-d-da-a. 3, Step angle: corresponding to a pulse signal, the motor rotor rotating angular displacement is expressed in θ. θ=360 Degree/(Number of rotor teeth * running beats), with conventional two or four-phase, rotor teeth of 50-tooth motor as an example. Four beat run time step angle is θ=360 degree/(50*4) =1.8 degree (commonly known as the whole step), eight beat run time step angle is θ=360 degree/(50*8) =0.9 degree (commonly known as half step). FIG. 3 Internal model diagram of stepping motor
three, drive mode1, 1 phase excitation method: Every moment only one coil connected, rest. (advantages) Simple, low power consumption, good accuracy. (disadvantage) torque is small, vibration is large, each excitation signal to go angle is the nominal angle. 2, 2 phase excitation method: Two coil conduction per moment. (advantage) torque is large, vibration is small. (disadvantage) the angle at which each excitation signal goes is the nominal angle. 3, 1-2 phase excitation method: 1-phase and 2-phase alternating conduction. (advantages) High precision, smooth operation, each send a excitation signal rotation 1/2 nominal angle, called half-step drive. (the first two are called 4-phase 4 beats, this one is called 4-phase 8 beats)(a) 1 phase excitation method (b) 2 phase excitation method (c) 1-2 phase excitation methodFigure 4 3 Ways to drive
third, the code
1 /*-----------------------------------------------2 Name: Stepper Motor3 Forum: Www.doflye.net4 written by: Shifang5 Date: 2009.56 Modified: None7 content: This program is used to test 4 phase stepper motor Conventional drive using 1 phase excitation8 ------------------------------------------------*/9#include <reg52.h>Ten OneSbit a1=p1^0;//Defining stepper Motor Connection ports ASbit b1=p1^1; -Sbit c1=p1^2; -Sbit d1=p1^3; the - #definecoil_a1 {a1=1; b1=0; c1=0;d1=0;}//a phase power, other phase power off - #defineCOIL_B1 {a1=0; B1=1; c1=0;d1=0;}//b Power on, other phase power off - #defineCOIL_C1 {a1=0; b1=0; c1=1;d1=0;}//C phase Power, other phase power off + #definecoil_d1 {a1=0; b1=0; C1=0;d1=1;}//d phase power, other phase power off - #defineCoil_off {a1=0; b1=0; c1=0;d1=0;}//all power off. + AUnsignedCharSpeed ; at /*------------------------------------------------ - US delay function with input parameter unsigned char T, no return value - unsigned char is a variable that defines an unsigned character, and the range of its values is - 0~255 here use crystal oscillator 12M, accurate delay please use assembly, approximate delay - length as follows T=tx2+5 US - ------------------------------------------------*/ in voidDELAYUS2X (unsignedChart) - { to while(--t); + } - /*------------------------------------------------ the ms Delay function with input parameters unsigned char T, no return value * unsigned char is a variable that defines an unsigned character, and the range of its values is $ 0~255 here use crystal oscillator 12M, accurate delay please use assemblyPanax Notoginseng ------------------------------------------------*/ - voidDelayms (unsignedChart) the { + while(t--) A { the //Approximate delay 1mS +DELAYUS2X (245); -DELAYUS2X (245); $ } $ } - /*------------------------------------------------ - Main function the ------------------------------------------------*/ - Main ()Wuyi { theSpeed=5;//Adjust Speed - while(1) Wu { -Coil_a1//encounter coil_a1 with {a1=1; b1=0; c1=0;d1=0;} Replace AboutDelayms (speed);//change this parameter to adjust the motor speed, $ //the smaller the number, the greater the speed, the less torque - COIL_B1 - delayms (speed); - COIL_C1 A delayms (speed); + coil_d1 the delayms (speed); - } $}
[51 single-chip microcomputer] four-phase five-wire reduction ratio of 1/64 stepper motor Drive Design