Hello,
I'm stuck again.
I have a little board that drives 4 x 7 Segment LED's via a shift register, I know what string of bits to sent to light up the correct digit and number
but I'm stuck on how to make some sort of table up so that if I wanted to send for example, number 8 to digit 1
The bits to send could be selected from the table. Last time I did something like this I used a BCD to 7 Segment Driver and it was fairly simple.
This is the table I've used to make a crude counter to test the board but there must be an easier way.
Thanks for any assistance.
//Select digit
dig1 = 0b0000001
dig2 = 0b0000010
dig3 = 0b0000100
dig4 = 0b0001000
Select number to send
// Numbers inverted and entered
// in reverse order
b0 = NOT 0b0111111 // 0
b1 = NOT 0b0000110 // 1
b2 = NOT 0b1011011 // 2
b3 = NOT 0b1001111 // 3
b4 = NOT 0b1100110 // 4
b5 = NOT 0b1101101 // 5
b6 = NOT 0b1111101 // 6
b7 = NOT 0b0000111 // 7
b8 = NOT 0b1111111 // 8
b9 = NOT 0b1101111 // 9
4 x 7 Segment LED and shift register help
Moderator: Benj
-
- Posts: 61
- Joined: Sat Apr 11, 2015 12:07 pm
- Has thanked: 20 times
- Been thanked: 14 times
- Contact:
4 x 7 Segment LED and shift register help
- Attachments
-
- 4 x 7 Seg LED and Shift Reg Test.fcfx
- (20.83 KiB) Downloaded 423 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: 4 x 7 Segment LED and shift register help
Hello,
How about this. It should simplify things a bit for you by using arrays to store the 7-seg control values.
How about this. It should simplify things a bit for you by using arrays to store the 7-seg control values.
To do this you would simply call the new Digit display macro with the parameters 0 and 8.if I wanted to send for example, number 8 to digit 1
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 61
- Joined: Sat Apr 11, 2015 12:07 pm
- Has thanked: 20 times
- Been thanked: 14 times
- Contact:
Re: 4 x 7 Segment LED and shift register help
Thanks I'll check it out when i get home.
I forgot to mention there are two registers
In series.
I missed the version 7 special offer
The email ended up in my spam folder
It had only just closed when i noticed it.
Still having great fun with v6 though.
I forgot to mention there are two registers
In series.
I missed the version 7 special offer
The email ended up in my spam folder
It had only just closed when i noticed it.
Still having great fun with v6 though.
-
- Posts: 61
- Joined: Sat Apr 11, 2015 12:07 pm
- Has thanked: 20 times
- Been thanked: 14 times
- Contact:
Re: 4 x 7 Segment LED and shift register help
Thank you that's very interesting.
Strange thing is, with that 1 sec delay in the main loop the first 3 digits were just a blur every second and the 4th a permanent zero,
but deleting that delay made it appear to slow down.
The first 2 digits almost a blur but the 3rd and 4th counting fast, with the delay deleted.
I will study it.
Strange thing is, with that 1 sec delay in the main loop the first 3 digits were just a blur every second and the 4th a permanent zero,
but deleting that delay made it appear to slow down.
The first 2 digits almost a blur but the 3rd and 4th counting fast, with the delay deleted.
I will study it.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: 4 x 7 Segment LED and shift register help
Hello,
Are the values static and you can write them and they stay for the different displays or do they need to be constantly multiplexed at high speed?
Multiplexing is certainly possible but I didn't allow for this in the program I sent.
Here is another version you can try which includes multiplexing using a timer interrupt which should give you a refresh rate of approx 61Hz (244Hz timer interrupt / 4 displays to multiplex between).
Are the values static and you can write them and they stay for the different displays or do they need to be constantly multiplexed at high speed?
Multiplexing is certainly possible but I didn't allow for this in the program I sent.
Here is another version you can try which includes multiplexing using a timer interrupt which should give you a refresh rate of approx 61Hz (244Hz timer interrupt / 4 displays to multiplex between).
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 61
- Joined: Sat Apr 11, 2015 12:07 pm
- Has thanked: 20 times
- Been thanked: 14 times
- Contact:
Re: 4 x 7 Segment LED and shift register help
Thanks for that, it works perfectly very smooth no flickering.
It's going to take me a while to fully understand how you've done that, a week I expect!
The basic thing I'm having trouble with is this, if for instance I read a time from a RTC module and want to send it to the
LED's how do I link a certain number to the correct string of bits. How would I link say 5 to 1101101 to be sent to the register that's the sort of thing I'm baffled on.
Is doesn't take much to baffle me. Would I use a lookup table or something. It's something dead simple I expect, for you anyway.
Last time I used a BCD to 7 segment display driver chip and it all worked fine.
I think I've only scratched the surface of what flowcode can do. It's keeps my old brain working, gives great enjoyment.
Thanks very much
It's going to take me a while to fully understand how you've done that, a week I expect!
The basic thing I'm having trouble with is this, if for instance I read a time from a RTC module and want to send it to the
LED's how do I link a certain number to the correct string of bits. How would I link say 5 to 1101101 to be sent to the register that's the sort of thing I'm baffled on.
Is doesn't take much to baffle me. Would I use a lookup table or something. It's something dead simple I expect, for you anyway.
Last time I used a BCD to 7 segment display driver chip and it all worked fine.
I think I've only scratched the surface of what flowcode can do. It's keeps my old brain working, gives great enjoyment.
Thanks very much
-
- Posts: 61
- Joined: Sat Apr 11, 2015 12:07 pm
- Has thanked: 20 times
- Been thanked: 14 times
- Contact:
Re: 4 x 7 Segment LED and shift register help
I don't think the display needs refreshing all the time, its a pair of MC74HC595AD it does latch the output.