PDA

View Full Version : Moving message on LED dot matrix



chai98a
- 10th November 2006, 02:59
Dear friend Microcode used
Now we study moving message on LED dot matrix but did not work.
We have sample in code (CSS) but i not under stand on code need you help to conver c code to basic code.


Code:(CSS )
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,PUT,NOLVP
#use delay(CLOCK = 10000000 )

#use fast_io(B)

#bit STROBE = 0x06.0 //PIN_B0
#bit LATCH = 0x06.1 //PIN_B1
#bit CLOCK = 0x06.2 //PIN_B2

#bit SIN3 = 0x06.3 //PIN_B3
#bit SIN2 = 0x06.4 //PIN_B4
#bit SIN1 = 0x06.5 //PIN_B5

//
//
// | | |
// | SIN2 | SIN3 |
// | | |
// | Colum3 | Colum2 | Colum1 | Colum0 |
// | | | | |
// |7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0 ------
// | | | | 1 |
// | | | | 2 |
// | | | | 3 |
// | | | | 4 | ROW0
// | | | | 5 |
// | | | | 6 |
// | | | | 7 |
// |----------------|-----------------|-----------------|----------------------- SIN1
// | | | | 0 |
// | | | | 1 |
// | | | | 2 |
// | | | | 3 |
// | | | | 4 | ROW1
// | | | | 5 |
// | | | | 6 |
// | | | | 7 |
// |----------------|-----------------|-----------------|-----------------|-----
// |


char const font[3][16] =
{
{0x00,0x00,0x00,0x00,0x00,0x7C,0x40,0x40,0x78,0x40 ,0x40,0x7C,0x00,0x00,0x00,0x00}, //E
{0x00,0x00,0x00,0x00,0x00,0x7C,0x10,0x10,0x10,0x10 ,0x10,0x10,0x00,0x00,0x00,0x00} //T
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00} //Space
};

char const ScanRow1[16] =
{
0,0,0,0,0,0,0,0,1,2,4,8,16,32,64,128
};

char const ScanRow0[16] =
{

1,2,4,8,16,32,64,128,0,0,0,0,0,0,0,0
};

int buffer[4][16];

int Colum3,Colum2,Colum1,Colum0,Row1,Row0;
//int CheckClock,ValueBitSIN3,ValueBitSIN2,ValueBitSIN1;
int k,l,m,n,o,p,q;


void SendData16Bit();
void SendDataSIN8BitHighbyte();
void SendDataSIN8BitLowbyte();
void BeginData();
void ClearData();
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$
#INT_TIMER1
void IntTimer1_isr()
{
STROBE = 1; //STROBE OFF

for (k=0;k<8;k++) // Row 0 to 7
{
Colum2 = buffer[2][k];
Colum0 = buffer[0][k];
Row0 = ScanRow0[k];
SendDataSIN8BitLowbyte();

Colum3 = buffer[3][k];
Colum1 = buffer[1][k];
Row1 = ScanRow1[k];
SendDataSIN8BitHighbyte();

LATCH = 0; //LATCH ON
LATCH = 1; //LATCH OFF

STROBE = 0; //STROBE ON
delay_us(50);
STROBE = 1; //STROBE OFF
}

for (k=8;k<16;k++) // Row 8 to 15
{
Colum2 = buffer[2][k];
Colum0 = buffer[0][k];
Row0 = ScanRow0[k];
SendDataSIN8BitLowbyte();

Colum3 = buffer[3][k];
Colum1 = buffer[1][k];
Row1 = ScanRow1[k];
SendDataSIN8BitHighbyte();

LATCH = 0; //LATCH ON
LATCH = 1; //LATCH OFF

STROBE = 0; //STROBE ON
delay_us(50);
STROBE = 1; //STROBE OFF
}

//STROBE = 0; //STROBE ON
//set_timer1(65451); // FF AB interrupt 34uS
set_timer1(65400);
}
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$
//################################################## ############################
void main()
{

//-----------------------------
set_tris_b(0x00);
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);
setup_timer_1(T1_INTERNAL | T1_DIV_BY_1);
set_timer1(65451); // FF AB interrupt 34uS

