DC Motor PWM Speed ​​Controller Implemented by AVR Microcontroller

8535 and L298 drives constitute a DC motor PWM speed controller. The working principle of the speed control system, the interface circuit of the photoelectric encoder, the PWM drive interface circuit and the corresponding control software design are introduced in detail. designed. Two encoder signals can be acquired.

Count the number of interrupts of INT1 to measure the number of pulses on channel B, and read the level of PC6 (that is, phase A signal) to determine the direction of rotation of the motor. Take the rising edge trigger as an example. When the rising edge of the B signal causes an interrupt, the microcontroller determines the level of the PC6 signal. If PC6 is low, the motor rotates forward and the value of counter N increases by 1. If it is high, the motor is reversed and the value of counter N is decremented by 1. The motor speed is the value of N in one sampling cycle. The amount of change. The rotational speed of the motor is: c AN x c - scale conversion factor. The count value in AN sampling cycles can be selected according to the dimension of the rotation speed. Its sign reflects the rotation direction of the motor - sampling cycle 1.3L298 drive interface number Power amplification is required to drive the motor. The L298 drive chip is used in this speed control system. The drive interface circuit is as shown.

L298 has unipolar, bipolar two kinds of working methods. The unipolar mode of operation means that the armature of the motor is only subjected to a unipolar voltage within one PWM period; the bipolar mode of operation means that the voltage across the armature of the motor changes positively and negatively during a PWM period. Speed ​​control system uses a unipolar mode of operation. The EnB pin of the MCU controls the motor speed; PD6 or PD7 of the MCU is connected to the IN1~IN4 input pins of the L298 through a certain logic circuit. It controls the direction of rotation of the motor. In order to enhance the L298's drive capability, the speed control system has been used in parallel with the two drives of the L298. The maximum drive capability can be up to 3A. The comparator LM393 primarily serves to limit overcurrent and protect the L298. The non-inverting terminal of the LM393 is connected directly to a variable potentiometer. The potentiometer's voltage is adjustable. Adjusting the potentiometer's voltage adjusts the L298's current limit voltage. The inverting termination of the LM393 is connected to the two sense terminals of the SENSSE and SENSEB of the L298. When the voltage across the sense resistor is greater than the current-limiting voltage, the voltage at the inverting terminal of the comparator is greater than the voltage at the non-inverting terminal, and the output terminal outputs a low level, thereby pulling the L298's EnA and EnB enable terminals low, and the L298 stops operating. This serves to limit over-current and protect the L298.

2 Control Software 2.1 Overall Block Diagram Start the timer interrupt. In the loop of the main program, the command word of the motor rotation speed is first obtained from the host computer (or the one-chip microcomputer system itself), including the speed and the rotation direction of the motor. Then read the encoder module to obtain the actual speed of the motor, and the difference between the given speed and the actual speed to obtain the control deviation. Then, call the control algorithm (such as PI) module. Check, wait for the arrival of the time. If the timing does not arrive, call the display module to display some system-specific parameters; if the timing is up, call the PWM driver module to drive the motor. This forms the speed closed loop of this control system.

2 encoder interface software encoder interface software includes encoder interrupt response program and read encoder program in two parts. Encoder interrupt response program principle: If the encoder A connected to PC6, B is connected to the INT1. When the encoder interrupt (INT1) arrives, check the direction of the pin PC6, if it is 1, that high, N value The register is incremented by 1. If it is 0, the N value register is decremented by 1. The encoder interrupt response program is as follows.

Protection of the scene, the press branch is 1, jump execution; PC6 is, execute in tandem; N value of the register is reduced by 1; interrupt return read encoder module program principle: the N value of the previous sampling period and the current sampling cycle of N The value is used as the difference to obtain the number of pulse changes AN. The speed of the motor can be calculated by (1).

3 control algorithm software AVR microcontroller 8535 through the encoder module program to obtain the motor speed feedback signal, and then with the upper computer given (or the system to give) the speed signal is subtracted, the control volume deviation, after a certain control algorithm (such as PI) derives the control output value. The PI control algorithm program is as follows: the upper machine is given the speed multiplied by the proportional coefficient, the result is placed; proportional and integral results are added, to control the output L298 drive interface software, AVR microcontroller 8535 main work is Control the direction of rotation of the motor and output the control output in the form of PWM. The driver interface software program is as follows: outocrlaH, temp19 is the control output, which outputs outocrlaL in the form of PWM, tempi8 is positive bit inversion 3, from the experimental curve can be seen, the overshoot is less than 10%, the settling time is 150ms At left and right, the steady-state error is less than 5%. The system has better rapidity and control accuracy.

4 Concluding remarks The DC speed controller adopts AVR single-chip computer 8535 to realize the PWM speed control of the DC motor.

From the point of view of practical application, it achieves a good speed control of DC motors, and has the advantages of high precision, good fast response, and good stability. AVR microcontroller 8535 is a new type of microcontroller, which has a good application prospect. Applying it to PWM speed control of DC motors not only has good performance, but also is economical and reliable, and therefore has great practical value.

COLD DRAWN SEAMLESS TUBE PRECISION TUBEMaterialSt35.8, St44 ,St52, 20Mn2 ,10, 20,35,45, 16Mn,Q345,20G,20MnG, 25MnG,15CrMoG,12Cr1MoVG, J55,K55,N80,P110,T1,T5,T11,T22,T23,and so onSTANDARDDIN GB ISO JIS BA ANSIGRADESt35.8, St44 ,St52, 20Mn2 ,10, 20,35,45, 16Mn,Q345,20G,20MnG, 25MnG,15CrMoG,12Cr1MoVG, J55,K55,N80,P110,T1,T5,T11,T22,T23,and so onBRANDXLSIZEOD30-508mm WT3-80mmUSAGEindustry machinery

Type: Seamless
Technique: Cold Drawn
Material: Carbon Steel
Surface Treatment: Oiled
Usage: Pipeline Transport, Boiler Pipe, Hydraulic/Automobile Pipe, Oil/Gas Drilling, Machinery Industry, Mining, Construction & Decoration
Section Shape: Round

Cold Drawn Seamless Steel Pipe

Cold Drawn Seamless Carbon Steel

Liaocheng Xinglong Seamless Tube Manufacturing Co., Ltd. , https://www.lcxlpipe.com