Dick Cappels' project pages http://www.projects.cappels.org

return to HOME

Minimum Mass Waveform Capture and Display

 A system for the capture and display of analog waveforms using a three Atmel AT90S2313's and a graphic LCD

This material formed the basis of an article that was first published in the July, 2004 issue of Circuit Cellar magazine.


A 128 x 64 graphic LCD is in the clear plastic box at the top.
It is connected to the waveform capture and control unit in the
green pencil box below the display.

Downloads
AVR Studio 3.5  ASSEMBLY SOURCE for the waveform capture controller.
AVR Studio 3.5  ASSEMBLY SOURCE for the control panel and LED Display controller.

Also needed: Circuit and Firmware to support and interface the Seiko-Epson G116 display.

Overview
Even before I finished the waveform capture circuit , which is separately describe in these web pages, I started thinking about making an oscilloscope-like instrument with it. I have enough respect for what goes into the design of a real digital oscilloscope to not even pretend this comes close. It has limited bandwidth, a sampling rate of only 1 MHz, and no anti-aliasing filtering. I do, however, find this tool very useful for observing repetitive waveforms. For example, I have used it to measure the ringing frequency of some LC networks and to diagnose a firmware problem that was the source of trouble on a micro controller's output pin.



This project has three micro controllers in it. On each in
the Graphic LCD panel, the waveform capture unit, and one
for the control panel and LED display.

The result was a project that includes a waveform capture circuit, a graphic LCD (Liquid Crystal Display) and a control panel with LED indicators. The details of the Graphic LCD display unit, composed of the LCD module, a serial interface, and bias supply were published earlier on this site, and you can see it HERE. As described, the display plugs directly into the waveform capture and control unit, which is what the what the rest of this page is dedicated to.

 

 Waveform Capture and Control Unit


On the left hand end of the Waveform Capture Unit circuit board is the the microcontroller that interfaces the input buttons and LED clock display to the Waveform Capture controller on the right hand end of the board. In the middle are the comparator and quad op amp used in the analog signal processing and triggering circuit. Along the bottom edge of the board is the interface to the control panel. Along the top edge are (left to right) connectors for the LCD Graphic display, unregulated +8 volt power in, signal and trigger signal inputs, and a ground point for troubleshooting.

Overview
The board contains all of the analog circuit including the +5 volt power supply as well as the waveform sampling circuit and control panel interface with LED display. A clock display picked up surplus is used to display the sampling rate and it is driven by the control panel controller. A separate LED mounted just below the clock display indicates that the sampling is being triggered and is driven directly by the analog circuitry.

The control panel controller appears as an ASCII terminal to the waveform capture controller and the two chips communicate using their on-chip hardware UARTs at 9600 baud. Both the controllers are Atmel AT90S2313. The control controller could have been implemented using an AT90S1200 but it was a little easier with the AT90S2313 because it has a hardware UART and a luxurious RAM stack, and by the time I came that part of the project I was much more anxious to see waveforms than to see if I could use the lower cost processor.

Circuit


The waveform capture and control and indicator unit only uses four easily
obtainable integrated circuits. The only part that might be tout of the ordinary for
a lot of people is programming the AT90S2313 microcontrollers.



The circuit is straight forward, having few frills.. Indeed, all of the input signal processing circuitry like the DC/AC coupling switch, 10:1 voltage divider, and the X10 gain amplifier could be left off entirely, as could the trigger circuit and trigger indicator and the button and display controller, leaving only the bare bones converter in a single AT90S2313 that can be controlled through and ASCII terminal. The "extra" circuitry was added to meet my expected near-term modest needs.


Waveform signal circuit
AC coupling through the two 0.33 uf capacitors in series gives a time constant on the input of about 2 seconds -may be a little long for some applications. The easiest way to shorten it is to replace the series capacitors (there are two of them because the ones in this range that I have on hand are tantalum) with a nonpolarized capacitor with a suitable voltage rating.

The 10: 1 divider on the input circuit is frequency compensated with a single 5 pf capacitor to ground. I used parts I had on hand. If you are picky, you can use metal oxide resistors to get a more precise and stable divider, but remember this is only a 6 bit waveform monitor.

The ideal case when the divider switch is in the "X1/10" position is for the capacitance across the 10 Meg Ohm resistor to be 1/10 the capacitance from the top of the 1 meg Ohm resistor to ground. A good practice is to place a relatively large resistor from the top of the 1 meg resistor to ground, say 10 or 15 pf, and then select or adjust a trimmer across the 10 meg resistor. This is exactly how a X10 scope probe works, and if you are so inclined, you could skip the 10:1 divider, ground the bottom of the 1 meg resistor (short the 100k), run the top of the 1 meg straight to a BNC connector and use it with either a X1 or X10 scope probe. If you do this you might have to increase the 5 pf capacitor a little bit to get a high enough shunt capacitance for the scope probe's frequency compensation to work.

