PROJECT M254 : XY-Plotter

A high performance LCD-based XY plotter or how to drive high-resolution graphic LCD panels without expensive LCD controller chips…

The use of a graphical LCD in a project is an excellent way to drastically change its look & feel. Unfortunately graphic LCDs are real resource-hungry devices, both in terms of memory and CPU power. So the embedded-systems designer is forced to leave its lovely minimalist designs and either select an intelligent LCD display (with on-board LCD controller and memory), or swap its usual micro-controller for a more classic microprocessor/memory/display-controller set. Both options are expensive, but there are unfortunately no other solution, right ? For example the 320x240 pixels display used in this project eats one 4-bits nibble each 677ns, and needs a minimum of 10KB of RAM just to store the displayed bitmap, so it is impossible to directly drive it with a high-end Microchip PIC controller providing a cycle of 100ns even when clocked at 40MHz, and just 1536 bytes of RAM in total, right ? Nothing useful could be done in less than seven assembly instructions per nibble, right ? As you might expect this project shows that impossible is possible with a very optimized firmware design, and that it’s even possible to use this minimalist concept to do something useful !

 

XY-Plotter is an autonomous analog-like display, with two main X and Y inputs. It continuously scans the two inputs and displays them on a real-time X/Y graph with configurable modes. Moreover both analog and digital auxiliary inputs allows to display configurable information’s on the screen. Lastly an RS-232 port in provided in order to dump hard-copies of the screen to a host computer.

 

 

 

The high level diagram of the XY-Plotter project highlights its simplicity, at least on the hardware side. The PIC 18F252 is managing everything including the LCD pixel generation in real time. A couple of Microchip MCP6022 rail-to-rail operational amplifiers are used to scale the analog inputs. An integrated power supply is built using a MCP1541 precision voltage reference.

The hardware is straightforward, so you will imagine that the firmware is not and you will be right. A main loop is executed each 13.4ms, and starts with a frame-batch routine which manage the push-buttons and more importantly reads all auxiliary inputs, analog and digital, and generates the text that will be displayed in the first 3 lines. Then a loop is executed for each of the 240 columns of the display. At each iteration the X and Y analog values are read and managed. The tricky part is the last one : for each line the firmware must generate the nibbles to send to the LCD on the fly, firstly the nibbles corresponding to the graphic area, then the ones for the three text lines at the top, in less than 42µs total or 500ns per word to send to the LCD, meaning only five assembly instructions !

The efforts to optimize the cycles count of such a firmware are huge. For example one of its basic tasks is to send N pulses to the nibble clock input of the LCD. An usual loop already needs 5 cycles to do it, and the firmware has other thinks to do thank just sending clock pulses ! So far more optimized techniques are needed, like code expansion and calculated goto (see listing 1).

On December 15th the XY-Plotter prototype is fully operational, clearly demonstrating that the concept actually works. The screen is refreshed 70 times per second and is free from any flicker. The A/D management and graph generation are perfect in all modes as well as the textual display. I have of course still a couple of remaining bugs to correct, but nothing that seems critic. One of the first on the list is the fact that different columns of the display have a quite different contrast. The root cause is a variation in the execution time of each column generation routine, that will be easily corrected thanks to one of the on-board timers. A couple of more nights and this project will be ready to be embedded into my next project.

Globally developing this useful project was really fun, I hope reading about it was fun too !

Schematic