Design of Simple Oscilloscope Based on AVR

Publisher:BlissfulDreamsLatest update time:2011-12-10 Keywords:AVR Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Figure 1 System structure diagram

1.1 Signal conditioning circuit

The functions that the signal conditioning circuit needs to complete are: program-controlled amplification and superimposed DC component. The function of program-controlled amplification is: when the amplitude of the input signal is very small, the input signal needs to be amplified so that the measured signal can be displayed as clearly as possible on the LCD. The function of superimposed DC component is: the A/D of ATmega16 is a single power supply, and it is impossible to input negative voltage, while the signal to be measured often has negative voltage. At this time, such a circuit is needed to raise the negative voltage to above the 0 level.

Figure 2 Schematic diagram of signal conditioning circuit

R1 and R2 are connected to different resistors by an analog switch CD4051. Different R1 and R2 can be connected by the formula: In this way, the programmable amplification function can be realized. The adjustable resistor R9 is used to set the size of the DC component added by the signal conditioning circuit. The amplified signal and the DC component are finally superimposed and output by the U3 analog adder.

The relationship between the input signal and the output signal: As long as the resistance values ​​of R4, R6, and R7 are the same, the relationship between the input and output of the conditioning circuit is simplified to: .

Ux is the output voltage of U3, and the voltage value of the output voltage is the same as the voltage of the middle tap of the adjustable resistor R9.

1.2. Main control chip software design

The main control chip of this system is Atmel's AVR series microcontroller ATmega16, which can reach a maximum instruction speed of 16MPIS. ATmega16 has 16K flash, 1K SRAM, 512B EEPROM, and a 10-bit precision successive approximation analog-to-digital converter with built-in sampling/holding circuit. The ADC clock is programmable. In this design, in order to achieve the highest sampling frequency of 100KHz, the ADC clock is set to 2MHz. The trigger source of the ADC is selected as the overflow of timer/counter 0, and the clock source of the timer of ATmega16 is also programmable. In this way, the sampling frequency of the ADC can be controlled by controlling the interrupt frequency of the overflow of timer/counter 0.

Figure 3 Simple oscilloscope system program flow chart

1.2.1 Keyboard Function

There are 7 buttons in this system: run and stop, increase magnification, decrease magnification, increase sampling frequency, decrease sampling frequency, trigger level up, and trigger level down.

Run and stop buttons: This is achieved by turning on and off the ATmega16 ADC conversion completion interrupt.

Increase and decrease of magnification: ATmega16 controls analog switch CD4051 to realize digital control of magnification. CD4051 is an 8-channel analog switch, so the programmable amplifier can have 8 levels.

Increase and decrease of sampling frequency: The sampling frequencies required by the system are achieved by controlling the clock source of ATmega16's timer 0 and the initial value of the timer. The interrupt frequency of timer 0 is equal to the sampling frequency of ADC.

The up and down movement of the trigger level: when the sampled data is digitally triggered, when the binary value of the data increases and the size of a certain data is exactly the same as the binary value of the digital trigger, the waveform data after this will be stored in the display RAM.

When any of these 7 buttons is triggered, the corresponding flag will be set to refresh the corresponding display information on the LCD screen.

1.2.3 Digital trigger function

How to achieve triggering? Using hardware will increase the complexity of the system hardware circuit. I thought of a way to achieve the triggering function with software. The implementation process is as follows:

for (ik=0;ik<500;ik++){

if (k0_ram){

if (box_buff[ik] < trigger) {

kk_ram = 1 ;

}

if (kk_ram){

if ((box_buff[ik] >= trigger) & (ik < 402)){

en_ram = 1 ;

k0_ram = 0 ;

kk_ram = 0 ;

}}}

if (en_ram){

boxing[adc_data]=box_buff[ik];

adc_data++;

if (adc_data > 96){

adc_data = 0x00;

en_ram = 0 ;

}}}

The size of the trigger can be set by pressing the trigger level up and trigger level down buttons.

1.2.3. Restore the waveform

GDM12864A is a dot matrix LCD with 128 dots x 64 dots. According to the characteristics of the selected LCD, there are only 64 dots on the Y axis, so the data range that can be displayed is 0 to 63 and the sampled data is 8-bit binary data from 0 to 255. In order to display it on this LCD, only the upper 6 bits of the 8-bit data are taken. So how to convert the upper 6 bits of binary data into the Y axis coordinates and data values ​​on the LCD? I thought of a calculation method like this:

The vertical direction of LCD is divided into 8 addresses from top to bottom, 0 to 7, and each address segment has 8 data points. If you want to light up these bits from top to bottom in a certain data segment, you need to send data 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 to this address segment in turn. After sending 0x00, the 8 data points in this address segment will not be lit. The specific process of implementation is shown in Figure 4.

dat = dat>>2

y = 7

dat >= 8 ?

dat = dat – 8; y--;

y == 1 ?

dat > 7 ?

dat = 7 ;

dat = 0x80 >> dat

write_add(y,x);

write_data(dat);

no

no

no

Figure 4 Flowchart of the program to restore data to points on the waveform

1.2.4 ADC sampling frequency control

The sampling frequency of ADC has been mentioned above. The calculation formula of ADC interrupt is: , The frequency can be changed by setting the lower 3 bits CS02, CS01, CS00 of ATmega16's special function register TCCR0. Then, by setting TCNT0 to different values, the sampling frequency values ​​required by this system can be obtained. The data in Table 1 are calculated by the above formula and then debugged and corrected by the actual system.

Table 1 Sampling frequency settings

Sampling frequency (KHz)

100

50

20

10

5

2

1

0.5

0.2

0.1

0.05

0.0033

TCCR0

0x02

0x02

0x02

