8X32 Dot Matrix Display with at89s52 in C

Discussion in 'Embedded Systems and Microcontrollers' started by agent5, Apr 19, 2013.

  1. agent5

    Thread Starter New Member

    Apr 19, 2013
    7
    0
    Hi guys,

    Need some help over here. I search through some entries but not much mentioning about C and how the display and shifting works. (I am very bad at C T.T)

    This is my schematics:
    [​IMG]

    * common cathode block
    * I orient it in such a way that the cathode column now become row for scanning

    Questions:
    1) Any problems with the schematics? The shift register is connecting to anode column / current sinker to cathode row.

    2) Would the scanning works? I tried to simulate in Proteus but the current sinker dont operate as expected - eg. a high in 1B is not giving a low in 1C but in fact all the C are always low.

    3) I found this pattern table and I dont understand how can I access to one of the character since all the characters are in a same array.
    Code ( (Unknown Language)):
    1.  
    2. unsigned char code table1[]={
    3.  0x80,0x80,0x80,0x80,0x80,0x80, // SPACE
    4.  0x80,0x80,0x5F,0x80,0x80,0x80, // !
    5.  0x04,0x02,0x05,0x02,0x01,0x80, // "
    6.  0x14,0x7F,0x14,0x7F,0x14,0x80, // #
    7.  0x26,0x49,0x7F,0x49,0x32,0x80,// $
    8.  0x22,0x10,0x08,0x04,0x22,0x80,// %
    9.  0x80,0x36,0x49,0x36,0x28,0x80,// &
    10.  0x04,0x02,0x01,0x80,0x80,0x80,// '
    11.  0x08,0x14,0x22,0x41,0x80,0x80,// (
    12.  0x80,0x41,0x22,0x14,0x08,0x80,// )
    13.  0x2A,0x1C,0x08,0x1C,0x2A,0x80,// *
    14.  0x08,0x08,0x3E,0x08,0x08,0x80,// +
    15.  0x80,0x58,0x38,0x80,0x80,0x80,// ,
    16.  0x08,0x08,0x08,0x08,0x08,0x80,// -
    17.  0x40,0x80,0x80,0x80,0x80,0x80,// .
    18.  0x20,0x10,0x08,0x04,0x02,0x80}; // ;
    19.  
    4) How the display actually comes about (no scrolling first). Eg. if I were to display ABC, does that mean that when I scanning the first row I need to send a string of 32-bits of data consist of the first row of ABC then go to the next row OR scan row 1 - 8 for A, then repeat the same B and C but in a very fast manner. :shock:

    Please help. Thanks ~
     
    Last edited by a moderator: Apr 19, 2013
  2. takao21203

    Distinguished Member

    Apr 28, 2012
    3,577
    463
    One of your tasks understanding the fundamentals of computer programming will be to figure out how to do this.

    Best of luck with that.

    If all fails, try Data Structures, Algorithms and Software Principles in C by Thomas A. Standish (1994, Paperback)

    This is very very dated computer programming book. If you spend some evenings really reading it, you'll know how to do 3)
     
    agent5 likes this.
  3. agent5

    Thread Starter New Member

    Apr 19, 2013
    7
    0
    Thanks for the pointer. :D
     
  4. absf

    Senior Member

    Dec 29, 2010
    1,493
    372
    You need to bring LE of your 74HC259 to one of the port pins. As your D (Data) is fixed at 5V, you are not able to send 0v to switch off the ROW lines and dont forget that 74259 is a latch. It will latch on the the ROW without releasing the previous ROW. See my simulation attached.

    Another thing to take note is that Port 0 has open-drain outputs IIRC. So you have to take care of that as well.

    Allen
     
    agent5 likes this.
  5. agent5

    Thread Starter New Member

    Apr 19, 2013
    7
    0
    Thanks Allen, for pointing out the flaws.

    I am lost on this, if LE is grounded then the whole thing wont work, what should I do? How would the ULN2803 connection possibly be ?

    As for the D, is it decoder or shift register? If D for 259 is grounded / open the chip wont work either ~

    A set of 1k pull up resistor should do the job for Port 0 right?



    Thanks for your time.
     
  6. absf

    Senior Member

    Dec 29, 2010
    1,493
    372
    There are many ways to do it.

    You can control the 'D' pin and Address pins from 8051. When 'D' is High & Address = "000", row 0 is activated. Make 'D' Low and select the next Row using Address = "001", then set 'D' High again and so on......

    You could also use 74HC238. This chip is same as 74HC138 but with active High outputs.

    Allen
     
    Last edited: Apr 22, 2013
    agent5 likes this.
  7. agent5

    Thread Starter New Member

    Apr 19, 2013
    7
    0
    thanks for the suggestion.
    I tried to look for the amount of current sink for both 238 and 138 but cant get one,cause the output is connected to cathode of led.
    I am doing 8*32 block, worst case woud be 15mA * 32 = 480mA ! That the reason I use ULN2803 but 74HC238 is like a combination of both demux and sinker (if able to) !
     
  8. absf

    Senior Member

    Dec 29, 2010
    1,493
    372
    The typical sinking capabilities of 74HC238 are the same as 74HC259. The main current sinking functions still have to be carried out by your ULN2803 Darlington drivers through Pin #9 which is not shown on the simulator. The HCTTL outputs only drive the Bases of the ULN2803 inputs. According to the datasheet, each driver only needs 1.35mA max.

    Allen
     
    agent5 likes this.
  9. agent5

    Thread Starter New Member

    Apr 19, 2013
    7
    0
    Okay, got it.

    Thanks allen.
     
  10. agent5

    Thread Starter New Member

    Apr 19, 2013
    7
    0
    * Not sure why I cant find the edit button (its just nowhere to be found !!), so I have to post instead of add into the topic, sorry Mod ~ *

    I am now working on the part getting the patterns from a string.

    For now I just want to display a sentence that already in the uC.

    Eg. const char msg[] = "Hello World!";

    I see the normal way is make a look up table and by identifying the ASCII of each character in the array, and look it up from the table then putting it into another array before displaying it on the matrix.

    Now is the part I am confused.
    -> From what I understand, msg[] contains only 1 element which is "Hello World!" as a whole.
    -> But how could I identify the ASCII of each letter, eg 'H','e' ... ? :(

    I did some readup on C but still cant figure it out, hope to get some pointer.
     
  11. agent5

    Thread Starter New Member

    Apr 19, 2013
    7
    0
    Having error, cant figure out why T.T

    Everything was fine but suddenly ~

    Code ( (Unknown Language)):
    1.  
    2. void get_char ()
    3. {
    4. unsigned int count;
    5. unsigned int x = 0;
    6. unsigned int s_idx = 0;
    7. unsigned int t_idx;
    8.    
    9.     while(msg[x] != '\0') // continue to collect each char from msg[] till the last element    
    10.     {
    11.         t_idx = msg[x];       // obtain ASCII of each char
    12.         t_idx -= 32;           // obtain offset by minus 32
    13.         x ++ ;             // increment of x for next element
    14.        
    15.         count = 0;      // counter for obtaining element from look up table, 8 sets of hex
    16.              
    17.         do{
    18.         save_data[s_idx] = table[t_idx];  // obtain the hex from look up table according to the offset
    19.                 s_idx ++ ;
    20.             t_idx ++ ;     
    21.         }while(++count != 8);
    22.    
    23.     }
    24. }
    25.  
    Errors:

     
Loading...