Design of Satellite Ground Measurement and Control System Based on AVR Microcontroller

Publisher:WiseThinkerLatest update time:2012-02-01 Source: 电子设计应用 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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 100s 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 100s 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.

Reference address:Design of Satellite Ground Measurement and Control System Based on AVR Microcontroller

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

ADC0804 Applications
#include reg51.h #define uint unsigned int #define uchar unsigned char sbit p20=P2^0; //digital tube bit selection definition sbit p21=P2^1; //digital tube bit selection definition sbit p22=P2^2; //digital tube bit selection definition sbit cs=P2^4; sbit rd=P2^5; sbit wr=P2^6; unsigned char code
[Microcontroller]
ADC0804 Applications
Using a Differential Amplifier to Drive a High-Speed ​​ADC
Today's world is full of massive data. People's lives benefit a lot from it, but the pressure faced by system designers is increasing. Selecting the right driver for the analog-to-digital converter (ADC) is an important issue. As an important bridge between the real world and the data world, the ADC often samples
[Analog Electronics]
[MCU framework][bsp layer][nrf51822][nrf51422][nrf51802][bsp_adc] ADC configuration and use
Analog to Digital Converter (ADC) The 10 bit incremental Analog to Digital Converter (ADC) enables sampling of up to 8 external signals through a front-end multiplexer. The ADC has configurable input, reference prescaling, and sample resolution (8, 9, and 10 bit). Note: The ADC module uses the same analog inputs as
[Microcontroller]
MSP430F149ADC12 single channel single conversion
#include #define uint unsigned int #define uchar unsigned char   static uchar adc_flag = 0 ; uint AD_TEMP = 0 ;   void int_clk() {   fly   BCSCTL1&=~XT2OFF; //Turn on XT oscillator   BCSCTL2|=SELM1+SELS; //MCLK is 8MHz, SMCLK is 8MHz   do   {      IFG1&=~OFIFG; //Clear oscillation error flag
[Microcontroller]
How to use ADC technology for data acquisition in MCU system
System designers using MCUs benefit from Moore's Law, which provides more feature-rich functionality in smaller packages at lower costs. Embedded system designers and MCU vendors are concerned with three basic functions of data acquisition systems: capture, computation, and communication. Understanding all of these fu
[Power Management]
How to use ADC technology for data acquisition in MCU system
51 microcontroller learning: ADC analog-to-digital conversion experiment-potentiometer voltage collection
Experiment name: ADC analog-to-digital conversion experiment - potentiometer voltage collection wiring instructions: Experimental phenomenon: After downloading the program, the digital tube displays the voltage value of the AD module collection potentiometer. Notes: *********** ****************************************
[Microcontroller]
High-speed, high-precision, low-power ADC for efficient and precise control
       Today's motor control and automotive application designs require high-speed ADCs that can digitize auxiliary input/output signals, output the results to the processor in real time, and perform sampling synchronously to maintain correct phase information. Meeting these requirements in a small package size is a ch
[Power Management]
Research and design of high-speed and high-precision ADC driving circuit
Introduction In the process of data acquisition, high-frequency interference signals are inevitable. When the frequency of these signals exceeds the Nyquist frequency, unpredictable interference will appear in the digital signal, namely frequency aliasing. In order to minimize or eliminate the impact of
[Analog Electronics]
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号