Subdivision control principle and application of instrument stepper motor based on ATMEGA48 single chip microcomputer

Publisher:jingyanLatest update time:2012-07-11 Source: 21ic Keywords:ATMEGA48 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Instrument stepper motor

The stepper motor is an open-loop control element that converts electrical pulse signals into angular displacement or linear displacement. In the case of non-overload, the motor speed and stop position only depend on the frequency and number of pulses of the pulse signal, and are not affected by load changes, that is, when a pulse signal is added to a phase coil of the motor, the motor rotates a step angle. The existence of this linear relationship, coupled with the characteristics of the stepper motor having only periodic errors but no cumulative errors, makes it very simple to use stepper motors to control in the fields of speed, position and other control. Although stepper motors have been widely used, they are not used in conventional conditions like ordinary DC motors and AC motors. They must be used under a control system composed of dual ring pulse signals, power drive circuits, etc.

Instrument stepper motors belong to the category of stepper motors with smaller size and power consumption. They can be directly driven by the pins of a microcontroller or a dedicated chip without the need for an external driver. Therefore, they are used to control the rotation of pointers in instruments.

Demand Analysis

The instruments used in this scheme have the following characteristics and design parameters:

●The pointer responds sensitively and moves accurately, that is, it cannot lose steps after receiving the drive pulse;

●The pointer rotates smoothly, that is, the pointer moves smoothly from the current position to the target position, and there should be no jitter in the forward and reverse directions;

●Two phases, step angle 10o, rotation range 300o.

According to the technical parameters, the step angles of two-phase four-beat and two-phase eight-beat are 10° and 5°, and only 30 and 60 scale divisions can be made within the range of 300°. In practical applications, it is found that the pointer step angle cannot meet the requirements and jitter is inevitable. In order to achieve high-precision accurate positioning and smooth operation of the pointer, the stepping motor step must be subdivided with high resolution, which is also the difficulty of the design.

The subdivision technology of stepper motor is an electronic damping technology, and its main purpose is to improve the running accuracy of the motor and realize the high-precision subdivision of the step angle of the stepper motor. The basic concept is: the step angle of the stepper motor becomes smaller through the drive of the subdivision driver. For example, when the driver works in the 10-subdivision state, its step angle is only one-tenth of the inherent step angle of the motor. Take two-phase four-beat as an example: when the motor works in the full-step state without subdivision, the control system sends a step pulse each time, and the motor rotates 10o; when the subdivision driver works in the 10-subdivision state, the motor only rotates 1o. The subdivision function is completely realized by the driver or the single-chip microcomputer by accurately controlling the phase current of the motor, and has nothing to do with the motor itself.

Segmentation principle

The driving state table of two-phase four-beat A, B, /A, /B is shown in Table 1.

The driving state table of two-phase eight-beat A, B, /A, /B is shown in Table 2. [page]

From the above analysis, we can know that two-phase four-beat is a full-step operation without subdivision, and two-phase eight-beat is actually 2 subdivisions. The angle between the synthetic magnetic field and the current vector changes in the manner of 90o and 45o, and so on.

After referring to relevant materials, it is not difficult to find that subdivision drive technology often uses a step-type current that is close to a sine wave instead of a rectangular wave current to generate a micro-step rotating magnetic field, thereby driving the motor to rotate at a smaller step angle. Its current waveform and rotating magnetic field vector are shown in Figure 1. At the same time, due to the smooth change of the sine wave current, the motor runs more smoothly and with less noise. That is, by changing the magnitude and direction of the current of the adjacent two phases (A, B) (the A phase sine wave and the B phase cosine wave vector are superimposed), the angle of the synthetic magnetic field is changed, and the operation of the stepper motor is controlled by the current vector synthesis method.


Hardware design and software programming

According to the subdivision principle, for a two-phase stepper motor, the voltage and direction of the two sets of coils need to be controlled simultaneously to achieve the purpose of synthetic current vector control. There are two solutions to control the current of the coil: one is to write digital quantities through the microcontroller, and the analog-to-digital converter outputs analog voltage to control the coil current; the other is to output a duty cycle-controllable square wave through the PWM pin of some microcontrollers, and use its AC effective value to control the coil current. Obviously, the duty cycle that changes according to the sinusoidal law determines that the coil current also changes according to the same sinusoidal law. The direction of the coil voltage application can be achieved through a logic gate circuit.

