Page 1 of 1

Custom 7Segment display characters

Posted: Thu Oct 17, 2013 10:20 pm
by prasha920
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.. :D

Prashant

Re: Custom 7Segment display characters

Posted: Thu Oct 17, 2013 11:44 pm
by Spanish_dude
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.

Code: Select all

LUT_7SEG[] = {
0x3F, // 0
0x06, // 1
0x5B, // 2
0x4F, // 3
// ...
};
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:

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
}
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 :).

Re: Custom 7Segment display characters

Posted: Fri Oct 18, 2013 1:11 am
by prasha920
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.. :D :)
thanks

Re: Custom 7Segment display characters

Posted: Fri Oct 18, 2013 12:51 pm
by medelec35
Spanish_dude wrote:PS: I always forget which bit value sets the I/O as output in a TRIS register.
Nice easy way to remember:

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

Re: Custom 7Segment display characters

Posted: Sun Oct 20, 2013 2:03 am
by Spanish_dude
:o ... I'll try to remember that Martin, thanks :D.

Re: Custom 7Segment display characters

Posted: Mon Oct 21, 2013 5:31 pm
by Benj
I as in Input looks like a 1
O as in Output looks like a 0
That's how I remember it too :D

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 :wink:

Re: Custom 7Segment display characters

Posted: Mon Oct 21, 2013 6:12 pm
by medelec35
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 :wink:
Thanks Ben,
I did not know that, so I need to remember that one!
Trust AVR to be so awkward!

Re: Custom 7Segment display characters

Posted: Mon Oct 21, 2013 9:10 pm
by prasha920
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.. :D
i am thinking to upload the respected file along with LUT for all custom characters and their index nos, may i?


Prashant

Re: Custom 7Segment display characters

Posted: Sat Oct 26, 2013 11:31 am
by beambase
Hello,
I am looking to do the same thing. If you have a modified 7 segment LED component, can you please post the code?

Re: Custom 7Segment display characters

Posted: Sat Oct 26, 2013 11:56 am
by medelec35
prasha920 wrote:thats really a cool way to remember
thanx for that, Martin :)
Your welcome. :)
prasha920 wrote: i have edited the component file of 7seg display accordingly and getting the expected output.. :D
i am thinking to upload the respected file along with LUT for all custom characters and their index nos, may i?
Of course you can,
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

Re: Custom 7Segment display characters

Posted: Sat Oct 26, 2013 5:43 pm
by prasha920
Hi Martin,

thanks a lot for clearing me where to post the files... :D
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?
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.



Prashant