Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Scrolling LED Message 8x8 PIC18F4620 w/ Mikroc pro for pic and Proteus

Status
Not open for further replies.

lloydi12345

Member level 4
Member level 4
Joined
Aug 31, 2010
Messages
77
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,288
Activity points
1,953
I know there are many threads on how to build these projects but I really would like to know the basics. It feels better to make my own code without copying and pasting from others work. I already understand how to use shift register 595 and I'm scanning the LEDs with a johnson counter 4022. I'm already done with displaying static letter.

So far here it is:

Although the letter is not perfect it's already good for me.

Here's my code:
Code:
/*
  Trial1 displaying matrix
*/

sbit clock_a at rc0_bit;
sbit data_a at rc1_bit;
sbit latch_a at rc2_bit;

sbit clock_b at rd6_bit;
sbit reset at rd7_bit;
sbit enable at rd5_bit;

const unsigned short arrays[][8] = {{0xFF,0xFF,0x80,0x77,0x77,0x77,0x80,0xFF}
                                   };
unsigned int scanner, scanner2, scantime, disp, row, column, mask, repeat;

void main() {
     LATC = 0x00;
     CMCON = 0x07; 
     ADCON0 = 0x00;
     ADCON1 = 0x0F;
     TRISC = 0x00;
     TRISD = 0x00;
     scanner2 = 0;
     while(1) {
              for(column=0;column<1;column++){
                for (repeat=0;repeat<80;repeat++){
                  for(row=0;row<8;row++){
                      disp = arrays[column][row];
                      mask = 0x01;
                      for (scantime=0;scantime<8;scantime++){
                          scanner = mask & disp;
                          if (scanner==0)
                             data_a = 0;
                          else data_a = 1;
                          mask = mask << 1;
                          clock_a = 1;
                          clock_a = 0;
                      }

                      latch_a = 1;
                      latch_a = 0;
                      clock_b = 1;
                      clock_b = 0;
                      delay_us(100);
                  }
                  }
              }
     }
}


Now I would like to scroll it from right to left. Can someone give me an idea how to do it? Basically my problem is the algorithm involved. I know I will be using logical operations like OR and then do some shifting but don't know how to start. Thanks.

Cheers, :-D

lloydi
 
Last edited:

Which variable that you store what you are want to display?
I have done before, I do shifting that variable.
 

This is my example scrolling array.
array[7]=0b0000000000000000;
array[6]=0b0000000000000000;
array[5]=0b0000000000000000;
array[4]=0b0000000000000000;
array[3]=0b0000000000000000;
array[2]=0b0000000000000000;
array[1]=0b0000000000000000;
array[0]=0b0000000000000000;

for(i=7;i>=0;i--) array=(array<<1)|((temp[j]>>i)&0x01);

Also involve Timer0 interrupt. This is part of 16X8 LED Signboard.
 
Last edited:

Thanks engshahrul but I don't get it. Can you expand it more?

---------- Post added at 13:44 ---------- Previous post was at 13:38 ----------

I was able to scroll it but adding another array. My code now is this one:

Code:
/*
  Trial1 displaying matrix
*/

sbit clock_a at rc0_bit;
sbit data_a at rc1_bit;
sbit latch_a at rc2_bit;

sbit clock_b at rd6_bit;
sbit reset at rd7_bit;
sbit enable at rd5_bit;

const unsigned long int arrays[][8] = {{0b11111111,0b11111111,0b10000000,0b01110111,0b01110111,0b01110111,0b10000000,0b11111111},
                                    {0b11111111,0b10000000,0b01110111,0b01110111,0b01110111,0b10000000,0b11111111,0b11111111},
                                    {0b10000000,0b01110111,0b01110111,0b01110111,0b10000000,0b11111111,0b11111111,0b11111111},
                                    {0b01110111,0b01110111,0b01110111,0b10000000,0b11111111,0b11111111,0b11111111,0b10000000},
                                    {0b01110111,0b01110111,0b10000000,0b11111111,0b11111111,0b11111111,0b10000000,0b01110111},
                                    {0b01110111,0b10000000,0b11111111,0b11111111,0b11111111,0b10000000,0b01110111,0b01110111},
                                    {0b10000000,0b11111111,0b11111111,0b11111111,0b10000000,0b01110111,0b01110111,0b01110111},
                                    {0b11111111,0b11111111,0b11111111,0b10000000,0b01110111,0b01110111,0b01110111,0b10000000},
                                   };
