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
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.
Previous article:Implementation of serial port protocol networking by single chip microcomputer
Next article:Research on H4001 non-contact IC card reading program
- Popular Resources
- Popular amplifiers
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
- KiCad calculates wire resistance and current passing through
- Optimizing DSP Power Budget by Adjusting Voltage Regulators
- Rapoo Multi-mode Bluetooth Mouse M600 Disassembly
- [Sipeed LicheeRV 86 Panel Review] 11- Audio Recording and Playback Test
- Reduce the allegro brd layout file version from 17.2 to 16.6
- UWB Market Outlook
- FPGA Design Rules
- Can single-threaded applications develop asynchronous tasks? How does the ACE JS framework do it?
- Protel/AD design software removes text
- 【FAQ】How to quickly understand LP50xx devices?