Controlling 60 LEDs

Hi Folks,

I want to individually control 60 LEDs for a clock. I need to start with just one on and each second turn another on until they are all on after 60 seconds after which the sequence restarts. The idea is to buld a Gorgy clock with a PICAXE as the basis.

http://pdf.directindustry.com/pdf/gorgy-timing/new-generation-ledi-clocks/12167-157644-_2.html

Does anyone have a simple solution for achieving this? Ideally some sort of multiplexed output to keep the number of wires down would be wonderful but I don't know of a device that would fit the bill.

Any ideas would be gratefully received!
 

westaust55

Moderator
A very simplistic solution:
  1. 1 x PICAXE 08M2 (bigger if you want to control more)
  2. 8 x 74HC595 shift registers.
  3. 60 x resistors
  4. 60 x LEDs

Use three PICAXE IO pins (1 = clock, 2 = latch, 3 = reset. No need for a data pin)
Have the eight 74HC595 shift regsiters in cascaded connection.
Have the data pin permanently pulled high - so always clock in a "1"

At/after 0/60 seconds reset all the 595's and latch the cleared values to output (maybe just before the advance to 1 second if you want 60 LEDs on for full minute)
At each second, pulse the clock pin which will advance the sequence of 1's further along the cascaded 595's then latch the new state for all 595's.

Advantage are:
  1. simple - no multiplexing,
  2. no flicker,
  3. simple program code (clock and latch each second)

disadvantage:
  1. highest chip count


Next solution:
  1. 1 x PICAXE 08M2(bigger if you want to control more)
  2. 4 x MCP23017 i2c IO expanders (each chip gives you 16 IO so 4 = 64 IO pins.
  3. 60 x resistors
  4. 60 x LEDs

But now you need to have more complex data handling within the PICAXE to handle 4 words,
Clear all 4 words
save msb from word 0 then shift word 0 left 1 bit and OR with 1.
save msb from word 1 then shift word 0 left 1 bit and OR with saved msb from word 0 into lsb of word 1
repeat for next 2 words
write the 4 words as 8 bytes to the IO expanders.


Next there is multiplexing options. There are a multitude of options within this category.
Could be done with one MCP23017 using one 8-bit port for rows and second 8-bit port of same chip for columns.
That gives you up to 64 LED capability.
With multiplexing, the PICAXE must run at higher closk speeds to avoid flicker,
Then must look for how to perform the maths to drive the LEDs elegantly.

Advantages:
  1. lower chip count (just 1 extra chip)


Disadvantages:
  1. Needs more PICAXE computing time
  2. PICAXE must clock faster
  3. possible flicker of LEDs
 
Last edited:

BeanieBots

Moderator
The MAX7219 is an 8-off seven segment display controller.
That would give you full control of 64 LEDs in 8 banks of 8 (only 16 control lines to the LEDs) using SPI so only 3 wires to the PICAXE.
It also does the current control so no need for series resistors and also gives brightness control.
 
Thank you everyone who responded to this post, especially westaust55: thank you for your ideas. Much appreciated. I think I will go with your simplistic solution... being a simple soul.
 

Buzby

Senior Member
Hi Adrian,

Westie's simple solution is elegant, but too simple methinks.

It will do exactly what you asked for, but nothing more.

You will still need another PICAXE to drive the digits.

I would suggest you consider the IO expander route.

Cheers,

Buzby
 

booski

Senior Member
Personally, I'd go with beanie.

It's a single chip, no additional resistors and easy to bit bang a SPI code for it.
 

booski

Senior Member
Actually, I would quite like to build this.

Can you provide the code and schematic please?

e
Well, I meant to say the chip is relatively easy to control with 16bits, 8 for register address and 8 for data.
How you wire up the individual LED's (60 of) is a bit beyond my current scale of thinking but im sure you'd be able to work it out.

a snippet of the code I've used previously with 7 segment display and an 08M

Code:
'MAX7219 connections
symbol datapin = 0
symbol clockpin = 1	
symbol load = 2 	

'MAX7219 shiftout variables
symbol counter = b7	' variable used during loop
symbol var_out = W0	' data variable used during shiftout
symbol bits = 16		' number of bits

'MAX7219 address and data out labels
symbol address = B1	' address to access in MAX7219
symbol dataout = B0	' data to transmit to MAX7219 after address been selected

'MAX7219 registers
symbol DECODE_MODE = $09
symbol INTENSITY = $0A
symbol SCAN_LIMIT = $0B
symbol SHUTDOWN = $0C
symbol DIGIT_TEST = $0F 
symbol DIGIT_TEST_OFF = $00
symbol DIGIT_TEST_ON = $01
symbol digit1 = $01
symbol digit0 = $02

Startup:
address = shutdown	
dataout = $01			' enables the display
gosub shiftout
address = decode_mode 
dataout = $0F		' sets the MAX7219 to decode all digits
gosub shiftout
address = scan_limit 
dataout = $01			' limits  the MAX7219 to display digit 0 and 1 but this can be changed to use all 8 
gosub shiftout
address = INTENSITY	
dataout = $00			' sets the intensity of the display
gosub shiftout

shiftout:
	for counter = 1 to bits
		if bit15 = 1 then   	' as data if shifted, if its a 1 it stays high, else goes low
			high datapin 
		else
			low datapin				
		endif
		pulsout clockpin,1 		' pulse clockpin for 10us 
		var_out = var_out * 2 		' shift variable left for MSB 
	next counter
	pulsout load,1
	return
Just fiddle with the data in the address registers for the settings and you should then using some sort of mathematical method be able to assign each led to a pin.

Datasheet is VERY handy for this one.
 

Billo

Senior Member
At the very most, using a shift register solution, you'd only need 3 I/O pins.

1 - data
2 - clock
3 - reset

And that is if you want to get fancy. You only need 2 otherwise.
 

westaust55

Moderator
Hi Adrian,

Westie's simple solution is elegant, but too simple methinks.

It will do exactly what you asked for, but nothing more.

You will still need another PICAXE to drive the digits.

I would suggest you consider the IO expander route.

Cheers,

Buzby
Not entirely true.
As indicated: as parts:
1. 1 x PICAXE 08M2 (bigger if you want to control more)​
To also drive the central time then you just use a bigger PICAXE (maybe a 14M2 would suffice) to have the extra IO to drive the digital clock in the centre.

However, you could also use two of the MAX7219 as flagged by Beaniebots - one for the digital clock and one for the analogue seconds "bar"

So far I/we have only considered the display side and still need some IO for switches to set the time.
One presumes Adrian has the rest of the clock sorted and is primarily only seeking an optimal solution for the analog seconds 'bar' around the circumference.
 

westaust55

Moderator
At the very most, using a shift register solution, you'd only need 3 I/O pins.

1 - data
2 - clock
3 - reset

And that is if you want to get fancy. You only need 2 otherwise.
The 74LS673 is a good alternative to the 74HC595 where there are long sequences of bits such as required for this project.
As mentioned earlier, you may get way with two signals as the data line is permanently high (pull up resistor).
1. Clock
2. Reset – to clear the registers.
3. Latch - maybe optional and could be permanently enabled ? as the data is alway 1's being clocked through flicker may not be an issue
 
I just want to thank everyone, especially BeanieBots (and booksi, for seconding). I used the MAX7219 and it is all working brilliantly.
 

westaust55

Moderator
Well done. :)

It would be worth your posting the shematic diagram, program code and a few photos in the completed projects section of the forum. That would then act as a resource for others to glean information from and as a reference to point other towards in future.
 
Top