Design of heavy object lifting control system based on Atmega16 single chip microcomputer

Publisher:幸福之星Latest update time:2011-10-24 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

With the development of microelectronics technology, electrical control methods have become more flexible and diverse, and the control accuracy has become higher and higher. In intelligent control, more and more control units with single-chip microcomputers as the core are used to realize intelligent control of equipment. This paper introduces the precise control of the displacement of heavy lifting with Atmega16 single-chip microcomputer as the control core.
1 Principle of heavy lifting control system
The design purpose of the heavy lifting control system is to use intelligent control technology to lift heavy objects to a predetermined height. As shown in Figure 1, it is a system control structure diagram. From the control structure diagram, it can be seen that the control system research object is the lifting and lowering of heavy objects. The main control object is the winch, and the control target is achieved through the forward and reverse motion of the winch.

The sensor in the figure uses a photoelectric encoder. A wheel is installed on the rotating shaft of the photoelectric encoder and fixed on the guide wheel. In this way, the photoelectric encoder and the guide wheel rotate coaxially, so that the angle of the photoelectric encoder is equal to the angle of the guide wheel. The distance the weight is lifted is the product of the circumference of the guide wheel and the total angle of rotation. Let the diameter of the guide wheel be d, and the number of pulses output per circle of the photoelectric encoder coaxially connected to it be k, then the pulse equivalent is:

2 Control method of the master-slave structure of the single-chip microcomputer
The research object of the engineering design is to control the rotation of the winch and lift the weight to a predetermined height. It is necessary to calculate the total number of pulses of the operation before operation; the design requires that the display screen can display the height of the weight in real time, and the collected data needs to be processed in real time during operation to calculate the moving distance; it also requires the setting of the height of the weight and the circumference of the guide wheel, and the set parameters must be able to be stored and read out, which requires an intelligent device with storage function. The Atmega16 single-chip microcomputer can complete data processing, contains an EEPROM storage area, and can save data even when the power is off. It contains 2 external input counters, which can realize counting tasks and simplify the hardware circuit. After comprehensive consideration, this design selects Atmega16 microcontroller as the core device to achieve the task requirements. In order to simplify the structure and highlight the module design, a dual-chip structure is adopted, and the control requirements are achieved by the design method of master and slave mode. The host unit is responsible for processing sensor signals, setting human-machine interface parameters, and real-time data processing. The slave unit is responsible for receiving the signal sent by the host and responding to the host's decision to output real-time control instructions.
3 Photoelectric encoder measures displacement
Photoelectric encoder is a sensor that converts the mechanical geometric displacement on the output shaft into pulses or digital quantities through photoelectric conversion. This is the most commonly used displacement measurement sensor in high-precision control systems. The photoelectric encoder consists of a grating disk and a photoelectric detection device. The grating disk is a circular plate with a certain diameter and several rectangular holes opened in equal parts. The principle diagram is shown in Figure 2. By calculating the number of pulses output by the photoelectric encoder, the current drag displacement can be known, and the speed measurement can also be achieved by calculating the number of pulses output by the photoelectric encoder per second. When measuring displacement
with a photoelectric encoder, not only the size of the displacement but also the positive and negative directions of the displacement must be known. Determining the direction is the key to successful measurement. The photoelectric encoders currently seen on the market are 4-wire interfaces or 5-wire interfaces. The photoelectric encoder with a 4-wire interface can output two pulses, A and B, and the 5-wire interface can output three pulses, A, B, and Z. The A and B pulses output by the photoelectric encoder differ in phase by 90°. When rotating forward, A leads B by 90°, and when rotating reversely, B leads A by 90°. In the measurement, the direction sign of the displacement can be determined based on the phase difference between A and B. Through the signed addition operation, the number of output pulses can be known and the displacement can be calculated.
4 Sensor signal extraction circuit design
As shown in Figure 3, the sensor signal extraction circuit. After the signal output by the photoelectric encoder is shaped by 74LS244, the ideal A and B phase waveforms are output. U3 (74LS74) is a D flip-flop. The A phase of the shaped square wave signal output by the sensor is input to D1, and the B phase is used as the clock signal CK of the D flip-flop. U3 and U9 (7400) together form a phase detection circuit to determine whether the photoelectric encoder disk is rotating forward or reverse.

