introduction
The most common flight state of a fixed-wing aircraft is horizontal flight. If it is allowed to fly at a large angle, the action cannot be maintained all the time. If it is allowed to fly perpendicular to the ground, the time it can maintain is even shorter. This project aims to realize a control system that allows the aircraft to fly perpendicular to the ground and stabilize at a fixed altitude. The three-axis acceleration sensor added to the fuselage is used to detect the attitude of the aircraft flying perpendicular to the ground. When the aircraft is detected to be swaying forward and backward, the horizontal tail is controlled to keep the aircraft stable in the forward and backward directions; when the aircraft is detected to be swaying left and right, the vertical tail is controlled to keep the aircraft stable in the left and right directions; when the aircraft is detected to be moving up and down, the throttle size (i.e. the speed of the propeller) is controlled to maintain the stability of the aircraft's flight altitude. When these controls are very precise, the fixed-wing aircraft can also hover steadily in the air like a helicopter. Using the control system designed in this article, the aircraft can turn 90° clockwise or counterclockwise (with a very small projection area) while decelerating in vertical flight, so as to reduce the projection area exposed to the aircraft behind and reduce the chance of being hit.
Design Overview
In order for the aircraft to fly vertically, the control circuit needs to have the following functions:
To determine whether the aircraft is flying vertically, for a real aircraft, it may be just a toggle switch to prevent false triggering; in the experimental remote control aircraft of this project, it is the pulse width signal of a certain channel. When the pulse width is greater than a certain set value, the control circuit knows that it is time to go into action.
Determining the aircraft's own attitude is one of the core parts of this control circuit. Before controlling the aircraft to maintain vertical flight, the aircraft's own attitude must be determined first. This project uses the MMA7260QT sensor to detect the aircraft's attitude.
Control This is the most time-consuming part of the design and production process of this project, but its principle is easy to understand: the attitude circuit has already understood the attitude of the aircraft, and the control circuit only needs to make corresponding actions. If the aircraft tilts forward, it will move the aircraft forward a little, and if it tilts backward, it will move it backward a little. There is another quantity that needs to be controlled - the altitude. The altitude of the aircraft should be kept stable when doing this action. The throttle should be reduced when the fuselage is rushing up, and the throttle should be increased when descending. To complete such control, two MC9S08QG8s are required. In order to achieve the above functions, this project should have a circuit block diagram as shown in Figure 1.
Two MC9S08QG8 chips are selected because there are two places in this project that have strict time requirements: one is to read the pulse width sent from the remote control; the other is to accurately send out the calculated pulse width. Both places must have an error within 10μS. If one chip is used, there will be conflicts even if interrupts are used. The general distribution of the work of the two MC9S08QG8 chips in this project is: one chip is used as the main control, which is used to read the pulse width sent by the remote control and received by the receiver (high real-time performance), read the aircraft attitude (low real-time performance), control calculation (PID calculation) and data transmission (send the data on how to control the aircraft, that is, the result of PID calculation, to another MCU); the other chip is used as an auxiliary chip, and only needs to send the read data to the aircraft's actuator in real time.
Hardware Description
The hardware circuit is shown in Figure 2.
The data of the three axes output by the sensor MMA7260QT are respectively sent to the three A/D input terminals ADP0, ADP1 and ADP2 of the main control MCU. The power supply is connected to a resistor and an inductor to prevent the power supply from interfering with the sensor.
The power supply of the whole circuit is introduced from the receiver through J1, and then converted to 3.3V by 78FC33 to power the MCU and sensor. J2, J3, and J4 are for left and right, throttle, and front and rear control respectively.
The capture input terminal TPMCH1 of the second TPM of the main control MCU is connected to the signal output terminal of the receiver. This remote control system is 9-channel, that is, it can control 9 mechanisms at the same time. The signal of this 9-channel is shown in Figure 3. It is composed of pulse trains with an interval of 20ms. Each pulse train has 9 pulses. The interval between the rising edges of two consecutive pulses is the effective control signal sent by the remote control. This interval is at least 1ms and at most 2ms. After TPM captures the width of 9 pulses, it can be sent directly to the servo according to needs or after PID calculation. As for how to identify whether a pulse is the end of the previous pulse train or the beginning of the next pulse train, this involves the concept of a synchronization pulse, which belongs to the software content and will not be explained here.
The serial output terminal of the main control MCU is connected to the serial input terminal of the auxiliary MCU. If the main control MCU wants to control the aircraft's movements, it only needs to send data to the auxiliary MCU through the serial port. The sending format is shown in Table 1, with a total of 8 characters, of which 0xAA and 0x55 are guide bits...
Three LEDs, D1 is the power indicator, D3 is used to indicate "I am the control circuit, I have started to control the aircraft to fly vertically", and D2 is "something went wrong, be careful of problems, switch back to your control quickly."
[page]
The auxiliary MCU has two tasks: one is to read the serial data sent by the main control MCU, and after finding the guide character, send the front, back, left, right, up, down (throttle) data into the corresponding array for storage; the other is to send the data in the corresponding array in the form of pulses every 20ms. The minimum pulse is 1ms and the maximum is 2ms. After this signal is sent to the aircraft's actuator - the servo, the corresponding output pattern is shown in Figure 4. A 1ms pulse puts the servo rocker arm in the leftmost position, a 1.5ms pulse puts the servo rocker arm in the middle position, and a 2ms pulse puts the servo rocker arm in the rightmost position. The servo rocker arm is connected to the aircraft's actuators, and when the rocker arm is shaken, the aircraft's actuators (such as the tail, etc.) also swing.
Software Description
For the main control MCU part, the flow chart is shown in Figure 5.
·Read remote control signal: This remote control signal is shown in the upper right corner of Figure 5. It is a pulse train composed of 9 pulses, one pulse per 20ms. The reading method is as follows: After the TPM captures the rising edge of the pulse and enters the modulo timer capture interrupt program, first check whether it is the first in the pulse train. If it is, clear the timer and then store the captured value in the array. After 9 times, the array stores the time of each pulse from low to high. By subtracting, the width of each pulse is obtained. In order to prevent errors, pulse number error prevention is added, which is to count the number of pulses. If more than 9 pulses are read in a pulse train, it means interference, and all pulse widths need to be processed as soon as possible according to the middle value of 1.5ms. Although this is different from the instructions issued by the remote control, it reduces the chance of major problems.
[page]
8ms timing interrupt: The system has a modulo timer 18ms interrupt program. Because a normal pulse train of 9 pulses will not exceed 18ms, the timer can be allowed to count at the beginning of the first pulse. When it reaches 18ms, it is considered that a pulse train has ended and the pulse counter is cleared. When the counter is cleared in the modulo timer capture interrupt program, it knows that the next pulse train has started. This interrupt also provides a time mark for the PID timing operation. The mark is set every time an interrupt is entered. The main program performs PID operation when it reads that the mark is set, thus ensuring that the cycle of the PID operation is fixed.
1.67ms interrupt program and A/D interrupt program: In order to read the data output by MMA7260QT, A/D reading is required. Here, an interrupt is entered every 1.6667ms to set the A/D channel. It takes 5ms to read three channels. Within the standard interval of 20ms between two pulse trains, four readings can be made for each channel. The sliding average algorithm can be used to filter out interference.
Main program introduction
Although the sensors are placed horizontally, the outputs of the three axes are different from the calculated outputs due to differences in temperature, voltage, etc., and there will be a slight deviation. To solve this problem, after power-on, the values of the three axes are read 64 times in succession and then averaged. This average value is used as the target value for the aircraft to stabilize, so that the aircraft is basically stable.
PID plays an indispensable role in stability. There are two points to mention about PID in the main program. First, due to the stability of the sensor and the jitter of the aircraft, it is normal for the A/D output value to differ by 2 or 3 numbers, so it is necessary to judge in the main program. If the error value is within 3, the PID operation will not be performed, thus reducing the unnecessary jitter of the servo. Second, because the weight of the front, back, left and right of the aircraft is inconsistent, different P values should be used for calculation when the aircraft tilts forward, backward, left and right.
The main program updates data every 20ms, and the data is the width of the control pulses of front, back, left, right, up and down. Should this data be directly used as the number captured in the modular timer capture interrupt program or the data of PID calculation? This is determined by a pulse width (the pulse width that determines whether the aircraft should fly vertically at this time). The pulse width used here is the pulse width of the 7th pulse, which is the 7th channel of the remote control. This parameter is named Helen. When Helen >1500 (1.5ms), it means that the operator wants to fly vertically and output the PID calculation data; when Helen <1500, it is a normal flight, and the number captured in the modular timer capture interrupt program can be directly output.
To get the width of each pulse, just subtract the time when each pulse occurs from low to high. This subtraction operation is also completed in the main program. After the subtraction is completed, the pulse width must be processed for errors. Check that less than 1ms is counted as 1ms, and greater than 2ms is counted as 2ms. After processing, the send interrupt can be called to send to the auxiliary MCU. The calling method is to arrange the array, clear the send data counter, and turn on the send interrupt enable bit. At this time, the send buffer is empty. Once the send interrupt is enabled, it will immediately enter the interrupt and start sending.
Serial port sending interrupt program: After the program enters this interrupt, it first sends the number indicated by the sending data counter to the sending buffer for sending. If the sending is completed, the sending interrupt enable bit is cleared to prevent the interrupt from entering again after the data being sent is sent; if the sending is not completed, it exits directly and waits for the next interrupt.
The auxiliary MCU program flow chart is shown in Figure 6.
Serial port receiving interrupt: The key to assisting the MCU program is the serial port receiving interrupt. The received number should be stored in the specified array. This is easy to implement, but it is not so easy to find the boot header, because 0xAA and 0x55 as the boot header may also be data. Only the connected ones are the boot headers. The judgment method is detailed in Figure 6.
Because this MCU has only two timers, but needs to control three pulses, two pulses are implemented using the PWM function of the timer, and the other pulse needs to be simulated by software. The method used in this article is to use a 20ms interrupt, set the I/O port after entering the interrupt, and then loop in the main program to judge the timer value. When the timer value is greater than the pulse value to be sent, reset the I/O.
Previous article:Noise Analysis and Design of Class D Audio Preamplifier
Next article:USB Implementation Solution Based on DSP and Special Interface Chip
Recommended ReadingLatest update time:2024-11-16 23:57
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
- Mir T527 series core board, high-performance vehicle video surveillance, departmental standard all-in-one solution
- Akamai Expands Control Over Media Platforms with New Video Workflow Capabilities
- Tsinghua Unigroup launches the world's first open architecture security chip E450R, which has obtained the National Security Level 2 Certification
- Pickering exhibits a variety of modular signal switches and simulation solutions at the Defense Electronics Show
- Parker Hannifin Launches Service Master COMPACT Measuring Device for Field Monitoring and Diagnostics
- Connection and distance: A new trend in security cameras - Wi-Fi HaLow brings longer transmission distance and lower power consumption
- Smartway made a strong appearance at the 2023 CPSE Expo with a number of blockbuster products
- Dual-wheel drive, Intellifusion launches 12TOPS edge vision SoC
- Toyota receives Japanese administrative guidance due to information leakage case involving 2.41 million pieces of user data
- 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
- Liyuan Award Live Broadcast: Interpreting ON Semiconductor Power Solutions, Transforming Server Power Supplies and Solar Inverters
- CC2640R2F Battery Fuel Measurement
- 【AT-START-F425 Review】Use of GPIO port and OLED screen display driver
- How to dynamically open the Bluetooth kernel log for the Allwinner V853 chip?
- Regarding the problem of leakage current when the MOS tube is not completely turned off
- Detailed explanation: ground wire and power wire
- EEWORLD University - Introducing the SimpleLink? MCU Platform
- In a battery-powered low-power product, the ADS/DIR/open-drain/pull-up/pull-down settings of each port pin
- Introduction on how to encapsulate functions into libraries
- Basic principles of PCB anti-interference design