There are a ton of digital picture frame tutorials out there. many are old laptops with crafty case reconfigurations that fit a photo frame profile.
We set out to build a 100% DIY, scratch-built digital picture frame. Our frame has a 12bit color LCD, gigabytes of storage on common, FAT-formatted microSD cards, and you can build it at home. We’ve got the details below.
Concept overview
The bitmap images are stored on common, PC-readable microSD cards. A picture microcontroller reads the images over a three wire SPI bus. The picture processes the image data and writes it to a color LCD over a unidirectional, 9bit SPI-like bus. A configuration file on the SD card defines the delay between images.
Hardware
Click for a full size schematic image (PNG). The circuit and PCB are developed using the freeware version of Cadsoft Eagle. All the files for this project are included in the project archive linked at the end of the article.
Microcontroller
We used a Microchip PIC24FJ64GA002 28pin SOIC microcontroller (IC1) in this project. We really like this chip because the peripheral pin select feature lets us put essential features on the pins we want; this gives a smaller, simpler, much more compact PCB. Each power pin has a 0.1uF bypass capacitor to ground (C1,2). The internal 2.5volt regulator requires a 10uF tantalum capacitor (C12). The chip is programmed through a five pin header, SV1. R1 is a pull-up resistor for the MCLR function on pin 1. read much more about this chip in our PIC24F introduction.
A 32.768kHz crystal (Q1) and two 27pF capacitors (C10,11) offer an oscillator for the real-time clock calendar (RTCC). These parts are optional, the initial firmware doesn’t use them. The RTCC could be used as part of a function that superimposes the current time on the screen. buttons connected to the programming header could be used to set the time.
SD karta
MicroSD cards are completely compatible with regular SD cards, microSD cards can be used in an SD card reader/writer with an adapter. We evaluated several microSD card holders, and settled on one from SparkFun Electronics. The microSD card requires a bypass capacitor between the power pin and ground (C3). An LED indicates microSD read activity, but its also helpful for general debugging (LED1, R2).
Color LCD 128×128 Nokia knock-off
This project is developed around SparkFun’s $20 color LCD panel. The LCD logic runs at 3.3volts and requires a decoupling capacitor (C4). The LED backlight requires a separate 7volt supply, and appears to have an internal current limiter because example designs don’t use external resistors.
The LCD has a separate input for the 3.3volt display supply. numerous report noise in the display if this voltage isn’t clean. We used a ferrite bead (L1) and 0.1uF capacitor (C5) to filter the supply, and haven’t experienced any problems. This even dealt with a dirty home-etched prototype. The ferrite bead type isn’t important, we used one left over from our tiny web server project.
The small connector is easy to solder on a professional board with a solder mask, but purchase several as insurance. SparkFun has a PCB footprint for this part in their Eagle parts library, but the spacing between the pads is smaller than Olimex or BatchPCB will manufacture. We fudged it by decreasing the pad size to get much more space between. Don’t depend on the connector to hold the LCD in place, use tape to hold it down. We used sticky-tack to attach the LCD temporarily.
We prototyped an LCD carrier board prior to sending the final design for manufacture. We recommend against using a ground fill under the connector without a solder mask.
Zdroj
A 3.3volt supply, offered by an LD1117S33 (IC2), powers the PIC, microSD card, LCD logic, and LCD display. IC2 requires a 0.1uF bypass capacitor (C6) on the supply side, and a 10uF capacitor (C13) on the output. We used the same tantalum capacitor that we used for the picture internal regulator.
The LCD backlight is powered by an LM317 adjustable regulator (IC3) configured to 7volts with 240 (R5) and 1100 (R6) ohm resistors. C7 and C8 are 0.1uF bypass capacitors for the LM317.
J1 is a SMD power jack for a common 2.1mm DC barrel plug. C11 is a 10uF electrolytic capacitor that smooths any lag in the supply voltage. C11 has a maximum 16volt input rating, so the supply voltage is best kept under 12volts. 9-12 volts is probably the idea power supply range.
PCB
Click for a full size placement diagram (PNG). L1, C5, and the LCD are on the opposite side. We can’t prototype two-sided boards in mom’s basement, so we sent this design to BatchPCB. next week we’ll show you how we did it.
Zoznam položiek
Časť
Description
IC1
PIC 24FJ64GA002 (SOIC)
IC2
LD1117S33 3.3volt regulator (SOT223)
IC3
LM317 adjustable regulator (SOT223)
U$1
Color LCD 128×128 Nokia knock-off
–
Nokia knock-off connector
C1-8
0.1uF capacitor (0805)
C10,11
27pF capacitor (0805)
C12,13
10uF tantalum capacitor (SMCA)
C14
10uF electrolytic capacitor (SMD)
L1
ferrite bead (0805)
LED1
LED (0805)
Q1
32.768kHz crystal
R1
2000 ohm resistor (0805)
R2
390 ohm resistor (0805)
R5
240 ohm resistor (0805)
R6
1100 ohm resistor (0805)
SD1
microSD card holder
J1
2.1mm power jack (SMD)
SV1
0.1” male pin header, best angle
Firmware
The firmware is written in C using the totally free demonstration version of the picture C30 compiler. learn all about working with this picture in our introduction to the picture 24F series. The firmware is included in the project archive at the end of the article.
FAT12/16/32 disk library
Microchip’s FAT 12/16/32 library gives us easy access to files stored on SD cards. We gave a comprehensive description of this library in our web server on a company card project. If you’re having trouble reading a card with the library, check that it was formatted in a digital video camera or using Panasonic’s SD card formatter.
Nokia 6100 LCD driver
SparkFun has a basic 8bit color chauffeur (ZIP) for the Nokia 6100. We ported it to the PIC, and updated it for the 2byte-per-pixel 12bit color mode. With a small amount of added complexity, the pixel write rate could easily be enhanced by using a different 12bit mode that delivers two pixels using 3 bytes.
The LCD uses a 9bit protocol, one bit much more than many SPI hardware will handle. The first bit tells the LCD whether the next 8bits are data or a command. On the picture 24F it’s impossible to manually bang in the first bit, and then use the SPI peripheral to send the remaining 8bits. We lose direct control of the pins when hardware SPI is enabled. The data entry has to be completely bit-banged, which dramatically reduces the screen revitalize rate.
Reading Bitmaps
There are a ton of bitmap formats. Windows compatibility keeps everyone using the ancient Windows v3 format. We created two C structs to read the V3 bitmap data.
Offset
Bytes
Bitmap file header
0
2
Always 0x42 0x4D (hex for BM)
2
4
File size (bytes)
6
2
Reserved, ignored
8
2
Reserved, ignored
10
4
Location in file of the first bitmap data
Bitmap files start with a 14byte file header. The first two bytes are the letters ‘BM’, indicating a bitmap. If the first two bytes are correct, the firmware loads the information header. The last four bytes indicate the beginning of bitmap data, but the current firmware just assumes it will begin at the end of the headers.
Offset
Bytes
Bitmap information header
14
4
Length of bitmap information header (40bytes for Windows V3 bitmaps)
18
4
Width (pixels)
22
4
Height (pixels)
26
2
Color planes, always 1
28
2
Color bits per pixel (1, 4, 8, 16, 24 and 32)
30
4
Compression method, we only read uncompressed (type 0)
34
4
Image data length
38
4
Horizontal resolution (pixels per meter)
42
4
Vertical resolution (pixel per meter)
46
4
Number of colors, ignored.
50
4
Number of essential colors, ignored.
A Windows V3 bitmap information header is 40bytes long. The firmware verifies that the header length (offset 14) is 40, indicating a V3 bitmap. If the width (132), height (132), color depth (24), and compression (0) all check out, the image data is processed and output to the screen.
Offset
Bytes
24bit image bitmap data
54+(3n)
1
pixel n red value
54+(3n+1)
1
pixel n green value
54+(3n+2)
1
pixel n blue value
Bitmap images have uncompressed, 1:1 representations of pixel data stored in three byte sequences. The data starts at the lower right-hand corner of the image; first the red value, then green and blue. Wikipedia has a complete bitmap walk through.
If the color depth of a bitmap image (24bits) is greater than the LCD can display (12bits), we need to discard the least significant bits of color data. To convert from 24bit color to 12bit color, we just chuck half the color data; an 8bit value of 11110011 is pushed four bits to the right, giving 1111.
Firmware walk-through
Init PIC, SD, LCD.
Read config.ini, create if it does not exist.
Use first character of config.ini to set between image delay.
Look for images, open next image.
Read and check bitmap file header for proper format.
Read and check bitmap information header for version, size, color.
Read and display each pixel value. adjust bit depth as needed.
Delay, then repeat from 4.
Preparing images
To keep this demo simple, the photo frame only displays the most common bitmap format. images should be sized to 132x132pixels, with 24bit color.
Open a picture with an image editing program.
Draw a square selection box over the part of the image you want to use, typically using shift and drag.
Crop the image.
Size the image to 132x132pixels.
Save the image as a windows bitmap, 24bits of color depth.
Other image sizes and formats could be supported with a firmware upgrade (PNG, JPG), especially with a pin-compatible microcontroller upgrade to a huge dsPIC 33F.
Using it
Put images in the root directory of a FAT formatted SD card. depending on the laSt Zariadenie na formátovanie karty, možno budete musieť naformátovať s digitálnou videokamerou alebo Panasonic SD formát.
Voliteľné: Urobte súbor Config.ini s textovým editorom. Zadajte jednu číslicu, od 0-9, na nastavenie oneskorenia s obrazom. Uložte súbor. Ak nevytvoríte vlastný súbor config.ini, bude pre vás vytvorený s 1 sekundovým oneskorením.
Dajte kartu do zásuvky a zapojte digitálny obrazový rám. Obrázky budú na obrazovke cyklovať s definovaným oneskorením.
Brať ďalej
V tomto jednoduchom digitálnom obrazovom rámci vidíme veľa potenciálu. Početné funkcie je možné pridať s aktualizáciou firmvéru, niektoré sú základom pre budúci hardvér.
Zobraziť iné formáty obrázkov, snímok stupnice
Náhodné zmizne a obrúsky
Zobrazenie času a dátumom obrazu, nastavte pomocou tlačidiel pripojených k programovacím pinom
Rozšírte možnosti konfigurácie v Config.ini, aby ste zahrnuli dlhšie oneskorenia, vyblednúť alebo utrite typu
Použite subdoldrový adresár pre obrázky, pretože existujú určité obmedzenia súboru do koreňového adresára FAk Formatted SD karty.
Pridajte ethernetové pripojenie pre sieťové aktualizácie displeja.
Stiahnuť: dpf.v1.zip sa tu presťahoval.