Step 4The Charliegrid...layout and programming
For those not familiar with this, it is a way of controlling lots of LEDs with only a few pins by taking advantage of the tri-state nature of a microcontrollers pins and the forward voltage of the LEDs. There are numerous explanations of the charliegrid and their applications on the net so I won't give more than a quick explanation.
Note the configuration of LEDs on the charliegrid.
You can put a +ve voltage on one control line, and you can put a 0V on another line. You leave the other control lines unconnected to anything. Imagine having the charligrid on a breadboard and you connect two control lines to a battery. In the case of the microcontroller, you program these two pins to be outputs, and set one pin to a logic '1' and the other to a logic '0'.
You leave the other control lines unconnected, or in the case of a micrcontroller you set these pins as inputs.
The LED with the most direct connection to this connection will light up. Even though there are multiple paths through these pins through other LEDs, only one will light because when it does, the forward voltage of that LED will always be lower than any combination of other LEDs.
When the position of the logic '1' and '0' are reversed, and the same control lines are selected, the LED in the reverse position lights up. You can see these in the circuit diagram as pairs of LEDs between every combination of control inputs. As such 6 control lines can operate 30 LEDs individually....not at the same time of course!
To light up an LED it is simply a matter to program the microcontroller to send a logic '1' or a logic '0' to which ever two control lines corresponded to that LED and set the others to inputs.
By briefly illuminating each desired LED in turn, you can build a display like a monitor due to persistance of vision effect. Because only one LED can be lit at a time, this is always necessary in a charliegrid.
In the code the porta/portb output registers and tris registers are loaded with values pre-calculated to light up an LED. Took a while to calculate them all. Here is a fragment:
// LED1 LED2 LED3 LED4
unsigned char LEDS_TRISA [31] = { 0xfd, 0xee, 0xf7, 0xfd,
unsigned char LEDS_PORTA [31] = { 0x02, 0x01, 0x08, 0x00, 0
unsigned char LEDS_TRISB [31] = { 0xfb, 0xff, 0xfb, 0xfb, 0
unsigned char LEDS_PORTB [31] = { 0x00, 0x00, 0x00, 0x04, 0x
If anyone knows of a generalised charliegrid algorithm, I'll be very interested.
But first the grid had to be layed out. For the microdot this was a big challenge because of the lack of space. The main picture shows how this became managable.
Initially I put the LEDs in pairs in the grid and the bottom components in as well where I wanted them. This was very confusing when trying to sort out the best most efficient connectivity of the complex charliegrid. By moving the LEDs away from the bottom components, the ratsnest became easier to read. After that it was simple to move the grid back onto the bottom side components and do the bottom layout with a minimum of layer to layer vias and crossover tracks. You can see the impact of moving and rotating the LEDs to get the best arrangement in the crazy naming sequence of the charliegrid schematic after renumbering LEDs on the board.
| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|












































