Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

5x5 Led matrix using PIC16F627A.

Status
Not open for further replies.

bitem2k

New Member
Im trying to make a 5x5 led matrix display, similar to the one found **broken link removed**

ive wired up the leds in rows and columns.
All the leds anodes in a column are wired up,
all the cathodes of leds in a row are wired up in series with a resistor.

Im utilising PortA ports 0,1,2,3,6 for the columns
and PortB ports 0,1,2,3,4 for the rows.

When i set PortA to 0xFF and portB to 0x00, most of the lights come on, appart from 3/25:mad:
Please consult picture.

I have checked the wiring on the LEDS and it all appears fine,
and obviously the wiring must be fine connecting the ports to the columns/rows as some leds on the row/column in question work.

Does anyone have any idea whats going on?

Heres my code:
Code:
INCLUDE "P16F627A.INC"
LIST P=16F627A


__Config _INTOSC_OSC_NOCLKOUT & _DATA_CP_OFF & _CP_OFF  &_LVP_OFF &_BOREN_ON    & _MCLRE_OFF    & _WDT_OFF & _PWRTE_OFF 

cblock    0x20
    delayOuter
    delayInner
endc

org 0
poweron
    BSF        STATUS,RP0     ;MOVE TO BANK1
    CLRF    TRISB        ;PORT B ALL OUTPUTS
    CLRF    TRISA        ;PORT a ALL OUTPUTS, EXCLUDING A5 OBVIOUSLY
    BCF        STATUS, RP0 ;MOVE TO BANK0

    CLRF    PORTA
    MOVLW 0x07 ;Turn comparators off and
    MOVWF CMCON ;enable pins for I/O
    movlw    0xff
    movwf    PORTA

again

    MOVLW    0xff
    movwf    PORTA
    MOVLW    0x00
    MOVWF    PORTB

    call     Delay

    MOVLW    0x00
    movwf    PORTA
    MOVLW    0x00
    MOVWF    PORTB

    call     Delay




    


    GOTO     again        ;ENDLESS LOOP


Delay
    MOVLW    D'255'        ;set up 
    MOVWF    delayOuter    ;outer number of delay loops
StartDelay
    MOVLW    D'255'        ;set up 
    movwf    delayInner    ;Set inner loops
InnerDelay
    decfsz    delayInner
    goto     InnerDelay
    decfsz    delayOuter
    goto    StartDelay
    return
    
    


END


Many thanks:)
 

Attachments

  • WHY.png
    WHY.png
    14.9 KB · Views: 388
The LEDs that are not lit probably have a higher on voltage than the rest. In effect, what you have is 5 sets of 5 LEDs in parallel. Try turning on one row at a time by just setting 1 bit of porta.

When you want to display something on the display you would do something like,
Code:
    MOVLW    b'00000001'
    movwf    PORTA
    MOVLW    b'00010101'
    MOVWF    PORTB
    call     ShortDelay
    MOVLW    b'00000010'
    movwf    PORTA
    MOVLW    b'00001010'
    MOVWF    PORTB
    call     ShortDelay
    MOVLW    b'00000100'
    movwf    PORTA
    MOVLW    b'00010101'
    MOVWF    PORTB
    call     ShortDelay
    MOVLW    b'00001000'
    movwf    PORTA
    MOVLW    b'00001010'
    MOVWF    PORTB
    call     ShortDelay
    MOVLW    b'00010000'
    movwf    PORTA
    MOVLW    b'00010101'
    MOVWF    PORTB
    call     ShortDelay
The above should give you a checker pattern.

The (short) delay routine should be in the order of a few milliseconds so you don't see the display flash.

Mike.
 
First check the matrix with a multimeter whether the LED’s working one by one by placing mulimeter probes to RA & RB ports after removing the PIC.

If so use this AGAIN routine in your program to check all the LED’s. No delay added in this part just to check all LED’s lit.

Code:
AGAIN	movlw	b'01001111'
	movwf	PORTA
	nop
	movlw	b'00000000'
	movwf	PORTB
	goto	AGAIN

Also there is a mistake in delay routine but that will not affect to this coding.
 
The circuit is designed for multiplexing, you need to do as Pommie has shown so that only a row at a time can be lit for a short time to reduce the average current through the ports.

If you don't do that, then you will exceed the individual port pin current limits (25mA) or the total ports limit (200mA).
 
Thanks everyone,
ok, Ive tried the following code pommie:
Code:
INCLUDE "P16F627A.INC"
LIST P=16F627A


__Config _INTOSC_OSC_NOCLKOUT & _DATA_CP_OFF & _CP_OFF  &_LVP_OFF &_BOREN_ON    & _MCLRE_OFF    & _WDT_OFF & _PWRTE_OFF 



org 0
poweron
    BSF        STATUS,RP0     ;MOVE TO BANK1
    CLRF    TRISB        ;PORT B ALL OUTPUTS
    CLRF    TRISA        ;PORT a ALL OUTPUTS, EXCLUDING A5 OBVIOUSLY
    BCF        STATUS, RP0 ;MOVE TO BANK0

    CLRF    PORTA
    MOVLW 0x07 ;Turn comparators off and
    MOVWF CMCON ;enable pins for I/O
    movlw    0xff
    movwf    PORTA

again
   MOVLW    b'00000001'
    movwf    PORTA
    MOVLW    b'00010101'
    MOVWF    PORTB
    call     Delay
    MOVLW    b'00000010'
    movwf    PORTA
    MOVLW    b'00001010'
    MOVWF    PORTB
    call     Delay
    MOVLW    b'00000100'
    movwf    PORTA
    MOVLW    b'00010101'
    MOVWF    PORTB
    call     Delay
    MOVLW    b'00001000'
    movwf    PORTA
    MOVLW    b'00001010'
    MOVWF    PORTB
    call     Delay
    MOVLW    b'00010000'
    movwf    PORTA
    MOVLW    b'00010101'
    MOVWF    PORTB
    call     Delay


        goto again





    


;--------------------------------------------------------------------------
;    SUBROUTINE    Short delay for multiplexing
;--------------------------------------------------------------------------
Delay
    MOVF H'40',0        ;Get current selected multiplex rate
        MOVWF    SDelayCount        ;Store desired delay count
SDelayLoop    NOP
        NOP
        NOP
        NOP
        DECFSZ    SDelayCount
        GOTO    SDelayLoop
        RETLW    0            ;Ignore return value


END


I get a checker board, but the same leds will not work.
see pic for illuminated leds.

many thanks
 

Attachments

  • WHY.png
    WHY.png
    12.8 KB · Views: 296
In your both attachments I see different LED’s LIT & NOT LIT.

In Picxie's method he is driving columns NOT through transistors directly from a PIC pin.So the code must be inverted.

Better you attach a diagram of matrix arrangement.
 
Last edited:
Sorry all.
Im a fool:eek:.

When I was checking the wiring last night(2.30 this morning!), i must have overlooked a broken trace or two!

Ive just checked the wiring again, and this time i found two broken traces, and hence bridged them with some wire.

All is now well!

Many thanks everyone.:)
 
I would have went with the physical first and thought the colprit was most likely the led orientation or open traces. Even if similar color leds have a slightly lower voltage than its neighbor, that does not cause a higher voltage neighbor to be completely turned off. This takes a step in wavelength to happen or on going gross negligence in quality control by the manufacturer.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top