CURRENT ISSUE

Contests

bottom corner

FEATURE ARTICLE



Issue #216 July 2008

Second Place Microchip 2007 Design Contest
’Net-Enabled Alarm Clock

by DJ Delorie

Start | System Overview | Network | Display | MP3 | ADC | Memory | Power | Software | Time | Alarms | GUI | Remote Protocols | Construction & Packaging | Smart Combinations | Sources & PDF

DISPLAY

The display for an alarm clock has to work in conditions that most displays never encounter. It has to be visible in bright daylight, but shouldn’t shine too brightly in a dark room. Most alarm clocks have seven-segment LED displays, which can be dimmed as needed. LCDs are either not visible at night or require a backlight that appears as a grey rectangle at night. I wanted the advantages of LEDs with the flexibility of LCDs, so I turned to OLED technology. The OLED display I chose uses a SPI bus, so any display that uses SPI (OLED, LCD, and VFD) can be used without major changes in the schematics. If you want to use a display with a parallel bus, you can use a PIC with more pins.

The OLED display is a matrix of tiny LEDs. Each can be set to one of 16 brightness levels. In addition, the drive current can be set to one of three levels. During the day, the drive current is maximized and the pixel values are used to control the brightness of the display, according to the photocell readings. At night, in addition to using the lowest (non-off) pixel value, the drive current is reduced to its lowest level, resulting in a dim display, which is suitable for night viewing.

One catch with the OLED display is that you can’t apply drive power until the controller chip is running. So, the PIC24FJ64 has one GPIO that controls a pair of transistors that switch on the 12-V power for the OLED, after it’s had time to come out of reset. The power rail also has extreme current swings, so it is bypassed with both a large electrolytic capacitor and a low-ESR tantalum.

Note that ceramics can’t be used here! Ceramic capacitors are piezoelectric, so those types of current swings cause the capacitor to move like a tiny piezo speaker. I wanted to make the clock as noiseless as possible. It took me a while to find the source of the noise because I expected the coils in the switching power supply to be the problem source. If you choose to use an LCD, this power switch could be used to control the backlight, either as a simple on-off switch or by reprogramming the PIC pin to be a pulse-width-modulated output.

The OLED routines write to the display exclusively with bit-blit (BITBLT: BITwise block transfer) routines, copying font elements or stored images to the display as needed. (Refer to the oled.c file on the Circuit Cellar FTP site.) Because the display uses 1 byte for every two pixels, all images are an even number of pixels wide. To save space in the EEPROM, all images are compressed, with one of three run-length compression algorithms. The “main font” used for the primary time display is stored as a 2-bit- per-pixel image, with pixel values representing background, foreground, and shadows. They are dynamically replaced with pixel values based on the photocell. Thus, the main display’s brightness depends on the room brightness.

The other two formats are a 4-bit-per-pixel image and a 1-bit-per-pixel image. The format used depends on the image. The internal functions allow any format for any image.

For debugging, there’s also a console emulator. It uses the smallest font to provide an 8 × 21 character screen and a printf-like function.

Previous | Next                *| Subscription Deals |*

 


bottom corner