Design of Virtual Oscilloscope Based on Ethernet

Publisher:国宝集团Latest update time:2015-07-07 Source: elecfansKeywords:Ethernet Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
  Virtual instruments use high-performance modular hardware combined with efficient and flexible software to design instrument test functions based on user needs on a general computer platform to achieve signal processing, calculation, analysis and waveform display. In recent years, with the rapid development of microelectronics and computer technology, and the deep integration of measurement technology and computers, virtual instruments have become one of the hot issues studied by scholars at home and abroad.

  The virtual oscilloscope proposed in the literature is based on PCI acquisition card hardware, which greatly limits its connection and loading performance; the serial interface transmission acquisition device used in the literature has a low transmission rate and unsatisfactory real-time performance; the virtual oscilloscope proposed in the literature uses USB interface data acquisition equipment. Although its technology is becoming more and more mature, its stability, data throughput, transmission rate and transmission distance are inferior to industrial Ethernet technology. Therefore, the virtual instrument technology is combined with Ethernet technology, and a new type of networked virtual oscilloscope is developed in the VC environment using its auxiliary development package MFC. It has a friendly interface and accurate data. It not only includes conventional functions such as traditional virtual oscilloscope data calculation, spectrum analysis and waveform display, but also can realize the rapid storage, playback and remote multi-machine control of waveforms.

  1 Virtual Oscilloscope Hardware Design

  The hardware system structure of the virtual oscilloscope is shown in Figure 1. The underlying hardware uses an embedded system based on DSP, which integrates signal conditioning circuits, A/D conversion modules and network interface devices to complete the acquisition, processing and transmission functions of the measured signal: the signal conditioning circuit performs voltage conversion on various input analog signals so that the variation range of the voltage amplitude of the sampled signal meets the requirements of the A/D conversion module. At the same time, it also filters the input signal to reduce signal distortion and noise and prevent false signals introduced by out-of-band frequencies. The A/D conversion module is the most important unit in the embedded system. The A/D conversion module in the TM320F2812DSP has 12-bit accuracy and a maximum sampling bandwidth of 12.5 MS/s for 16 channels.

Virtual Oscilloscope Hardware System Structure

Figure 1 Virtual oscilloscope hardware system structure

  Its excellent dynamic performance is sufficient to meet the requirements of a virtual oscilloscope. The system network interface device uses the Ethernet controller LAN91C111 and connects it to the MCU as a peripheral device. The device supports a transmission rate of 100/10 Mb/s. After the embedded system establishes a network connection with the host computer, it transmits data to the host computer via Ethernet and uses the upper-level software to complete the waveform display, calculation and related analysis of the data.

  2 Virtual Oscilloscope Software Design

  In order to improve the running efficiency of the virtual oscilloscope program, the programming adopts the multi-threading concept. The so-called multi-threading is to divide the program into sub-tasks that run independently, including the main thread and sub-threads. Using the CPU time-sharing mechanism, each thread can cyclically obtain its own CPU time. Since the polling speed is very fast, all threads seem to be running at the same time. The main thread of the virtual oscilloscope program processes data and displays waveforms; the sub-threads independently complete the functions of receiving UDP datagrams, saving data and sending messages to the main thread. The virtual oscilloscope program flow chart is shown in Figure 2.

Virtual Oscilloscope Program Flowchart

