|
|
View previous topic :: View next topic |
Author |
Message |
Isaac aiyanyo Guest
|
HOW TO SCROLL 8X8 LED |
Posted: Mon Nov 04, 2002 6:53 am |
|
|
Please picstars
could assist me on how i could make this 5x7 led
display scroll the letter across the screen.
i have being trying for days now i can't seem to
do it i am pulling my hair out
Here is the code below
i found this at
<a href="http://www.blitzlogic.com/Matrix.htm" TARGET="_blank">http://www.blitzlogic.com/Matrix.htm</a>
and intead to use it to help me learning process
Thanks in advance
Isaac
#include <16c84.h>
#USE DELAY( CLOCK=4000000 ) /* Using a 4 Mhz clock */
#FUSES XT,NOWDT,NOPROTECT,NOPUT
/* Use XT mode, No Watch Dog, No Code Protect, No Power-up Timer */
#byte port_b=6 /* define the location of register port_b */
#byte port_a=5 /* define the location of register port_b */
char const pat[5]={0x3f,0x02,0x04,0x02,0x3f};
main(){
char cnt, col;
set_tris_b(0); /* set port_b as outputs */
set_tris_a(0); /* set port_a as output */
port_b = 0; /* ZERO port_a & port_b */
port_a = 0;
for( ;; )
{
col = 1;
for(cnt = 0;cnt < 5;cnt++)
{
port_b = pat[cnt];
port_a = col;
delay_ms(1);
col<<=1;
}
}
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 8481 |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
Re: HOW TO SCROLL 8X8 LED |
Posted: Mon Nov 04, 2002 7:59 am |
|
|
#include <16c84.h>
#USE DELAY( CLOCK=4000000 ) /* Using a 4 Mhz clock */
#FUSES XT,NOWDT,NOPROTECT,NOPUT
/* Use XT mode, No Watch Dog, No Code Protect, No Power-up Timer */
#byte port_b=6 /* define the location of register port_b */
#byte port_a=5 /* define the location of register port_b */
char const pat[5]={0x3f,0x02,0x04,0x02,0x3f};
main(){
char cnt, scrollcnt, col;
set_tris_b(0); /* set port_b as outputs */
set_tris_a(0); /* set port_a as output */
port_b = 0; /* ZERO port_a & port_b */
port_a = 0;
col = 0b00000001; // The column that we are driving
scrollcnt = 0;
while(1) // Infinite loop to avoid run on code
{
++scrollcnt; // scrollcnt is used as a delay before we switch columns
if (scrollcnt == 250)
{
scrollcnt = 0;
col>>=1; // Rotate our mask for the next column
if (col == 0) // Reset our mask if needed
col = 0b00010000;
}
for(cnt = 0;cnt < 5;cnt++)
{
if (col == 0) // Reset our mask if needed
col = 1;
port_a = 0; // Turn off any previous data displayed
port_b = pat[cnt]; // Setup the data to display
port_a = col; // Display the new data
delay_ms(1); // Give some delay before we output the next column
col<<=1; // Rotate our mask for the next column
}
}
}
Regards
Mark
:=
:= Please picstars
:= could assist me on how i could make this 5x7 led
:= display scroll the letter across the screen.
:= i have being trying for days now i can't seem to
:= do it i am pulling my hair out
:=
:=Here is the code below
:=i found this at
:=
:=and intead to use it to help me learning process
:=Thanks in advance
:=Isaac
:=
:=#include <16c84.h>
:=
:= #USE DELAY( CLOCK=4000000 ) /* Using a 4 Mhz clock */
:=
:= #FUSES XT,NOWDT,NOPROTECT,NOPUT
:= /* Use XT mode, No Watch Dog, No Code Protect, No Power-up Timer */
:=
:= #byte port_b=6 /* define the location of register port_b */
:= #byte port_a=5 /* define the location of register port_b */
:=
:= char const pat[5]={0x3f,0x02,0x04,0x02,0x3f};
:=
:=
:= main(){
:= char cnt, col;
:=
:= set_tris_b(0); /* set port_b as outputs */
:= set_tris_a(0); /* set port_a as output */
:=
:= port_b = 0; /* ZERO port_a & port_b */
:= port_a = 0;
:=
:= for( ;; )
:= {
:= col = 1;
:= for(cnt = 0;cnt < 5;cnt++)
:= {
:= port_b = pat[cnt];
:= port_a = col;
:=
:= delay_ms(1);
:=
:= col<<=1;
:= }
:= }
:= }
___________________________
This message was ported from CCS's old forum
Original Post ID: 8482 |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
Re: HOW TO SCROLL 8X8 LED |
Posted: Mon Nov 04, 2002 9:40 am |
|
|
Here is an example of scrolling a message:
#include <16c84.h>
#USE DELAY( CLOCK=4000000 ) /* Using a 4 Mhz clock */
#FUSES XT,NOWDT,NOPROTECT,NOPUT
/* Use XT mode, No Watch Dog, No Code Protect, No Power-up Timer */
#byte port_b=6 /* define the location of register port_b */
#byte port_a=5 /* define the location of register port_b */
char const pat[34]={0x7F,0x08,0x08,0x08,0x7F,0x00,0x7F,0x49,0x49,0x41,0x41,0x00,0x7F,0x01,0x01,0x01,0x01,0x00,0x7F,0x01,0x01,0x01,0x01,0x00,0x3E,0x41,0x41,0x41,0x3E,0x00,0x00,0x00,0x00,0x00};
main(){
char cnt, cnt2, scrollcnt, col;
set_tris_b(0); /* set port_b as outputs */
set_tris_a(0); /* set port_a as output */
port_b = 0; /* ZERO port_a & port_b */
port_a = 0;
scrollcnt = 0;
cnt2 = 0;
while(1) // Infinite loop to avoid run on code
{
col = 0b00000001; // The column that we are driving
++scrollcnt; // scrollcnt is used as a delay before we switch columns
if (scrollcnt == 250)
{
scrollcnt = 0;
++cnt2;
if (cnt2 == 34)
cnt2 = 0;
}
for(cnt = 0;cnt < 5;cnt++)
{
port_a = 0; // Turn off any previous data displayed
port_b = pat[cnt+cnt2]; // Setup the data to display
port_a = col; // Display the new data
delay_ms(1); // Give some delay before we output the next column
col<<=1; // Rotate our mask for the next column
}
}
}
Regards,
Mark
:=
:= Please picstars
:= could assist me on how i could make this 5x7 led
:= display scroll the letter across the screen.
:= i have being trying for days now i can't seem to
:= do it i am pulling my hair out
:=
:=Here is the code below
:=i found this at
:=
:=and intead to use it to help me learning process
:=Thanks in advance
:=Isaac
:=
:=#include <16c84.h>
:=
:= #USE DELAY( CLOCK=4000000 ) /* Using a 4 Mhz clock */
:=
:= #FUSES XT,NOWDT,NOPROTECT,NOPUT
:= /* Use XT mode, No Watch Dog, No Code Protect, No Power-up Timer */
:=
:= #byte port_b=6 /* define the location of register port_b */
:= #byte port_a=5 /* define the location of register port_b */
:=
:= char const pat[5]={0x3f,0x02,0x04,0x02,0x3f};
:=
:=
:= main(){
:= char cnt, col;
:=
:= set_tris_b(0); /* set port_b as outputs */
:= set_tris_a(0); /* set port_a as output */
:=
:= port_b = 0; /* ZERO port_a & port_b */
:= port_a = 0;
:=
:= for( ;; )
:= {
:= col = 1;
:= for(cnt = 0;cnt < 5;cnt++)
:= {
:= port_b = pat[cnt];
:= port_a = col;
:=
:= delay_ms(1);
:=
:= col<<=1;
:= }
:= }
:= }
___________________________
This message was ported from CCS's old forum
Original Post ID: 8484 |
|
|
isaac aiyanyo Guest
|
Re: HOW TO SCROLL 8X8 LED |
Posted: Mon Nov 04, 2002 11:20 am |
|
|
Thank you very much mark
i am going to try them right now
i shall let you know the outcome
Top gun
Isaac
___________________________
This message was ported from CCS's old forum
Original Post ID: 8488 |
|
|
aiyanyo Guest
|
Re: HOW TO SCROLL 8X8 LED |
Posted: Mon Nov 04, 2002 7:15 pm |
|
|
Mark,
Your example worked perfectly, and it has developed my
understanding of C programming.
i modified the program for an 8x8 Led using pic 16f873
the program scrolls the word hello acrsoss the display
it's perfect !!!
one more problem, when the program exits i tried to put
in a continous loop so that it starts again .
i use for (;;)& do-while but the program still would
not loop back.
am i doing something really bad here.
Thanks a million
Isaac
The program is attached below :
#if defined(__PCM__)
#include <16F873.H>
#fuses XT,NOWDT,NOPUT,NOPROTECT,NOBROWNOUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7,RESTART_WDT,ERRORS)
//THIS IS ANOTHER PROGRAM CALLED SROLL2//
#byte port_a=5
#byte port_b=6
#byte port_c=7
char const pat[48]={0,255,255,24,24,255,255,0,0,255,255,219,219,195,195,0,
0,255,255,192,192,192,192,0,0,255,255,192,192,192,192,0,
0,60,126,195,195,126,60,0,0,0,0,0,0,0,0,0};
// The table above should scroll 'HELLO' across the display//
// the 1st 8 values reps 'H' the next 8 reps 'E' etc //
main()
{
char cnt, cnt2, scrollcnt, col; //declare variables
set_tris_b(0); /* set port_b as outputs */
set_tris_c(0); /* set port_a as output */
//do
// {
start:
delay_ms(500);
port_b = 0; /* ZERO port_c & port_b */
port_c = 0;
scrollcnt = 0; /* set scrolcnt to zero */
cnt2 = 0;
while(1)
// Infinite loop to avoid run on code
{
col = 0b00000001; // The column that we are driving
++scrollcnt; // scrollcnt is used as a delay before we switch columns
if (scrollcnt == 25)
{
scrollcnt = 0;
++cnt2;
if (cnt2 == 48)
cnt2 = 0;
}
for(cnt = 0;cnt < 8;cnt++)
{
port_c = 0; // Turn off any previous data displayed
port_b = pat[cnt+cnt2]; // Setup the data to display
port_c = col; // Display the new data
delay_ms(1); // Give some delay before we output the next column
col<<=1; // Shitf bit 1 place left
}
}
// }while(1);
// the program works fine but i can't seem to be able to put it into
// an infinate loop so that program starts again from the begining
// i still need your expert help
goto start;
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 8524 |
|
|
aiyanyo Guest
|
Re: HOW TO SCROLL 8X8 LED |
Posted: Mon Nov 04, 2002 7:18 pm |
|
|
the goto & start were just for test
___________________________
This message was ported from CCS's old forum
Original Post ID: 8525 |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
Re: HOW TO SCROLL 8X8 LED |
Posted: Mon Nov 04, 2002 9:47 pm |
|
|
My mistake! cnt+cnt2 exceeded the array size! Try this:
:=
:= Mark,
:= Your example worked perfectly, and it has developed my
:= understanding of C programming.
:= i modified the program for an 8x8 Led using pic 16f873
:= the program scrolls the word hello acrsoss the display
:= it's perfect !!!
:= one more problem, when the program exits i tried to put
:= in a continous loop so that it starts again .
:= i use for (;;)& do-while but the program still would
:= not loop back.
:= am i doing something really bad here.
:=
:= Thanks a million
:= Isaac
:=
:= The program is attached below :
:=
:=#if defined(__PCM__)
:=#include <16F873.H>
:=#fuses XT,NOWDT,NOPUT,NOPROTECT,NOBROWNOUT,NOLVP
:=#use delay(clock=4000000)
:=#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7,RESTART_WDT,ERRORS)
:=//THIS IS ANOTHER PROGRAM CALLED SROLL2//
:=
:=#byte port_a=5
:=#byte port_b=6
:=#byte port_c=7
:=
:=char const pat[48]={0,255,255,24,24,255,255,0,0,255,255,219,219,195,195,0,
:= 0,255,255,192,192,192,192,0,0,255,255,192,192,192,192,0,
:= 0,60,126,195,195,126,60,0,0,0,0,0,0,0,0,0};
:= // The table above should scroll 'HELLO' across the display//
:= // the 1st 8 values reps 'H' the next 8 reps 'E' etc //
:=
:=main()
:={
:=
:= char cnt, cnt2, scrollcnt, col; //declare variables
:=
:= set_tris_b(0); /* set port_b as outputs */
:= set_tris_c(0); /* set port_a as output */
:=//do
:=// {
:= start:
:= delay_ms(500);
:= port_b = 0; /* ZERO port_c & port_b */
:= port_c = 0;
:=
:= scrollcnt = 0; /* set scrolcnt to zero */
:= cnt2 = 0;
:=while(1)
:= // Infinite loop to avoid run on code
:= {
:= col = 0b00000001; // The column that we are driving
:= ++scrollcnt; // scrollcnt is used as a delay before we switch columns
:= if (scrollcnt == 25)
:= {
:= scrollcnt = 0;
:= ++cnt2;
if (cnt2 == 40)
:= cnt2 = 0;
:= }
:=
:=for(cnt = 0;cnt < 8;cnt++)
:= {
:= port_c = 0; // Turn off any previous data displayed
:= port_b = pat[cnt+cnt2]; // Setup the data to display
:= port_c = col; // Display the new data
:=
:= delay_ms(1); // Give some delay before we output the next column
:= col<<=1; // Shitf bit 1 place left
:= }
:=
:= }
:= // }while(1);
:= // the program works fine but i can't seem to be able to put it into
:= // an infinate loop so that program starts again from the begining
:= // i still need your expert help
:=goto start;
:=}
:=
:=
:=
:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 8528 |
|
|
Isaac aiyanyo Guest
|
Re: HOW TO SCROLL 8X8 LED |
Posted: Tue Nov 05, 2002 7:04 am |
|
|
Perfert work mark.
It loops fine now.
you being a great,great help.
something that i wanted to get of my chest.
Why does the 7th column stay permanently ON during
the scroll process.
it only goes off after the last character'O'
is this a feature of the scroling method?
i can't thank you enough
Isaac
___________________________
This message was ported from CCS's old forum
Original Post ID: 8541 |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
Re: HOW TO SCROLL 8X8 LED |
Posted: Tue Nov 05, 2002 9:41 am |
|
|
When you say 7th column, do you mean the last column? Are you numbering the columns 0-7 or 1-8? I am assuming that you did change from a 5x7 LED matrix to a 8x8 matrix.
Mark
:= Perfert work mark.
:= It loops fine now.
:= you being a great,great help.
:= something that i wanted to get of my chest.
:= Why does the 7th column stay permanently ON during
:= the scroll process.
:= it only goes off after the last character'O'
:= is this a feature of the scroling method?
:= i can't thank you enough
:= Isaac
___________________________
This message was ported from CCS's old forum
Original Post ID: 8548 |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
Re: HOW TO SCROLL 8X8 LED |
Posted: Tue Nov 05, 2002 9:47 am |
|
|
Try the following to see if it helps with your problem. The last column is on a bit longer than the rest. This should take care of that.
Mark
:=
:= Mark,
:= Your example worked perfectly, and it has developed my
:= understanding of C programming.
:= i modified the program for an 8x8 Led using pic 16f873
:= the program scrolls the word hello acrsoss the display
:= it's perfect !!!
:= one more problem, when the program exits i tried to put
:= in a continous loop so that it starts again .
:= i use for (;;)& do-while but the program still would
:= not loop back.
:= am i doing something really bad here.
:=
:= Thanks a million
:= Isaac
:=
:= The program is attached below :
:=
:=#if defined(__PCM__)
:=#include <16F873.H>
:=#fuses XT,NOWDT,NOPUT,NOPROTECT,NOBROWNOUT,NOLVP
:=#use delay(clock=4000000)
:=#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7,RESTART_WDT,ERRORS)
:=//THIS IS ANOTHER PROGRAM CALLED SROLL2//
:=
:=#byte port_a=5
:=#byte port_b=6
:=#byte port_c=7
:=
:=char const pat[48]={0,255,255,24,24,255,255,0,0,255,255,219,219,195,195,0,
:= 0,255,255,192,192,192,192,0,0,255,255,192,192,192,192,0,
:= 0,60,126,195,195,126,60,0,0,0,0,0,0,0,0,0};
:= // The table above should scroll 'HELLO' across the display//
:= // the 1st 8 values reps 'H' the next 8 reps 'E' etc //
:=
:=main()
:={
:=
:= char cnt, cnt2, scrollcnt, col; //declare variables
:=
:= set_tris_b(0); /* set port_b as outputs */
:= set_tris_c(0); /* set port_a as output */
:=//do
:=// {
:= start:
:= delay_ms(500);
:= port_b = 0; /* ZERO port_c & port_b */
:= port_c = 0;
:=
:= scrollcnt = 0; /* set scrolcnt to zero */
:= cnt2 = 0;
:=while(1)
:= // Infinite loop to avoid run on code
:= {
:= col = 0b00000001; // The column that we are driving
:= ++scrollcnt; // scrollcnt is used as a delay before we switch columns
:= if (scrollcnt == 25)
:= {
:= scrollcnt = 0;
:= ++cnt2;
if (cnt2 == 40)
:= cnt2 = 0;
:= }
:=
:=for(cnt = 0;cnt < 8;cnt++)
:= {
:= port_c = 0; // Turn off any previous data displayed
:= port_b = pat[cnt+cnt2]; // Setup the data to display
:= port_c = col; // Display the new data
:=
:= delay_ms(1); // Give some delay before we output the next column
port_c = 0; // Turn off any
:= col<<=1; // Shitf bit 1 place left
:= }
:=
:= }
:= // }while(1);
:= // the program works fine but i can't seem to be able to put it into
:= // an infinate loop so that program starts again from the begining
:= // i still need your expert help
:=goto start;
:=}
:=
:=
:=
:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 8550 |
|
|
Isaac aiyanyo Guest
|
Re: HOW TO SCROLL 8X8 LED |
Posted: Tue Nov 05, 2002 10:25 am |
|
|
My numbering are 1 - 8 and i am using an 8x8 led
This would mean RC6 on my pic as i am using a 16f873.
my table looks like this
RC0= COL1
RC1= COL2
RC2= COL3
RC3= COL4
RC4= COL5
RC5= COL6
RC6= COL7
RC7= COL8
i hope this gives you the picture
Isaac
from the above its col 7
___________________________
This message was ported from CCS's old forum
Original Post ID: 8558 |
|
|
Isaac aiyanyo Guest
|
Re: HOW TO SCROLL 8X8 LED |
Posted: Tue Nov 05, 2002 10:53 am |
|
|
i still have the problem
___________________________
This message was ported from CCS's old forum
Original Post ID: 8560 |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
Re: HOW TO SCROLL 8X8 LED |
Posted: Tue Nov 05, 2002 12:53 pm |
|
|
Can you describe the problem in a little more detail? Are all eight LEDs in column 7 on the whole time? Does column 7 appear brighter than the rest? Does column 7 show incorrect data? What kind of circuit board are you using? Have you checked all the connections? Is there anything else on RC6?
Mark
___________________________
This message was ported from CCS's old forum
Original Post ID: 8570 |
|
|
Isaac aiyanyo Guest
|
Re: HOW TO SCROLL 8X8 LED |
Posted: Wed Nov 06, 2002 6:17 am |
|
|
Mark,
its was all my fault.
i was complied the wrong project in malab.
so each time i recomplied it wasn't making any
changes.
its work perfectly now, and all credits to you.
Honestly you have being so helpful (HATS OFF 4 U)
i am still studying the way the program works and
when i have taken it all in.
My next project would be to modified the example
to use the 74hc595 shift reg on portc for my columns.
to save myself a few pins.
i would let you know how i get on, just making the
hardware at this minute.
Thanks a million
Isaac
___________________________
This message was ported from CCS's old forum
Original Post ID: 8596 |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
Re: HOW TO SCROLL 8X8 LED |
Posted: Wed Nov 06, 2002 8:20 am |
|
|
How many columns are you planning on driving. The more columns you drive, then dimmer the LEDs will get.
Mark
:= Mark,
:= its was all my fault.
:= i was complied the wrong project in malab.
:= so each time i recomplied it wasn't making any
:= changes.
:= its work perfectly now, and all credits to you.
:= Honestly you have being so helpful (HATS OFF 4 U)
:= i am still studying the way the program works and
:= when i have taken it all in.
:= My next project would be to modified the example
:= to use the 74hc595 shift reg on portc for my columns.
:= to save myself a few pins.
:= i would let you know how i get on, just making the
:= hardware at this minute.
:= Thanks a million
:= Isaac
:=
:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 8601 |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|