Configuring a PSoC as a DIY oscilliscope/logic analyzer - Part 1 -

Configuring a PSoC as a DIY oscilliscope/logic analyzer – Part 1


Commercially available lab equipment like oscilloscopes, logic analyzers, and function generators are bulky and expensive, making them difficult to use for hobbyists and budding electronic engineers. The analog bandwidth of oscilloscopes ranges from 1MHz to 33GHz with sampling rates from 500MS/s to 10TS/s and record length ranges from 2.5Kpoint to 500Mpoint. Depending on included features and capabilities, the cost can range from $790 to over $55,000.

The above numbers are fine for companies who can utilize all the features from their investment. However, an entry-level engineering student or a hobbyist who is interested in determining the unknown outputs of the circuit does not require such high-end performance from their oscilloscope. For such a usage there is a requirement of designing a simple oscilloscope which can be both cost-effective and portable.

Integration of analog and digital components in commercially available mixed-signal PSoCs (programmable systems on chip) plus low-cost touch screens provide an affordable opportunity to build a touch screen-based electronic lab kit. The functionality of this PSoc-based system not only includes the features of a normal oscilloscope, but also includes features like a logic analyzer and signal generator that can be of great utility for debugging designs.

Oscilloscope functionality is implemented by sampling and scaling the input signal to be displayed on a graphic LCD. With the availability of sampled values, statistics of the signal like amplitude and frequency are derived. The implementation of a logic analyzer in the device can be used to verify the functionality of digital circuits. This lab kit incorporates a function generator to generate fundamental test signals like sine, square and triangular waves. The user also has the option to obtain the FFT (fast Fourier transform) of the input signal.

This article discusses how a PSoC can be used to build an integrated handheld solution kit with an oscilloscope, a signal generator, and a logic analyzer, the schematics of which are shown in Figure 1 and Figure 2 below.

Figure 1: Schematic of the project in PSoC Creator (a)

Figure 2: Schematic of the project in PSoC Creator (b)

The programmable embedded system-on-chip (PSoC) from Cypress Semiconductors integrates configurable analog peripherals, configurable digital peripherals, memory, and a microcontroller on a single chip. The PSoC family that is used in this article for depicting the implementation is PSoC 5LP (Figure 3 below).


Figure 3: Block diagram of PSoC-based handheld electronic lab kit

The PSoC 5LP device is a mixed signal SoC that forms the heart of the kit. It generates the necessary control signals to the graphic LCD controller for display of appropriate pixels on the graphic LCD.
The four-wire resistive touch screen user interface for the kit is realized by suitably mapping the touch positions to planar coordinates. The controller does this critical function by switching the planes for supply, meanwhile obtaining the ADC output at the other plane to obtain a unique set of values for each position on the screen. The analog front end consists of a voltage follower and SAR ADC to sample the input signal and store the data in a buffer for further processing.

Analysis of digital circuits imposes huge bandwidth requirements whose display is limited by the ADCs maximum sampling rate. This limitation can be overcome by treating the signals of the logic circuitry as two-level signals and analyzing these directly through GPIOs (general purpose input/outputs). Now the bandwidth is improved to that of the system’s maximum clocking speed. The PSoC thus generates the necessary test signals to the logic circuit – combinational or sequential, analyzes the output of the same, and displays on the LCD.

There is also a requirement for generating test signals to obtain the responses of several electronic systems. Adding a function generator to the kit would make it a complete lab kit. The function generator block is responsible for generating sine, triangle, and square waves of user-defined frequencies. The user interfaces for these modalities are shown in Figure 4 .

Figure 4: User interfaces of the electronic lab kit

The oscilloscope
The oscilloscope is an essential tool to design or repair electronic equipment. Energy, vibrating particles, and other invisible forces are everywhere in our physical universe. Sensors can convert these forces into electrical signals that we can observe and study with an oscilloscope. Oscilloscopes let us “see” events that occur in a split second.

The oscilloscope is basically a graph-displaying device – it draws a graph of an electrical signal. In most applications, the graph shows how signals change over time: the vertical (Y) axis represents amplitude and the horizontal (X) axis represents time. The intensity or brightness of the display is sometimes called the Z axis.