0x02

0x02

0x03

0x03

0x04

0x04

0x05

0x05

0x05

TCNT0

250

235

204

149

42

189

123

188

89

169

89

4

2. System performance indicators and errors

2.1 System performance indicators

The main performance indicators of the system are shown in Table 2.

Table 2 Main performance indicators of the system

System operating voltage

+5V and -5V power supplies

Frequency measurement range

0.33Hz ~ 3KHz

Voltage measurement range

10mV ~ 2V

2.2 System Error

The error of the system mainly comes from the signal conditioning circuit, because the analog switch has a certain internal resistance of about 80Ω, which will have a certain impact on the amplification factor of the conditioning circuit. The resistance value calculated by the calculation formula in 1.1 does not exist in reality, and there will still be a certain error when it is realized by connecting several resistors in series. The balancing resistor R3 is fixed. When R1 and R2 change, the balancing resistor may not be balanced, which will also introduce a certain error to the operational amplifier.

2.3 Areas for improvement

The area where the system can be further improved is the signal conditioning circuit. By selecting analog switches and operational amplifiers with better performance and more reasonable resistor selection, the amplification accuracy of the signal conditioning circuit can be improved, and the performance of the entire system can be further improved.

2.4. Actual working status of the system

The information displayed on the LCD includes the waveform image, the horizontal axis scale on the top of the waveform, the system operation status (Run / Stop) on the right side of the screen, Time is the time length of the entire waveform frame, Volt- is the voltage range, and there is a small dot between the waveform frame and the information frame for the trigger level of the signal. The frequency of the signal = the number of cycles of the signal in the waveform frame / Time.

3. Conclusion

This method can be used to realize a simple oscilloscope. The whole system structure is simple and clear. The internal resources of the AVR microcontroller are fully utilized to simplify the system circuit. Even the system's working clock is built into the AVR. Through testing, the system has a very small error in the direction of measuring frequency, and can be used to measure the frequency of the test signal more accurately.

[References]

[1] Liu Haicheng. AVR MCU Principles and Measurement and Control Engineering Applications [M]. Beijing: Beijing University of Aeronautics and Astronautics Press, 2008.3.

[2] Gao Jixiang. National College Student Electronic Design Competition Training Series [M]. Beijing: Publishing House of Electronics Industry, 2007.6.

[3] Liu Zugang. Fundamentals of Analog Circuit Analysis and Design [M]. Beijing: Machinery Industry Press, 2007.10.

Keywords:AVR Reference address:Design of Simple Oscilloscope Based on AVR

Previous article:Design of a high-power lead-acid battery charger controlled by P89LPC93X single-chip microcomputer
Next article:Design of LED screen image data decoding based on ATmegal28

Recommended ReadingLatest update time:2024-11-16 19:31

AMPIRE12864 LCD C language code
  #include iom16v.h #include macros.h #define uchar unsigned char #define uint unsigned int #define RS_H() PORTD|=BIT(4); #define RS_L() PORTD&=~BIT(4); #define RW_H() PORTD|=BIT(5); #define RW_L() PORTD&=~BIT(5); #define E_H() PORTD|=BIT(6); #define E_L() PORTD&=~BIT(6); #define CS1_L() PORTA&=~
[Microcontroller]
AMPIRE12864 LCD C language code
Design of LED Color Light Controller Using AVR Single Chip Microcomputer
8 LED lights are directly connected to Vcc, and no current limiting resistor is required. This production uses a synchronous timer and uses sleep mode to save power. If you want to change the pin connected to the LED, please modify the hardware.h file. If you want to change the brightness of the LED, please modify the
[Microcontroller]
Design of LED Color Light Controller Using AVR Single Chip Microcomputer
An AVR SD card interface program
/************************************************************/ /* SD Code for M32L */ /* By pasyong */ /* 2006-4 */ /* Base ICC6.31A */ /************************************************************/ #include #include #include "1011.h" #define uchar unsigned char #define uint unsigned int #define MMC_CS_PIN
[Microcontroller]
AVR microcontroller tutorial - lighting up the first LED
After so much preparation, we can finally start doing something with the development board. There are some differences between microcontroller programming and computer programming. Programs must have zero or more inputs and one or more outputs, which both have, but the input and output of computer programming mainly
[Microcontroller]
AVR microcontroller tutorial - lighting up the first LED
TimerMode.h header file download - AVR timer working mode name definition
/********************************************************************************       File name: TimerMode.h       File ID: _TIMERMODE_H_       Abstract: AVR timer working mode name definition *********************************************************************************/ #ifndef _TIMERMODE_H_ #define _TIMERM
[Microcontroller]
LCD2004AVR MCU driver source program
/*===========================================================  20x4 character LCD main program, compilation software (I CC AVR_6.31)  CPU internal crystal oscillator 8M  data line B0~B7 connects PORTB, E=D7 RW=D6 RS=D5  ================================================================ The wiring diagram is as follows:
[Microcontroller]
ATtiny2313 Core Introduction
This section discusses the structure of the ATtiny2313 AVR core in general. The main task of the CPU is to ensure the correct execution of the program. Therefore, it must be able to access memory, perform calculations, control peripherals, and handle interrupts. Figure 3. Block diagram of the AVR architecture To a
[Microcontroller]
ATtiny2313 Core Introduction
Design of dam monitoring system based on AVR and vibrating wire piezometer
Abstract: A dam monitoring system based on AVR and vibrating string osmometer is designed. The principle, mathematical model and characteristics of the vibrating string osmometer and ATmega128 microcontroller are briefly introduced. The system's excitation and frequency measurement methods are improved by using the
[Industrial Control]
Design of dam monitoring system based on AVR and vibrating wire piezometer
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号