dot matrix display programming in c

DickCappels

Joined Aug 21, 2008
10,187
Sounds like an exciting project.

To decode the 7 segment display, you can make a table of 1 byte constants in program memory. Bit 0 could correspond to segment a, Bit 1 corresponds to segment b, etc. Write a 1 for each segment that would be lit for each number.

The first entry in the table would be for the zero character, the second for the 1 character, etc. Use an index into the table, starting at zero, compare the incoming 7 segment data with the byte at which the index is pointing. When the contents of the table matches the incoming 7 segments, you have found the value of the 7 segment display and the answer is the value of the index register.

Sorry, I cannot remember exactly how to do this in an 8051.
 

DickCappels

Joined Aug 21, 2008
10,187
For testing you can have the uC take a pin on the output port high, so you can leave the dot matrix encoding and output until after the 7 segment decoder is working correctly.
 

Thread Starter

nikhilsonar29

Joined Sep 26, 2014
68
sir,
and also if you can program this code in pic micro controller ,that will be also convenient for me...because then i can compare that code with 8051.
although i am not restricted to 8051 only ,
 

Thread Starter

nikhilsonar29

Joined Sep 26, 2014
68
hi sir,
i got the output..
i have attached files for the same for reference
if any one can have keil uvision and proteus simulator can check the output
now my task is to scrowl that character .
plz any one can give me basic detail concept behind it,

Code:
//..........................................................
                

LS74_154 EQU  P1
UDN2981  EQU  P2
SWICH    EQU  P3

                 ORG 00H
                          
                MOV P3,0FFH
//---------------------------------------------------------------------------------0         
START:           CLR  A
              
                 MOV A ,SWICH            
                ADD  A,#01000000B
                CJNE A,#01111111B,NEXT
                
FLOOR0:          MOV DPTR,# MYDATA1
                 MOV R0,#0H
            
REV0:             CLR A
                 MOV LS74_154,R0
                 MOVC A,@A+DPTR
                 JZ   FLOOR0
                 MOV UDN2981,A
                 INC DPTR
                 INC R0
                
                ACALL DELAY
                
                MOV A,    SWICH
                 CJNE A,#00111111B,START
            
                 SJMP REV0
//----------------------------------------------------------------------------------1
                
NEXT:            CLR  A
                MOV  A ,SWICH
               ADD  A,#01111001B
               CJNE A,#01111111B,NEXT1


              
FLOOR1:         MOV DPTR,# MYDATA2
                 MOV R0,#0H
      
REV1:            CLR A
                 MOV LS74_154,R0
               MOVC A,@A+DPTR
                JZ FLOOR1
                MOV UDN2981,A
                INC DPTR
                INC R0
      
                ACALL DELAY
                
                MOV A,SWICH
                 CJNE A,#00000110B,START 
            
               SJMP REV1
//---------------------------------------------------------------------------------2
NEXT1:            CLR  A
                 MOV  A ,SWICH
                ADD  A,#00100100B
                CJNE A,#01111111B,NEXT2


              
FLOOR2 :         MOV DPTR,# MYDATA3
                MOV R0,#0H
      
REV2:            CLR A
               MOV LS74_154,R0
               MOVC A,@A+DPTR
                 JZ FLOOR2
                 MOV UDN2981,A
                 INC DPTR
                 INC R0
      
                ACALL DELAY
                
                MOV A,SWICH
                 CJNE A,#01011011B,START
            
                SJMP REV2

//---------------------------------------------------------------------------------3
NEXT2:            CLR  A
                MOV  A ,SWICH
                ADD  A,#00110000B
              CJNE A,#01111111B,NEXT3


              
FLOOR3 :         MOV DPTR,# MYDATA4
                MOV R0,#0H
      
REV3:            CLR A
               MOV LS74_154,R0
               MOVC A,@A+DPTR
                 JZ FLOOR3
                 MOV UDN2981,A
                 INC DPTR
                 INC R0
      
                ACALL DELAY
                
                MOV A,SWICH
  NEW:               CJNE A,#01001111B,START
            
                SJMP REV3



