PDA

View Full Version : Seven segment controller question - Is there a better way?



Christopher4187
- 21st August 2013, 18:44
I am making a custom LED scoreboard. It's all volunteer work so the budget is paper thin. I know there's more than one way to do things but I'd like to know if this is it or if there's a better way.

The scoreboard has five digits and each digit will have seven segments. The numbers will be about 19" tall by 10" wide. What I was planning to do is have a host PIC to control everything. Because there are a number of things it will do other than the scoreboard, I decided to use MCP23S08's to control how the number is displayed and ULN2003's to drive the LED's. It works out pretty well seeing as how the MCP23S08's have 8 outputs and the ULN2003 has 7 outputs.

I was going to label the segments A-G so I would have 1A, 1B....1G then 2A, 2B, etc. Then I was going to use GOSUB's for the numbers. So if I want to display 14, I would put(I'm simulating with outputs instead of using the SPI since I haven't started it yet)

X=14

DIGIT_1=X/10
DIGIT_2=X//10

GOSUB DISPLAY_DIGIT_1
GOSUB DISPLAY_DIGIT_2

DISPLAY_DIGIT_1:
SELECT CASE DIGIT_1
CASE 1
1A=1
1B=1
CASE 2
1F=1
1A=1
1G=1
1D=1
1C=1
CASE 3
ETC.....

END SELECT


Does someone have a better idea?

aerostar
- 21st August 2013, 21:50
There are many designs on the net for this - many use a shift register, daisy chained to the next one,(74hC595s) rather than use your port expander, you would still use the uln to provide the current. many 7 segs have a decimal point so that makes a nice 8 to fit byte format.

Your digits would be sent as a bytes shifted out in bits to the register so your digit "1" would be %00000011, digit 2 would be %01101101, A is the least sig bit in this example. So any segment with a 1 will be on 0 =off. 8th bit for decimal point if used , but does not need to be connected as you only have 7 output on uln, but you must shift out the 8 bits regardless.


Have a look here http://www.picbasic.co.uk/forum/showthread.php?t=981 and post 3 - there is a pdf schematic.

to set up your 5 digits use a look up (or is it down) table with just 0-9. so for a 1 you would have %00000011 = $03 for 2 %01101101 =$6d and so on.


you have 5 digits , look up value for first and shift it out, same for the second and so on.

Christopher4187
- 21st August 2013, 22:31
Thanks for the reply. I don't understand why the shift register is more advantageous (or that much different) than using a port expander. Lets forget about cost for a second seeing as how the shift register is cheaper but we're talking about a one off device, not volume production.

The schematic you provided a link to shows pretty much the same thing I was thinking (which is perfectly fine by the way - I have no problems with it). He is using one shift register per digit, which is the same as the design I was thinking about. However, now that I think about it I can use a 23S17 and reduce my chip count from 5 to 3.

Does the shift register reduce the amount coding that you have to do? In other words, pretend you're a salesman, what's the selling point with using the shift register as opposed to a port expander?

aerostar
- 22nd August 2013, 10:05
You said "the budget is paper thin." so usually 74HC etc stuff is cheaper than port expanders.

When I scanned your expander and the new one, I see that there seems to be a lot of settings to be sorted, so I looked for an easier route, hardware and programming.

The shift registers are easy to use, and the program is relatively straight forward.

You store the binary patten of each digit in on board pic eprom starting at location 0, so you have 10 values (led patterns) there 0-9.

you have your x=14 or whatever , THEORETICALLY 00014

If you store that 5 into an array eg numbers(0) = 4 numbers(1) =1 and so on

remember to send the least significant digit out first as that will be the far right hand on the display

you then do a loop something like

FOR COUNTER = 0 TO 4 ' 5 DIGITS
pattern = numbers(counter)
read patten , temp ' get the led patten into temp
then shift out temp to the shift register
next

you now have all the segments for the 5 digits done

with some extra programming you could make the leading "0"s be unlit.

aerostar
- 27th August 2013, 21:38
Presumably he has done his own thing - pity he did not have the courtesy tell us whether he went with shift registers or port expanders and why.

Dave
- 28th August 2013, 11:53
Chris4187, Personally I would use a MIC5842 for the shift register/driver as it has 8 bits and latch for each large led display.