CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

LED MESSAGE DISPLAY
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
isaac aiyanyo
Guest







Re: Help in using <74595.C> file (still need your help
PostPosted: Tue Nov 12, 2002 7:18 am     Reply with quote

Thanks Mark
i have just tried it but i get 0111111111111111
displayed on my leds using columns 1 - 16 0 being col 1
i am still worried
i can't understand why the function does not work

___________________________
This message was ported from CCS's old forum
Original Post ID: 8784
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

Re: Help in using <74595.C> file (still need your help
PostPosted: Tue Nov 12, 2002 9:17 am     Reply with quote

Try this and see how it works.

#include <16F873.H>
#fuses XT,NOWDT,NOPUT,NOPROTECT,NOBROWNOUT,NOLVP
#use delay(clock=4000000)

#define EXP_OUT_ENABLE PIN_C2
#define EXP_OUT_CLOCK PIN_C1
#define EXP_OUT_DO PIN_C0

#byte port_c=7

void write_outputs(long data)
{
byte i;

output_low(EXP_OUT_CLOCK);
output_low(EXP_OUT_ENABLE);

for(i=1;i<=16;++i)
{
if (bit_test(data,0x0F))
output_high(EXP_OUT_DO);
else
output_low(EXP_OUT_DO);
data <<= 1;
output_high(EXP_OUT_CLOCK);
output_low(EXP_OUT_CLOCK);
}
output_high(EXP_OUT_ENABLE);
}

main()
{
long mask = 0x01; // mask for turning on 1 column at a time
set_tris_c(0);
port_c = 0;
do
{
delay_ms(500);
write_outputs(mask);
delay_ms(500);
// shift to the next column
mask <<=1;
// if our mask is 0 then start over
if (mask==0)
mask = 0x01;
}
while(1);

}



Regards,
Mark
___________________________
This message was ported from CCS's old forum
Original Post ID: 8798
isaac aiyanyo
Guest







Re: Help in using <74595.C> file (still need your help
PostPosted: Wed Nov 13, 2002 6:30 am     Reply with quote

MARK,
i feel so stupid.
i stayed up last night faulting on my vero board only
to find out that one of the oscillator pins to the pic
was shorted to gnd.
i found the fault at about 2am last night then tried the
program again and it worked perfectly.
Thank you very much for your patience with me.
Isaac

___________________________
This message was ported from CCS's old forum
Original Post ID: 8840
aiyanyo
Guest







Re: Help in using <74595.C> file (still need your help
PostPosted: Thu Nov 14, 2002 5:56 am     Reply with quote

Mark,
Sorry to bother you again.]
As i said b4 i am new to c programming and i am practising real hard.
i was wondering if you could please explain some part of the program to i want to try and understang the flow of the program
but i am getting confused with data[1]=mask>>8
would this not make data[1] zero.
i have just finished my circuit, i didn't want to take any chance so i did it on pcb.
i want tested it using picbasic to display hello using 16 cols x 8 rows
so i need to understand the program so that i can intergrate it
to c.
thank for your help
Isaac

main()
{
long mask = 1; // mask for turning on 1 column at a time
int data[2]; // array to store our data
set_tris_c(0); // set portc as outputs
port_c = 0; // set portc to 0
do // start of infinate loop
{
// store our mask in an array. we need to do this because
// the call to write_expanded_outputs will destroy the value
// passed in.
data[0] = mask; // set data[0] to 0000000000000001 is this correct?
data[1] = mask>>8; // set data[1] to 0000000100000000 i got confused here
// what happens here does data[1] value = the value of mask
// which i think is 0000000000000001 get shifted 8 places to the
// right which would become 0 ?

write_expanded_outputs(data);
delay_ms(5);
mask <<=1; // shift to the next column


if (mask==0) // if our mask is 0 then start over
mask = 0x01; // make mask = 0000000000000001
}
while(1);

}
___________________________
This message was ported from CCS's old forum
Original Post ID: 8897
aiyanyo
Guest







Re: Help in using <74595.C> file (program flow)
PostPosted: Thu Nov 14, 2002 8:26 am     Reply with quote

Mark,
its me trouble again,sorry for being a pain but i do
need your help still in trying to understand the flow
of the program
i can't seem to get my head round the place i commented
data[1] = mask>>8;

main()
{
long mask = 1; // mask for turning on 1 column at a time
int data[2]; // array to store our data
set_tris_c(0); // set portc as outputs
port_c = 0; // set portc to 0
do // start of infinate loop
{
// store our mask in an array. we need to do this because
// the call to write_expanded_outputs will destroy the value
// passed in.
data[0] = mask; // set data[0] to 0000000000000001 is this correct?
data[1] = mask>>8; // set data[1] to 0000000100000000 i got confused here
// what happens here does data[1] value = the value of mask
// which i think is 0000000000000001 get shifted 8 places to the
// right which would become 0 ?

write_expanded_outputs(data);
delay_ms(5);
mask <<=1; // shift to the next column


if (mask==0) // if our mask is 0 then start over
mask = 0x01; // make mask = 0000000000000001
}
while(1);

}


Please could you just explain that part (data [1]mask>>8) for
me.
i looked in my c book and this suggest that example if mask is
00000101 >> 2 = 00000001
So if the value of mask is 0x01;=0000000000000001
0000000000000001 >>8 would this not be zero
Please put me out of my misery i am pulling my hair out hear
i managed to complete the hardware for an 8 row by 16 col
which i tested today.
i used the example you gave me just to move the column across
the display .
this is why i wan't to learn to code so that i can make modifications
to display 'Hello'
Thanks for your guildance
Isaac
___________________________
This message was ported from CCS's old forum
Original Post ID: 8905
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

Re: Help in using <74595.C> file (program flow)
PostPosted: Thu Nov 14, 2002 9:59 am     Reply with quote

I will try to explain it for you.
mask is a 16 bit number.
Each member of data is 8 bits.
This statement "data[0] = mask;" loads data[0] with the lowest 8 bits of mask.
This statement "data[1] = mask>>8;" loads data[1] with the most significant 8 bits of mask.
The first time through data[0] = 0b00000001 and data[1] = 0b00000000.
The 2nd time data[0] = 0b00000010 and data[1] = 0b00000000.
The 3rd time data[0] = 0b00000100 and data[1] = 0b00000000.
.
.
.
The 8th time data[0] = 0b10000000 and data[1] = 0b00000000.
The 9th time data[0] = 0b00000000 and data[1] = 0b00000001.
.
.
.
The 15th time data[0] = 0b00000000 and data[1] = 0b01000000.
The 16th time data[0] = 0b00000000 and data[1] = 0b10000000.

After the 16th time through the mask will have a value of 0 because the 1 would have been shifted 16 times. Thus there is a check for mask == 0 so that it can be reset.

I hope this helps. If not, let me know.

Regards,
Mark

:= Mark,
:= its me trouble again,sorry for being a pain but i do
:= need your help still in trying to understand the flow
:= of the program
:= i can't seem to get my head round the place i commented
:= data[1] = mask>>8;
:=
:=main()
:={
:= long mask = 1; // mask for turning on 1 column at a time
:= int data[2]; // array to store our data
:= set_tris_c(0); // set portc as outputs
:= port_c = 0; // set portc to 0
:= do // start of infinate loop
:= {
:= // store our mask in an array. we need to do this because
:= // the call to write_expanded_outputs will destroy the value
:= // passed in.
:= data[0] = mask; // set data[0] to 0000000000000001 is this correct?
:= data[1] = mask>>8; // set data[1] to 0000000100000000 i got confused here
:= // what happens here does data[1] value = the value of mask
:= // which i think is 0000000000000001 get shifted 8 places to the
:= // right which would become 0 ?
:=
:= write_expanded_outputs(data);
:= delay_ms(5);
:= mask <<=1; // shift to the next column
:=
:=
:= if (mask==0) // if our mask is 0 then start over
:= mask = 0x01; // make mask = 0000000000000001
:= }
:=while(1);
:=
:=}
:=
:=
:= Please could you just explain that part (data [1]mask>>8) for
:= me.
:= i looked in my c book and this suggest that example if mask is
:= 00000101 >> 2 = 00000001
:= So if the value of mask is 0x01;=0000000000000001
:= 0000000000000001 >>8 would this not be zero
:= Please put me out of my misery i am pulling my hair out hear
:= i managed to complete the hardware for an 8 row by 16 col
:= which i tested today.
:= i used the example you gave me just to move the column across
:= the display .
:= this is why i wan't to learn to code so that i can make modifications
:= to display 'Hello'
:= Thanks for your guildance
:= Isaac
___________________________
This message was ported from CCS's old forum
Original Post ID: 8911
isaac aiyanyo
Guest







Re: Help in using <74595.C> file (program flow)
PostPosted: Fri Nov 15, 2002 7:04 am     Reply with quote

Mark the explaination was well received.
but how can i keep track of the individaul elements of data[0]
and data[1]
so that i can set portb accordingly to display my characters so that when data[0]=0b00000001 portb =pat[0]
data[0]=0b0000010 portb =pat[1]
upto when data[0]=0b1000000 portb =pat[8]
would then need to do the same for when data[1]=0b000000001
portb=pat[9]
and so on to get my message displayed
this is the table i intend to use which is the same as the one i used for the 8x8 display
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};
Any pointers would be greatfully received
Isaac


___________________________
This message was ported from CCS's old forum
Original Post ID: 8980
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

Re: Help in using <74595.C> file (program flow)
PostPosted: Fri Nov 15, 2002 8:46 am     Reply with quote

Try this:

#include <16F873.H>
#fuses XT,NOWDT,NOPUT,NOPROTECT,NOBROWNOUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_A0, rcv=PIN_A1,RESTART_WDT,ERRORS,INVERT)


#IFNDEF EXP_OUT_ENABLE

#define EXP_OUT_ENABLE PIN_C2
#define EXP_OUT_CLOCK PIN_C1
#define EXP_OUT_DO PIN_C0
#define NUMBER_OF_74595 2
#ENDIF
#include <74595.C>


#byte port_c=7
#byte port_b=6

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};

main()
{
long mask = 0x01; // mask for turning on 1 column at a time
int data[2]; // array to store our data
int delaycount;
int startposition;
int index;
int i;

set_tris_c(0);
set_tris_b(0);
port_c = 0;
port_b = 0;
startposition = 0;
while(1)
{
delaycount = 50; // adjust this value to control how fast the display scrolls
while (delaycount)
{
index = startposition;
mask = 0x01;
for (i=0;i<16;i++) // we have sixteen columns to drive
{
// store our mask in an array. we need to do this because
// the call to write_expanded_outputs will destroy the value
// passed in.
data[0] = mask; // store which column we are driving
data[1] = mask>>8; // in an array
index = i + startposition; // point to the next pattern to display
if (index >= sizeof(pat)) // make sure that we don't exceed the array
index -= sizeof(pat);
port_b = 0; // disable driving the LEDs
write_expanded_outputs(data); // enable our column driver
port_b = pat[index]; // drive our LEDs
mask <<=1; // shift to the next column for next time
delay_ms(1); // adjust this value to control the drive time for the leds
}
--delaycount; // decrement our delay loop counter
}
++startposition; // Point to the next data pattern
if (startposition >= sizeof(pat)) // make sure that we don't exceed the array
startposition = 0;
}

}


Regards,
Mark
:= Mark the explaination was well received.
:= but how can i keep track of the individaul elements of data[0]
:= and data[1]
:= so that i can set portb accordingly to display my characters so that when data[0]=0b00000001 portb =pat[0]
:= data[0]=0b0000010 portb =pat[1]
:= upto when data[0]=0b1000000 portb =pat[8]
:=would then need to do the same for when data[1]=0b000000001
:= portb=pat[9]
:= and so on to get my message displayed
:= this is the table i intend to use which is the same as the one i used for the 8x8 display
:= 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};
:= Any pointers would be greatfully received
:= Isaac
:=
:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 8988
isaac aiyanyo
Guest







