What correct PIC to use for multiplexing 51 characters?

Thread Starter

oookey

Joined May 24, 2010
70
Hi All,

I need guidance to select the right PIC preferable PIC16F or PIC18F type for the purpose of LED multiplexing display.

The scrolling message consists of 51 characters including spacing, the LED dot matrix is 7 rows by 15 columns, the rows are controlled by MCU’s port, and columns are controlled by two units of 74HC138, a 3 to 8 line de multiplexer, via MCU’s port. Its datasheet is attached.

I tried 16F628A, it could handle scrolling message of around 20 characters, but for 51 characters encountered out of memory when trying to compile. Could the experts here give advice for the correct PIC I should be using? In the PIC datasheet which figure should I be notice? The SRAM or EEPROM?

Thanks :D

oookey
 

Attachments

absf

Joined Dec 29, 2010
1,968
Where did you store the 51 characters to be displayed? And how big is your display buffer needed to be during displaying of your message?

The 16F628A has only 224 bytes of RAM while 16F648 has slightly more RAM (256 bytes). I think you might need >768 bytes to 1.5 Kbytes of RAM in order for your program to work properly.

I did this project on an 8051 with external 8K RAM. So there was no shortage of display buffers for my program. My LED matrix is 128 columns by 8 rows.

Use the link below to look for a PIC with bigger RAM size.

http://www.microchip.com/maps/microcontroller.aspx

Allen
 
Last edited:

Markd77

Joined Sep 7, 2009
2,806
15 by 7 pixels?
If you only need the pixels to be on/off then you only need 15 bytes of RAM to display and another 15 bytes to store the next scrolled position while it is being calculated.
You would need a lot more if you want to store a bitmap of the whole message in memory, which would save processing, but if the PIC isn't doing much else then it should have plenty of time.
At the moment I'm working on a 16X40 pixel clock with the 16F84A, which doesn't have enough RAM for one bit per pixel, so I'm recalculating each row while displaying the previous one. I like a challenge.
 
Last edited:

ErnieM

Joined Apr 24, 2011
8,377
Could the experts here give advice for the correct PIC I should be using? In the PIC datasheet which figure should I be notice? The SRAM or EEPROM?

Flash is the program memory.

SRAM is the RAM registers, the memory that gets set then read when the code runs.

EEPROM is there to hold information that mostly is the same but sometimes changes, like some calibration constants.

Character patterns would go in flash. Which character would go into SRAM.

When I do new projects I tend to pick a PIC with the number of pins I will need, and the largest memory I can find. That way

PICs are relatively cheap: the most expensive PIC (a PIC32) is only about 10 bucks, so you ain't saving much money by buying a smaller PIC.

Before I would offer any suggestions I would need to know how many pins you want to use, and which series (PIC16, PIC18 or such).

I'm not sure if this link will work, but Microchip has pretty good selector guides: http://www.microchip.com/ParamChartSearch/chart.aspx?branchID=1002&mid=10&lang=en&pageId=74
 

takao21203

Joined Apr 28, 2012
3,702
16f1824 is a good start for this or the 1828 variant if you don't use serial interface.

I made a matrix scroller on the 16f57 but really maxing it out, and I use external RAM to buffer the complete computed bitmap.

If you run out of RAM you can use external RAM, but soon maybe you will also run out of FLASH.

http://pic.hitechworld.org/data/ledmatrixtag/

The source is included but it is unusual, proportional fonts are used as well the bitmap is remapped to the LED matrix.

The C spelling is also nasty apparently the dereferencing wasn't supported correctly. On a regular PIC you can do it with less lines.
 

Thread Starter

oookey

Joined May 24, 2010
70
Hi thanks all,

Quote ErnieM:

" Before I would offer any suggestions I would need to know how many pins you want to use, and which series (PIC16, PIC18 or such). "

I'll be using 7pins for rows; 3pins for inputs to 74HC138; 5pins for activating the corresponding 74HC138, so at least 15pins needed, and i may be using the internal oscillator.

The 51 characters are purely capital alphabets, no special characters.

:)
 

MMcLaren

Joined Feb 14, 2010
861
It sounds like you're refreshing one column at a time (1/15th duty cycle) but I can't imagine why you would need eight pins to control the 74HCT138 pair. Why not wire them up as a four line to sixteen line decoder to drive the matrix columns?


If you were to store the message in program memory as an image, you'd only need six words of program memory for each character and your sixty or so characters would only require about three hundred sixty (360) words of program memory. Add a couple hundred words for the main program and you're up to about six hundred words of memory (using the free/lite version of BoostC). Double that if you're using the free/lite version of Hi-Tech C or XC8.

If you're interested, here's an untested example program (BoostC) that demonstrates a simple method for scrolling the image of a message contained in a constant array (in program memory). The program is for a 16F88 with RB0..RB6 driving the matrix rows (top to bottom) and RA0..RA3 driving the A0..A3 address lines for the 74HCT138 decoder pair (11 pins total). The program contains a short sixteen character message and uses 225 words of program memory and about a dozen bytes of RAM memory. You'll want to add a "speed" loop to slow down the display.

Good luck on your project...

Cheerful regards, Mike

Rich (BB code):
/********************************************************************
 *                                                                  *
 *                                                                  *
 *  Example 16F88 7x15 Message display                              *
 *                                                                  *
 *                                                                  *
 *      IDE: MPLAB 8.80 (tabs = 4)                                  *
 *     Lang: SourceBoost BoostC v7.01, Lite/Free version            *
 *                                                                  *
 *                                                                  *
 ********************************************************************/

 #include <system.h>

 #pragma DATA _CONFIG1, _CCP1_RB0&_LVP_OFF&_MCLR_OFF&_WDT_OFF&_INTRC_IO
 #pragma DATA _CONFIG2, _IESO_OFF & _FCMEN_OFF

 #pragma CLOCK_FREQ 8000000     // 8-MHz Internal Oscillator

