introduction
This paper introduces the application of single-chip microcomputer Atmega128 in a satellite ground measurement and control system. The system uses Atmega128 to complete the measurement of 10 analog signals, the frequency measurement of 4 pulse signals and the measurement of pulse width. The 16-bit timing counter on the single-chip microcomputer outputs two signals with a phase relationship with the input signal, and communicates with other test modules and industrial computers through the external serial port. Since the system is required to work continuously and stably for 3 years and data cannot be lost, a dual power supply redundant hot backup solution is adopted in the design, and a design solution of two industrial computers receiving data at the same time and backing up each other is adopted.
Figure 1 Structure diagram of satellite ground measurement and control system
Figure 2 Hardware schematic diagram of the test box
Figure 3 Phase relationship between electric and earth waves
Hardware Design
Atmega128 belongs to Atmel's AVR series of microcontrollers. It is a high-performance, low-power 8-bit controller that only needs one clock cycle to execute most instructions. Its maximum main frequency can reach 16MHz; it comes with 128KB online programmable flash memory, 4KB EEPROM, 4KB SRAM, and the program can be encrypted; it comes with a JTAG interface for easy program debugging; integrated peripherals: two 8-bit timer counters, two 16-bit timer counters, two 8-bit PWM channels, 6 16-bit PWM channels, 8 10-bit ADC channels, an I2C interface, two programmable asynchronous serial interfaces, an SPI interface, a watchdog timer and 8 external interrupt sources.
The satellite ground measurement and control system is mainly composed of power supply module, electronic chassis, test box, industrial computer and infrared earth sensor. The system structure is shown in Figure 1. Two power supplies are connected in parallel, and the output is connected in series with diodes. In the entire measurement and control system, the control function of the test box is completed by Atmega128.
The hardware principle of the test box is shown in Figure 2. The test system is based on the AVR microcontroller, and the peripheral circuits are composed of serial communication, ADC sampling and DAC output.
The single-chip microcomputer and the industrial computer communicate with each other through the RS-232 standard bus. The level conversion chip MAX202 is used in the design to achieve level compatibility between the two. In order to be able to communicate with other modules of the test system through serial ports, the dual serial port chip ST16C2552 of Xicor Company is used to expand two serial ports. Since the signal communicating with the expanded serial port is -12V~+12V, which is not a standard level, a level conversion circuit must be designed separately. The programmable logic device EPM7128 of Altera Company is used to realize the logic control of DAC and ADC; the 12-bit ADC of BB Company is used to realize the measurement of telemetry signals; the 12-bit DAC chip DAC7615 of BB Company is used to generate electrical earth wave signals.
The specific functions are as follows:
ADC measurement: The 10 input analog signals are connected to the channel selector after impedance matching, and then connected to the signal input end of the ADC chip ADS7835. The ADC output signal and control signal are connected to the EPLD logic through optical isolation. The ADC start signal, conversion channel selection, and clock signal and data signal control are implemented inside the logic.
DAC output: The microcontroller controls the chip select, clock, data and other signals of the DAC through the logic chip. The output signal of the DAC is optically isolated and impedance matched by the operational amplifier before being connected to other modules of the entire test system. The stability of the DAC reference voltage is very important. If the reference voltage is not stable, the output of the entire DAC will fluctuate greatly and fail to meet the output accuracy requirements. Therefore, a voltage regulator chip AD584 is used to provide the reference voltage to the DAC.
Frequency measurement: The electric measuring box needs to measure 2 reference signals and 2 grating signals, and the measurement is realized by using the external interrupt and counters 1 and 3 of the AVR microcontroller. The 2 reference signals are connected to the external interrupts INT0 and INT1 of the microcontroller, and the grating signals are connected to the counters 1 and 3 of the microcontroller. Among the various functions that need to be realized by the electric measuring box, the output of the electric earth wave is a difficult point, because the output of the electric earth wave needs to have a phase relationship with the reference signal, and the output is required to have a variable phase, amplitude and slope. This article realizes the output of the electric earth wave through the comparison interrupt of counters 1 and 3.
Serial communication: Through the two asynchronous serial ports of the microcontroller, it communicates with the upper industrial computer after level conversion, and communicates with other modules of the test system through two external serial ports of the dual serial port chip ST16C2552. In addition, to ensure the reliability of the system, all signals are optically isolated.
Software Implementation
MCU Software
The underlying software running on the microcontroller is mainly responsible for ADC acquisition, DAC output and serial port communication. The following is a detailed introduction to each part:
1. Grating frequency measurement: measure the number of gratings in one cycle of the analog reference
In the program, each time the external interrupt 0 handler void int0_isr(void) is entered (i.e. when the rising edge of the reference pulse arrives), the void do_gd_opt_frq() function is called to measure the grating frequency.
In the do_gd_opt_frq() function, the count value of counter 1 read the previous time is first saved in the global variable time1_prev, and then the value of counter 1 is read and saved in time1_next. Because the interval between two interrupts is the cycle of the analog reference, counter 1 is increased by 1 when there is a grating pulse, so the difference between the two times is the number of gratings in one cycle of the analog reference.
2. Simulation reference amplitude
In the interrupt processing function of INT0, set a global flag refoa_gd_flag = 0xff. In the interrupt processing function of a 100s timer, query this global flag. If it is set, the ADC channel of the analog reference is sampled 400 times continuously. After sampling, clear the refoa_gd_flag flag and set the sampling end flag refoa_gd_finished = 0xff. In the main program main() function, continuously query the refoa_gd_finished flag. If it is set, call the do_refoa_high() function to find the analog reference amplitude, and then clear the flag. In the do_refoa_high() function, find the maximum and minimum values of the 400 sampled points, and the difference between the two is the analog reference amplitude.
3. Simulation base cycle: measures the millisecond value of a simulation base cycle
In a 1ms timer overflow interrupt processing function, the global count variable ref_gd_count is incremented by 1, and ref_gd_count is initialized to 0. In the processing function int0_isr() of external interrupt 0, the value of ref_gd_count is read, which is the period of the analog reference, and then ref_gd_count is cleared to 0. In this way, only the first measurement value is invalid, and all subsequent values are valid analog reference periods.
4. Simulation reference width
In the INT0 interrupt processing function, set the global variable refoa_width_gd_ count = 0. In the 100s timer interrupt, check whether the pin of external interrupt 0 is at a high level. If it is a high level, refoa_width_gd_count increases by 1 until it becomes a low level. The value of refoa_width_gd_ count is the width of the analog reference.
5. Electric Earth Wave
In the do_ein() function, the electric ground wave information transmitted from the industrial computer serial port is processed. If it is a stop electric ground wave command (state=0), the DA electric ground wave directly outputs a high level and clears the electric ground wave enable flag ein_gd_enable. If it is a start electric ground wave command (state=1), the phase, width, amplitude, slope and other information are assigned to global variables for storage, and the output values of each point on the step and slope are calculated, and the electric ground wave enable flag ein_gd_enable is set.
The generation of electrical earth waves is based on analog reference. In the interrupt processing function of INT0, the comparison interrupt of the counter is set and enabled.
In Figure 3, the phase of the earth wave is between T0 and T1, and the width of the earth wave is between T2 and T5. At T1, the comparison interrupt timer1_compa_isr() of counter 1 is entered, and the global variable ein_count_gd is initialized to 0. If ein_count_gd is not equal to 1, the initial value of the comparison interrupt register is set to the next step distance point and output through DA. If the next comparison interrupt comes and ein_count_gd is not equal to 1, the initial value of the comparison interrupt register is continued to be set to the next step distance and the amplitude is output until all the amplitudes on the slope are output. Set ein_count_gd equal to 1 and set the comparison interrupt register to make T4 enter the comparison interrupt. T4 enters the comparison interrupt and outputs all the amplitudes on the slope according to the above method. After completion, the comparison interrupt is disabled and ein_count_gd=0xff is set.
ADC acquisition and serial communication are relatively simple and will not be described in detail here.
Software compilation and download
Since the MCU program is designed in C language, it needs to be compiled with Image Craft's ICCAVR compiler to generate a COF file, and then debugged with AVR STUDIO debugging software and Ssangyong's AVR JTAG emulator. After debugging, the JTAG interface of the MCU can be used to write to the internal flash memory.
Host industrial computer software
The software running on the industrial computer is mainly responsible for processing the data transmitted by the AVR microcontroller through the serial port and checking the deviation and alarm, and then storing the data in the ACCESS database for viewing. The software can set the amplitude, width, and phase of the electric earth wave, and can autonomously control the generation or stop of the electric earth wave.
The upper industrial computer software is written in VC6.0, and the database part uses ADO technology. ADO is designed by Microsoft for the latest and most powerful data access paradigm OLE DB. It is an easy-to-use application layer interface. The main advantages of ADO are ease of use, fast speed, low memory consumption and small disk footprint.
Conclusion
The system design uses Atmel's AVR series microcontrollers, which have rich peripheral devices, easy-to-use integrated development environment, and support for online simulation, which greatly shortens the system development cycle. The system introduced in this article uses a lot of Atmega128 peripheral resources, and solves the problems in system design through the comparison interrupt of the timer counter provided by Atmega128.
Previous article:Design of infrared body temperature device
Next article:Timing control system composed of ATMEGA48 and DS1302
Recommended ReadingLatest update time:2024-11-17 14:39
- 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
- New breakthrough! Ultra-fast memory accelerates Intel Xeon 6-core processors
- New breakthrough! Ultra-fast memory accelerates Intel Xeon 6-core processors
- Consolidating vRAN sites onto a single server helps operators reduce total cost of ownership
- Consolidating vRAN sites onto a single server helps operators reduce total cost of ownership
- 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!
- 【XMC4800 Relax EtherCAT Kit Review】+ FreeRTOS real-time system usage
- ADI Continuous Non-Invasive Blood Pressure Solutions
- Understanding wireless communication technology
- Infineon Tmall flagship store offers huge discounts Part 1 - Limited cashback on a first-come, first-served basis, Double 11 special promotion!
- Good evening, experts.
- The startup method of high performance DSP in large capacity wireless transmission technology
- You may need oscilloscope information urgently, especially analog ones. You can get the information here.
- XMC4800 Review (Part 2) - Unboxing and Lighting
- Share the use of Allegro Color command with everyone
- Comparison of technical indicators between N76E003AT20 and STM8S003F3P6