Cheap XY plotting with Arduinos

The basic idea

A while ago I experimented with plotting XY signals with an Arduino.1 The key idea was to digitize a couple of analogue signals with the Arduino, then send the samples to a PC where they could be plotted as XY pairs. Recently, I’ve revisited this, but displaying the results on a 320×240 LCD screen connected via SPI.

You can buy the Arduino2 and screen3 from Adafruit for about $50 (£32), or from Chinese suppliers on eBay for about $9 (£6). I wanted to buy half-a-dozen, so took the latter route.

However, there is a problem with the Chinese displays: they need 3.3V logic levels, but the Arduino has 5V rails. The Adafruit display includes level-shifters to accomodate this.

Happily there is an easier hack: just replace the 5V regulator on the Arduino with a 3.3V equivalent e.g. the TLV1117-334 from Texas Instruments. I am not sure if all Arduino clones use regulators with the same pinout, so check before doing this.

One other caveat: the regulator only affects power supplied by the jack socket, and not the USB port. I was going to power the Arduinos from batteries in production so that was fine, but for code development I used an Adafruit display board.

Software

The software is trivial: a simple marriage of the TFT example from Adafruit and some fast ADC code from Guy van den Berg. You can grab it from GitHub5 though.

No attempt is made to expire old points, nor is any reset provided beyond the master Arduino reset button. So, it is only useful if the signal is stationary.

Wiring notes

Three sets of wiring are needed:

Signal. Attach the X-signal to A0 and the Y-signal to A1.

The display. This is the only tricky part, so see the helpful diagram below.

Power. Attach 6–9V to the power jack.

Crude specification

As you can see, there is no input processing, so the signals are DC-coupled with a range from ground to Arduino’s supply voltage. If you’ve changed the regulator that will be 0–3.3V, otherwise it will be 0–5V.

The lack of low-pass filters means that aliasing artefacts are quite possible. Characterizing the useful frequency range is not trivial though because there are three different time scales:

The time between samples: roughly 40μs;

The skew between X- and Y-samples: roughly 20μs.

The sample time: ‘short’ according to the Atmel datasheet;

For periodic signals the middle term often dominates. See my earlier experiments6 for a fuller discussion of this.