//-----------------------------
STROBE = 1; //STROBE OFF
LATCH = 1; //LATCH OFF
CLOCK = 0; //Clock OFF Active High

SIN3 = 0; //S-IN3 OFF
SIN2 = 0; //S-IN3 OFF
SIN1 = 0; //S-IN3 OFF




ClearData();
BeginData();


//LOOP
while(1)
{

for(p=0;p<8;p++)
{

//----------------------------------------
for (n=0;n<16;n++)
{
buffer[3][n] = ((buffer[3][n]) * 2) + (((buffer[2][n]) &0B10000000)/128) ; //colum3
}
//----------------------------------------
//----------------------------------------
for (n=0;n<16;n++)
{
buffer[2][n] = ((buffer[2][n]) * 2) + (((buffer[1][n]) &0B10000000)/128) ; //colum2
}
//----------------------------------------
//----------------------------------------
for (n=0;n<16;n++)
{
buffer[1][n] = ((buffer[1][n]) * 2) + (((buffer[0][n]) &0B10000000)/128) ; //colum1
}
//----------------------------------------
//----------------------------------------
for (n=0;n<16;n++)
{
buffer[0][n] = ((buffer[0][n]) * 2) + (((buffer[3][n]) &0B10000000)/128) ; //colum0
}
//----------------------------------------

delay_us(100);

}



}
}
//################################################## ############################
//================================================== ============================
void SendDataSIN8BitHighbyte()
{
int i;

for(i=0;i<8;i++)
{
SIN3 = bit_test(Colum1,(i));
SIN2 = bit_test(Colum3,(i));
SIN1 = bit_test(Row1,(i));

CLOCK = 1; //Clock ON
CLOCK = 0; //Clock OFF

}
}
//================================================== ============================
//================================================== ============================
void SendDataSIN8BitLowbyte()
{
int i;

for(i=0;i<8;i++)
{
SIN3 = bit_test(Colum0,(i));
SIN2 = bit_test(Colum2,(i));
SIN1 = bit_test(Row0,(i));

CLOCK = 1; //Clock ON
CLOCK = 0; //Clock OFF

}
}
//================================================== ============================
//================================================== ============================
void BeginData()
{
//----------------------------------------
for (n=0;n<16;n++)
{
buffer[0][n] = font[2][n]; // Space
}
//----------------------------------------
//----------------------------------------
for (n=0;n<16;n++)
{
buffer[1][n] = font[1][n]; // T
}
//----------------------------------------
//----------------------------------------
for (n=0;n<16;n++)
{
buffer[2][n] = font[1][n]; // T
}
//----------------------------------------
//----------------------------------------
for (n=0;n<16;n++)
{
buffer[3][n] = font[0][n]; // E
}
//----------------------------------------
//----------------------------------------
//for (n=0;n<16;n++)
//{
// buffer[4][n] = font[2][n]; // Space
//}
//----------------------------------------
}
//================================================== ============================
//================================================== ============================
void ClearData()
{
//========================================
for(l=0;l<4;l++) // clear buffer
{
for (m=0;m<16;m++)
{
buffer[l][m] =0;
}
}
//========================================
}
//================================================== ============================

mister_e
- 10th November 2006, 03:05
I suggest you download the CCS documentation + their Demo and try to understand what it does yourself first.

Or like i said in another thread... pay someone here :D

Out of curiosity.. is this for a school work?

sougata
- 10th November 2006, 08:42
Hi,

I have done a moving display with PBP but cannot share it due to commercial restrictions. If you are using Shift Registers then the idea is :

1. Get the font data from a lookup table
2. Dump column data for every row and light up that row, do it in even periods and you have got the scanning.

3. For moving message use a pointer in your message table and update it at regular intervals to scroll.

I know that this is very rudimentary. Post your schematic and I will try to help. I got the lookup table for the 5x7 matrix from this forum by dave and thankful for the same. So perhaps its my turn.

chai98a
- 10th November 2006, 14:25
Hi sougata
Here is picture of circuit 512 ...
There are 8 pin for control

