Note: * is required
Please fill it out during the registration stage↓
In some simple electronic circuit designs, there is no need to use a high-performance and bulky desktop oscilloscope. Therefore, this project is a compact USB virtual oscilloscope. During the design process, on the basis of considering the cost issue, we tried our best to realize the functions of the standard oscilloscope and give full play to the chip performance. The parameters and features of this virtual oscilloscope are as follows.
•Sampling rate 2MSa/S
•Measurement range ± 10V
•AC coupled and DC coupled modes
•Input impedance is approximately 1M Ω /100pF
•Maximum 100 times programmable gain
•Voltage measurement accuracy 2%
•Supports one-click automatic function
•Support FFT mode
•Screen refresh rate up to 20FPS in fast mode
•The cost of components is less than 30 yuan (calculated based on the price of Lichuang Mall)
The hardware part, microcontroller program and host computer program are all original designs. I have not participated in other competitions and have not participated in the defense at school.
GPL3.0 open source agreement
Please fill in during the competition stage↓
•Physical map
PCB size is 6 × 4 cm, double-layer board design, components are only on the top layer. The analog signal is input from the SMA interface on the left end, connected to the host computer through the Micro-USB interface, and leads to the program debugging port.
In order to facilitate manual welding, the resistor components are packaged in 0805 , and the spacing is also increased during design, so there is still room for optimization in PCB layout and wiring. It is worth mentioning that this time the silk screen is inexplicably clearer than before, and you can clearly see the component values and Jialichuang's logo .
•in summary
The hardware mainly includes the conversion part that converts the measurement signal to the analog signal that can be collected by the microcontroller AD , the microcontroller circuit USB serial port digital circuit part and the ± 3.3V power supply part. This will be explained in turn below.
•Chip and solution selection
Since there is no need to drive OLED , the performance of the main control chip can be lower, and it only needs to implement AD conversion and serial port sending functions. STM32G030F6 microcontroller was selected , TSSOP20 package, 8KRAM , 12 -bit AD maximum conversion rate is 2.5M , and more importantly, the price on Lichuang Mall is only 8 yuan, which meets the design requirements.
In order to measure small signals, the op amp in the signal conversion part requires bipolar power supply. Considering that the overall current is small, a polarity reversal charge pump scheme is selected for the negative power supply. I couldn't find one with a suitable price in Lichuang Mall, so I finally chose SGM3204 (the only chip used in this project that is not available in Lichuang Mall), a charge pump with 200mA output current, and only three capacitors can convert the + The 5V power supply is converted into a -5V power signal.
The ripple of the -5V power supply is large, and the LDO voltage stabilizing chip is required to power the op amp circuit. The XC6902N331 voltage stabilizing chip is selected , and the price is close to 3 yuan. Similarly, the +5V power supply also needs to go through a voltage stabilizing chip to power the op amp and microcontroller. The common 1117 linear voltage stabilizing chip was selected.
The op amp chip is NCS20072 , which has a bandwidth of 3.2MHz , a slew rate of 2.4V/us , extremely high input impedance, unit stable gain, and an input and output range of ± 3V under ± 3.3V power supply. The price is only 1.6 yuan. . Fully meets design requirements.
In addition, the analog switch CD4053 , the serial port to USB chip CH340 , and the general comparator LM393 were also selected , which will not be described in detail.
•Signal conversion circuit
The signal first passes through an attenuation circuit composed of 680K Ω and 220K Ω resistors and capacitors, converting the ± 10V signal into the ± 2.5V range that the op amp can handle . The subsequent voltage follower makes the input impedance of the oscilloscope 900K Ω /90pF .
The single-pole double-throw switch controls whether to pass through the RC high-pass filter to achieve AC-DC coupling switching. Using a relay is a better solution here, but the price of the analog switch CD4053 is obviously more suitable.
两个同相比例放大器构成类似于级联的形式,由模拟开关控制是否进行放大。第一级放大倍数为5倍,第二级放大倍数接近于20倍。从而可以实现放大倍数为1倍、5倍、20倍、100倍的不同增益。相比较由一个运放构成的改变反馈电阻的程控放大电路,该电路对于频率较高的小信号有更好的放大能力。
后续经过电压抬升电路,将正负电压信号转换成单片机AD可以采集的信号,最终的信号将叠加在1.5V直流量上。比较器的正比较端也接入1.5V直流信号,比较器输出端即为同频率的脉冲信号。加入比较器的主要作用是获取波形的频率值,以更快的实现一键自动功能。
此外,图中所用的LM358通用运放在实际调试中改成了性能更好的NCS20072运放。可能由于LM358的压摆率太低,导致在频率超过10KHz时就会出现奇怪的失真波形。
•电源电路
电脑USB的5V电源信号质量较差,含有大量的高频脉冲噪声,故首先经过简单的LC滤波电路。之后的SGM3204电荷泵可以将+5V电源信号转换至-5V电源,XC6902N331稳压器和ZLDO1117稳压器用于输出稳定的±3.3V信号。该电路均参考各自的芯片手册。
•数字电路
简单的单片机外围电路,用于注意程序调试的PA14引脚和BOOT0引脚为同一个,需要接入下拉电阻。20引脚的STM32G030F6P6TR的没有将模拟电源和数字电源分开,这可能会使得单片机AD有更大的噪声。在实际测试过程中,在2M采样率,256个采样点中,单片机AD的测量结果会产生最大15LSB的偏差(即0.3%的偏差)。
STM32G030F6没有USB接口,需要接入串口转USB芯片以实现串口数据传输的功能。CH340N内置晶振,只需要一个去耦电容即可。
•调试图片
软件包括STM32单片机部分和LabVIEW上位机部分。下面将分别说明。
•单片机程序总体说明
单片机主要实现串口接收指令、AD采集、波形数据转换和串口发送波形数据的功能。采用STM32Cube预先配置各项参数,在Keil中进一步编程。
•单片机参数配置
配置ADC触发方式为定时器触发,这样可以更精准的控制采样间隔。由DMA控制器将波形数据保存至数组,并设置DMA为非循环模式。
配置串口波特率为256000(没有采用常用的115200,因为只有在该波特率下才能够实现20FPS的刷新率)。开启接收中断。由DMA控制串口发送数据,这样在发送串口数据时,不会影响主程序的运行,从而可以提高刷新速度。
在频率测量中,配置定时器为输入捕获模式,将定时器从模式设置为复位,触发源为TI1FP1。由DMA控制器将每次脉冲信号来临时,将定时器的计数值保存至数组。另外,比较器的输出端含有高频脉冲噪声,需要配置定时器输入通道滤波器。
•单片机波形采集程序
串口波形数据格式为< Time00640+Fre00100+Amp0+DC+波形数据点>的形式。其中AD触发定时器的计数值Time,最大65535;输入捕获定时器的计数值Fre,最大65535;程控放大器的放大倍数Amp,最大值3;耦合方式用DC和AC表示。
波形采集过程如下。
•上位机程序
The main job of the host computer is to parse the strings from the serial port, process waveforms, calculate relevant parameters and display them. There is no floating point operation in the microcontroller. All waveform data are original data collected by AD and are in the form of integers. In the host computer, these integers need to be converted into voltage values. Obviously, there is a completely linear relationship in theory between the AD value of the microcontroller and the input voltage value. In the host computer, the actual voltage value needs to be obtained based on this linear relationship. In this work, there are 4 types of programmable gains, which correspond to 4 functional relationships.
The schematic diagram of the host computer is as follows.
•Summarize
This work can realize basic oscilloscope measurement functions and has good accuracy for voltage measurement. Its 2M sampling rate can fully measure signals within the audio range, that is, 20KHz signals. Since the bandwidth of the oscilloscope is small, its own noise floor is also small. In the video below, the test was performed on a 20mV sine wave. In addition, the virtual oscilloscope can measure small signals with a DC offset of 5V , a frequency of 50KHz , and an amplitude of only 50mV . This measurement is also demonstrated in the video below.
Of course, general handheld oscilloscopes use the FPGA + high-speed AD solution to achieve high sampling rates, which is far beyond the reach of the built-in AD in the microcontroller. But in terms of price, the cost of this work is about 35 yuan, which is also the biggest feature of this work. In the circuit design and selection process, we also try to simplify the circuit and reduce costs.
Please enter content...
It is divided into two videos: regular function display and function display.
All reference designs on this site are sourced from major semiconductor manufacturers or collected online for learning and research. The copyright belongs to the semiconductor manufacturer or the original author. If you believe that the reference design of this site infringes upon your relevant rights and interests, please send us a rights notice. As a neutral platform service provider, we will take measures to delete the relevant content in accordance with relevant laws after receiving the relevant notice from the rights holder. Please send relevant notifications to email: bbs_service@eeworld.com.cn.
It is your responsibility to test the circuit yourself and determine its suitability for you. EEWorld will not be liable for direct, indirect, special, incidental, consequential or punitive damages arising from any cause or anything connected to any reference design used.
Supported by EEWorld Datasheet