//----------------------------------------------------------------------------------4
NEXT3:            CLR  A
                MOV  A ,SWICH
                ADD  A,#00011011B
              CJNE A,#01111111B,NEXT4


              
FLOOR4 :         MOV DPTR,# MYDATA5
                MOV R0,#0H
      
REV4:            CLR A
               MOV LS74_154,R0
               MOVC A,@A+DPTR
                 JZ FLOOR4
                 MOV UDN2981,A
                 INC DPTR
                 INC R0
      
                ACALL DELAY
                
                MOV A,SWICH
                 CJNE A,#01100100B,NEW
            
                SJMP REV4








//----------------------------------------------------------------------------------5
NEXT4:            CLR  A
                MOV  A ,SWICH
                ADD  A,#00010010B
              CJNE A,#01111111B,NEXT5


              
FLOOR5 :         MOV DPTR,# MYDATA6
                MOV R0,#0H
      
REV5:            CLR A
               MOV LS74_154,R0
               MOVC A,@A+DPTR
                 JZ FLOOR5
                 MOV UDN2981,A
                 INC DPTR
                 INC R0
      
                ACALL DELAY
                
                MOV A,SWICH
                 CJNE A,#01101101B,NEW
            
                SJMP REV5

//,...........................................................................    6


NEXT5:            CLR  A
                MOV  A ,SWICH
                ADD  A,#00000010B
              CJNE A,#01111111B,NEXT6


              
FLOOR6 :         MOV DPTR,# MYDATA7
                MOV R0,#0H
      
REV6:            CLR A
               MOV LS74_154,R0
               MOVC A,@A+DPTR
                 JZ FLOOR6
                 MOV UDN2981,A
                 INC DPTR
                 INC R0
      
                ACALL DELAY
                
                MOV A,SWICH
  NEW1:               CJNE A,#01111101B,NEW
            
                SJMP REV6


//................................................................................7



NEXT6:            CLR  A
                MOV  A ,SWICH
                ADD  A,#01111000B
              CJNE A,#01111111B,NEXT7


              
FLOOR7 :         MOV DPTR,# MYDATA8
                MOV R0,#0H
      
REV7:            CLR A
               MOV LS74_154,R0
               MOVC A,@A+DPTR
                 JZ FLOOR7
                 MOV UDN2981,A
                 INC DPTR
                 INC R0
      
                ACALL DELAY
                
                MOV A,SWICH
                 CJNE A,#00000111B,NEW1
            
                SJMP REV7  
  
  
  
    //................................................................................8



NEXT7:            CLR  A
                MOV  A ,SWICH
                ADD  A,#00000000B
              CJNE A,#01111111B,NEXT8


              
FLOOR8 :         MOV DPTR,# MYDATA9
                MOV R0,#0H
      
REV8:            CLR A
               MOV LS74_154,R0
               MOVC A,@A+DPTR
                 JZ FLOOR8
                 MOV UDN2981,A
                 INC DPTR
                 INC R0
      
                ACALL DELAY
                
                MOV A,SWICH
                 CJNE A,#01111111B,NEW1
            
                SJMP REV8  
                
    //.................................................................................    9
  
  
  
  
    NEXT8:            CLR  A
                MOV  A ,SWICH
                ADD  A,#00010000B
              CJNE A,#01111111B,NEW1


              
FLOOR9 :         MOV DPTR,# MYDATA10
                MOV R0,#0H
      
REV9:            CLR A
               MOV LS74_154,R0
               MOVC A,@A+DPTR
                 JZ FLOOR9
                 MOV UDN2981,A
                 INC DPTR
                 INC R0
      
                ACALL DELAY
                
                MOV A,SWICH
                 CJNE A,#01101111B,NEW1
            
                SJMP REV9
                
                //..................................................................
                
                        
DELAY:
MOV R6,#10
DL1:
MOV R7,#249
DJNZ R7,$
DJNZ R6,DL1
RET

MYDATA1: DB 3EH,41H,41H,41H,3EH,0H  //....0
                                  
