7 segment counter with 14M chip.

peg

Active member
Good evening
Has anyone got information on the pin out for 14M to 7 segment display.

Thank you
 
Driving a (single digit) 7-segment display with a 14M2 should be reasonably straightforward but you will have to work around the limitations of the ports. Port B has 6 output pins: you need 7 or 8 if you want to use the decimal point LED. Slightly differently, Port C has 8 pins but only 7 output pins, with C.3 being input-only, which is a bit of a nuisance. Port C, having 7 usable output pins, wiould be the most useful for a 7-segment display.

Software for 7-segment displays usually involve using a 'lookup table' configured in EEPROM, with 10 locations (bytes) each holding the bit patterns for the 10 digits. You would need to configure this lookup table to suit which pin is connected to each segment. If you want to display a 0, you would read location 0 from the EEPROM into a byte register (Eg b5) and output that to Port C.

Below is a lookup table that I created a few years ago to drive a 7-segment display. Note that I configured the bit patterns to suit my particular wiring of my 7-segment display and I was using a 28X2, which has all 8 pins avalable on a couple of ports. I used a common-cathode display - you would have to invert the zeros and ones in the table if using a common anode display.

Rich (BB code):
Symbol e7Seg0 = 0          'Below, %gfedcba0 (bit 0, decimal point not connected)
EEPROM e7Seg0, (%01111110, %00001100, %10110110, %10011110, %11001100)  '0-4
EEPROM         (%11011010, %11111010, %00001110, %11111110, %11011110)  '5-9
 
Driving a (single digit) 7-segment display with a 14M2 should be reasonably straightforward but you will have to work around the limitations of the ports. Port B has 6 output pins: you need 7 or 8 if you want to use the decimal point LED. Slightly differently, Port C has 8 pins but only 7 output pins, with C.3 being input-only, which is a bit of a nuisance. Port C, having 7 usable output pins, wiould be the most useful for a 7-segment display.

Software for 7-segment displays usually involve using a 'lookup table' configured in EEPROM, with 10 locations (bytes) each holding the bit patterns for the 10 digits. You would need to configure this lookup table to suit which pin is connected to each segment. If you want to display a 0, you would read location 0 from the EEPROM into a byte register (Eg b5) and output that to Port C.

...

Since I am busy with a new project (Lightning Detector Circuit) which needs a single 7-segment display to be driven from a 14M2, I provide here a code that I successfully used to test the display part of the circuit. This is a concrete implementation of Inglewoodpete's concept: it counts endlessly, with the decimal point flickering. Both PortB and PortC are needed on a 14M2, since PortB has 6 bits only on this chip ... . This example shows how this could be done, where the code also respects the status of the other PortC input/output bits that are not used for the display. Enjoy!
/Jurjen

Code:
REM Test Program, Driving a 7-segment display directly from a Picaxe-14M2 using PortB and PortC
REM June 2026, Jurjen Kranenborg

#Picaxe 14m2

REM Definitions:
REM ------------
REM Main Input/output signals for this project:
SYMBOL Outputs_B = %00111111
SYMBOL Outputs_C = %00000001
LET dirsB = Outputs_B
LET dirsC = Outputs_C

REM Register naming:
SYMBOL number = b0




REM ===================
REM Main Program:
REM Test 7Seg Display: count 0 - 9
REM and toggle the decimal point
REM ===================

DO
    FOR number = 0 TO 9
        CALL ShowNumber_7Seg
        PAUSE 500
        TOGGLE Kdp
        PAUSE 500
        TOGGLE Kdp
    NEXT number
LOOP

END

REM Subroutine, variable "number" to be shown
ShowNumber_7Seg:

    REM ------------
    REM: 7-Seg Display definitions (Common Anode Display)
    SYMBOL Kg = C.0
    SYMBOL Kf = B.0
    SYMBOL Ka = B.1
    SYMBOL Kb = B.2
    SYMBOL Kc = B.3
    SYMBOL Kd = B.4
    SYMBOL Ke = B.5
    SYMBOL Kdp = C.1
    REM ------------
    REM EEPROM adresses:
    SYMBOL B_7Seg = 0
    SYMBOL C_7Seg = 10


    REM Define connections portB (6x) and portC (1x) on 14m2 to 7-seg display
    REM In this example a CA (Common Anode) display has been used (0=On, 1=Off)
    REM Kdp (digital Point) can be manipulated independently from this routine (happens in the main program)

    REM Below, B-channel wiring: %00edcbaf:
    EEPROM B_7Seg, (%00000000, %00110011, %00001001, %00100001, %00110010)  '0-4
    EEPROM         (%00100100, %00000100, %00110001, %00000000, %00100000)  '5-9
    REM Below, C-channel wiring: %0000000g:
    EEPROM C_7Seg, (%00000001, %00000001, %00000000, %00000000, %00000000)  '0-4
    EEPROM         (%00000000, %00000000, %00000001, %00000000, %00000000)  '5-9
 
    SYMBOL j = b1
    SYMBOL data_7Seg_B = b2
    SYMBOL data_7Seg_C = b2 'identical register for portC as for portB, but separate naming for clarity
    SYMBOL acc_C = b3        'accumulator/data manipulation register for port setting
 
    ' Read 7-seg connection data from eeprom
    ' ... first the PortB part
    LET j = B_7Seg + number
    READ j, data_7Seg_B
    ' ... and write it to the display:
    LET pinsB = data_7Seg_B
    ' ... then the PortC part, only altering here the 7-seg bit (Kg on C.0), keeping the other output pins' statuses on this port as they were
    LET j = C_7Seg + number
    READ j, data_7Seg_C
    LET acc_C = pinsC AND %11111110 'First read the current status for portC, copy status of all bits (including Kdp) except Kg
    ' ... and write it to the display:
    LET pinsC = acc_C OR data_7Seg_C 'set all output pins again (defined by dirsC settings), now including 7-seg bit Kg
 
RETURN
 
Last edited:
Back
Top