unsigned int scanner, scanner2, scantime, disp, row, column, mask, repeat;

void main() {
     LATC = 0x00;
     CMCON = 0x07;
     ADCON0 = 0x00;
     ADCON1 = 0x0F;
     TRISC = 0x00;
     TRISD = 0x00;
     scanner2 = 0;
     while(1) {
              for(column=0;column<8;column++){
                for (repeat=0;repeat<50;repeat++){
                  for(row=0;row<8;row++){
                      disp = arrays[column][row];
                      mask = 0x01;
                      for (scantime=0;scantime<8;scantime++){
                          scanner = mask & disp;
                          if (scanner==0)
                             data_a = 0;
                          else data_a = 1;
                          mask = mask << 1;
                          clock_a = 1;
                          clock_a = 0;
                      }
                      latch_a = 1;
                      latch_a = 0;
                      clock_b = 1;
                      clock_b = 0;
                      delay_ms(1);
                  }
                  }
              }
     }
}

I know there's a simpler way since it occupies my rom a lot.
 

Thanks engshahrul but I don't get it. Can you expand it more?
Only that I can give. The array[7] to array[0] to store display content. Then, my Timer Interrupt will do the blinking. I'm just scrolling this variable to get display scrolling.
 

I think I already know what you're showing to me. Is that applicable only until 4 led matrices. I would like to extend it like 6 to 8.
 

Oh I see but I don't think you are using the scanning method? are you also scanning? and you're not using a shift register? I think it's another concept.
 
Last edited:

Oh I see but I don't think you are using the scanning method? are you also scanning? and you're not using a shift register? I think it's another concept.
If scanning you mean switching, of course it need to do switching line-by-line. I just ON 1 line per time. The blinking is 1/8. I count 0-7 for sending this line in the interrupt.
 

Okay, what are you switching? the columns or the rows?
 

I just got back from Maplins with some 40pin headers and a couple of crystals...!
We've spoke about using a big PIC as a, near-enough, RAMDAC, I just thought that if you can use a (pretty big) cheep-as-chips De-Mux Chip, as big as possible, we wouldn't need a shift register and could drive its inputs from PORTA or B or C or D, to select the "Row" and use 16 of the other pins as the "Data"... (OR scaled up or down!)
I got stuff to think about to do with the scrolling, did you see my post on another thread with the big "Declare" in it for you mate?
NEAL

---------- Post added at 12:40 ---------- Previous post was at 11:55 ----------

What about 74154, its 4 to 16 line MUX... Use 4 if have to!!!
NEAL
 

I hate to jump on someone elses Ideas, but I've just made this in 20 mins your thought inspiring me mate, its an on 5x5 LEDs soldered together, commons and rows, and just a lame program that makes them flash a bit... It'll be full text again soon but 5x5 is not impressive... Could be 24x8 though!!

To test using this as a "RamDac" I'm going to try and talk to it through SPI from another chip, I got a 12f 8pin pic as well today, to be the master... 8Pins should be enough to test eh...!
Thanks for the inspiration!
Best regards
NEAL

 

**broken link removed**

This is the board I knocked up for playing at developing on, 40pin 16f877a @ 20Mhz (I got them without realising there is no internal RC clock, so it NEEDs the xtal too).

Code:
// This is all thats running, randomness itself!
void main()
 {
	TRISB=0;TRISD=0;
	char portbb=0xaa;
	char portdd=0x3D;
	while(1)
	{
		PORTB= portbb; portbb=~portbb;
		PORTD= portdd; portdd+=3;
		DelayS(1);
	}

}
 

This displays a "Picture" that is in "5x5DeclareTest.h" as a declare....

#include "5x5DeclareTest.h"