The 10k resistor serves to limit the current into the gate of the FET for large positive signals, and to limit the current into the 1N916 for large negative signals, thus protecting the circuitry. There is still some susceptibility, however, because of the shunt capacitance across the 10k resistor, so don't go probing the output of a fluorescent LCD backlight with this.

The FET in my circuit is an MPF102 but you can probably use any one of many JFETs you have around. The FET must be selected to provide a suitable shift in the DC level of the input signal when the input is grounded. Try for 2.5 volts ± 1 volt, to allow some room for the signal. The LM324 operates from the unregulated power supply to provide a little extra latitude in this operating point, but remember to keep the input level, which can be 1 volt P-P or more plus the offset to well below 4.5 volts DC where the differential gain of the comparator on the AT90S2313 gets to be too poor even for 6 bit operation. The value of the 15k source follower resistor can also be varied to obtain the necessary level shift. If the resistor gets too large, the bandwidth might suffer noticeably, and if it is made to small, then a lot of the input signal will be dropped across the source resistance, thought there is quite a bit of adjustment range in the waveform capture circuit itself to make up for quite a bit of this loss.

A X10 direct coupled amplifier is implemented with an LM324. The LM324 has a gain-bandwidth product of 1 MHz, so the 3 db corner frequency of this X10 amplifier is 100 KHz, which is acceptable tradeoff given the LM342's ability to operate from a single +5V power supply and low cost. The gain of the amplifier is set by the 62k and 6.8 k resistors. The gain comes out pretty close at 10.1:1, so it would only be 1% off if the resistors were right on value. The bottom of the feedback divider made of the 62k and 6.8k resistors connects to the voltage follower made from another section of the LM324, and this voltage follower appears as if it were a ground at about 2.5 volts, which is appropriate given that the input signal was level shifted up by 2.5 volts by the source follower. The input to to the voltage follower is set by a coarse (10k pot) and a fine (50k pot) offset adjustment.

The 2N2907 connected across the 62k feedback resistor in the X10 amplifier serves to limit the circuit's maximum output voltage swing to just above the +5V supply. This is because the LM324 is powered from the unregulated +8 volt input and could otherwise swing well above the +5V power supply, which could be bad for the input of the AT90S2313. Note that in a higher resolution application, where noise was more of an issue, noise on the 5 volt supply coupled to the inverting input of the op amp though the transistor's collector to base capacitance could be a problem and in that case it would be better to decouple the base from the power supply with a small resistor and a small capacitor.


Trigger circuit

The trigger circuit couldn't be much more straight forward. The trigger signal, whether from the external trigger input or the waveform signal itself, is compared to a trigger level set by the trigger level potentiometer. The resulting sliced signal is applied to the trigger input of the waveform capture controller. The signal is also AC coupled to a detector made from the remain half of the dual comparator. Whenever a pulse swings above 2.5 volts, as set by the two 470k resistors, the output of the comparator dumps the change on the 0.33 uf capacitor on its output to ground. The purpose of the 1k resistor in series with the capacitor is to limi the peak current on the output of the comparator to 5 miliamps. A 100k resistor charges the capacitor back up slowly and the voltage across the capacitor drives an LED through a voltage follower made with a 1/4 of the LM324. The more the capacitor is kept low by trigger pulses, the more the LED is on, thus the LED serves as an indicator that the trigger circuit is sending trigger pulses to the waveform capture controller.

The voltage on the wiper of the 10k trigger level potentiometer sets the level on the incoming waveform at which the trigger pulse starts. If The waveform were, as an example, a sine wave, the trigger level control would allow the circuit to smoothly vary the triggering time as the threshold traversed the amplitude of the sine wave. The selection of the positive or negative slope takes place in the microcontroller


Waveform Capture controller (10 MHz AT90S2313) and centering circuit
The waveform capture controller is the same approach described elsewhere on this site. This implementation differs in the RC filter in that the 160k resistor was replaced with a 180k resistor because I ran out of 160k resistor and besides the lower part of the divider was made adjustable to allow a little more flexibility as well as accuracy in the full scale calibration.

An adjustable DC offset is provided for to allow vertical centering of the waveform signal on the display. This circuit is discussed in some detail elsewhere on this site.

The bit-banged 19200 baud interface to to the serial interface to the Seik-Epson LCD is unbuffered on this end because I expect the display to be plugged into the connector all the time, so there will be little chance of a problem from electrostatic discharge, or worse yet, serious wiring errors.


Display and button controller (4 MHz AT90S2313)

This chip's purpose is to refresh the display and scan for pressed buttons on the control panel. Communication is to and from the waveform capture controller via ASCII codes over a serial interface running at 9600 baud. Not that the signals between the waveform capture controller and the display and button controller are inverted compared to RS-232 signals because of the absence of inverting buffers.

