# Picaxe 28x2 BCD to Decimal conversion?

Hi, Bit of a daft question really. I am trying to output my clock data from my Pic' 28X2 to a custom array of LED's. I have the code that reads my clock (RTC DS1307) and coverts the BCD input to decimal but no matter what I can't seem to find out how to output the decimal data or have the picaxe arrange it in such a way that it will be displayed on my LED array. My array is, put simply, an LED version of an analogue clock with 60 LEDs for the seconds, minutes etc.
If I could have some pointers with regard to either decimal output or BCD output to a dedicated BCD to DEC chip, that would be much appreciated.
Thanks

1 year ago
How have you connected the 60 leds ?

What do you mean here by decimal output ?
LED Maestro (author)  steveastrouk1 year ago
My LEDs are multiplexed with the common annodes and cathodes connected to all available op pins. And by decimal I mean the standard notation of numerical value ie 0,1,2,3,4 etc as opposed to BCD (Binary Coded Decimal) which, as the name suggests, is in binary where 0001=1, 0010=2, 0011=3 etc. as I previously said I already have a working code to convert binary to decimal but I don't know how to output the converted values to my LEDs. The reason I ask is that I understand it can be difficult to display time information on led displays, whether they be segment displays or big LED boards, in BCD, that's why I mentioned dedicated chips that take a BCD input and convert to a decimal output.
Hope this sheds some clarity, my apologies if I wasn't clear
Thanks
1 year ago
In a BCD number , the decimal number 100 is represented as
0001 0000 0000
Not
01100100

Are your 60 leds arranged in 7 segment matrix then ?
1 year ago
...if they're in 7 segment, and they only need a few mA a piece, then I HIGHLY recommend using the MAX7221 that I used in my carbarduino project - SPI in, 8 x 7 segments out. Simples.
LED Maestro (author)  steveastrouk1 year ago
Steve, my apologies once again. you are correct in your previous statement regarding BCD number values. The LEDs are arranged in an 8x8 grid (minus 4 LEDs) but spread over a radius to create the clock look, however for the sake of keeping my mind sane we shall imagine an 8x8 grid (see image, basic diagram without the necessary resistors and transistors etc). I will look into the MAX7221 in any case, thanks.
LED Maestro (author)  LED Maestro1 year ago
I have just looked at the data sheet for the MAX7221. It looks fantastic. It says it is capable of running 64 LEDs (Ideal as I only use 60) I am assuming that I can just interface it with my PIC', wire up my multiplex to the MAX and away it goes (In the best case scenario)?
Thanks
1 year ago
It IS a wonderful chip. You have it pretty well nailed, I would say the only "gotcha" is it can't drive a HUGE current through the LEDs, unless you take extra, complex measures - I did massive 250mm road signs driven by the logic of that chip, but with a load of extra bits to drive over 400 LEDs simultaneously with one of 'em,

The other note I would make, is that you can save yourself a TON of code, if you map the leds logically, ie the first 8 leds go to digit 0 and are mapped dp,a,b,c,d,e,f,g, the second 8 are on digit 1 and map dp,a,b,c,d,e,f,g etc etc.
LED Maestro (author)  steveastrouk1 year ago
I can't thank you enough for all your help on this. I have been looking at the problem for over a week now until I relented and came here. I will have a look at your carbarduino, I am sure it is filled with much that will help me. I will be getting a couple of MAX7221's so I can prototype and work it into my project.
My thanks to you once again
Best regards
1 year ago
The 7221 will do what you want. The great secret is to map the LEDS into a linear array, so that you can know which LED is lit for every "decimal" value

0 0
1 15
2 27
3 33
4 28

Of course, it makes a huge difference if you map the LEDs to the 7221 in a sensible order !!!!

The 7221 can map digits to 7 seg, or just write to LEDs as you wish.
It contains (various stuff) 8 registers that map 8 rows of 8 LEDs.

So to set the 1st and 3rd LED in the 2nd row, I send 00000101 to register 2.
to set all on in the 8th,7th,6th and 5th leds on the third row, I send the byte 11110000 to the 3rd register.

Again, if you tear down my carbarduino code, you can see how I carefullly mapped the bargraphs to the chip.