Re: Help in using <74595.C> file (program flow)
PostPosted: Fri Nov 15, 2002 10:48 am     Reply with quote

Mark,
Please how can i get to my array elements so that i could set portb values
with the values in the table.
i went back to basic and put the individual values as below .
the program works but the characters lean to left loosing me column 1 and i loose the contains of column1
which is moved to column 16.
when i increase the delay the positions of the characters are ok but with a lot of flicker
and i also loose the contains of (row 5 ,columns 3&4 ) and (row 5 ,columns 11&12 )
is there a valid reason for this.
Thanks in advance
Isaac

#if defined(__PCM__)
#include <16F876.H>
#fuses XT,NOWDT,NOPUT,NOPROTECT,NOBROWNOUT,NOLVP
#use delay(clock=4000000)

#IFNDEF EXP_OUT_ENABLE

#define EXP_OUT_ENABLE PIN_C2
#define EXP_OUT_CLOCK PIN_C1
#define EXP_OUT_DO PIN_C0
#define NUMBER_OF_74595 2
#ENDIF
#include <74595.C>

#byte port_a=5
#byte port_b=6
#byte port_c=7

char const pat[16]={0,255,255,24,24,255,255,0,0,255,255,219,219,195,195,0}; // 'HE'

// 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()
{ int i;
long mask = 1; // mask = 0b0000000000000001
int data[2]; // array to store our data
set_tris_b(0); //set portb to outputs
set_tris_c(0); //set portc to outputs
port_c = 0; //zero port c
do //start of infinate loop
{

// store our mask in an array. i need to do this because
// the call to write_expanded_outputs will destroy the value
// passed in.

data[0] = mask; //load data[0] with lower 8bits of mask
if (data[0]==0b00000001)
{
255;
}
else
if (data[0]==0b00000010)
{
port_b=255;
}
else
if (data[0]==0b00000100)
{
port_b=255;
}
else
if (data[0]==0b00001000)
{
port_b=24;
}
else
if (data[0]==0b00010000)
{
port_b=24;
}
else
if (data[0]==0b00100000)
{
port_b=255;
}
else
if (data[0]==0b01000000)
{
port_b=255;
}
else
if (data[0]==0b10000000)
{
port_b=0;
}
data[1] = mask>>8; //load data[1] with upper 8bits of mask

if (data[1]==0b00000001)
{
port_b=0;
}
else
if (data[1]==0b00000010)
{
port_b=255;
}
else
if (data[1]==0b00000100)
{
port_b=255;
}
else
if (data[1]==0b00001000)
{
port_b=219;
}
else
if (data[1]==0b00010000)
{
port_b=219;
}
else
if (data[1]==0b00100000)
{
port_b=195;
}
else
if (data[1]==0b01000000)
{
port_b=195;
}
else
if (data[1]==0b10000000)
{
port_b=0;
} // value for rows

write_expanded_outputs(data); // output of shift regs
delay_ms(0); // delay
mask <<=1; // shift to the next column
port_b=0;
if (mask==0) // if our mask is 0
{ // then start over again
mask = 1; // mask = 1
}
}while(1);

}
___________________________
This message was ported from CCS's old forum
Original Post ID: 8998
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