#include<htc.h> //include MCU head file
#include "always.h"
#include "delay.h"
void main()
{
//PORTD =Row Select... PORTB = DATAx5
// ANSEL=00;
TRISB=0;TRISD=0;
char portbb=0xFF;
char portdd=0x00;
int i; char i2;
while(1)
{
// PORTB= portbb;
//portdd+=3;portbb+=1;
//PORTD= portdd;

i++;
if(i>100) { i =0; i2++;}
i2 %=BitmapLengthTot;
for(char c=0;c<5;c++)
{
portdd = (0x80>>c) ^ 255;
PORTD=portdd;
portbb = bmap[c+i2][0]<<3;
PORTB=portbb;
DelayMs(1);
PORTB=0;


}

}

}

---------- Post added at 19:41 ---------- Previous post was at 19:40 ----------

5x5declare.h
///////////////////////////////////////////////////////////
// Output from MakeMultiDisplayBitmapHungarian(NealAndZsoltSoft2011)v3.
// Neal-S & Zsolt-K. Paste into DisplayData.H
// ABCDEFG
// GFEDCBA
// ABCDEFG
// GFEDCBA
const char bmap[32][4] =
{
{0b00000000, 0b00000000, 0b00000000, 0b00000000 },//
{0b00011110, 0b00001110, 0b00011110, 0b00001110 },// OOO OOOO OOO OOOO
{0b00000101, 0b00010001, 0b00000101, 0b00010001 },// O O O O O O O O
{0b00000101, 0b00010101, 0b00000101, 0b00010101 },// O O O O O O O O O O
{0b00011110, 0b00001101, 0b00011110, 0b00001101 },// OO O OOOO OO O OOOO
{0b00000000, 0b00000000, 0b00000000, 0b00000000 },//
{0b00011111, 0b00000001, 0b00011111, 0b00000001 },// O OOOOO O OOOOO
{0b00010101, 0b00111111, 0b00010101, 0b00111111 },// OOOOOO O O O OOOOOO O O O
{0b00011111, 0b00001001, 0b00011111, 0b00001001 },// O O OOOOO O O OOOOO
{0b00001010, 0b00000001, 0b00001010, 0b00000001 },// O O O O O O
{0b00000000, 0b00000000, 0b00000000, 0b00000000 },//
{0b00001110, 0b00011111, 0b00001110, 0b00011111 },// OOOOO OOO OOOOO OOO
{0b00010001, 0b00010101, 0b00010001, 0b00010101 },// O O O O O O O O O O
{0b00010001, 0b00010101, 0b00010001, 0b00010101 },// O O O O O O O O O O
{0b00001010, 0b00010001, 0b00001010, 0b00010001 },// O O O O O O O O
{0b00000000, 0b00000000, 0b00000000, 0b00000000 },//
{0b00010001, 0b00010001, 0b00010001, 0b00010001 },// O O O O O O O O
{0b00011111, 0b00011111, 0b00011111, 0b00011111 },// OOOOO OOOOO OOOOO OOOOO
{0b00010001, 0b00010001, 0b00010001, 0b00010001 },// O O O O O O O O
{0b00001110, 0b00001110, 0b00001110, 0b00001110 },// OOO OOO OOO OOO
{0b00000000, 0b00000000, 0b00000000, 0b00000000 },//
{0b00011111, 0b00001110, 0b00011111, 0b00001110 },// OOO OOOOO OOO OOOOO
{0b00010101, 0b00010001, 0b00010101, 0b00010001 },// O O O O O O O O O O
{0b00010101, 0b00010001, 0b00010101, 0b00010001 },// O O O O O O O O O O
{0b00010001, 0b00001010, 0b00010001, 0b00001010 },// O O O O O O O O
{0b00000000, 0b00000000, 0b00000000, 0b00000000 },//
{0b00000001, 0b00011111, 0b00000001, 0b00011111 },// OOOOO O OOOOO O
{0b00111111, 0b00010101, 0b00111111, 0b00010101 },// O O O OOOOOO O O O OOOOOO
{0b00001001, 0b00011111, 0b00001001, 0b00011111 },// OOOOO O O OOOOO O O
{0b00000001, 0b00001010, 0b00000001, 0b00001010 },// O O O O O O
{0b00000000, 0b00000000, 0b00000000, 0b00000000 },//
};
static const unsigned int BitmapLength=4;
static const unsigned int BitmapLengthTot=32;
 