The LED display is common cathode and it is driven one digit at a time from left to right, and each digit is driven at a 20% duty cycle. After the rightmost digit has been driven, the output pins on port B, which act a segment drivers, switch to inputs with the internal pull-ups activated. After a short settling time, the values on the pins on port B are read. If any of the pushbuttons on the control panel is pressed, the corresponding pins on port B will be held low. The purpose of the 1K resistor in series is to make sure that damaging currents are not drawn from the I/O pins through the push buttons while driving an LED segment.

The cathodes of the LED digits are driven directly from the PORT D output pins because the the peak possible current (21 ma for the first second after power-on reset as a check of the display) is well below Atmel's recommendation for the AT90S2313.



Power supply
The unregulated +8 volts into the circuit is shunted by a 14 volt metal oxide varistor because the line operated "battery eliminator" I used doesn't have any protection of its own. Sometimes varistors are hard to get, so you might want to substitute an 18 volt zener in its place, or if you feel daring, omit it altogether.

After the power switch, the +8 volts connects to the LM324 and the 5 volt regulator. The LM324 draws less than 3 milliamps for each of its 4 op amps.

The significant loads on the 5 volt regulator are the LEDs, which take about (5V-2V)/1K or 3 ma peak per segment. The worst case display is "50-3" which has a total of 15 segments, which are run at a 20% duty cycle, so the current for the display is 15 x 3 ma x 0.2 = 9 ma.

        LED display < 9 ma
        LM393 < 1 ma
        10 MHz AT90S2313 < 13ma
        4 MHz AT90S2313, excluding the LED display, < 7 ma
        Everything else < 5 ma
        Total maximum current = 35 ma.

If the maximum average input voltage is 15 volts, then the voltage across the voltage regulator is 15 volts-5 volts = 10 volts, so the maximum power dissipation in this package is 10 volts X 50 ma = 350 mw. The thermal resistance from junction to ambient for a TO-92 package is about 200 degrees C per watt so we're looking at a 70 degree maximum temperature rise above ambient. I don't plan to run this above 45 degrees C (when it gets that hot its too hot to think) so that would put the junction temperature at less than 115 degrees, which sounds fine, and a quick check of the data sheet shows about 150 mw margin for the worst case mounting. If I was driving the LED display with much more current, I would have to give serious thought to using a larger voltage regulator.


Waveform Capture Controller Firmware

This program runs on an Atmel AT90S2313 microcontroller at 10 MHz to capture a repetitive waveform by comparing the incoming waveform with 64 successive DC levels using the on-chip analog comparator. It also uses the UART to communicate with a simple user control panel or ASCII terminal using ASCII commands, and has a firmware UART to communicate with a dot graphic LCD. The firmware is adapted from the basic Minimum Mass Waveform Capture firmware described HERE. The program also communicates with the Control Panel and LED Controller, which is described below.

The Waveform Capture Controller echos all commands it receives from the Control Panel and LED Controller. Below is a table of commands that can be received from the Control Panel and LED Controller and the actions that are taken in respond
   
The interface is via the AT90S2313 hardware UART, running at 9200 baud, 1 stop bit, no parity

Command Returns Action
(from terminal)
0 echo set timing to 1 us
1 echo set timing to 2 us
2 echo set timing to 5 us
3 echo set timing to 10 us
4 echo set timing to 20 us
5 echo set timing to 50 us
6 echo set timing to 100 us
7 echo set timing to 200 us
8 echo set timing to 500 us
9 echo set timing to 1000 us
: echo set timing to 2000 us
; echo set timing to 5000 us
< echo set timing to 10000 us

E,e echo, (status + $50) toggle auto erase before write on/off
C,c echo, (status + $50) toggle capture enable on/off
D,d echo, (status + $50) decrement delay time (note 1)
I,i echo, (status + $50) increment delay time (note 1)
F,f echo, (status + $50) toggle trigger polarity
A,a echo, (status + $50) Toggle triggered/free run


Note 1: Delay values decrement to zero and increment to "<". Repeated assertion of
increment or decrement after these limits are reached results in the echo and staus being
returned, but delay values will not change. Delay values are represented via the ASCII interface
by the ASCII characters "0" though "<".

Flags
0 if set, enables erasing before writing
1 if set, enables capture
2 if set, trigger set to positive edge
3 if set, free run (not triggered) mode

The flags are returned by adding $50 to the flag register and sending it as the status byte.

When the waveform capture controller comes out of power-on reset and after initializing the LCD,
it sends status and the delay value to the control panel. The actual values sent are
"_" followed by "2".


Here is are brief descriptions of some of the firmware's functions:

