|
|
View previous topic :: View next topic |
Author |
Message |
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Dec 09, 2004 8:48 pm |
|
|
Can you send me a movie of the above code. |
|
|
Gizz
Joined: 15 Jun 2004 Posts: 21 Location: Nottingham UK
|
|
Posted: Mon Dec 13, 2004 7:20 am |
|
|
Ernest, et al.
Just a thought - 80 columns is a lot to scan through. I have just set up a protoype for this application and I use the following:
5 outputs from PIC driving multiple P fet transistors driving each column of a 5x7 display. So every 'col0' etc is on at the same time. The P-fet has a 2A current.
The rows are fed via a 82R resistor to a 74HC373, giving about 35mA per LED max. The LEDs are rated at 10mA. So each matrix unit has a single 373 latch to feed it 7 bits of data.
It works well, cos I can latch in all 6 chars (in my protoype) in a few uS, then hold the column on for a few mS, then repeat for all 6 chars, all 5 columns, getting good fast data rates with 35/5 = 7mA (almost good enough) brightness.
I think you will always be up against current and data rate limitations unless you do some commonning of the matrix and add in some latches.
And my solution uses off-the-shelf easy to get bits. |
|
|
Matrix4U
Joined: 20 May 2007 Posts: 7
|
LED Moving Message 8X80 |
Posted: Mon Aug 06, 2007 12:57 am |
|
|
Hello
copied from ernest
I was trying to build moving messages display as i search in the forums i saw that u made i try to make the same as u did
as is used ur code and PIC16F877A For rows i connected to Portd directly and for cols connecting from uln2803a through 74hc595 when i give the power pic16f877a getting heat and its not displaying any thing
is am i doing anything wrong or my hardware is not good
pls can u tell me the schematic plss for learning i am trying to do i be so thankful to u if u tell me ur schematic how u connected plssss
here is the code that u did
Code: |
#if defined(__PCM__)
#include <16F877A.H>
#fuses HS,NOWDT,NOPUT,NOPROTECT,NOBROWNOUT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_A4, rcv=PIN_A5,RESTART_WDT, ERRORS)
#define PIN_RCLK PIN_C1 // RCLK ----> Pin 12
#define PIN_SCLK PIN_C2 // SRCLK ---> Pin 11
#define PIN_SER_IN PIN_C0 // SER -----> Pin 14
#define NUMBER_OF_74595 10
#ENDIF
//#include <74595_V02.C>
#byte port_a=5
#byte port_b=6
#byte port_c=7
#byte port_d=8
#use fast_io(C)
#use fast_io(D)
long s1_char_size=41;
char s1[79];
long i;
void get_line1(void)
{
for(i=0; i<s1_char_size; i++)
{
if(kbhit())
{
s1[i]=getc();
delay_cycles(2);
printf("%C",s1[i]);
delay_us(1);
}
else
i -= 1;
}
} // END of void get_line1()
char const msg_default[] = " Welcome to SDTC <C>Ernest-->2004 (er)";
char const ascii1[32][5] = {
{0,0,0,0,0} // 0
{0,0,95,0,0} // {0,95,0,0,0,0}
// 1
{0,7,0,7,0} // {0, 7,0,7,0,0}
// 2
{20,127,20,127,20} // 3
{36, 42, 127, 42, 18} // 4
{39, 21, 107, 84, 114} // 5
{54, 73, 86, 32, 80} // 6
{0, 11, 7,0,0} // {0, 11, 7,0,0,0}
// 7
{0, 28, 34, 65,0} // {0, 28, 34, 65,0,0}
// 8
{0, 65, 34, 28,0} // {0, 65, 34, 28,0,0}
// 9
{42, 28, 127, 28, 42} // 10
{8, 8, 62, 8, 8} // 11
{0, 88, 56, 0,0} // {0, 88, 56,0,0,0}
// 12
{8,8,8,8,8} // 13
{0, 96, 96, 0,0} // {0, 96, 96,0,0,0}
// 14
{32, 16, 8, 4, 2} // 15
{62, 81, 73, 69, 62} // 16
{0, 66, 127, 64,0} // {0,66, 127, 64,0,0}
// 17
{114, 73, 73, 73, 70} // 18
{34, 65, 73, 73, 54} // 19
{24, 20, 18, 127, 16} // 20
{39, 69, 69, 69, 57} // 21
{60, 74, 73, 73, 48} // 22
{1, 113, 9, 5, 3} // 23
{54, 73, 73, 73, 54} // 24
{6, 73, 73, 41, 30} // 25
{0, 54,54,0,0} // {0, 54, 54,0,0,0}
// 26
{0, 91, 59, 0,0} // {0, 91, 59,0,0,0} // 27
{8, 20, 34, 65,0} // 28
{20, 20, 20, 20, 20} // 29
{65, 34, 20, 8,0} // 30
{2, 1, 81, 9, 6} // 31
};
char const ascii2[32][5] = {
{50, 73, 121, 65, 62} // 0
{124, 18, 17, 18, 124} // 1 A
{65, 127, 73, 73, 54} // 2 B
{62, 65, 65, 65, 34} // 3 C
{65, 127, 65, 65, 62} // 4 D
{127, 73, 73, 65, 65 } // 5 E
{127, 9, 9, 1, 1} // 6
{62, 65, 73, 73, 58} // 7
{127, 8, 8, 8, 127} // 8
{0, 65, 127, 65, 0} // {0, 65, 127, 65,0,0}
// 9
{32, 64, 65, 63, 1} // 10
{127, 8, 20, 34, 65} // 11
{127, 64, 64, 64, 64} // 12
{127, 2, 12, 2, 127} // 13
{127, 2, 4, 8, 127} // 14
{62, 65, 65, 65, 62} // 15
{127, 9, 9, 9, 6} // 16
{62, 65, 81, 33, 94} // 17
{127, 9, 25, 41, 70} // 18
{38, 73, 73, 73, 50} // 19
{1,1,127, 1, 1} // 20
{63, 64, 64, 64, 63} // 21
{7, 24, 96, 24, 7} // 22
{127, 32, 24, 32, 127} // 23
{99, 20, 8, 20, 99} // 24
{3, 4, 120, 4, 3} // 25
{97, 81, 73, 69, 67} // 26
{0, 127, 65, 65,0} // {0, 127, 65, 65,0,0}
// 27
{2, 4, 8, 16, 32} // 28
{0, 65, 65, 127,0} // {0, 65, 65, 127,0,0}
// 29
{4, 2, 1, 2, 4} // 30
{64, 64, 64, 64, 64} // 31
};
char const ascii3[31][5] = { // 0 -- 30 == 31 elements
{0, 0, 7, 11,0} // {0, 7, 11,0,0,0}
// 0
{32, 84, 84, 84, 56} // 1
{127, 40, 68, 68, 56} // 2
{56, 68, 68, 68,0} // 3
{56, 68, 68, 40, 127} // 4
{56, 84, 84, 84, 24} // 5
{8, 126, 9, 9, 2} // 6
{8, 84, 84, 84, 60} // 7
{127, 8, 4, 4, 120} // 8
{0, 68, 125, 64,0} // {0, 68, 125, 64,0,0}
// 9
{32, 64, 68, 61,0} // 10
{127, 16, 40, 68,0} // 11
{0, 65, 127, 64, 0} // {0, 65, 127, 64,0,0}
// 12
{124, 4, 120, 4, 120} // 13
{124, 8, 4, 4, 120} // 14
{56, 68, 68, 68, 56} // 15
{124, 20, 20, 20, 8} // 16
{8, 20, 20, 20, 124} // 17
{124, 8, 4, 4, 8} // 18
{72, 84, 84, 84, 36} // 19
{4, 63, 68, 68,0} // 20
{60, 64, 64, 32, 124} // 21
{28, 32, 64, 32, 28} // 22
{60, 64, 48, 64, 60} // 23
{68, 40, 16, 40, 68} // 24
{12,80, 80, 80, 60} // 25
{68, 100, 84, 76, 68} // 26
{0, 8, 54, 65,0} // {0, 8, 54, 65,0,0}
// 27
{0,0,119,0,0} // {0, 119,0,0,0,0} // 28
{0, 65, 54, 8,0} // {0, 65, 54, 8,0,0}
// 29
{2,1,2,4,2} // 30
};
void main(void)
{
int char_index;
int col_index;
int x = 0;
long MSD, LSD;
int delaycount;
int16 startposition;
set_tris_b(0); //set portb to outputs
set_tris_c(0x90); //set portc to outputs, C7 to input
set_tris_d(0);
port_b = 0;
port_c = 0; //zero port c
startposition = 0;
for(i=0; i<79; i++)
s1[i] = 46;
for(i=0; i<sizeof(msg_default); i++)
s1[i] = msg_default[i];
delay_ms(100);
do
{
if(!input(PIN_E1)) //if RE1==LOW (pressed)
{
do
{
delay_cycles(2);
printf("\f\r\n");
printf("\f\r\n How many char.(0--99):");
MSD=getc();
delay_cycles(2);
printf("%C",MSD);
delay_us(1);
}while(!isamoung(MSD,"0123456789"));
do
{
LSD=getc();
delay_cycles(2);
printf("%C",LSD);
delay_us(1);
}while(!isamoung(LSD,"0123456789"));
s1_char_size = 10*(MSD-48) + (LSD-48);
delay_cycles(2);
printf("\r\n\n Enter the %lu char.: ",s1_char_size);
get_line1(); // acquire 16 char.
} // END of INPUT(PIN_E1)
// The delay count controls how fast the message scrolls
delaycount=4;
while (delaycount)
{
// This will be the index into our character
col_index = startposition % 6;
// This will be the index into our display msg array
char_index = startposition / 6;
// Make sure that our index doesn't exceed our array size
if (char_index >= sizeof(s1))
{
startposition = 0;
char_index = 0;
col_index = 0;
}
// grab the first char
x = s1[char_index];
output_high(PIN_RCLK);
output_high(PIN_SCLK);
// The first bit is a 1, so put it there
output_high(PIN_SER_IN);
output_low(PIN_SCLK);
delay_us(1);
output_high(PIN_SCLK);
output_low(PIN_SER_IN);
for (i=0;i<80;i++) // we've 80 columns to
{
port_d=0;
// put the shift register values on the outputs
output_low(PIN_RCLK);
delay_us(1);
output_high(PIN_RCLK);
delay_us(1);
// rotate the 1 through the 595's
output_low(PIN_SCLK);
delay_us(1);
output_high(PIN_SCLK);
// if the column index is 5, then grab the next char from our array
if (col_index == 5)
{
// This is the 6th column so grab the next char
col_index = 0;
char_index++;
if (char_index >= sizeof(s1))
char_index = 0;
x = s1[char_index];
}
else
{
// This is an invalid char. Note that we do not really need to set portd since it is already 0
if ( x < 32)
port_d = 0;
// check if s1[] is inside ascii1[] array
else if( x < 64)
port_d = ascii1[x-32][col_index];
// check if s1[] is inside ascii2[] array
else if( x < 96 )
port_d = ascii2[x-64][col_index];
// check if s1[] is inside ascii3[] array
else if( x < 128)
port_d = ascii3[x-96][col_index];
// Any other invalid chars won't get printed either
// Move to the next column in the char
col_index++;
}
//adjust this value to control the drive time
delay_us(120);
}// END for-loop
// decrement our delay loop counter
delaycount--;
}
//Point to next data pattern
startposition++;
} while(1); //End of do-while
}// END main()
|
|
|
|
ravi Guest
|
shift ragister |
Posted: Thu Feb 19, 2009 4:50 am |
|
|
i want run 7segment or led with help of shift ragister
i wrote follwing pprogram
but its not work
plz halp me
#include<reg51.h>
sbit carry=PSW^7;
sbit P1b0=P1^1;
sbit clk=P1^2;
sbit out=P1^3;
void delay()
{
unsigned int i;
for(i=0;i<=60000;i++){;}
}
void main()
{
unsigned char x,y;
unsigned int mynum[]={0xAA,0xAA,0xAA};
for(y=0;y<3;y++)
{
for(x=0;x<8;x++)
{
clk=0;
delay();
clk=1;
mynum[y]>>=1;
P1b0=carry;
delay();
}
out=0;
delay();
out=1;
}} |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Thu Feb 19, 2009 6:35 am |
|
|
Your code is apparently dedicated to a 8051 processor, so it's obviously out of topic here.
Generally, you seem to expect, that mynum[y]>>=1; is shifting the LSB to carry and that it's value is kept until the next instruction. I wouldn't do that. (It may be the case, but rather by chance). There are many options to achieve the intended result with portable C code, e.g. P1b0 = (mynum[y] & 1); |
|
|
karthickiw
Joined: 09 Aug 2007 Posts: 82 Location: TN, India
|
problem with dot matrix display... |
Posted: Tue Mar 31, 2009 3:17 am |
|
|
Mark wrote: | The human eye notices flicker at anything below 100Hz. Therefore you have to turn the LED on at least every 10ms. So you have 80 columns to turn on/off in 10ms. So that means that they can only be on 125us. The longer they are on, the brighter they get until they are full on. So if you are driving them longer than 125us, that is the problem. Note the time to copy data, shift out, blah, blah, blah all goes into this time. It is NOT just some delay after you turn them on. The time required to setup the current column is added to the "ON" time of the previous column. Make sense? |
Dear Mark,
I write the program to display the “Hello” in scrolling 7X60 LED display. I successful to scrolling the “Hello” message in 7X60 LED display. I have problem with brightness of LED display. I don't put any resistor for LED display. My coding is below…
Code: | #include<16f876.h>
#use delay(clock=20M)
#fuses NOWDT,HS, PUT, PROTECT, NODEBUG, BROWNOUT, NOLVP, CPD, WRT
#byte port_b=6
#define EXP_OUT_ENABLE PIN_A2 //RCK
#define EXP_OUT_CLOCK PIN_A1 //SCK
#define EXP_OUT_DO PIN_A0 //SER
#define NUMBER_OF_74595 7
#include <74595.C>
int inc=0,chr_no=31,column_no=56,last_inc; // chr_no calculate from zero//
long int time2=0;
int CONST str_MAP[]={0x00 , 0x00 , 0x00 , 0x00 , 0x00,
0x7F , 0x08 , 0x08 , 0x08 , 0x7F,
0x00 , 0x38 , 0x54 , 0x54 , 0x54,
0x48 , 0x00 , 0x7F , 0x00 ,
0x00 , 0x7F , 0x00 ,
0x38 , 0x44 , 0x44 , 0x44 , 0x38,
0x00 , 0x00 , 0x00 , 0x00 , 0x00};
#INT_timer2 // move the character in display
void seconds_timer2()
{
time2++;
if(time2==100)
{
inc++;
if (inc==(chr_no+1)) inc=0;
time2=0;
}
}
void main() {
int data[7]=0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X7F;
int mask[7]; //ffef
int Column=0,str=0,act=0;
setup_timer_2(T2_DIV_BY_16,255,1);
enable_interrupts(INT_TIMER2);
enable_interrupts(GLOBAL);
//disable_interrupts(INT_TIMER2);
set_tris_b (0x00);
str=chr_no;
column=column_no;
while (TRUE)
{
IF (str==255)
{
str=chr_no;
}
mask[0]=data[0]; // move the data into the mask temp space
mask[1]=data[1];
mask[2]=data[2];
mask[3]=data[3];
mask[4]=data[4];
mask[5]=data[5];
mask[6]=data[6];
// port_b=0x00;
write_expanded_outputs (data); // sent the data to 74HC595
act=str+inc;
if (act >chr_no) act=act-(chr_no+1); // rotate the string
port_b= str_map[act]; // sent the string to port B
data[0]=mask[0]; // move the temp data into the data
data[1]=mask[1];
data[2]=mask[2];
data[3]=mask[3];
data[4]=mask[4];
data[5]=mask[5];
data[6]=mask[6];
str--; // increase the string pointer
if(Column==1) // check colume is end or not
{
data[0]=0XFF; // referene from frist column
data[1]=0XFF;
data[2]=0XFF;
data[3]=0XFF;
data[4]=0XFF;
data[5]=0XFF;
data[6]=0X7F;
Column=column_no;
str=chr_no;
}
else
{
Column--;
if ( column <= 8)
{
if (column==8)
{
data[0]=0X7F;
data[1]=0XFF;
data[2]=0XFF;
data[3]=0XFF;
data[4]=0XFF;
data[5]=0XFF;
data[6]=0XFF;
}
else
{
rotate_right( &data[0] , 1); //move the next column L <---- R
}
}
else if( column<=16)
{
if (column==16)
{
data[0]=0XFF;
data[1]=0X7F;
data[2]=0XFF;
data[3]=0XFF;
data[4]=0XFF;
data[5]=0XFF;
data[6]=0XFF;
}
else
{
rotate_right( &data[1] , 1); //move the next column L <---- R
}
//rotate_right( &data[1] , 1);
}
else if( column<=24)
{
if (column==24)
{
data[0]=0XFF;
data[1]=0XFF;
data[2]=0X7F;
data[3]=0XFF;
data[4]=0XFF;
data[5]=0XFF;
data[6]=0XFF;
}
else
{
rotate_right( &data[2] , 1); //move the next column L <---- R
}
}
else if( column<=32)
{
if (column==32)
{
data[0]=0XFF;
data[1]=0XFF;
data[2]=0XFF;
data[3]=0X7F;
data[4]=0XFF;
data[5]=0XFF;
data[6]=0XFF;
}
else
{
rotate_right( &data[3] , 1); //move the next column L <---- R
}
}
else if( column<=40)
{
if (column==40)
{
data[0]=0XFF;
data[1]=0XFF;
data[2]=0XfF;
data[3]=0XFF;
data[4]=0X7F;
data[5]=0XFF;
data[6]=0XFF;
}
else
{
rotate_right( &data[4] , 1); //move the next column L <---- R
}
}
else if( column<=48)
{
if (column==48)
{
data[0]=0XFF;
data[1]=0XFF;
data[2]=0XfF;
data[3]=0XFF;
data[4]=0XFF;
data[5]=0X7F;
data[6]=0XFF;
}
else
{
rotate_right( &data[5] , 1); //move the next column L <---- R
}
}
else if( column<=56)
{
if (column==56)
{
data[0]=0XFF;
data[1]=0XFF;
data[2]=0XfF;
data[3]=0XFF;
data[4]=0XFF;
data[5]=0XFF;
data[6]=0X7F;
}
else
{
rotate_right( &data[6] , 1); //move the next column L <---- R
}
}
}
//delay_us(500);
}// while
}// main |
Give the idea to increase the brightness of the LED display… |
|
|
|
|
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
|