What correct PIC to use for multiplexing 51 characters?

Discussion in 'Embedded Systems and Microcontrollers' started by oookey, Apr 2, 2013.

  1. oookey

    Thread Starter Member

    May 24, 2010
    62
    0
    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
     
  2. absf

    Senior Member

    Dec 29, 2010
    1,492
    372
    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: Apr 3, 2013
    oookey likes this.
  3. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    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: Apr 3, 2013
    absf likes this.
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,387
    1,605

    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
     
    absf likes this.
  5. takao21203

    Distinguished Member

    Apr 28, 2012
    3,577
    463
    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.
     
  6. oookey

    Thread Starter Member

    May 24, 2010
    62
    0
    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.

    :)
     
  7. MMcLaren

    Well-Known Member

    Feb 14, 2010
    759
    116
    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?

    [​IMG]
    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

    Code ( (Unknown Language)):
    1. /********************************************************************
    2.  *                                                                  *
    3.  *                                                                  *
    4.  *  Example 16F88 7x15 Message display                              *
    5.  *                                                                  *
    6.  *                                                                  *
    7.  *      IDE: MPLAB 8.80 (tabs = 4)                                  *
    8.  *     Lang: SourceBoost BoostC v7.01, Lite/Free version            *
    9.  *                                                                  *
    10.  *                                                                  *
    11.  ********************************************************************/
    12.  
    13.  #include <system.h>
    14.  
    15.  #pragma DATA _CONFIG1, _CCP1_RB0&_LVP_OFF&_MCLR_OFF&_WDT_OFF&_INTRC_IO
    16.  #pragma DATA _CONFIG2, _IESO_OFF & _FCMEN_OFF
    17.  
    18.  #pragma CLOCK_FREQ 8000000     // 8-MHz Internal Oscillator
    19.  
    20. /********************************************************************
    21.  *  variables & constants                                           *
    22.  ********************************************************************/
    23.  
    24.  #define r08 const rom unsigned char
    25.  
    26.  r08 msg[] = {                  //
    27.                0b00000000,      //
    28.                0b00000000,      //
    29.                0b00000000,      //
    30.                0b00000000,      //
    31.                0b00000000,      //
    32.                0b00000000,      //
    33.                0b01111111,      // "M"
    34.                0b00000010,      //
    35.                0b00000100,      //
    36.                0b00000010,      //
    37.                0b01111111,      //
    38.                0b00000000,      //
    39.                0b01111111,      // "E"
    40.                0b01001001,      //
    41.                0b01001001,      //
    42.                0b01001001,      //
    43.                0b01001001,      //
    44.                0b00000000,      //
    45.                0b01111111,      // "R"
    46.                0b00001001,      //
    47.                0b00001001,      //
    48.                0b00001001,      //
    49.                0b01110110,      //
    50.                0b00000000,      //
    51.                0b01111111,      // "R"
    52.                0b00001001,      //
    53.                0b00001001,      //
    54.                0b00001001,      //
    55.                0b01110110,      //
    56.                0b00000000,      //
    57.                0b00000111,      // "Y"
    58.                0b00001000,      //
    59.                0b01111000,      //
    60.                0b00001000,      //
    61.                0b00000111,      //
    62.                0b00000000,      //
    63.                0b00000000,      // " " (space)
    64.                0b00000000,      //
    65.                0b00000000,      //
    66.                0b00000000,      //
    67.                0b00111110,      // "C"
    68.                0b01000001,      //
    69.                0b01000001,      //
    70.                0b01000001,      //
    71.                0b00100010,      //
    72.                0b00000000,      //
    73.                0b01111111,      // "H"
    74.                0b00001000,      //
    75.                0b00001000,      //
    76.                0b00001000,      //
    77.                0b01111111,      //
    78.                0b00000000,      //
    79.                0b01111111,      // "R"
    80.                0b00001001,      //
    81.                0b00001001,      //
    82.                0b00001001,      //
    83.                0b01110110,      //
    84.                0b00000000,      //
    85.                0b01000001,      // "I"
    86.                0b01111111,      //
    87.                0b01000001,      //
    88.                0b00000000,      //
    89.                0b00000110,      // "S"
    90.                0b01001001,      //
    91.                0b01001001,      //
    92.                0b01001001,      //
    93.                0b00110000,      //
    94.                0b00000000,      //
    95.                0b00000001,      // "T"
    96.                0b00000001,      //
    97.                0b01111111,      //
    98.                0b00000001,      //
    99.                0b00000001,      //
    100.                0b00000000,      //
    101.                0b01111111,      // "M"
    102.                0b00000010,      //
    103.                0b00000100,      //
    104.                0b00000010,      //
    105.                0b01111111,      //
    106.                0b00000000,      //
    107.                0b01111110,      // "A"
    108.                0b00001001,      //
    109.                0b00001001,      //
    110.                0b00001001,      //
    111.                0b01111110,      //
    112.                0b00000000,      //
    113.                0b00000110,      // "S"
    114.                0b01001001,      //
    115.                0b01001001,      //
    116.                0b01001001,      //
    117.                0b00110000,      //
    118.                0b00000000 };    //
    119.  
    120.  
    121. /********************************************************************
    122.  *  functions                                                       *
    123.  ********************************************************************/
    124.  
    125. /********************************************************************
    126.  *  main init                                                       *
    127.  ********************************************************************/
    128.  
    129.  void main()
    130.  { char column = 0;             // column, 0..14
    131.    int msgptr = 0;              //
    132.    int msglen = sizeof(msg);    //
    133.    int msgndx = 0;              //
    134.  
    135.    ansel = 0;                   // a2d off, digital i/o
    136.    osccon = 0b01110000;         // set INTOSC to 8 MHz
    137.    while(!osccon.IOFS);         // wait 'til oscillator stable
    138.    trisb = 0b00000000;          // set PORTB to outputs
    139.    trisa = 0b00000000;          // set PORTA to outputs
    140.    portb = 0b00000000;          // set output latches to '0'
    141.    porta = 0b00000000;          // set output latches to '0'
    142.  
    143.   /******************************************************************
    144.    *  main loop                                                     *
    145.    ******************************************************************/
    146.  
    147.    while(1)
    148.    { portb = 0x00;              // blank the display
    149.      porta = column++;          // select new column
    150.      portb = msg[msgndx++];     // display new column
    151.  
    152.      if(column == 15)           // if last column
    153.      { column = 0;              // reset column
    154.        if(++msgptr >= msglen)   // if end-of-message
    155.          msgptr = 0;            // reset message pointer
    156.        msgndx = msgptr;         // reset message index
    157.      }                          //
    158.  
    159.      if(msgndx >= msglen)       // if index overflow
    160.        msgndx -= msglen;        // adjust index
    161.      delay_ms(1);               // approx 66 Hz Refresh Rate
    162.    }                            //
    163.  }                              //
    164.  
     
    Last edited: Apr 8, 2013
    oookey likes this.
  8. MMcLaren

    Well-Known Member

    Feb 14, 2010
    759
    116
    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

    Code ( (Unknown Language)):
    1.   /******************************************************************
    2.    *  main loop                                                     *
    3.    ******************************************************************/
    4.  
    5.    while(1)                     //
    6.    { char speed = 8;            //
    7.      while(speed)               //
    8.      { portb = 0x00;            // blank the display
    9.        porta = column++;        // select new column
    10.        portb = msg[msgndx++];   // display new column
    11.  
    12.        if(column == 15)         // if last column
    13.        { column = 0;            // reset column
    14.          msgndx = msgptr;       // reset message index
    15.          speed--;               //
    16.        }                        //
    17.  
    18.        if(msgndx >= msglen)     // if index overflow
    19.          msgndx -= msglen;      // adjust index
    20.        delay_ms(1);             // approx 66 Hz refresh rate
    21.      }                          //
    22.      if(++msgptr >= msglen)     // if end-of-message
    23.        msgptr = 0;              // reset message pointer
    24.      msgndx = msgptr;           // reset message index
    25.    }                            //
    26.  }                              //
    27.  
     
Loading...