The hardware UART communicates with the control panel at 9600/1/N and expects inverting buffers between the UART and the RS-232 channel. Alternatively, it can communicate with the signals inverted compared to RS-232 is the control panel is set up to be compatible with this data polarity.

A soft UART communicates with the display at 19200 baud and does not expect inverting buffers between it and the serial channel as the inversion is already done in firmware. In other words, the data polarity is the same as that on an the serial connector of an ASCII terminal.

The dumptodisplay routine includes formatting for the Seiko-Epson 1216 128 x 64 dot graphics display with a serial interface described elsewhere in these pages (here). In initial operation, the controller sends a command of $80 to erase the display, then $82 to put the display in binary mode. Then the x and y coordinates of the dots to be turned on to represent the captured waveform are sent. The display's serial interface is expected to send a character as a handshake after each dot or erase operation is completed. The handshake keeps the waveform capture controller from sending commands faster than the display can handle them.

The pulse width modulator that supplies the 64 different DC levels for the purpose of waveform capture assumes a 5:1 divider on the output and an RC filter time constant of 1 millisecond. The PWM is operated in the 8 bit mode and data is shifted left twice before being written to the PWM.

The firmware main routines are:

scanspan -This is the main loop and repeatedly samples the incoming waveform and checks the hardware UART for control panel activity before each iteration.

capture - Performs the actual waveform capture routine.

incomingbyte - Interprets control panel commands and returns status via the hardware UART.

dumptodisplay - Formats and dumps the waveform data to dot graphics display in binary form.

The interval between samples of the incoming waveform is done with delay loops that are selected using an indirect jump within the sampling routine. There is a separate subroutine for each of the selectable timing intervals of 1 us, 2 us, 5 us, 10 us, 20 us, 50 us, 100 us, 200 us, 500 us, 1ms, and 10 ms. There are 100 samples taken along the time axis, so the 10 millisecond interval results in the capture of a repetitive waveform with a one second period.

Here is theAVR Studio 3.5  ASSEMBLY SOURCE for the waveform capture controller.

Control Panel and LED Display Controller Firmware

This program is meant to simulate an ASCII serial terminal for the purpose of displaying control panel information from the Waveform Capture controller on a 4 digit LED clock display and accepting input from a set of push buttons on the control panel. There are five tasks called by the interrupt-driven round robin multitasked, which are:

1. Refresh LED display digit 1
2. Refresh LED display digit 2
3. Refresh LED display digit 3
4. Refresh LED display digit 4
5. Get the status of control panel buttons.

Communication with the waveform capture controller is via the on-chip hardware UART running at 9600 baud, 1 stop bit, no parity.

If, while loading the status of the control panel buttons, a button is found to be down, the controller will wait for the button to be released before sending the button's associated code and continuing program execution.

Here is The AVR Studio 3.5  ASSEMBLY SOURCE for the control panel and LED Display controller.

Layout and Mechanical Aspects

I tried to lay the front panel out to feel like an analog scope, and a reasonable front panel layout took priority over other aspects of the mechanical arrangement. I had already chosen the plastic pencil case as being large enough to hold the controls, and a handy size as well. The LED display went at the top so my hand would not obscure it while adjusting the controls. The arrangement of the buttons is intuitive to me, so I rarely need to take my eyes from the displays as I make adjustments.



The layout of the controls is similar to that on
analog scopes.


On the circuit board, the locations of the two microcontrollers were known from the start -the LED controller would be near the LED at the top, and I  put the waveform capture controller at the opposite end of the board to minimize noise pickup from the LED refresh. That meant that I had to squeeze all the circuitry between these two controllers, positioning them so that the pots on the top did not interfere with the socketed integrated circuits on the circuit board. The layout, within these constraints, was critical, particularly the input voltage divider and grounding.

It was important to keep the trigger signal from coupling into the analog signal path. The divider needed to be laid out with minimum parasitic capacitance.  The leads to the attenuator switch added shunt capacitance across the 10 Meg resistor, for which C2 in the schematic provided compensation.


Arranging the parts on the top of the box so they would not interfere with the high profile
parts on the circuit board was a tedious task.


The tool that resulted from this project has come in very useful time and time again. The device, along with its captive AC adapter are kept in a cabinet and it is easily brought out and set up on my desk next to the computer or on my small work bench in my small Bangkok apartment whenever I need it. Its nothing like a real-time analog oscilloscope, but I have found it very handy for a variety of testing and troubleshooting tasks.

 Use of information presented on this page is for personal, nonprofit educational and noncommercial use only. This material (including object files) is copyrighted by Richard Cappels and may not be republished or used directly for commercial purposes. For commercial license, CLICK HERE.

 HOME

Please see the liability disclaimer on the HOME page.

Contents © 2004 Richard Cappels All Rights Reserved. http://www.projects.cappels.org/