Figure 2 Virtual oscilloscope program flow chart

  2.1 Ethernet data communication design

  The virtual oscilloscope adopts distributed Ethernet access technology, that is, the Ethernet control module is embedded in the embedded system, so that the device can be directly connected to the Ethernet. When the embedded system sends the Ethernet data frame containing the measured signal data information to the host computer in the local area network. It is necessary to determine the destination interface based on the 48b Ethernet hardware address. The address resolution protocol ARP provides a mapping between the Ethernet hardware address and the IP address. When the virtual oscilloscope is running, the embedded system sends an ARP request to the destination host computer. After the host computer with a pre-set IP address receives the message, it recognizes that this is the sender asking for its hardware address, and then sends an ARP response containing its own IP address and hardware address. After receiving the response, the embedded system can send datagrams to the destination host computer.

  After the embedded system establishes a network connection with the host computer, it needs to implement the TCP/IP protocol family to complete the encapsulation and sharing of data for Ethernet communication. In the four-layer protocol system of application layer, transport layer, network layer, and link layer, each layer is mainly responsible for communicating with the peer layer on other machines. The link layer mainly includes the physical layer and the data link layer. To complete the physical interface connection protocol, Ethernet (IEEE802.3) is used in the design to ensure the data transmission volume; the transport layer protocol mainly includes TCP and UDP. Although the TCP protocol has higher reliability, it is complex to implement in software, the program is lengthy, and it occupies a large amount of network traffic during verification; in contrast, the UDP protocol has more advantages in reducing DSP resource consumption and improving network transmission efficiency. In order to enhance the reliability of the UDP protocol, in the actual communication protocol, the key values ​​are guaranteed to be transmitted reliably through the return verification mechanism. This method combines the simplicity of the UDP protocol with the reliability of the TCP protocol, and also saves a lot of network traffic used for verification, enhancing the real-time performance of the network. Therefore, the UDP protocol is selected for the transport layer protocol. The Ethernet data sending/receiving flow chart is shown in Figure 3.

Ethernet Flowchart

Figure 3 Ethernet flow chart

  In the specific virtual oscilloscope program, sending and receiving data information are all completed by sockets. The embedded system acts as the client side, and the host computer acts as the server side. The connection process can be divided into three steps: server *, client request, and connection confirmation. After a successful connection, the embedded system as the client side will package the measured signal data and send it to the host computer via Ethernet after receiving the data sending command sent by the host computer. In terms of monitoring network connection, the embedded system and the host computer are connected through heartbeat frames. When the network connection fails, the heartbeat frame sent by the embedded system is interrupted. The host computer can detect and exit the network in time to issue an alarm. The Ethernet communication operation mechanism is shown in Figure 4. [page]

Ethernet communication operation mechanism

Figure 4 Ethernet communication operation mechanism

  The virtual oscilloscope communication design fully utilizes the advantages of Ethernet's large data volume and fast transmission speed, improves the real-time performance of the virtual oscilloscope waveform display, and makes it closer to the waveform displayed by a real oscilloscope.

  2.2 Channel selection and data coordinate calculation module

  The UDP data packet sent by the embedded system to the host computer contains data information of 6 types of measured signals, totaling 60 sampling points and 360 data points. In the program, the array NUM[6][60] is established to save and write them into the host computer buffer area. At the same time, the virtual oscilloscope interface uses the check box control to set 6 display channels, thereby realizing the function of displaying 6 channel waveforms at the same time. When channel C (C=1~6) is selected, the member variable value associated with its corresponding check box control changes from FALSE to TRUE, and the current NUM[C][60] data is called to calculate the coordinates of the data points one by one and display them in the waveform display window. For digital oscilloscopes, not only ultra-high-speed real-time sampling rate is required, but also high waveform analysis details are required. Therefore, the virtual oscilloscope in this paper uses a linear interpolation algorithm to restore and reconstruct the original signal. The so-called linear interpolation is to insert a point between two sampling points and connect the sampling point and the interpolation point with a straight line. The calculation method of the sampling point data coordinate Pi(xi, yi) and the interpolation point data coordinate is as follows:

  In the formula, left is the coordinate of the leftmost data point on the screen, cnt is the number of the current data point, that is, the number of data points received by the oscilloscope. And xvalue is the distance between the two points. yvalue is the vertical axis amplitude coefficient, yoffset is the currently selected vertical axis offset, and the interpolation point is the midpoint of two adjacent sampling points.

  2.3 Trigger module

  In order to synchronize the scanning signal with the measured signal, some conditions can be set to continuously compare the measured signal with these conditions. The scanning is started only when the measured signal meets these conditions, so that the scanning frequency is the same as the measured signal or there is an integer multiple relationship, that is, synchronization. The purpose of triggering is to make the initial moment of each display start from the same position of the waveform to ensure stable waveform display.

  The main thread in the program continuously receives data sent by the sub-threads. First, it determines whether the current data point is greater than the 5 data points before it. If the judgment is true, it means that the current is the rising edge of the waveform. Then the data point is compared with the preset trigger level; if they are equal or within the allowable error band, the data point is determined to be the trigger point. Since the trigger function is implemented by software, the virtual oscilloscope's "hang time", that is, the time to re-prepare for triggering, is very short, and the probability of missing important events in the waveform is extremely low.

  2.4 Waveform storage and playback module

  The virtual oscilloscope program receives data by creating a thread and also takes care of the task of saving data. Two files are created when the program is initialized.

  1) History page file: When the user clicks the "Start Saving" control, the program starts the saving function and writes all the data sent by Ethernet into the history page file;

  2) Historical page information file, which is used to save various types of information about the data in a save operation, such as the start and end time of the data save, the amount of data saved, the location of the data point that meets the trigger conditions, etc.

  When waveform playback is required, the program filters out data within a specified time period from the history page information file based on the information saved in the history page information file, calculates the coordinates of each data point and displays it on the oscilloscope screen.

  2.5 Parameter calculation module

  While the virtual oscilloscope displays the waveform normally, it calculates various indicators of the current signal in real time based on the received data. The algorithm for the average value, effective value and frequency of the signal is as follows:


  Where n is the number of data points involved in the calculation, NUM[c][m] is the array that stores the data, and tmax1-tmax2 means the average time between two adjacent maximum values ​​of the waveform, which is defined as the period of the waveform.

  2.6 Front panel design

  Compared with the virtual oscilloscope front panel designed by LabVIEW development tools in the literature, the virtual oscilloscope front panel control types in this paper are richer and more beautiful. It simulates the various operations of the actual oscilloscope and displays the processing results. Its design is shown in Figure 5. The interface consists of two parts: the waveform display window and the control area. The control area is equipped with various control buttons such as channel selection, scale selection, waveform storage, spectrum analysis, and calculation according to the needs of the instrument function.