MYDATA2: DB 02H,42H,7FH,40H,0H,0H  //....1

MYDATA3: DB 42H,61H,51H,49H,46H,0H  //....2

MYDATA4: DB 22H,41H,49H,49H,36H,0H  //....3
                                  
MYDATA5: DB 18H,14H,12H,7FH,10H,0H  //....4

MYDATA6: DB 27H,45H,45H,45H,39H,0H  //....5

MYDATA7: DB 3EH,49H,49H,49H,38H,0H  //....6

MYDATA8: DB 01H,01H,71H,09H,07H,0H  //....7

MYDATA9: DB 3EH,49H,49H,49H,3EH,0H  //....8

MYDATA10: DB 06H,49H,49H,49H,3EH,0H  //....9




//MYDATA2: DB 3EH,41H,41H,41H,3EH,0H  //....0
//MYDATA2: DB 7CH,12H,11H,12H,7CH,0H  //....A
//MYDATA2: DB 18H,14H,12H,7FH,01H,0H  //....4
//MYDATA2: DB 42H,61H,51H,49H,46H,0H  //....2
//MYDATA2: DB 00H,42H,7FH,42H,0H,00H  //....1


END
Moderators note : Please use code tags for pieces of code
 
Last edited by a moderator:

takao21203

Joined Apr 28, 2012
3,702
its quite a challenge to get Dot matrix right, so it can be changed easily and still is readable.

I have done it.

Basically you need a RAM buffer for the content as bitmap.

1. you build the bitmap.

Then you need to represent the IO and how it is addressing the actual display hardware.

2. Interfacing external hardware to available IO ports

Next you need to make clear the multiplexing scheme.

3. Derive a scheme how to show/represent a fraction of the current display window

then you copy a section of the bitmap into the display window.

4. its called bitblt or bitmap blitting

often at first you copy a section of the bitmap into the display window buffer, then you show one line or more than one line at a time by the means of multiplexing.


If there is an error at some stage you get garbled display.

In assembler doing all this correctly is quite lengthy and quite a pain, i did it one time, stretching over 3 pages, and showing it to someone, he wasnt able to understand it. me neither after some while.

By all means, C language should be used, and RAM buffers should be used instead of passing through bits on the fly.
Especially messy to pass throgh bits directly from character ROM to the multiplex IO port / ports.
 

Thread Starter

nikhilsonar29

Joined Sep 26, 2014
68
hi goodmorning
thanks for this meaning full concept
can you plz give me code for the same, by which it can be easy to understand concept.
 

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
Did you come here to make money ?
Or to help ?
Make that clear to us.

I was to thinking,that i post ?
because what i learn is without paying you can't earn !
 

MrCarlos

Joined Jan 2, 2010
400
Hello nikhilsonar29
As per your original message I understand that You want to capture the seven BITs in the Display And to Show in a Dot Matrix according the number in that 7-Segment Display.
Now, The title of this theme say: 'dot matrix display programming in c'
But you present some code in assembly language. . . why?
However, I will assume that the 7-segment display, you have, is the common cathode type.
In such a way that the segments are light having high level.
Carefully unpack and studies the contained in the .ZIP file that I attached. (7-Seg To PORTB PORTC With 74LS48.zip).
The code was written in C language and the simulation was developed with ISIS Proteus Ver. 8.1. .
Run the simulation in ISIS and study the Code.
But you want to display these numbers on a Dot-Matrix. . .
Well, now unpack the second .ZIP file that I attached. (7-Seg PORTB To 5X7 D-M With 74LS48.ZIP).
As above, run the simulation in ISIS and study the Code.
There are currently 0 on the 7-segment display.
Enabling the column C0, with a high level, the Dot-Matrix is ready to turn ON, in that column, the points needed to be forming the zero.
HEX number 41 will be applying to the Dot-Matrix through the D port of PIC.
Port C is enabling each of the columns.
Give me your comments, please.
By the way, you also have another unfinished theme here: http://forum.allaboutcircuits.com/threads/dot-matrix-programming-in-c-using-mplab-and-proteus.110013/
 

Attachments

Top