With the help of oscilloscope we will be able to:

  • Determine the time and amplitude values of a signal
  • Calculate the frequency of an oscillating signal
  • See the “moving parts” of a circuit represented by the signal
  • See how often a particular portion of the signal is occurring relative to other portions
  • See if a malfunctioning component is distorting the signal
  • Find out how much of a signal direct current (DC) or alternating current (AC) is
  • See how much of the signal is noise and whether the noise is changing with time and more

Apart from checking the input signals, having test signals to check the functionality of the circuits is essential. Incorporating a function generator that can generate basic test signals will come in handy when testing the functionality of circuits. To check the functionality of digital circuits, integration of logic analyzer functionality along with the above features makes a complete troubleshooting tool.

Analog front end for the oscilloscope
The analog front end consists of the voltage scaling circuitry, involving simple resistor division and voltage level shift, to convert input signal to the range of the PSoC, i.e. between 0V to 5V. The attenuated input signal for oscilloscope is fed to op amp configured in voltage follower mode, whose output is connected to 12 bit SAR ADC (successive approximation register ADC). The maximum analog bandwidth obtainable with the PSoC 5LP SAR ADC is 70 KHz.Display on the graphic LCD
The JHD12864E graphic LCD is usedto display the acquired analog signal. This graphic LCD is driven by aSamsung KS0108 controller and two such drivers are integrated in theLCD. The LCD is interfaced with the PSoC using an 8-bit parallelinterface and the control signals for the driver are generated by thePSoC.

The LCD is made up of 128 horizontal pixels and 64vertical pixels, in total 128*64 pixels. Each pixel is associated withthe horizontal co-ordinate (time) and the vertical co-ordinate(voltage). To accommodate signals over the specified range, the voltageper vertical division (or voltage per vertical pixel) has to be adjustedbased on the amplitude of the signal. This requires developing analgorithm that takes the user input and updates the LCD accordingly.

Similarly,in order to display varied frequency signals on the display, theseconds per horizontal division (or seconds per horizontal pixel) haveto be adjusted based on the input frequency.

Voltage scaling
Voltagescaling is performed by dividing the acquired signal with the valuesdefined in an array. The array consists of the values {128, 512, 1024,2048, 4096}. These values look random, but the requirement is to fit thesampled values of the 12-bit ADC in the display, which has a verticalresolution of 50 pixels.

The user can scale voltages byselecting the UP or the DOWN tab. When the user presses the UP tab, avariable is decremented, selecting a smaller divider value. When theuser presses the DOWN tab, the variable is incremented, selecting alarger divider value defined in the array.

The variable isconditioned to prevent overflow and underflow beyond the defined arrayindices. Shown below are the displays of results using the followingvoltage scale: Input- 6.5 KHz, 700mVp-p Sine Wave. A high voltage viewis shown in Figure 5 and Figure 6 is for a low voltage view.

Figure 5: High Voltage Scale

Figure 6: Low Voltage Scale

Time scaling
Timescaling works similarly to voltage scaling in which the period of thetimer is updated. The terminal count of the timer serves as the start ofconversion (SOC) signal to the ADC. By varying the period of the timer,the sampling frequency of the SAR is controlled. Shown below are viewsof a low time scale (Figure 7 ), an ideal time scale (Figure 8 ), and a high time scale (Figure 9), all with the following setting for: Input-6.5 KHz Sine Wave.

Similarto voltage scaling, an array is defined whose values can go in as aperiod to the 16-bit timer. The array values are {10, 101530, 10156,1015, 101, 45, 10}.

The user has the option for time scaling byselecting the RIGHT or the LEFT tab. When user presses the RIGHT tab, avariable is incremented which selects a smaller period value for thetimer. When the user presses the LEFT tab, the variable is decremented,which selects a larger period value defined in the array.

The variable is suitably conditioned to prevent overflow and underflow beyond the defined array indices.

Figure 7: Low Time Scale

Figure 8: Ideal Time Scale

Figure 9: High Time Scale