Re: Help in using <74595.C> file (program flow)
PostPosted: Fri Nov 15, 2002 1:17 pm     Reply with quote

Did my previous code not work correctly?

I simplified your code. Try this:
#if defined(__PCM__)
#include <16F876.H>
#fuses XT,NOWDT,NOPUT,NOPROTECT,NOBROWNOUT,NOLVP
#use delay(clock=4000000)

#IFNDEF EXP_OUT_ENABLE

#define EXP_OUT_ENABLE PIN_C2
#define EXP_OUT_CLOCK PIN_C1
#define EXP_OUT_DO PIN_C0
#define NUMBER_OF_74595 2
#ENDIF
#include <74595.C>

#byte port_a=5
#byte port_b=6
#byte port_c=7

char const pat[16]={0,255,255,24,24,255,255,0,0,255,255,219,219,195,195,0}; // 'HE'

// 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()
{
int i = 0;
long mask = 1; // mask = 0b0000000000000001
int data[2]; // array to store our data

set_tris_b(0); //set portb to outputs
set_tris_c(0); //set portc to outputs
port_c = 0; //zero port c
do //start of infinate loop
{

// store our mask in an array. i need to do this because
// the call to write_expanded_outputs will destroy the value
// passed in.

data[0] = mask; //load data[0] with lower 8bits of mask
data[1] = mask>>8; //load data[1] with upper 8bits of mask
port_b=pat[i];

write_expanded_outputs(data); // output of shift regs
delay_ms(0); // delay
mask <<=1; // shift to the next column
++i;
port_b=0;
if (mask==0) // if our mask is 0
{ // then start over again
mask = 1; // mask = 1
i = 0;
}
}while(1);
}