Virtual Oscilloscope Front Panel

Figure 5 Virtual oscilloscope front panel

  3 Operation Results and Analysis

  3.1 Multi-channel waveform display function

  Start the virtual oscilloscope and use the check box control to select channels CH1 and CH2 at the same time, where CH1 is a sine wave and CH2 is a square wave. The waveform display is shown in Figure 6.

Multi-channel waveform display

Figure 6 Multi-channel waveform display

  3.2 Waveform storage and playback function

  When you click the "Open" control in the interface, a dialog box as shown in Figure 7 pops up. The dialog box displays the historical waveforms of each time period that have been successfully saved before. Select one and click "Open Waveform". The data waveform of this time period will be displayed on the virtual oscilloscope screen as shown in Figure 8. [page]

Waveform playback selection dialog box

Figure 7 Waveform playback selection dialog box

Historical waveform playback function

Figure 8 Historical waveform playback function

  3.3 Waveform calculation function

  When the waveform of the measured signal is displayed normally, the calculation result display dialog box can be popped up by clicking the "Calculate" control. Taking the CH2 square wave in Figure 8 as an example, its peak-to-peak value is 6.002 06 V, the effective value is 3.001 03 V, the maximum value is 3.001 03 V, the minimum value is -3.001 03 V, the frequency is 27.777 78 Hz, and the duty cycle is 0.5. As shown in Figure 9.

Calculation results display dialog box

Figure 9 Dialog box showing calculation results

  4 Conclusion

  The virtual oscilloscope introduced in this article is fast, accurate, scalable, and low in development cost. It not only has the basic functions of an actual oscilloscope, but also gives full play to the powerful advantages of computers and the flexibility of software design, realizing waveform display, storage, playback, parameter calculation, spectrum analysis, etc. It has been actually used in the monitoring platform of the new urban rail transit traction power supply system described in the literature to monitor the various parameters of the power supply system in real time and display the waveform. This virtual oscilloscope combines Ethernet communication technology for data transmission, giving full play to the advantages of Ethernet's long transmission distance, large transmission data volume, and high signal reliability, increasing the amount of data transmitted and the monitoring distance, meeting the application requirements in actual systems, and has good development prospects.

References:

[1]. PCI datasheet http://www.dzsc.com/datasheet/PCI_1201469.html.
[2]. LAN91C111 datasheet http://www.dzsc.com/datasheet/LAN91C111_1054180.html.

Keywords:Ethernet Reference address:Design of Virtual Oscilloscope Based on Ethernet

Previous article:You must understand the oscilloscope amplitude-frequency characteristic curve
Next article:Technical research on simple multi-channel virtual oscilloscope

Latest Test Measurement Articles
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号