Implementation of resistive touch
TheResistive Touch interface is implemented with the help of the resistivetouch component available in PSoC Creator. This component isimplemented using a 12-bit Delta Sigma ADC. The implementation involvespolling a press on a 4-wire resistive touch panel using a function inthe firmware that returns 1 on touch detect.

The values of X andY coordinates obtained from the component function is mapped to thedisplay. Therefore any touch on a text displayed would result in thecorresponding function to be executed based on the mapped values.

Autosetis a unique functionality incorporated in the design that workssimilarly to the Autoset functionality of commercially availableoscilloscopes. Shown in Figure 10 and Figure 11 are viewsof a 12 KHz Sine wave input before and after the use of the Autosetfunction. Following is a brief description of how the Autosetfunctionality is implemented:

  • The first step is to measure the signal frequency and then automatically change the time scale by changing the sampling rate of the ADC to fit the signal.
  • A three sample array is defined.
  • On obtaining the three samples, the middle sample is compared with the first and the third sample.
  • Another variable indicating sample count is defined.
  • If the middle sample is the largest then the variable sample count is incremented.
  • The comparison routine is continued but this time to obtain the minimum.
  • If the middle sample is the minimum then incrementing the sample count is stopped.
  • The sample count value directly corresponds to the frequency of the signal, since the sampling rate of the ADC is fixed.
  • However, to eliminate highlighting local maxima and minima that could be due to noise or ringing, a threshold is defined.
  • If the difference between the sampled values corresponding to the maximum and minimum are less than the threshold then the sampling rate is not varied and the auto set operation is continued.
  • If the difference is greater than the threshold value then the sampling rate is adjusted to accommodate the signal for user visibility.
Figure 10: Very low sampling rate as a result of which display shows poor reconstruction

Figure 11: Wave displayed after AUTOSET

Run/Stop Mode

RUNand STOP modes work similarly to the commercially availableoscilloscope. When the user presses the S tab, the signal update isstopped on the display. The S tab in the menu is replaced with R, whichindicates that the oscilloscope is in STOP mode. User needs to press theR tab, to resume the signal update on the display.

Gathering statistics of the signal
The user can get the signal parameter by selecting Stats in the Menu. Stat consists of Frequency, Vaverage, Vp-p, and Vrms.

Theimplementation to determine the signal parameters is a crude method.When the user selects the Stats, the program enables the Autosetfunctionality. As described previously, Autoset selects a suitablesampling frequency to fit the signal in the display.

Out of thecollected samples, first maxima and first minima are found with theircorresponding array index. The difference between the Maximum andMinimum values is utilized to determine the Vp-p, Vaverage and Vrmsvalue of the signal. The difference between the indices of the maximaand minima along with the Timer period is utilized to determine thefrequency of the signal.

Turbo Display
Shown in Figure 12 and Figure 13 is a 60 kHz sine wave signal using the kit’s turbo display. Thisfeature allows the engineer or developer to view signals that are out ofthe maximum bandwidth (>70 kHz), with suitable interpolationtechniques. However this is appropriate for smoothly varying signals.Using the turbo feature the bandwidth could be expanded to about 100kHz.

Figure 12: Wave being displayed without Turbo feature

Figure 13: Wave being displayed with Turbo feature

Part 2 of this article covers building a logic analyzer and function generator

Achuth Rao MV is an Applications Engineer at Cypress Semiconductor. He holds aBachelor’s Degree in Electronics and Communication Engineering from RVCollege of Engineering, Bangalore. His interests include signalprocessing and building touch sense solutions. He can be reached at .

Anush M Shet is currently working as an Applications Engineer at CypressSemiconductor. He holds a Bachelor’s Degree in Electronics andCommunication Engineering from RV College of Engineering, Bangalore. Hisinterests lie in the area of Analog Circuit Design and SoC baseddesigns . He can be reached at .

Sachin M Dhareshwar works as an Applications Engineer at Cypress Semiconductor. He holds aBachelor’s Degree in Electronics and Communication Engineering from RVCollege of Engineering, Bangalore. He enjoys building Analog and Mixedsignal designs. He can be reached at .

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.