:=
:= Mark,
:= Please how can i get to my array elements so that i could set portb values
:= with the values in the table.
:= i went back to basic and put the individual values as below .
:= the program works but the characters lean to left loosing me column 1 and i loose the contains of column1
:= which is moved to column 16.
:= when i increase the delay the positions of the characters are ok but with a lot of flicker
:= and i also loose the contains of (row 5 ,columns 3&4 ) and (row 5 ,columns 11&12 )
:= is there a valid reason for this.
:= Thanks in advance
:= Isaac
:=
:=#if defined(__PCM__)
:=#include <16F876.H>
:=#fuses XT,NOWDT,NOPUT,NOPROTECT,NOBROWNOUT,NOLVP
:=#use delay(clock=4000000)
:=
:=#IFNDEF EXP_OUT_ENABLE
:=
:=#define EXP_OUT_ENABLE PIN_C2
:=#define EXP_OUT_CLOCK PIN_C1
:=#define EXP_OUT_DO PIN_C0
:=#define NUMBER_OF_74595 2
:=#ENDIF
:=#include <74595.C>
:=
:=#byte port_a=5
:=#byte port_b=6
:=#byte port_c=7
:=
:=char const pat[16]={0,255,255,24,24,255,255,0,0,255,255,219,219,195,195,0}; // 'HE'
:=
:= // 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()
:={ int i;
:= long mask = 1; // mask = 0b0000000000000001
:= int data[2]; // array to store our data
:= set_tris_b(0); //set portb to outputs
:= set_tris_c(0); //set portc to outputs
:= port_c = 0; //zero port c
:= do //start of infinate loop
:= {
:=
:= // store our mask in an array. i need to do this because
:= // the call to write_expanded_outputs will destroy the value
:= // passed in.
:=
:= data[0] = mask; //load data[0] with lower 8bits of mask
:= if (data[0]==0b00000001)
:= {
:= 255;
:= }
:= else
:= if (data[0]==0b00000010)
:= {
:= port_b=255;
:= }
:= else
:= if (data[0]==0b00000100)
:= {
:= port_b=255;
:= }
:= else
:= if (data[0]==0b00001000)
:= {
:= port_b=24;
:= }
:= else
:= if (data[0]==0b00010000)
:= {
:= port_b=24;
:= }
:= else
:= if (data[0]==0b00100000)
:= {
:= port_b=255;
:= }
:= else
:= if (data[0]==0b01000000)
:= {
:= port_b=255;
:= }
:= else
:= if (data[0]==0b10000000)
:= {
:= port_b=0;
:= }
:= data[1] = mask>>8; //load data[1] with upper 8bits of mask
:=
:= if (data[1]==0b00000001)
:= {
:= port_b=0;
:= }
:= else
:= if (data[1]==0b00000010)
:= {
:= port_b=255;
:= }
:= else
:= if (data[1]==0b00000100)
:= {
:= port_b=255;
:= }
:= else
:= if (data[1]==0b00001000)
:= {
:= port_b=219;
:= }
:= else
:= if (data[1]==0b00010000)
:= {
:= port_b=219;
:= }
:= else
:= if (data[1]==0b00100000)
:= {
:= port_b=195;
:= }
:= else
:= if (data[1]==0b01000000)
:= {
:= port_b=195;
:= }
:= else
:= if (data[1]==0b10000000)
:= {
:= port_b=0;
:= } // value for rows
:=
:= write_expanded_outputs(data); // output of shift regs
:= delay_ms(0); // delay
:= mask <<=1; // shift to the next column
:= port_b=0;
:= if (mask==0) // if our mask is 0
:= { // then start over again
:= mask = 1; // mask = 1
:= }
:= }while(1);
:=
:=}
___________________________
This message was ported from CCS's old forum
Original Post ID: 9019
aiyanyo
Guest







