Designing the PC-Based 4-Channel Digital Storage Oscilloscope by

advertisement
Designing the PC-Based 4-Channel
Digital Storage Oscilloscope
by using DSP Techniques
Abstract
Nowadays, the Digital Storage starts to replace analog type Oscilloscope due to
the better functionality and features. Digital Storage Oscilloscope (DSO) is a device
used by engineers, scientist or engineering students to verify or check the electronic
circuit operation where the displayed signal in the DSO monitor can be analyzed
and saved for future reference. DSO uses an Analog-to-Digital Converter (ADC) to
convert the electrical voltage or current being measured into digital form at certain
sampling time. The sample of the signal will be saved and accumulated until it able
to describe a waveform and reassembles the waveform for viewing in on the monitor
screen. The purpose of the research is to design the PC-Based 4-Channel
Oscilloscope where the electrical signal being measured will be displayed on the PC
(Personal Computer) monitor equipped with functionality button shown in term of
Window based GUI (Graphical User Interface). The GUI is developed by using
Microsoft Visual C++6.0. The PIC (Peripheral Interface Controller) is used for data
acquisition which transfers the data being measured to PC through RS232. Here 4
built-in ADCs are used in order to produce 4 channels Oscilloscope. The PIC is
programmed by using C language to read the data from ADC and then transfer the
data to PC. Frequency of 5 kHz is used as a sampling rate. Meanwhile, the clock
speed of 20 MHz is selected in order to reduce the power consumption and noise. In
addition, 8 Kbytes RAM chip is used for storing purpose. The research outcome
shows 3 types of waveforms such as Sinusoidal, Square and Triangular are
displayed with the correct frequency and amplitude. It is tested by using Signal
Generator as an input to produce the waveform to the hardware. The integration
between hardware (PIC) and software (GUI) is fully working. Beside that, the GUI
is very user friendly and easy to be configured. The data from the signal being
measured also can be saved and restored.
Index Terms:-DSO, ADC, GUI, PIC, PC-Based 4-ChannelOscilloscope
I .NOMENCLATURE
DSO - Digital Storage Oscilloscope
PC - Personal Computer
GUI - Graphical User Interface
ADC - Analog-to-Digital Converter
RAM - Random Access Memory
PIC - Peripheral Interface Computer
USART - Universal Synchronous Asynchronous Receiver Transmitter
SPI - Serial Peripheral Interface
I2C - Inter IC
UART - Universal Asynchronous Receiver Transmitter
TACQ - Time Acknowledgement for PIC
BOR - Brown-Out-Reset
TC - Hold Capacitor Charging Time
II. INTRODUCTION
His document explains and demonstrates how the DSO can be operated virtually, namely,
running at PC. In addition, the document also explains how the GUI is developed, tested
and how the integration between hardware and software is done. DSO has been
preferable equipment by scientists or engineers or academicians or students as well to
verify the electrical or electronic circuit operation and to save the analyzed signal for
future reference. DSO will display the signal amplitude, frequency, period and wave
shape and changes in voltage over time. DSO uses ADC to sample the signal and convert
the voltage being measured into digital form. The vital criterion in designing the PCBased Oscilloscope is the capability to measure and display the signal correctly and
accurately. In order to achieve it, several factors need to be considered. Among them are
the sampling rate, good amplifier bandwidth, good data acquisition devices,number of
ADC chip, size of RAM, a good PIC, external Flash ADC with direct memory access and
DSP techniques used to process the signal and filter the signal from noise. Besides, the
functional button of the DSO need to be studied so that the button created in GUI will
carry the same functionality as the normal DSO. Moreover, DSO is selected in this
research not the analog type Oscilloscope because of the capability of the equipment to
observe slow moving signals as a solid presentation on the monitor screen [6]. The
DSO also has an ability to hold or retain a signal in memory for long periods of time. In
order to sample the correct signal and to avoid aliasing, Low-pass anti-aliasing filter is
used. For the display format to represent the captured waveform on the screen, sine
interpolation technique is used because it can provide a good representation with as few
as 2.5 samples per cycle [6].The brain of the hardware is PIC which will process the
received signal and then send the data to PC through RS232.
According to the instruction embedded to the chip. The PIC contains 4 built-in ADCs to
represent the 4 channel scope. The PIC uses Harvard architecture due to fast, efficient
and effective processors. In order to make the communication between PIC and PC work
correctly and effectively, the USART is used [8]. The data from PIC then sent to the
MAX232 buffer and then transferred to PC’s port through RS232 9-pin. The GUI at
PCneeds to be configured in order to interpret the data and showthe waveform on the
monitor screen. The illustration how the data is transmitted to PC through RS232 is
shown in Figure 1.
Fig. 1. Data transmission to PC through RS232
III. METHODOLGY
The research began by selecting the correct and suitable components. The main
components are Flash type Microcontroller (PIC16F877) with 4 built-in ADCs, SPI,
I2C,UART, 8-channel 10 bit ADC, two 8-bit timers, one 16-bittimer, watchdog timer,
BOR and In-Circuit-Serial Programming, RS-485 type UART. Other components
include 8 Kbytes RAM chip, MAX232 (for line buffer) andRS232 9-pin connected at PC
and a 5V voltage regulator (7805) to power the circuit. The MAX232 buffer is used to
convert the TTL serial logic of the PIC’s UART to the correctRS232 format [5]. The four
PIC’s ADC pins are used for data Acquisition. The UART has baud rates of 300 bps to
115 kbps with 8 or 9 bits, parity, start and stop bits. A clock speed to the PIC is set to 20
MHz not only to reduce power consumption and noise, but to obtain a maximum baud
rate of 115 kbps of the UART for the faster communication between PIC and PC [5]. The
simplified block diagram of the research component is shown in Figure 2.
Fig. 2. Simplified block diagram of research components
From Figure 2, it can be clearly seen that 8Kbytes RAM issued for storage purpose, 8
data line connected to port B (D7 –D0) and 13 address lines connected to port C and pot
D. Since2 bytes are required per reading. Hence, 4000 readings can be stored, that’s 1000
for each channel. Notice also one control line connected from PIC to RAM chip. This
line is used to put the RAM chip in read or write mode. The MAX 232 line buffer is
connected to pin RC7 and RC6 of the PIC. Port D is ued for the first 8-bits of the 13-bits
address bus (213= 8192address). Port E is used to select RS232 baud rate as shown in
Table 1. The RC4 to RC0 is used for the upper 5-bits of the address bus and Port B is
used for 8-bit data bus. The only
Component making use of the data and address buses is the external RAM chip. In
addition, one line is needed to put RAM chip in Read or Write mode [5].
.
For communication protocol development, there are two main communication protocols;
real-time and storage [10].The block diagram of real-time communication protocol is
shown in Figure 3.
Fig. 3. Real-time mode with four channels
The RS232 communication is the bottleneck as the maximum sampling frequency of
PIC16F877 Microcontroller is higher than can be transmitted over RS232 [8].Therefore,
it makes sense to calculate the maximum sample rate base based on capacity of data
transmitted through RS232
at different baud rates. Two bytes are sent per frame which each byte contains 8-bits plus
a start bit and stop bit. Hence, 20-bits are sent per reading. The formula for calculating
the sample rate is shown below.
Sample rate = Baud rate / 20
----------------------------- (1)
No. of Channels
Table 1 shows the theoretical real-time sample rates for 10-bit ADC.
TABLE 1
THEORETICAL REAL-TIME SAMPLE RATES(10-bit ADC)
Number of
Max Sample
Max Sample
MaxSample
Channels
Rate
Rate
Rate
at 230 Kbps
at 115 Kbps
at 67.2 Kbps
(2 serial
(2 serial
(2 serial
links at 115
links at 56.6
links at
Kbps)
Kbps)
33.6
Kbps)
1
11.5 KHz
5.75 KHz
3.36 KHz
2
5.75 KHz
2.87 KHz
1.68 KHz
3
3.83 KHz
1.91 KHz
1.12 KHz
4
2.88 KHz
1.43 KHz
840 Hz
From table 2, it can be clearly seen that the sample rate on each channel is affected by the
baud rate. For the storage mode, at the maximum sample rate, the datasheet for
thePIC16F877 specifies time acknowledgement, TACQ is defined as the summation of
the amplifier setting time, hold capacitor charging time and temperature coefficient as
shown below in formula below.
TACQ = Amplifier Setting Time + Hold Capacitor Charging
Time + Temperature Coefficient
= 2s + TC + [(Temperature – 25oC)(0.05s/0C)] (2)
Here, TC is determined as 16.47s by using formula shown below.
TC = CHOLD (RIC + RSS + RS) In (1 / 2047) (3)
= (-120 pF)(1 k+ 7 k+ 10 k) In(0.0004885)
= 16.47s
Thus, the TACQ is set as below:
TACQ = 2s + 16.47s + [(500 C – 250 C)](0.05s/0 C)
= 19.72s
The GUI for the research is developed by using Microsoft Visual C++ 6.0. The program
is called Scope.exe. The program is shown in Figure 4.
Fig. 4. Display of Scope.exe program
The left half of the window displays the waveform and the right half of the window
display the control panels. The control dialog is hidden and it can be activated by clicking
on the wave form display as shown in Figure 5.
Fig. 5. Control dialog window
The sample rate can be configured by clicking the sample button at the right half of the
scope window. Another window will pop up as shown in Figure 6.
Fig. 6. Sample rate setting
The grid configuration in control dialog window is used to specify the number of
horizontal squares (X) and the number of vertical squares (Y). The default setting is
shown in Figure7.
Fig. 7. Grid Configuration
The scope program was designed so that multiple scope windows can be displayed; each
one with its own selected channels enabled, impendent triggering, time-bases and scales.
Figure 8 demonstrates the multiple window features.
Fig. 8. Multiple Scope View
The Debug dialog box in the control dialog window is used to test the graphical display
and triggering method before the simulation program and PIC hardware is ready for
testing. The Debug menu is shown in Figure 9.
Fig. 9. Debug menu
The flow chart of the design methodology is shown in Figure 10.
Fig. 10. Design Flow Chart
IV. RESULTS
The integration of the hardware (PIC) and software (GUI) isfully working even though
the scope program shows only halfof the measured waveform. It may due to the
synchronization between PIC and computer timer. Before the testing is done, the
communication protocol between RS232 TX and RX terminals are tested to ensure the
communication exits between hardware and software. The testing is done by using a
Signal Generator as an input to the hardware. First, type of the signal selected is Sine
wave. The amplitude of the Sine waveis measured by using normal oscilloscope. The
amplitude of the Sine Wave is 5 Vpp (Peak to peak). The frequency is 5 Hz. Hence, the
Sample rate at Scope program is set to 1000 Hz equivalent to 10 horizontal samples per
division. The scope time-base is set to 10 milliseconds per division and baud rate
is set to 115000 baud. The results of the testing are shown in Figure 13.
Fig. 13. Scope display for Sine Wave at frequency of 5Hz
From Figure 13, there are 20 horizontal divisions and 16vertical divisions. With
resolution of 200 x 160, there will be19 divisions per cycle. Thus the calculated
frequency from the scope program is 1 / (19 * 0.01) = 5.26 Hz which is about the same
frequency as the input signal from signal generator.
Figure 14 shows the scope display for Sine wave with frequency of 20 Hz injected to the
hardware. Other parameters remain the same.
Fig. 14. Scope display for Sine Wave at frequency of 20 Hz
With resolution of 200 x 160, there will be 3.9 divisions per cycle. Hence, the calculated
frequency from the scope program is 1 / (3.9 * 0.005) = 51.3 Hz which is about the same
frequency as the input signal from signal generator.
Figure 15shows the used of the 4 channels scope program to display the4 types of
waveform.
Fig. 15. Scope program at sample rate of 1 kHz, CH1 & CH2 = Square waveand CH3 &
CH4 = Triangular wave.
The recommendation for the future development is to use higher sampling frequency at
least 20 kHz and the use of USB port as a transport medium between PIC and PC.
V. REFERENCES
[1] I. Matanle, “PC-based virtual test and measurement speed bench
Testing,” AA Vol. 15 No. 4, 1995.
[2] A. McFarlane, “Digital signal processing,” Journal: Sensor
Review, vol. 17, 1997, Publisher: Emerald.
[3] R. M. Parkin and B. S. Dalay, “Computer integrated
Documentation,” Industrial Management & Data Systems, Vol. 94
No. 1, 1994.
[4] B. C. Baker, “Anti-aliasing, analogue filters for data
Acquisition systems,” Microchip application note AN699, © 1999
[5] I. Hickman, Oscilloscopes – How to use them, How they
work, Newnes,1995.
[6] B. Ross, Hands-On Guide to Oscilloscopes, McGraw –
Hill. 1994.
[7] Dr. S. Katzen, The Quintessential PIC Microcontroller,
Springer, 2001.
[8] S. Sedra and K. C. Smith, Microelectronic Circuits,
4th ed., Oxford University Press, 1998.
[9] A. S. Tanenbaum, Computer Networks, 3rd ed.,
Prentice Hall. 1996.
[10] H. Schildt, The Complete C+, McGraw-Hill. 1998.
.
Download