When the photoelectric encoder rotates forward, the output waveform of channel A leads the output waveform of channel B by 90°, the output Q of the D flip-flop is high, Q is low, the upper U9A NAND gate is closed and keeps high, and the counting pulse cannot pass through U11; at this time, the lower U9B NAND gate is opened, and its output counting pulse D can be smoothly transmitted through U12, as shown in Figure 4(a).
When the photoelectric encoder rotates counterclockwise, the output waveform of channel A lags 90° behind the output waveform of channel B, the output Q of the D flip-flop is low, Q is high, the upper U9A NAND gate is opened, and its output counting pulse C can be transmitted through U11; at this time, the lower U9B NAND gate is closed and keeps high, and the counting pulse cannot pass, as shown in Figure 4(b). [page]

5 Calculation of displacement of heavy objects
The Atmega16 microprocessor contains three independent timer/counter modules, of which T/C0 and T/C2 are 8-bit timer/counter modules, and T/C1 is a 16-bit timer/counter module. In the hardware design, T0 and T1 are selected as forward and reverse counters to record the number of positive and negative pulses output by the photoelectric encoder. In the software design, the T0 and T1 counters must be expanded to have enough counting space to expand the displacement measurement range. When designing the software, the author expanded T0 and T1 so that they are both in the form of long integers (32 bits), and the overflow interrupt was used. In this way, T0 counts 256 pulses and generates an interrupt once, and T1 counts 65,536 pulses and generates an interrupt once.
The T0 and T1 control register settings and overflow interrupt generation procedures are:

TCCR0=0x06; //Counting pulses are input from the T0 pin, and the falling edge is valid.
TCCR1B=0x06; //Counting pulses are input from the T1 pin, and the falling edge drive
is valid.

#pragma interrupt_handler timer1_ovf_isr:9 //Positive count 16 bits
void timer1_ovf_isr(void){
cnt1++; //32-bit count
}
#pragma interrupt_handler timer0_ovf_isr:10 //Negative count 8 bits
void timer0_ovf_isr(void){
long c;
cnt0++; //32-bit count
c=(cnt0>>8); //Prevent cnt0,cnt1 from overflow
if(c && (cnt1>=c))
{cnt1-=c; //Calculate the count difference
cnt0=cnt0&0xff; //Only keep the lower 8 bits
} }
In the design, the S38-J3V100 photoelectric encoder is selected, and the output code is 500 codes/rev. The pulse equivalent is πd/500, and the current displacement is the product of the total number of pulses and the pulse equivalent. The software calculation procedure is as follows:

posicnt=(cnt1<<16)|TCNT1; //Number of positive pulses
negcnt=(cnt0<<8)|TCNT0; //Number of negative pulses
totalcnt =posicnt-negcnt; //Total number of pulses that generate large displacement
curPosi=(totalcnt*(meterCyl*1000+ CentCyl));
curPosi/=PLS_PER_ROUND; //Current displacement

After executing the run command, the microprocessor will calculate the set displacement and convert the displacement into the number of pulses. The number of pulses is compared during operation. If they are equal, the operation is stopped, indicating that the target position has been reached. The software calculation program is as follows:
sysStatus = SYS_RUN;
PosiSet=meterPosi*1000+CentPosi; //millimeter calculation
cntSet=(PosiSet*PLS_PER_ROUND)/(CentCyl+
meter Cyl*1000);
if(cntSet>totalcnt) Command=CMD_FWD;
//Execute forward command
else if(cntSet //Execute reverse command
else sysStatus=SYS_IDLE; //Stop state
The heavy object lifting control system designed in this scheme has achieved good dynamic performance, precise control and high intelligence in the actual operation process. Using photoelectric encoder as displacement sensor, high-precision control signal can be obtained. The cost-effective Atmega16 microcontroller greatly reduces the cost, improves the flexibility of software design, simplifies the hardware circuit design, and has good practical value.
References
[1] Li Jinsong. Design of real-axis incremental photoelectric encoder measurement circuit [J]. Laboratory Research and Exploration 2007.26(2): 12~14.
[2] Atmel Corporation.ATMEG16 User Manual [Z]. Atmel Corporation, 2002.
[3] Atmega16/Atmega16L Datasheet: 8 b Microcont roller with 128K bytes in 2 System Programmable Flash [Z].
[4] Yan Shi. Fundamentals of Digital Electronic Technology [M]. Beijing: Higher Education Press, 1997.
[5] Shen Wen, Zhan Weiqian. Getting Started Guide to C Language Development of AVR Microcontroller [M]. Beijing: Tsinghua University Press, 2003.
[6] Ma Chao, Zhan Weiqian, Geng Degen. ATmega 8 Principle and Application Manual [M]. Tsinghua University Press, 1998.

Reference address:Design of heavy object lifting control system based on Atmega16 single chip microcomputer

Previous article:Implementation of serial port protocol networking by single chip microcomputer
Next article:Research on H4001 non-contact IC card reading program

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号