Custom 7Segment display characters
-
- Posts: 30
- Joined: Tue Apr 16, 2013 3:10 pm
- Has thanked: 48 times
- Been thanked: 9 times
- Contact:
Custom 7Segment display characters
hi all,
searched through the forum and also checked the custom code for 7segment display component custom code but didnt understand that how custom chanracters like "P","L","n","o","U","A","d","b","E" can be used to display on 7segment display.. any suggesions would be greatly appreciated..
Prashant
searched through the forum and also checked the custom code for 7segment display component custom code but didnt understand that how custom chanracters like "P","L","n","o","U","A","d","b","E" can be used to display on 7segment display.. any suggesions would be greatly appreciated..
Prashant
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
- Contact:
Re: Custom 7Segment display characters
Hi,
It's quite simple. Make a LUT (lookup table)/array and go through the table whenever you want to display a certain pattern on your 7 segment display.
Checkout wikipedia for other hexcode:
http://en.wikipedia.org/wiki/Seven-segm ... ng_letters
Once you have your lookup table set. You can simply do something like:
PORTB = LUT_7SEG[X], X being a value between 0 and the highest index of the array.
That's pretty much it.
Here's a little example:
PS: I always forget which bit value sets the I/O as output in a TRIS register.
EDIT:
Btw, you assign 1 pin of a port to each LED of the 7 segment display.
By setting or clearing a pin, depending on what model of display you have (C.A. or C.K.), you turn on or off one of the LEDs of your display.
It's that simple .
It's quite simple. Make a LUT (lookup table)/array and go through the table whenever you want to display a certain pattern on your 7 segment display.
Code: Select all
LUT_7SEG[] = {
0x3F, // 0
0x06, // 1
0x5B, // 2
0x4F, // 3
// ...
};
http://en.wikipedia.org/wiki/Seven-segm ... ng_letters
Once you have your lookup table set. You can simply do something like:
PORTB = LUT_7SEG[X], X being a value between 0 and the highest index of the array.
That's pretty much it.
Here's a little example:
Code: Select all
// simple 7 segment counter on portb
char LUT_7SEG[16] = {
// set 7 seg code for 0x0 to 0xF
}
char counter = 0;
// Set PORTB I/O to output
while (1)
{
PORTB = LUT_7SEG[counter]; // Set PORTB output to LUT value
delay_ms(250); // 250ms delay;
counter = counter + 1; // increase counter by 1
}
EDIT:
Btw, you assign 1 pin of a port to each LED of the 7 segment display.
By setting or clearing a pin, depending on what model of display you have (C.A. or C.K.), you turn on or off one of the LEDs of your display.
It's that simple .
-
- Posts: 30
- Joined: Tue Apr 16, 2013 3:10 pm
- Has thanked: 48 times
- Been thanked: 9 times
- Contact:
Re: Custom 7Segment display characters
hi Dude,
thanks for such a quick reply.
btw i am not very much familiar with some functions of C language.
i went through the flocode 7 segment Display component Code and changed Array values to my custom characters values, and i got what i wanted.. was much happier seeing the result.
when i saw your reply, i understood the original code of 7segment display component.
still i want to know that in FC component macro custom code, that array was having values like %c, %d,%e.... where these values came from?
%c = code of "0" dec code is 192,
%d = code of "1" 249 ...
how this %c became 192 and so on?
appreciate your quick and nice reply which took me to next step of my project..
thanks
thanks for such a quick reply.
btw i am not very much familiar with some functions of C language.
i went through the flocode 7 segment Display component Code and changed Array values to my custom characters values, and i got what i wanted.. was much happier seeing the result.
when i saw your reply, i understood the original code of 7segment display component.
still i want to know that in FC component macro custom code, that array was having values like %c, %d,%e.... where these values came from?
%c = code of "0" dec code is 192,
%d = code of "1" 249 ...
how this %c became 192 and so on?
appreciate your quick and nice reply which took me to next step of my project..
thanks
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Custom 7Segment display characters
Nice easy way to remember:Spanish_dude wrote:PS: I always forget which bit value sets the I/O as output in a TRIS register.
I as in Input looks like a 1
O as in Output looks like a 0
So with TRIS register:
Use 1 for Input
Use 0 for Output
Martin
Martin
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
- Contact:
- 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: Custom 7Segment display characters
That's how I remember it tooI as in Input looks like a 1
O as in Output looks like a 0
Unfortunately AVRs work the other way, 1 is output, 0 is input. Here I just remember that AVRs are backwards to what you would expect
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
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Custom 7Segment display characters
Thanks Ben,Benj wrote:Unfortunately AVRs work the other way, 1 is output, 0 is input. Here I just remember that AVRs are backwards to what you would expect
I did not know that, so I need to remember that one!
Trust AVR to be so awkward!
Martin
-
- Posts: 30
- Joined: Tue Apr 16, 2013 3:10 pm
- Has thanked: 48 times
- Been thanked: 9 times
- Contact:
Re: Custom 7Segment display characters
thats really a cool way to remember
thanx for that, Martin
btw i understood the way to use custom characters for 7Segment displays, i have edited the component file of 7seg display accordingly and getting the expected output..
i am thinking to upload the respected file along with LUT for all custom characters and their index nos, may i?
Prashant
thanx for that, Martin
btw i understood the way to use custom characters for 7Segment displays, i have edited the component file of 7seg display accordingly and getting the expected output..
i am thinking to upload the respected file along with LUT for all custom characters and their index nos, may i?
Prashant
-
- Posts: 94
- Joined: Wed Jul 29, 2009 5:15 pm
- Has thanked: 6 times
- Been thanked: 8 times
- Contact:
Re: Custom 7Segment display characters
Hello,
I am looking to do the same thing. If you have a modified 7 segment LED component, can you please post the code?
I am looking to do the same thing. If you have a modified 7 segment LED component, can you please post the code?
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Custom 7Segment display characters
Your welcome.prasha920 wrote:thats really a cool way to remember
thanx for that, Martin
Of course you can,prasha920 wrote: i have edited the component file of 7seg display accordingly and getting the expected output..
i am thinking to upload the respected file along with LUT for all custom characters and their index nos, may i?
Forum users are more than welcome by everyone to post any projects, modified files, tips and tricks etc.
In fact what your asking to post will be really welcome in the Tips and Tricks section of the forums.
Martin
Martin
-
- Posts: 30
- Joined: Tue Apr 16, 2013 3:10 pm
- Has thanked: 48 times
- Been thanked: 9 times
- Contact:
Re: Custom 7Segment display characters
Hi Martin,
thanks a lot for clearing me where to post the files...
Prashant
thanks a lot for clearing me where to post the files...
yes surely i am going to upload the corresponding files in my next post.. as mentioned by Martin, you will find those files in the Tips and Tricks sectin of the forum.beambase wrote:Hello,
I am looking to do the same thing. If you have a modified 7 segment LED component, can you please post the code?
Prashant