Hello everyone, through the previous study, we have learned and become familiar with the use and learning methods of ICD2 simulation burner and enhanced PIC experiment board, and learned how to use single chip microcomputer to control light-emitting tube, relay, buzzer, button, digital tube, RS232 serial port and other resources, and realized the ease of use and learning of the learning board. After reading the examples in the previous issues, you must be very excited and have a sense of accomplishment when your experiment is successful! Now we will strike while the iron is hot and take another step forward to learn the working principle and use of stepper motors. This is the beginning of our use of single chip microcomputer to control mechanical movement.
A stepper motor is an actuator that converts electrical pulses into angular displacement. When the stepper driver receives a pulse signal, it drives the stepper motor to rotate a fixed angle (step angle) in the set direction. By controlling the number of pulses to control the angular displacement, accurate positioning can be achieved; at the same time, the speed and acceleration of the motor can be controlled by controlling the pulse frequency to achieve the purpose of speed regulation; the direction of rotation of the stepper motor can be controlled by changing the power-on sequence of each phase.
Characteristics of stepper motors
1. The angular displacement of the stepper motor is strictly proportional to the input pulse. Therefore, it has no cumulative error and has good followability.
2. The stepper motor has fast dynamic response and is easy to start and stop, reverse and change speed.
3. The speed can be smoothly adjusted within a fairly wide range, and a large torque can still be obtained at low speed. Therefore, the load can generally be driven directly without a reduction device.
4. The stepper motor can only operate by being powered by a pulse power supply. It cannot directly use AC power supply and DC power supply.
So how do we control the rotation of the stepper motor? For a DC motor, we just need to add voltage to the two poles of the motor, and the motor will rotate immediately, but this is not the case with a stepper motor. It is a digital control method, which converts electrical pulse signals into angular displacement, that is, when a pulse signal is given, the stepper motor rotates an angle, so it is very suitable for the control of a single-chip microcomputer.
Generally, a complete stepper motor control system includes three parts: controller, driver, and motor. The block diagram is shown in Figure 1:
Figure 1 Stepper motor control system
Now, we take the reactive stepper motor as an example to introduce its basic principles and application methods. The reactive stepper motor can achieve large torque output, and the step angle is generally 1.5 degrees. The rotor magnetic circuit of the reactive stepper motor is made of soft magnetic material, and the stator has multi-phase excitation windings, which use the change of magnetic poles to generate torque. The actual object of the commonly used small stepper motor is shown in Figure 2. This stepper motor can be directly connected to our enhanced PIC experiment board to complete the stepper motor control experiment.
Figure 2 Physical picture of stepper motor
Excitation method of stepper motor.
The excitation modes of stepper motors are generally divided into 1-phase excitation, 2-phase excitation, and 1-2-phase excitation.
When the 1-phase excitation is used, the stepper motor is energized in a cyclic manner, and only one phase is energized at a time. The magnetic field rotates one circle and needs to be changed phase 4 times, and the rotor rotates one pitch angle. Its energization method is the simplest and has the smallest torque. See Table 1 for the excitation method.
Table 1 1-phase excitation mode
When two phases are excited, each time two phases are energized at the same time, the magnetic field needs to be switched 4 times for one rotation, and the rotor rotates one pitch angle. In the double three-beat working mode, the power-on sequence for the forward rotation of the stepper motor is: ; the power-on sequence for the reverse rotation is:
The advantages of the double triple-beat working mode are:
It can generate a larger torque and is not prone to losing steps. See Table 2 for the excitation method.
Table 2 2-phase excitation method
1-2 phase excitation is a method of alternating 1-phase excitation and 2-phase excitation. The magnetic field needs to be changed 8 times for one rotation, and the rotor rotates through a step angle, which is a half-step method. That is to say, the step angle of 1-2 phase excitation is half of the step angle of the first two methods, so the step accuracy is doubled. See Table 3 for 1-2 phase excitation method.
Table 3 1-2 phase excitation mode
Stepper motor application drive circuit
There are two types of stepper motor drive circuits: unipolar DC drive and H-bridge drive. The small stepper motor in this example uses the simplest unipolar DC drive circuit. The purpose is to verify the use of stepper motors. In formal industrial control, it is generally more complicated. The simple drive circuit is shown in Figure 3.
Figure 3 Unipolar DC drive circuit for stepper motor
In practical applications, there are usually more than one drive path. The discrete circuit shown in Figure 3 is large in size and the consistency of parameters of each path is difficult to guarantee. It is best to use a ready-made integrated circuit as a multi-path driver. Commonly used small stepper motor drive circuits can use ULN2003 or ULN2803. ULN2003 is used on our experimental board. ULN2003 is a series of high-voltage and high-current Darlington transistor array products with high current gain, high operating voltage, wide temperature range, strong load capacity, etc., and is suitable for various systems requiring high-speed and high-power drive.
ULN2003A consists of 7 groups of Darlington transistor arrays and corresponding resistor networks and clamping diode networks. In this example, only 4 groups are actually used. The internal structure of ULN2003 is shown in Figure 4, and the equivalent circuit diagram of Darlington transistor is shown in Figure 5.
Figure 4 ULN2003 internal structure diagram
Figure 5 Darlington transistor equivalent circuit diagram
The typical application circuit block diagram of the ULN2003A high-voltage and high-current Darlington transistor array circuit is shown in Figure 6. The clamping diode is used to protect the back electromotive force from breaking through the integrated circuit when the coil is turned on and off. It can be seen that the circuit is much simpler than discrete components after applying ULN2003.
Through the introduction of the principle in the previous article, we have a general understanding of the characteristics and working principles of stepper motors, but when we get a stepper motor, we still don’t know how to use it correctly. For example, what should we do if we want to control the motor to rotate forward, reverse, high-speed, or low-speed? To control the forward and reverse rotation of a stepper motor is not as simple as a DC motor. It is not as simple as adding a positive and negative power supply to both ends of the motor. Instead, it is controlled by outputting "forward and reverse" timing pulses with different rules. Now, let's take a look at how to control the forward and reverse rotation and rotation speed of a stepper motor. Through an example, I believe it will give you a perceptual understanding.
First, let's take a look at the stepper motor control circuit on the enhanced PIC experiment board, because we need to combine software and hardware to consider how to program. The circuit schematic of the stepper motor control part is shown in Figure 7. The RD0~RD3 of the PIC microcontroller is the motor pulse output pin, which drives the small stepper motor through the ULN2003 integrated chip. We just need to plug the plug of the stepper motor directly into the J3 socket of the board. Jumper J4 is the stepper motor intelligent power supply jumper designed for the experiment board, so that the experiment board can be applied to stepper motors with different working voltages. When the jumper jumps to the VCC end, the stepper motor is provided with VCC +5V power supply. The working voltage of the stepper motor used in our experiment is 5V, so we can set the jumper to the VCC end. If the user uses his own stepper motor voltage that is not 5V, then the jumper can be jumped to the VIN end, that is, the user's external power supply is provided to the stepper motor working voltage.
For the programming of the microcontroller software, we use MPLab IDE software for C language programming, which is our programming environment. At the same time, we can use the ICD2 simulation burner and the enhanced PIC experimental board to connect the program for simulation debugging and burning steps. We have already made detailed descriptions and introductions of the specific operation steps in previous issues, so we will not repeat them here. Readers can refer to previous articles or log in to our website directly to view the information. Now we can enter the program code for debugging. We create a new project in MPLabIDE software, add source code, and select the chip model and set the configuration bit. The chip model used in our experiment is PIC16F877A. The program code written is as follows:
/* Stepper motor demonstration program */
#include #define key RB0 void delay(void) { int k; for(k=0;k<2000;k++); } void main() { TRISD=0x00; //Set RD as output port TRISB=0xFE; // Set RB0 as output port, RB1~RB7 as input port PORTD=0x00; // Initialize RD output low level key=1; //Set the button to input state while(1) // Main loop { if (key == 1) // If no key is pressed, the motor will rotate forward { PORTD=0xFC; //1100 delay(); PORTD=0xF6; //0110 delay(); PORTD=0xF3; //0011 delay(); PORTD=0xF9; //1001
Previous article:PIC microcontroller I2C bus
Next article:Temperature acquisition of PIC microcontroller
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- The ov7725 camera has serious distortion. What's going on?
- 【CH579M-R1】+Help: How to receive complete serial port data
- Regarding the calculation of the values of TA0CCR1 and TA0CCR2 configured by the PWM library function
- What does the Y axis of the graph displayed by the baud meter mean? For example, if it starts at 5DB and ends at -100DB, how do you understand it? Attenuation signal...
- Ask SAMD21 question
- LORA SX1308
- Newbie question: When using the PCB antenna library, one of the antenna pins is not connected. I want to know how to solve it.
- Why is this power circuit connected like this?
- 【National Technology N32G430】03 Development foundation, the platform is emerging
- Four major Bluetooth antenna design methods