Re: Help in using <74595.C> file (program flow)
PostPosted: Sat Nov 16, 2002 9:35 am     Reply with quote

Wow!
Mark
i am still suffering from the hang over of the display.
the program works perfectly it scrolls HELLO across
the the display with no flicky at all.
i have being through the program line by line to make
sure i understand works going on.
i got cut out by the sizeof operator at first,as i had never
come across that before.
i had to go and read my books to find out that it was used to
find out the size in bytes or characters in memory occupied
by a data object.
(what is the maximum number of columns i can use with the
display without runing out of Ram)
That was an excellent piece of programming genius.
sizeof(pat)
Would it not matter if for example the array pat had
say 60 elements
i am on top of the world,it had always being my dream
to build an 8 x 40 scrolling message display and i am
getting there.(Would i need to use an external eprom?)
i have learn't a lot from you and i do wish one day
i could get even up to 50\% of how you write your programs
i just don't know how you do it.
YOU R DA TOP MAN!!
Isaac



:=Try this:
:=
:=#include <16F873.H>
:=#fuses XT,NOWDT,NOPUT,NOPROTECT,NOBROWNOUT,NOLVP
:=#use delay(clock=4000000)
:=#use rs232(baud=9600, xmit=PIN_A0, rcv=PIN_A1,RESTART_WDT,ERRORS,INVERT)
:=
:=
:=#IFNDEF EXP_OUT_ENABLE
:=
:=#define EXP_OUT_ENABLE PIN_C2
:=#define EXP_OUT_CLOCK PIN_C1
:=#define EXP_OUT_DO PIN_C0
:=#define NUMBER_OF_74595 2
:=#ENDIF
:=#include <74595.C>
:=
:=
:=#byte port_c=7
:=#byte port_b=6
:=
:=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};
:=
:=main()
:={
:= long mask = 0x01; // mask for turning on 1 column at a time
:= int data[2]; // array to store our data
:= int delaycount;
:= int startposition;
:= int index;
:= int i;
:=
:= set_tris_c(0);
:= set_tris_b(0);
:= port_c = 0;
:= port_b = 0;
:= startposition = 0;
:= while(1)
:= {
:= delaycount = 50; // adjust this value to control how fast the display scrolls
:= while (delaycount)
:= {
:= index = startposition;
:= mask = 0x01;
:= for (i=0;i<16;i++) // we have sixteen columns to drive
:= {
:= // store our mask in an array. we need to do this because
:= // the call to write_expanded_outputs will destroy the value
:= // passed in.
:= data[0] = mask; // store which column we are driving
:= data[1] = mask>>8; // in an array
:= index = i + startposition; // point to the next pattern to display
:= if (index >= sizeof(pat)) // make sure that we don't exceed the array
:= index -= sizeof(pat);
:= port_b = 0; // disable driving the LEDs
:= write_expanded_outputs(data); // enable our column driver
:= port_b = pat[index]; // drive our LEDs
:= mask <<=1; // shift to the next column for next time
:= delay_ms(1); // adjust this value to control the drive time for the leds
:= }
:= --delaycount; // decrement our delay loop counter
:= }
:= ++startposition; // Point to the next data pattern
:= if (startposition >= sizeof(pat)) // make sure that we don't exceed the array
:= startposition = 0;
:= }
:=
:=}
:=
:=
:=Regards,
:=Mark
:=:= Mark the explaination was well received.
:=:= but how can i keep track of the individaul elements of data[0]
:=:= and data[1]
:=:= so that i can set portb accordingly to display my characters so that when data[0]=0b00000001 portb =pat[0]
:=:= data[0]=0b0000010 portb =pat[1]
:=:= upto when data[0]=0b1000000 portb =pat[8]
:=:=would then need to do the same for when data[1]=0b000000001
:=:= portb=pat[9]
:=:= and so on to get my message displayed
:=:= this is the table i intend to use which is the same as the one i used for the 8x8 display
:=:= 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};
:=:= Any pointers would be greatfully received
:=:= Isaac
:=:=
:=:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 9037
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

