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.

Random effect for led dot matrix

Status
Not open for further replies.

deniah

Member level 4
Joined
Nov 28, 2005
Messages
74
Helped
6
Reputation
12
Reaction score
5
Trophy points
1,288
Location
Montenegro
Activity points
1,777
I'm doing some experiments with 40x7 led matrix display and I'm trying to built effect where dots are switch on randomly to form letters.
Say, first column has to be 0b11111110.
First pass column looks like 0b00000000
Second pass 0b00001010
Third pass 0b10001110
forth pass 0b10111110
fifth pass 0b11111110

Every column must have own random pattern.

i've been struggling with this few days with no success.

Here is my code for static massage:

Code:
#define SHIFT_DATA       PORTB.F2         // 74HC595 Data
#define SHIFT_LATCH      PORTB.F0         // 74HC595 Latch
#define SHIFT_CLOCK      PORTB.F1         // 74HC595 Clock

#include "fnt.h"

char x,row,j,pos,i;
char buffer[40];
char msg[] = "Demotxt";

void main() {
   init();
   row = 0x01;
   j=0;
   pos=0;
   while (1){
   
      for (i=0; i<=39; ++i) {
         buffer[i] = font6x7[((msg[pos]-32)*6)+j];
         if (++j == 0x06) {
            j=0;
            pos++;
         }
      }
      
      for (i=0; i<=200; ++i) {
         for (x=0; x<=39; ++x) {
            SHIFT_DATA = 1;
            if (buffer[x] & row) SHIFT_DATA = 0;
            SHIFT_CLOCK = 1;
            SHIFT_CLOCK = 0;
         }
         SHIFT_LATCH = 1;
         SHIFT_LATCH = 0;
         portc = ~row;
         row <<= 1;
         if (row == 0x80) row = 0x01;
         delay_us(1100);
         portc = 0xff;
      }
   pos=0;
   j=0;
   }
}

Fonts definitions are in one dimmension array:

Code:
const unsigned short font6x7[] = {
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00,      // Code for char  
        0x00, 0x00, 0x7D, 0x00, 0x00, 0x00,      // Code for char !
        0x00, 0x60, 0x00, 0x60, 0x00, 0x00,      // Code for char "
        ....

Can you give me idea how to solve this?

Regards
Refik Zaimovic
 

I found out one solution using constant char table

Code:
const char random_table[] = {0x00,0x00,0x00,0x00,0x00,0x00,
                             0x80,0x40,0x10,0x08,0x40,0x20,
                             0x88,0x48,0x18,0x0A,0x60,0x28,
                             0xC8,0x68,0x1C,0x4A,0x68,0x2A,
                             0xCA,0x69,0x5C,0x5A,0x69,0x3A,
                             0xDA,0x6D,0x5D,0xDA,0x6B,0xBA,
                             0xDE,0xED,0x5F,0xFA,0xEB,0xBB,
                             0xFE,0xEF,0x7F,0xFE,0xFB,0xBF,
                             0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};

and then prepare buffer like this:

Code:
      for (i=0; i<=39; ++i) {
         //test1 = ((msg[pos]-32)*6)+j;
         buffer[i] = font6x7[((msg[pos]-32)*6)+j];
         buffer[i] &= random_table[j+tempj];
         if (++j == 0x06) {
            j=0;
            pos++;
         }
      }

With random_table stored in internal eeprom, 57 program words is saved.
 
Last edited:

You can generate random number in some different ways.
One of them is to use ADC of your uC with pin FLOATING, take the ADC reading and use it for your SEED for RND function.
 

use ADC of your uC with pin FLOATING

Can you explain me what is pin floating?

I did try to use rnd function, but cant be sure that dots that are on at the one moment do not turn off in the next call of rnd.

I have another question. How to rotate one character for 90°, 180° and 270°?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top