In summary, the ATMEGA48 microcontroller with two 16-bit precision PWM functions is selected, and the peripheral hardware circuit design is shown in Figure 2.


Use the PB1 and PB2 with PWM function of the microcontroller to connect PWM_A and PWM_B, and use two ordinary pins to connect DIR_A and DIR_B to control the motor. The principle is as follows: A, /A, B, /B of the motor correspond to 3, 6, 8, 11 pins of the four-input AND gate circuit respectively. When DIR_A and DIR_B are low, the 1 and 9 pins of the gate circuit are in the 0 state, the transistors Q3 and Q4 are cut off, and the 4 and 12 pins of the gate circuit are in the 1 state due to the pull-up. In this way, the 3 and 8 outputs of the AND gate circuit are 0, that is, A and B are 0; at this time, the 6 and 11 outputs of the AND gate circuit are consistent with PWM_A and PWM_B, that is, /A and /B are determined by PWM_A and PWM_B. In other states, it also has similar characteristics: the polarity of the conduction between A and /A, and between B and /B is determined by DIR_A and DIR_B; the current between A and /A, and between B and /B is determined by the duty cycle of PWM_A and PWM_B. Moreover, as long as transistors Q3 and Q4 work normally, there will be no logical confusion in the AND gate circuit.

In conjunction with the hardware design, an array of 64 data was written in the software, corresponding to the 8-bit digital quantization values ​​of the sine wave amplitude change from 0 to 90 degrees (simulating 64-point sine wave sampling in a step wave manner). Each value is used to control the duty cycle of the output waveform, and actually participates in the calculation of the current magnitude during the process of the current vector angle rotating 90 degrees. As we all know, the phase difference between sine and cosine waves is 90o. After the sine wave amplitude variation table of 0~90o is known, the sine wave and cosine wave amplitude variation tables of 90o~180o, 180o~270o, and 270o~360o (0o) can also be obtained. Therefore, through the evolution of the 8-bit digital quantization table of the sine wave amplitude variation of 0~90o, the current vector angle can be divided into four quadrants on the basis of two-phase eight beats (two subdivisions). With the control of polarity, 8 combinations of A or/A sine wave and B or/B cosine wave can be made in each quadrant. The current size can be changed in each combination, and finally two-phase 64 beats (16 subdivisions) control can be achieved. Moreover, the most ingenious point is that by selecting 64 data corresponding to 64 points of the sine wave in the range of 90 degrees, one byte can be used as a mark to distinguish the four quadrants, which is convenient for the evolution of the sine and cosine angles, that is, 0~63 corresponds to 0~90 degrees, 64~127 corresponds to 90 degrees~180 degrees, 128~191 corresponds to 180 degrees~270 degrees, and 192~255 corresponds to 270 degrees~360 degrees.

The driving state table of two-phase 64 beats A, B, /A, /B is shown in Table 3 (with B as the starting state).

Since the change amount of the instrument pointer will be different when it points from the current angle to the target angle, in order to ensure that the pointer responds sensitively and without jitter, acceleration and deceleration control must be considered during positive and negative rotation. In the program, several control intervals can be set according to the size and positive and negative of the change amount, and different delay parameters can be written respectively. According to this delay parameter, the change time of the current size and direction (changing PWM_A and PWM_B, DIR_A and DIR_B) can be controlled to achieve the purpose of acceleration and deceleration control.

Conclusion

By controlling the two-phase stepper motor with dual PWM, the purpose of high-precision subdivision is achieved while optimizing the hardware cost. By adding a power drive circuit to the back stage of the existing circuit and making a small modification to the program, a high-precision, multi-subdivision stepper motor driver can be made.

Keywords:ATMEGA48 Reference address:Subdivision control principle and application of instrument stepper motor based on ATMEGA48 single chip microcomputer

Previous article:A Reconfigurable MAC Protocol Design Based on ARM and FPGA
Next article:Realization of intelligent auxiliary maintenance system for electric locomotive based on AVR microcontroller

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号