[Nealcode]
const char bmap[32][4] =
{
{0b00000000, 0b00000000, 0b00000000, 0b00000000 },//
{0b00011110, 0b00001110, 0b00011110, 0b00001110 },// OOO OOOO OOO OOOO
{0b00000101, 0b00010001, 0b00000101, 0b00010001 },// O O O O O O O O
{0b00000101, 0b00010101, 0b00000101, 0b00010101 },// O O O O O O O O O O
{0b00011110, 0b00001101, 0b00011110, 0b00001101 },// OO O OOOO OO O OOOO
{0b00000000, 0b00000000, 0b00000000, 0b00000000 },//
{0b00011111, 0b00000001, 0b00011111, 0b00000001 },// O OOOOO O OOOOO
{0b00010101, 0b00111111, 0b00010101, 0b00111111 },// OOOOOO O O O OOOOOO O O O
{0b00011111, 0b00001001, 0b00011111, 0b00001001 },// O O OOOOO O O OOOOO
{0b00001010, 0b00000001, 0b00001010, 0b00000001 },// O O O O O O
{0b00000000, 0b00000000, 0b00000000, 0b00000000 },//
{0b00001110, 0b00011111, 0b00001110, 0b00011111 },// OOOOO OOO OOOOO OOO
{0b00010001, 0b00010101, 0b00010001, 0b00010101 },// O O O O O O O O O O
{0b00010001, 0b00010101, 0b00010001, 0b00010101 },// O O O O O O O O O O
{0b00001010, 0b00010001, 0b00001010, 0b00010001 },// O O O O O O O O
{0b00000000, 0b00000000, 0b00000000, 0b00000000 },//
{0b00010001, 0b00010001, 0b00010001, 0b00010001 },// O O O O O O O O
{0b00011111, 0b00011111, 0b00011111, 0b00011111 },// OOOOO OOOOO OOOOO OOOOO
{0b00010001, 0b00010001, 0b00010001, 0b00010001 },// O O O O O O O O
{0b00001110, 0b00001110, 0b00001110, 0b00001110 },// OOO OOO OOO OOO
{0b00000000, 0b00000000, 0b00000000, 0b00000000 },//
{0b00011111, 0b00001110, 0b00011111, 0b00001110 },// OOO OOOOO OOO OOOOO
{0b00010101, 0b00010001, 0b00010101, 0b00010001 },// O O O O O O O O O O
{0b00010101, 0b00010001, 0b00010101, 0b00010001 },// O O O O O O O O O O
{0b00010001, 0b00001010, 0b00010001, 0b00001010 },// O O O O O O O O
{0b00000000, 0b00000000, 0b00000000, 0b00000000 },//
{0b00000001, 0b00011111, 0b00000001, 0b00011111 },// OOOOO O OOOOO O
{0b00111111, 0b00010101, 0b00111111, 0b00010101 },// O O O OOOOOO O O O OOOOOO
{0b00001001, 0b00011111, 0b00001001, 0b00011111 },// OOOOO O O OOOOO O O
{0b00000001, 0b00001010, 0b00000001, 0b00001010 },// O O O O O O
{0b00000000, 0b00000000, 0b00000000, 0b00000000 },//
};
static const unsigned int BitmapLength=4;
static const unsigned int BitmapLengthTot=32;
[/Nealcode]

Cut and paste this into notepad and set to Courier (or System) font and you will see the text... I've got a nice C# program I've made that turns text into a bitmap... I'll send you to the link where it is but you may need to install c# (express is free) to get best results! :))

Best regards
NEAL

---------- Post added at 09:59 ---------- Previous post was at 09:58 ----------

I've managed to get the bitmap length to over 1000 so on 5x5 thats 200 characters!

---------- Post added at 10:00 ---------- Previous post was at 09:59 ----------

Cut and paste to notepad not brilliant, I'll link the file "DisplayData.h" somewhere so you can see it mate

---------- Post added at 10:01 ---------- Previous post was at 10:00 ----------

And there are 4 line (bmap[32][4]) just to make it easy to do graphics, swapping display lines in the code and "swinging" between them on Sin-Scrolling

---------- Post added at 10:03 ---------- Previous post was at 10:01 ----------

so 200 characters x 4 lines = 800
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top