Multiplexing 7 Segment Displays with PIC 16F627

Status
Not open for further replies.

alifred

Member
Hi,

I have a PIC 16F627, and I want to make a digital clock with it. The only problem I have is that I only have enough outputs for one 7-seg display unless I multiplex them.

Can someone please point me in the right direction of multiplexing 6 common cathode 7-seg displays (to show hours, minutes, and seconds).

Thanks to everyone in advance!

Cheers

Fred
 
Last edited:

Use the Forum SEARCH for charlieplexing

See Pommies drawing here:
https://www.electro-tech-online.com...g-max-per-pin.42151/?highlight=charlieplexing
 
Last edited:
help

Hi,

I have a PIC 16F627 with 32.768khz cristal, and I want to make a digital clock with date and time .I have 7-seg display with cd4543 drivers. Can any one help me to write codes for this pic.I dont have any experiance writing codes.so please help me..

Yours
Bimal
 

Start your own new thread for this topic.
 
One simple thing. Just take 8 pin for displaying and connect this to all the six seven segment display and take 6 for controlling displaying. Connect first controlling input to first seven segment displays Vcc(Through transistor) and second contorl pin to second seven seg's Vcc and so on. program will be similar to.

#bit c1=0x05.0
#bit c2=0x05.0
#bit c3=0x05.0
#bit c4=0x05.0
#bit c5=0x05.0
#bit c6=0x05.0
#byte val=0x06

c1=1;
c2=0;
c3=0;
c4=0;
c5=0;
c6=0;
val=disp1;
delay_ms(20);//20 ms delay
c1=0;
c2=1;
c3=0;
c4=0;
c5=0;
c6=0;
val=disp2;
delay_ms(20);//20 ms delay
//so on for all digit.
 
hi
i'm designing the digital voltmeter for a car battery by using pic16f690 for displaying the value that has been measured,may you help for a source code plz!!
 
hi
i'm designing the digital voltmeter for a car battery by using pic16f690 for displaying the value that has been measured,may you help for a source code plz!!

Well here are a bunch of key routines. All u need now is the 8 bit adc capture of the Voltage placed in the 'Voltage' variable and a 3 or 4 digit strobe routine to to display the Thousands,Hundreds,Tens,Units variables. The calculation routines may be a bit elaborate, but I pulled them from another asm system I wrote, so they are structured to be compatible with independent calling routines.

This is one feature out of 18 in a multigauge/ controller I am designing for Turbocharged gasoline autos. My display strobe uses a shift register so it won't work for u. If u in a jam I can whip up one for u. But hey, ya gotta do to learn! I started with PIC's under 4 months ago and with help from this forum my program is now over 6K words,253 bytes of Eprom and about 300 bytes of GPR variables. The asm file is 270KB as its heavily commented.

Code:
Voltsx4     bsf Voltx4,0 ; call this if u want a 0-20V display, else
Volts    ; 0-5V = 0-255 adc. (8bits) => 1V=51 out of  255, .1=5. Derive decimal display from this.
    ;Inputs: Read binary voltage from 'voltage' variable (0-5V) =>(0-255 binary)
    ;uses Tmp2 as ADC binary voltage input variable -low byte, Offset as binary Input Variable High byte needed for x4 display
    ; Voltx4,0 is set if 0-20V display required. Otherwise 0-5V
    ; volts from a 9.1k/27K  resistor 1/4 voltage divider feeding the PIC ADC.
    
    call Vcalc; returns with with Tmp=V and Tmp1= decimal V

    goto Vdecimal ; display current voltage.

Vcalc    movf Voltage,w
Vcalc1    call WregX100 ; source in wreg,results in TempL/H
    movlw .51; 1 Volt in binary (divisor)
    call Div16X8; divisor in wreg,Dividend in TempL/H & results in TempL/H, with 500 as a max value => 5.00V
    btfss Voltx4,0 ; test if to x4 the input, must be set from before .
    return
    movlw .10; divisor
    call Div16X8; divide by 10, leaving 50 as a max value => 8 bit
    movlw .4 ; multiplier
    call Mult8X8; for 50 x 4 = 200 max value => 20.0V, results in TempL/H
    return

; now get patterns for com. cathode. digital display of volts in human readable digits
Vdecimal
    call Bindec1; decimal display of # in TempL/H
    btfss Voltx4,0 ; test if to x4 the input, must be set from before .    
    bsf Hundreds,7; set 2 decimal places (5.00V)
    btfsc Voltx4,0 ; test if to x4 the input, must be set from before .
    bsf Tens,7; set 1 decimal place (20.0V)
    return
;*********************************************************************************************************************************************
Bindec1    ; Converts 2 byte binary (tempL/TempH) into 4 digit decimal display.
    ; might be a good idea to clear the display digits (Thousands,Hundreds,Tens,Units) before this executes.
    call Thou ; get thousands in decimal
    Call Hundred ; get hundreds
    call Ten ; get tens & units.
    return

Thou    movlw .3 ; high byte set to 3 = 768
    movwf FixedH ; high byte of # to be subtracted.
    movlw .232 ; low byte
    movwf FixedL ; 768 + 232 = 1000's column

ThouCount
    call Subtract
    xorlw .1 ; check for returned wreg value. A  zero occurs if a 1 was returned
    btfss STATUS,Z ; branch if 1 was returned, else
    goto Fixremainder ; due to last subtraction the remainder went -ve, so we fix this.
    incf Thousands,f
    goto ThouCount

Fixremainder ;restore remainder to continue calculating for next decimal column.
    movf    FixedL,w ; low byte
            addwf   TempL,f ; TempL=TempL + FixedL
            movf    FixedH,w ; hi byte
            btfsc   STATUS,C ; check for carry, set if  TempL + FixedL >255
            incfsz  FixedH,w ; Increment due to carry set ,if zero skip next.
            addwf   TempH,f    ; TempH=TempH+FixedH (+1 if carry was set)
    return

Hundred    movlw 0 ; high byte set to 0
    movwf FixedH ; high byte of # to be subtracted.
    movlw .100 ; low byte
    movwf FixedL ; 0 + 100 = 100's column

HdrdCount
    call Subtract
    xorlw .1 ; check for returned wreg value. A  zero occurs if a 1 was returned
    btfss STATUS,Z ; branch if 1 was returned, else
    goto Fixremainder ; due to last subtraction the remainder went -ve, so we fix this.
    incf Hundreds,f
    goto HdrdCount


Ten    movlw .10 ; for small magnitude digit displays load TempL with under 100 and call this directly.
    subwf TempL,f; test for 10 if carry clr wreg is under 10
    btfsc STATUS,C ;skip if carry clr (-ve result) , else
    incf Tens,f; incr the tens column
    btfsc STATUS,C ; skip if carry clr (-ve result), else
    goto Ten ; now check for 20,30 etc
    movf TempL,w
    addlw .10; as last calc was -ve recreate +ve number.
DispLEDS ; for just a display with under 10 magnitude, call this directly with the # in wreg. Then clr the tens,hundreds & thousands bytes after.
    call Dpattern
    Movwf Units ; store 7 seg display pattern for units
    movf Tens,w
    call Dpattern
    movwf Tens; store 7 seg display pattern for tens
    movf Hundreds,w
    call Dpattern
 
Last edited:
hi

i'm a new user for this site sorry for relplying later oky i've an input which is analog i use portC as my display could you
 
The portA RA4/AN3 is my analog input then portC RC0-RC7 is the pins that connected to the 7-segment to display and RA0,RA1a and RA2 assigned as digital output that are connected to the transistors could you help me about the program using pic16f690 in MPLAB.
"Thankyou"
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…