/********************************************************************
 *  variables & constants                                           *
 ********************************************************************/

 #define r08 const rom unsigned char

 r08 msg[] = {                  // 
               0b00000000,      //
               0b00000000,      //
               0b00000000,      //
               0b00000000,      //
               0b00000000,      //
               0b00000000,      //
               0b01111111,      // "M"
               0b00000010,      //
               0b00000100,      //
               0b00000010,      //
               0b01111111,      //
               0b00000000,      //
               0b01111111,      // "E"
               0b01001001,      //
               0b01001001,      //
               0b01001001,      //
               0b01001001,      //
               0b00000000,      //
               0b01111111,      // "R"
               0b00001001,      //
               0b00001001,      //
               0b00001001,      //
               0b01110110,      //
               0b00000000,      //
               0b01111111,      // "R"
               0b00001001,      //
               0b00001001,      //
               0b00001001,      //
               0b01110110,      //
               0b00000000,      //
               0b00000111,      // "Y"
               0b00001000,      //
               0b01111000,      //
               0b00001000,      //
               0b00000111,      //
               0b00000000,      //
               0b00000000,      // " " (space)
               0b00000000,      //
               0b00000000,      //
               0b00000000,      //
               0b00111110,      // "C"
               0b01000001,      //
               0b01000001,      //
               0b01000001,      //
               0b00100010,      //
               0b00000000,      //
               0b01111111,      // "H"
               0b00001000,      //
               0b00001000,      //
               0b00001000,      //
               0b01111111,      //
               0b00000000,      //
               0b01111111,      // "R"
               0b00001001,      //
               0b00001001,      //
               0b00001001,      //
               0b01110110,      //
               0b00000000,      //
               0b01000001,      // "I"
               0b01111111,      //
               0b01000001,      //
               0b00000000,      //
               0b00000110,      // "S"
               0b01001001,      //
               0b01001001,      //
               0b01001001,      //
               0b00110000,      //
               0b00000000,      //
               0b00000001,      // "T"
               0b00000001,      //
               0b01111111,      //
               0b00000001,      //
               0b00000001,      //
               0b00000000,      //
               0b01111111,      // "M"
               0b00000010,      //
               0b00000100,      //
               0b00000010,      //
               0b01111111,      //
               0b00000000,      //
               0b01111110,      // "A"
               0b00001001,      //
               0b00001001,      //
               0b00001001,      //
               0b01111110,      //
               0b00000000,      //
               0b00000110,      // "S"
               0b01001001,      //
               0b01001001,      //
               0b01001001,      //
               0b00110000,      //
               0b00000000 };    //


/********************************************************************
 *  functions                                                       *
 ********************************************************************/

/********************************************************************
 *  main init                                                       *
 ********************************************************************/

 void main()
 { char column = 0;             // column, 0..14
   int msgptr = 0;              //
   int msglen = sizeof(msg);    //
   int msgndx = 0;              //

   ansel = 0;                   // a2d off, digital i/o
   osccon = 0b01110000;         // set INTOSC to 8 MHz
   while(!osccon.IOFS);         // wait 'til oscillator stable
   trisb = 0b00000000;          // set PORTB to outputs
   trisa = 0b00000000;          // set PORTA to outputs
   portb = 0b00000000;          // set output latches to '0'
   porta = 0b00000000;          // set output latches to '0'

  /******************************************************************
   *  main loop                                                     *
   ******************************************************************/

   while(1)
   { portb = 0x00;              // blank the display
     porta = column++;          // select new column
     portb = msg[msgndx++];     // display new column

     if(column == 15)           // if last column
     { column = 0;              // reset column
       if(++msgptr >= msglen)   // if end-of-message
         msgptr = 0;            // reset message pointer
       msgndx = msgptr;         // reset message index
     }                          //

     if(msgndx >= msglen)       // if index overflow
       msgndx -= msglen;        // adjust index
     delay_ms(1);               // approx 66 Hz Refresh Rate
   }                            //
 }                              //
 

Attachments

Last edited:

MMcLaren

Joined Feb 14, 2010
861
You're welcome, oookey.

Does the example program make sense? Basically, it's refreshing the 15 columns of the display directly from the constant message array. It's not a complicated method and you should be able to use just about any PIC with eleven I/O pins and 2048 words of program memory.

Once you understand the display method you'll want to add code to slow down the display while maintaining a decent refresh rate. Perhaps something similar to the example below.

Good luck on your project.

Cheerful regards, Mike

Rich (BB code):
  /******************************************************************
   *  main loop                                                     *
   ******************************************************************/

   while(1)                     //
   { char speed = 8;            // 
     while(speed)               //
     { portb = 0x00;            // blank the display
       porta = column++;        // select new column
       portb = msg[msgndx++];   // display new column

       if(column == 15)         // if last column
       { column = 0;            // reset column
         msgndx = msgptr;       // reset message index
         speed--;               // 
       }                        //

       if(msgndx >= msglen)     // if index overflow
         msgndx -= msglen;      // adjust index
       delay_ms(1);             // approx 66 Hz refresh rate
     }                          //
     if(++msgptr >= msglen)     // if end-of-message
       msgptr = 0;              // reset message pointer
     msgndx = msgptr;           // reset message index
   }                            //
 }                              //
 
Top