Re: Help in using <74595.C> file (program flow)
PostPosted: Sat Nov 16, 2002 10:52 am     Reply with quote

Thanks for the complements :)

You should have plenty of RAM/ROM to do a 8x40 display. It shouldn't be that hard to expand upon the program to achieve this.

You will need to change the mask to an array. CCS has a nice function for shifting it called shift_left().

int mask[5];

// init our mask
mask[0] = 0x01;
mask[1] = 0x00;
mask[2] = 0x00;
mask[3] = 0x00;
mask[4] = 0x00;

This is how you would shift the mask

if (shift_left(mask,5,0)) // when a 1 comes out it is time to reset our mask
// init our mask
mask[0] = 0x01;


The next task would be to "patterns" for all the characters that you want to display (A,B,C,D...). To keep things simple, make sure that all have the same number of elements. Then create an array of char for a message. After that, implement some RS232 to a PC and you are set!

If you run out of room. Don't worry too much about it. You can always move to the 16F876 which is pin for pin compatiable and has double the RAM/ROM.

Regards
Mark


:= Wow!
:= Mark
:= i am still suffering from the hang over of the display.
:= the program works perfectly it scrolls HELLO across
:= the the display with no flicky at all.
:= i have being through the program line by line to make
:= sure i understand works going on.
:= i got cut out by the sizeof operator at first,as i had never
:= come across that before.
:= i had to go and read my books to find out that it was used to
:= find out the size in bytes or characters in memory occupied
:= by a data object.
:= (what is the maximum number of columns i can use with the
:= display without runing out of Ram)
:= That was an excellent piece of programming genius.
:= sizeof(pat)
:= Would it not matter if for example the array pat had
:= say 60 elements
:= i am on top of the world,it had always being my dream
:= to build an 8 x 40 scrolling message display and i am
:= getting there.(Would i need to use an external eprom?)
:= i have learn't a lot from you and i do wish one day
:= i could get even up to 50\% of how you write your programs
:= i just don't know how you do it.
:= YOU R DA TOP MAN!!
:= Isaac
:=
:=
:=
:=:=Try this:
:=:=
:=:=#include <16F873.H>
:=:=#fuses XT,NOWDT,NOPUT,NOPROTECT,NOBROWNOUT,NOLVP
:=:=#use delay(clock=4000000)
:=:=#use rs232(baud=9600, xmit=PIN_A0, rcv=PIN_A1,RESTART_WDT,ERRORS,INVERT)
:=:=
:=:=
:=:=#IFNDEF EXP_OUT_ENABLE
:=:=
:=:=#define EXP_OUT_ENABLE PIN_C2
:=:=#define EXP_OUT_CLOCK PIN_C1
:=:=#define EXP_OUT_DO PIN_C0
:=:=#define NUMBER_OF_74595 2
:=:=#ENDIF
:=:=#include <74595.C>
:=:=
:=:=
:=:=#byte port_c=7
:=:=#byte port_b=6
:=:=
:=:=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};
:=:=
:=:=main()
:=:={
:=:= long mask = 0x01; // mask for turning on 1 column at a time
:=:= int data[2]; // array to store our data
:=:= int delaycount;
:=:= int startposition;
:=:= int index;
:=:= int i;
:=:=
:=:= set_tris_c(0);
:=:= set_tris_b(0);
:=:= port_c = 0;
:=:= port_b = 0;
:=:= startposition = 0;
:=:= while(1)
:=:= {
:=:= delaycount = 50; // adjust this value to control how fast the display scrolls
:=:= while (delaycount)
:=:= {
:=:= index = startposition;
:=:= mask = 0x01;
:=:= for (i=0;i<16;i++) // we have sixteen columns to drive
:=:= {
:=:= // store our mask in an array. we need to do this because
:=:= // the call to write_expanded_outputs will destroy the value
:=:= // passed in.
:=:= data[0] = mask; // store which column we are driving
:=:= data[1] = mask>>8; // in an array
:=:= index = i + startposition; // point to the next pattern to display
:=:= if (index >= sizeof(pat)) // make sure that we don't exceed the array
:=:= index -= sizeof(pat);
:=:= port_b = 0; // disable driving the LEDs
:=:= write_expanded_outputs(data); // enable our column driver
:=:= port_b = pat[index]; // drive our LEDs
:=:= mask <<=1; // shift to the next column for next time
:=:= delay_ms(1); // adjust this value to control the drive time for the leds
:=:= }
:=:= --delaycount; // decrement our delay loop counter
:=:= }
:=:= ++startposition; // Point to the next data pattern
:=:= if (startposition >= sizeof(pat)) // make sure that we don't exceed the array
:=:= startposition = 0;
:=:= }
:=:=
:=:=}
:=:=
:=:=
:=:=Regards,
:=:=Mark
:=:=:= Mark the explaination was well received.
:=:=:= but how can i keep track of the individaul elements of data[0]
:=:=:= and data[1]
:=:=:= so that i can set portb accordingly to display my characters so that when data[0]=0b00000001 portb =pat[0]
:=:=:= data[0]=0b0000010 portb =pat[1]
:=:=:= upto when data[0]=0b1000000 portb =pat[8]
:=:=:=would then need to do the same for when data[1]=0b000000001
:=:=:= portb=pat[9]
:=:=:= and so on to get my message displayed
:=:=:= this is the table i intend to use which is the same as the one i used for the 8x8 display
:=:=:= 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};
:=:=:= Any pointers would be greatfully received
:=:=:= Isaac
:=:=:=
:=:=:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 9038
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