Strobe = control On/Off Dot matrix led display, logic "0" active led on
Latch = control data transfer logic "0"
Clock = clock
Sin1 = control row0,row1
Sin2 = control culum2 , culum3
Sin3 = control culum0 , culum1
Vcc_led = power +5 v
Vcc_IC = power +5 v

isaac
- 11th November 2006, 12:58
From your post i can see that you have a 16 row by 32 Cols
the easy way i would have dont this is use PortB & Portc for for Rows
Then use 4 74hc595 shift reisters for your cols to give you 32bits then use the shiftout command.
Here is an example of an 8 Row by 16 Cols
i used portb for the Rows and 2 74hc595 for the cols
This should get you started

' Program USING 74HC595 .BAS

INCLUDE "Modedefs.bas"
ADCON1=7
TRISA=0:TRISB=0:TRISC=0

'PORT ASSIGNS******************************************* ***
DataP VAR PORTC.0'Data pin (74x595.14)
Clk VAR PORTC.1'shift clock (74x595.11)
Latch VAR PORTC.2'Output Latch(74x595.12)
RowVAR BYTE

'Variables ***********************************************
Delay CON 0'Delay
pattern VAR WORD 'Output pattern
A VAR BYTE ' Loop counter for 16 values of Rows



Pause 1000
Low Latch

main :
pattern = %0000000000000001 'pattern for my columns
For A=0 To 15 ' set the Count 16 times
LookUp A,[0,255,255,24,24,255,255,0,0,255,255,219,219,195,19 5,0],Row
'Those values in the Table should give HE on your display
ShiftOut DataP,Clk,msbFirst,[pattern\16] 'Send pattern to 74x595
PORTB=0 'Blank portb before changing
column
PulsOut Latch,1 'Latch 74x595 outputs
PORTB=Row 'Transfer values from table to
portb
Pause Delay 'Delay
pattern=pattern <<1 'shift pattern 1 place the to left
Next A 'this should give me 0000000000000001 to 1000000000000000


GoTo main






Isaac

chai98a
- 13th November 2006, 10:35
How to set like becode with PBP....

Now we used lookup but we cannot specify line or font number

char const font[3][16] =
{
{0x00,0x00,0x00,0x00,0x00,0x7C,0x40,0x40,0x78,0x40 ,0x40,0x7C,0x00,0x00,0x00,0x00}, //E
{0x00,0x00,0x00,0x00,0x00,0x7C,0x10,0x10,0x10,0x10 ,0x10,0x10,0x00,0x00,0x00,0x00} //T
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00} //Space
};

isaac
- 13th November 2006, 13:04
you are mixing pbp with c ?

isaac
- 13th November 2006, 13:06
why not use the data command and prewrite the data to eeprom

Isaac

mister_e
- 13th November 2006, 16:09
Char var byte[48]
char[0]=
char[1]=
char[2]=
char[3]=
char[4]=
'
'
'
'
'


or have a look HERE (http://www.picbasic.co.uk/forum/showthread.php?t=3891&highlight=modifier)
and HERE (http://www.pbpgroup.com/modules/wfsection/article.php?articleid=10)

chai98a
- 14th November 2006, 14:14
Thank all friend for advise

I have question ..

I would to know valve of each bit of A (see below)

A con % 10010111

A bit 0 = 1
A bit 1 = 1
A bit 2 = 1
A bit 3 = 0
A bit 4 = 1
:
:
:

we write as below but not work...

A con % 10010111
For i = 0 to 8 ' loop for bit number
x [i] = A.[i]
print x[i]
next i

Sorry .... it may not cler for my question ( I don't how to say)

mister_e
- 14th November 2006, 14:34
xVar=A.0[i]

And 'print' is not a Melabs PicBasic statement ;)

chai98a
- 14th November 2006, 15:33
Hi Mister_e
Thank for you advise ..

leonardojc
- 25th May 2011, 21:30
isaac, i'm using your code to drive 4x74hc595, but i can't find the things to change in the code.

i need to use 4 x 8x8 led matrix, but only work 2 of those.

i apreciate your help