The problem with using a microcontroller to drive an LCD is that an LCD requires constant attention. This can be mitigated with a CPLD driven over SPI (using DMA, of course), but then you run into the other problem: Color LCDs require a lot of data. 320x240 in black and white is marginal at 9.6KB, but make it 24 bit color and suddenly you need to deliver 230KB of data in 1/60th of a second. (Don't forget, though, that you can get 4-bit, 16-color control just by tieing the low 20 bits to one setting). A 24-bit frame buffer no longer fits in onboard RAM on most microcontrollers, and you probably don't have time to read from an external RAM chip, clock the data out, and still do other processing. Trying to do this with a CPLD (or an FPGA) and a RAM chip gets you well over the $2 price that caused you to balk in your question.
The traditional solution to interfacing a microcontroller with a color LCD is a display controller like an SSD1963. Here's a very simple block diagram:
Parallel input to a big RAM frame buffer (Translation: More than $2) interfaced with a register-configurable parallel LCD interface. The parallel input is usually compatible with a memory bus interface.
The color LCD market is not always easy to find on the web, usually being the domain of OEMs only, with the rest buying displays from companies who integrate the controller with the display. The best resource I've found has been Crystal Fontz, specifically this page on choosing graphic LCDs. Scroll to the bottom for the controllers, which include the following options (note: Not all are color controllers):
- Epson S1D13521B01 E Ink Broadsheet (1 module)
- Epson S1D13700 (11 modules)
- Epson SED1520 Compatible (8 modules)
- Himax HX8345 Compatible (1 module)
- ILITek ILI9325 Compatible (3 modules)
- KS0107/KS0108 Compatible (26 modules)
- Novatek NT7534 (14 modules)
- Orise Technology OTM2201A (1 module)
- Orise Technology SPFD5420A (1 module)
- RAiO RA8835 (1 module)
- Sanyo LC7981 (13 modules)
- Sino Wealth SH1101A (2 modules)
- Sitronix ST7920 (29 modules)
- Solomon SSD1303 (1 module)
- Solomon SSD1305 (9 modules)
- Solomon SSD1325 (2 modules)
- Solomon SSD1332 (1 module)
- Solomon SSD2119 (2 modules)
- ST STV8105 (1 module)
- Toshiba T6963 (23 modules)
Do you have a diode across your relay? If not the inductive spikes on closing/opening will likely cause problems.
When you e.g. stop the current flowing through a relay, it tries to keep it going, if there is no route of discharge it will create a large voltage (essentially it will keep rising until it finds a route).
Specifically the formula is V = L(dI/dT). This means the inductor opposes changes in current through it by developing a voltage across it proportional to the rate of change of current.
Try placing a diode across the relay, orientated to oppose normal current flow.
EDIT - checking the product page it seems it is a "ready rolled" relay in a box with peripheral components added, so it's unlikely to be the above. Even so I would try placing the diode across the power to the relay.
Also make sure your supply is well filtered as mentioned in the comments. Place a few capacitors of at least 1uF next to the ICs and LCD, and a bulk cap of >100uF somewhere (all from power to ground)
Best Answer
That display requires you to send each frame as a frame in its entirety. You need to send the full pixel data for each and every pixel with all the right timing. Kind of like driving a VGA monitor.
While it is possible to do it with a generic microcontroller, that microcontroller must:
There are specialized microcontrollers that have extra hardware in them to specifically drive this kind of display. The one I have used in the past is the PIC24FJ256DA210.