Re: Help in using <74595.C> file (program flow)
PostPosted: Sun Nov 17, 2002 4:02 pm     Reply with quote

Thanks for the complements Smile You should be able to use the 16F873 with no problems. If you do run out of RAM/ROM you can always step up to the 16F876. It has double the space. To do the 40 columns, you will need to convert the "mask" to an array and use the shift_left() function.

int mask[5];

// Initialize our mask
mask[0]=0x01;
mask[1]=0x00;
mask[2]=0x00;
mask[3]=0x00;
mask[4]=0x00;

When you need to shift it do something like this:

// When a one is returned from the shift_left() function, our mask is 0 so reload our mask.
if (shift_left(mask,5,0))
mask[0] = 0x01;


Once you have the 40 columns working, I would create patterns for each character. All of them should be the same size to make things easier. Once you do this, then you can send characters from a PC to be displayed on the display.

Regards,
Mark

:= Wow!
:= Mark
:= i am still suffering from the hang over of the display.
:= the program works perfectly it scrolls HELLO across
:= the the display with no flicky at all.
:= i have being through the program line by line to make
:= sure i understand works going on.
:= i got cut out by the sizeof operator at first,as i had never
:= come across that before.
:= i had to go and read my books to find out that it was used to
:= find out the size in bytes or characters in memory occupied
:= by a data object.
:= (what is the maximum number of columns i can use with the
:= display without runing out of Ram)
:= That was an excellent piece of programming genius.
:= sizeof(pat)
:= Would it not matter if for example the array pat had
:= say 60 elements
:= i am on top of the world,it had always being my dream
:= to build an 8 x 40 scrolling message display and i am
:= getting there.(Would i need to use an external eprom?)
:= i have learn't a lot from you and i do wish one day
:= i could get even up to 50\% of how you write your programs
:= i just don't know how you do it.
:= YOU R DA TOP MAN!!
:= Isaac
:=
:=
:=
:=:=Try this:
:=:=
:=:=#include <16F873.H>
:=:=#fuses XT,NOWDT,NOPUT,NOPROTECT,NOBROWNOUT,NOLVP
:=:=#use delay(clock=4000000)
:=:=#use rs232(baud=9600, xmit=PIN_A0, rcv=PIN_A1,RESTART_WDT,ERRORS,INVERT)
:=:=
:=:=
:=:=#IFNDEF EXP_OUT_ENABLE
:=:=
:=:=#define EXP_OUT_ENABLE PIN_C2
:=:=#define EXP_OUT_CLOCK PIN_C1
:=:=#define EXP_OUT_DO PIN_C0
:=:=#define NUMBER_OF_74595 2
:=:=#ENDIF
:=:=#include <74595.C>
:=:=
:=:=
:=:=#byte port_c=7
:=:=#byte port_b=6
:=:=
:=:=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};
:=:=
:=:=main()
:=:={
:=:= long mask = 0x01; // mask for turning on 1 column at a time
:=:= int data[2]; // array to store our data
:=:= int delaycount;
:=:= int startposition;
:=:= int index;
:=:= int i;
:=:=
:=:= set_tris_c(0);
:=:= set_tris_b(0);
:=:= port_c = 0;
:=:= port_b = 0;
:=:= startposition = 0;
:=:= while(1)
:=:= {
:=:= delaycount = 50; // adjust this value to control how fast the display scrolls
:=:= while (delaycount)
:=:= {
:=:= index = startposition;
:=:= mask = 0x01;
:=:= for (i=0;i<16;i++) // we have sixteen columns to drive
:=:= {
:=:= // store our mask in an array. we need to do this because
:=:= // the call to write_expanded_outputs will destroy the value
:=:= // passed in.
:=:= data[0] = mask; // store which column we are driving
:=:= data[1] = mask>>8; // in an array
:=:= index = i + startposition; // point to the next pattern to display
:=:= if (index >= sizeof(pat)) // make sure that we don't exceed the array
:=:= index -= sizeof(pat);
:=:= port_b = 0; // disable driving the LEDs
:=:= write_expanded_outputs(data); // enable our column driver
:=:= port_b = pat[index]; // drive our LEDs
:=:= mask <<=1; // shift to the next column for next time
:=:= delay_ms(1); // adjust this value to control the drive time for the leds
:=:= }
:=:= --delaycount; // decrement our delay loop counter
:=:= }
:=:= ++startposition; // Point to the next data pattern
:=:= if (startposition >= sizeof(pat)) // make sure that we don't exceed the array
:=:= startposition = 0;
:=:= }
:=:=
:=:=}
:=:=
:=:=
:=:=Regards,
:=:=Mark
:=:=:= Mark the explaination was well received.
:=:=:= but how can i keep track of the individaul elements of data[0]
:=:=:= and data[1]
:=:=:= so that i can set portb accordingly to display my characters so that when data[0]=0b00000001 portb =pat[0]
:=:=:= data[0]=0b0000010 portb =pat[1]
:=:=:= upto when data[0]=0b1000000 portb =pat[8]
:=:=:=would then need to do the same for when data[1]=0b000000001
:=:=:= portb=pat[9]
:=:=:= and so on to get my message displayed
:=:=:= this is the table i intend to use which is the same as the one i used for the 8x8 display
:=:=:= 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};
:=:=:= Any pointers would be greatfully received
:=:=:= Isaac
:=:=:=
:=:=:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 9044
isaac aiyanyo
Guest







