Bi-directional pins -- I need eight of 'em

dmaccole

New Member
Hiya:

I'm starting out on a new project where I need to control 56 LEDs -- multicolors, just on and off (no fading).

I'd read about Charlieplexing (http://en.wikipedia.org/wiki/Charlieplexing) and was able to implement it on a 14M, using the LET DIRESC command, but I wanted to confirm that only physical pins 5-10 can be set up as bi-directional. Physical pins 3-4 are hard-wired input-only and physical pins 11-12 are hardwired output only, right?

To get to my 56 LEDs, I am assuming I will need an 18X, where I can use Hippy's poke methodology to turn physical pins 6-13 into either input or output as necessary, correct?

Thanks for your insights.

\dmc
 

jmumby

Senior Member
I have done this and you will shortly be flamed, as I was for asking. Hippys method does work but I was not bright enough to work out the sequence for more than three pins so if you do better please share it with the group. Look here http://www.picaxeforum.co.uk/showthread.php?t=7742&highlight=charlieplex for my thread.

One thing you should know, as I found out, you control each individual LED rather than turn any one on and off as you please. The picaxe is too slow to maintain a frequency fast enough to turn each one on and off fast enough to appear on all the time.
 

hippy

Technical Support
Staff member
@ dmc : All 6 of the 14M's Port C can be changed, plus Pins 1, 2 and 4 so that would allow 9 bi-directionals in total, not too difficult to do that but it adds quite an overhead. The 18X with just a single Poke to change LED setting is easier and thus faster. Much more program code memory too.

@ jmumby : I just did some calculations and a 56 LED solution may be possible on an 18X. The sequence would be, set the LED, calculate the next, change the LED setting, calculate the next, change again, repeat. At 50Hz refresh, 20mS that would give 360uS per LED. I can't really comment on the 1/50th brightness but it might be possible by reducing the R to 1/50th ( 6R8 ), but there should be no flicker.

Thet 360uS is perhaps enough for about 2 PICAXE instructions, 4 at 8MHz. That might be enough to read two bytes from SFR and write PortB and TrisB. Because of the delay between the two one might have to set TrisB first to turn all LED's off, set PortB then set TrisC. Takes longer, LED's are on for even less time.

Altering the display is another issue, as you'd need to turn of the LED's whenever that loop is left to prevent any LED on from burning the I/O out. The 28X1 with background serial would seem the best candidate there but any 'going off to update the display bitmap' would stop the display and introduce flicker so animating it might not be very successful. That can also run at 20MHz with standard PC baud rates on background receive. So that's around 10 instructions allowed per LED.

One can always go down from 56 LED's to two separate 28 LED units which gives more time for processing between LED settings.

So it might be possible, but the easiest solution is an 8x8 LED multiplexor chip.
 

dmaccole

New Member
@ dmc : All 6 of the 14M's Port C can be changed, plus Pins 1, 2 and 4 so that would allow 9 bi-directionals in total, not too difficult to do that but it adds quite an overhead. The 18X with just a single Poke to change LED setting is easier and thus faster. Much more program code memory too.
Thanks.

So it might be possible, but the easiest solution is an 8x8 LED multiplexor chip.
Ah, the clouds part and the sun begins to stream in. Somehow, I had missed all the issues about refresh rate and -- most importantly to me -- the dimness of a Charlieplexed LED. I had been experimenting during the day in a bright room, so I attributed the dimness of the LEDs to the ambient light. I just took the breadboard into a windowless room and now see the problem inherent in the Charlieplex scheme.

A little research shows that the Maxim 7219 seems to be the 8x8 multiplexer that is the most popular. However, I'm a little taken aback at its price: $US13.

For that price, I can buy a Picaxe 28X and a ULN2803A and do the job right.

I'll probably be back with more questions when I get the new HW.

\dmc
 
Top