**EEWeb Forum**

FPGA Rocket IO

**aBlogtoRead.com**

Ball Engineer Hydrocarbon Ceramic XV Watch Review

Sun, 2010-09-05 16:26 — rolo

This is an easy to build X-Y oscilloscope. To try this an ATmega324P and two KAD0820 (same as National Semiconductor's ADC0820) were used. Originally this oscilloscope was built around an AT90S4414 hence the external AD converters. Some rose and Lissajous curves were used to test this oscilloscope.

For videos of animated curves, schematics, firmware and curve generation instructions, follow the link...

This circuit looks a bit messy as built on the protoboard, and takes a bit of experimentation to get it to work correctly. To begin with, I fed the same sinewave to both channels and once I got a reasonably clear diagonal line I proceeded to test other curves. The contrast setting for the LCD was set for a relatively cool 20ºC (68ºF) so if you try it in a warmer environment, your LCD could look a bit too dark.

**How it works**

There are two analog to digital converters (ADC) one of which converts a signal for the X axis and the other for the Y axis. The data from the converters is scaled down and then used as coordinates to draw a dot on the screen. If you feed a sinewave to each channel with an offset of π/2 radians, a circle will be drawn.

The ADC0820 converters are in the WR-RD mode which is the fastest of both available modes, taking only 1,5 uS to convert a sample, and the microcontroller reads them as often as it can from an infinite loop. The ADCs are read at a rate of about 1666 times per second, but the much higher speed of the converters is not exactly useless. I actually tried with the ATmega324P internal converters and with its slower conversion time, about 13uS, the distortion in the curves was too obvious. Both of the ADC0820s conversion cycles are started within nanoseconds so the conversions are almost simultaneous and it's not necessary to correct for phase changes between both source signals. So instead of complicating the firmware to be able to use the Atmega324P internal converters I decided to build the original circuit and recompile the old C source code for the newer microcontroller.

Capacitors C2 and C6 block the DC component of the signal and RV1 and RV2 give DC bias to the AC only signal allowing to center the curve on the screen. Magnification can be marginally changed by changing the reference voltage trimpot RV3. As it was conceived to be used from an audio card, the card's own volume control is the best curve size adjustment.

The persistence of the curve is simulated by the use of a buffer.

The Nokia LCD used for this experiment is the one in the Nokia 3390/3310 cell phone. Note that in the pinout indicated in the schematic, pin 1 corresponds to the contact next to the plastic positioning pin in the back of the LCD module. For this experiment I used an old prototype board that belongs to a different project. It made things much easier and also provided backlight, but you don't need to use something similar. There are a lot of web resources that explain how to use the Nokia LCD. This link may help or search Google for so many other related webpages.

The following image shows the whole circuit. The fan is used only to help support the LCD board to an angle that makes the screen easy to view.

**Firmware**

Click here to download the HEX file for this project.

**Circuit schematics**

Below is the Schematic for this circuit. Click the image for a larger version.

**Generating the waveforms**

When using a sound card to generate the waveforms, to get a clear curve, it is necessary to switch off all the sound enhancement features of the sound card, such as bass boost and the ambient simulation effects.

To generate the sound files I used the Audacity audio editor. First I tried a few roses and then some Lissajous curves. To generate the roses I converted the equations to parametric form and then, using a simple trigonometric identity I converted the equations for X and Y from products to sums. This is necessary because the the audio software can only sum the waves (as far as I know).

In this experiment, the right channel of the audio card will go to the X input of the oscilloscope, and the left channel will be connected to the Y input of the oscilloscope.

All the necessary information to generate the rose curve was taken from this Wikipedia article.

The polar equation for the roses is:

r = sin (k*θ)

In parametric form:

x = sin (k*θ) * cos (θ)

y = sin (k*θ) * sin (θ)

Converting to sums:

x = ½ sin ((k+1)*θ) + ½ sin ((k-1)*θ)

y = ½ cos ((k-1)*θ) - ½ cos ((k+1)*θ)

So, for k = 2 we have:

x = ½ sin (3*θ) + ½ sin (1*θ)

y = ½ cos (1*θ) - ½ cos (3*θ)

We are interested in the ratios between the frequencies, so generating sine waves of frequencies that are multiples of the factors obtained above will work perfectly. The frequency must be high enough that the oscilloscope can show a complete curve within the limits of its simulated persistence. So, for k=2 I chose 150Hz and 50Hz. To obtain the cosine waves it is necessary to displace the sine wave generated by Audacity one quarter of its period. It is also necessary to invert the wave for the negative cosine. Also, all the waves are generated with the amplitude setting set to 0,5 to comply with the equations above. All the required features to do this are already provided in Audacity.

In Audacity I used a monoaural sound track because it has a left-right balance slider that allowed me to make a monoaural sound track to be reproduced in the left (Y) or right (X) audio channel.

The resulting file for k = 3 is shown below:

Just below is a table showing all the parameters necessary to generate the rose curves:

In this table, k = n/d. The frequencies are f1 and f2 and the offset necessary to get the cosines is f1(cos) and f1(cos), both of these columns are given in seconds.

Below are shown some curves that are possible to obtain:

(Image from wikipedia.org)

On the Nokia LCD screen some of the roses look as follow:

To obtain the Lissajous curves, the same methodology is followed but is already given in parametric form in the Wikipedia article.

x = sin (at + δ)

y = sin (bt)

The following table show the parameters used for the Lissajous curves used in the test.

For all the Lissajous curves generated, δ = π/2.

On the Nokia LCD screen some of the Lissajous curves looked as in the following image:

**Video**

**Conclusion**

This was a fun to build and play with project and really liked it. The current setup seemed to work well to around 600Hz, but that could be much improved by optimizing the firmware, because the AD converters are fast. Most of the microcontroller time is spent drawing and erasing the dots on the screen.

- 3698 reads