Re: Help in using <74595.C> file (program flow)
PostPosted: Tue Nov 19, 2002 3:10 pm     Reply with quote

Mark

i need some expert advice from you with regards to my FINAL design.
what i really want to do as i explained to you before is to design 8 rows by 40 columns
Led display.
You have helped me all the way but i and a bit confused on and i am a bit worried
about how the characters can be entered without hoving to write a new massege complier
before i can change the message.
i am taking your advise about getting the 40 columns working then sending the characters
from a PC.
i have being thinking really hard about this so, i came up with a solution but don't know
if its a good one (i can haer you laugh !).
i wrote a program sometime ago in picbasic that allow me to edit all ascii values
between 32 & 126. using 4 buttons connected to porta and an lcd in 4 bit mode but connecting
the R/W line.
so just like entering a text mssage on a moblie phone the ascii characters are then
read from the Ram of the lcd (up to 16 depending on the size of the lcd) and stored in the
the internal eeprom (address 0 - 15)of the pic so that even if power is removed ,when
the pic is next power up the characters are still displayed.
So i know where the characters are located .
the only problem is that for me to implement the design this way is that
i lose about 6 pins on my pic.
if this would be a good solution i have some pic16f874 which have got
3 8bits ports so that wouldn't be a problem.
i just need to convert my program from picbasic to pic C
so i would like to here from you to know what you think, at least i should still
have enough pins to implement the program your written for me so far.
Please let me know as i value your advice!

Isaac

___________________________
This message was ported from CCS's old forum
Original Post ID: 9117
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

Re: Help in using <74595.C> file (program flow)
PostPosted: Tue Nov 19, 2002 7:42 pm     Reply with quote

You should start a new thread (message). I tried replying to your last message a couple of times but could not see the results.

As for the idea, it sounds like you want to make the unit somewhat self contained so that you don't have to use a PC to send the data. There is nothing wrong with this idea. However, you were talking about adding an LCD as a display. Why not use the LED display that you are creating. It will save you those io pins and be "cooler" in my opinion. I would leave an RS232 port there just in case you want to use it in the future.

Regards
Mark

:= Mark,
:= its me trouble again,sorry for being a pain but i do
:= need your help still in trying to understand the flow
:= of the program
:= i can't seem to get my head round the place i commented
:= data[1] = mask>>8;
:=
:=main()
:={
:= long mask = 1; // mask for turning on 1 column at a time
:= int data[2]; // array to store our data
:= set_tris_c(0); // set portc as outputs
:= port_c = 0; // set portc to 0
:= do // start of infinate loop
:= {
:= // store our mask in an array. we need to do this because
:= // the call to write_expanded_outputs will destroy the value
:= // passed in.
:= data[0] = mask; // set data[0] to 0000000000000001 is this correct?
:= data[1] = mask>>8; // set data[1] to 0000000100000000 i got confused here
:= // what happens here does data[1] value = the value of mask
:= // which i think is 0000000000000001 get shifted 8 places to the
:= // right which would become 0 ?
:=
:= write_expanded_outputs(data);
:= delay_ms(5);
:= mask <<=1; // shift to the next column
:=
:=
:= if (mask==0) // if our mask is 0 then start over
:= mask = 0x01; // make mask = 0000000000000001
:= }
:=while(1);
:=
:=}
:=
:=
:= Please could you just explain that part (data [1]mask>>8) for
:= me.
:= i looked in my c book and this suggest that example if mask is
:= 00000101 >> 2 = 00000001
:= So if the value of mask is 0x01;=0000000000000001
:= 0000000000000001 >>8 would this not be zero
:= Please put me out of my misery i am pulling my hair out hear
:= i managed to complete the hardware for an 8 row by 16 col
:= which i tested today.
:= i used the example you gave me just to move the column across
:= the display .
:= this is why i wan't to learn to code so that i can make modifications
:= to display 'Hello'
:= Thanks for your guildance
:= Isaac
___________________________
This message was ported from CCS's old forum
Original Post ID: 9123
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
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