View Index by Level
RANDOM PAGE

SITE SEARCH

LOG
IN

SIGN UP

HELP

Picaxe 7 Segment Multiplex


This is the AQA version closing after June 2019. Visit the the version for Eduqas instead.

To gain access to revision questions, please sign up and log in.

A2

Wire up the Seven Segment Displays and Emitter Followers as shown below.

If you are using the ENSFC boards, you don't need current limiting resistors because these are built into the Picaxe board.

7SegCA MPX Task.GIF

7SegCA MPX-PAB.jpg

This code is for the PICAXE only.

; =====================================
; ===== COUNT FROM 00 TO 99 ===========
; ===== SEE IF YOU CAN SOLVE THIS =====
; ===== WITH A LOT LESS CODE ==========
; =====================================

SETFREQ     EM20
    
SYMBOL      UNITS   = B0
SYMBOL      TENS    = B1
SYMBOL      COUNTDN = B2

    MOVW    0X0
    MOVWR   TRISC    ; PORTC OUTPUTS
    MOVWR   UNITS    ; INITIALISE TENS
    MOVWR   TENS    ; INITIALISE UNITS
; =====================================
START:
    MOVW    0X10
    MOVWR   COUNTDN
REP:
    MOVW    0X0
    MOVWR   PORTC
    CALL    UNITS_LOOP
    MOVW    0X2
    MOVWR   PORTC
    CALL    WAIT10MS
    
    MOVW    0X0
    MOVWR   PORTC
    CALL    TENS_LOOP
    MOVW    0X1
    MOVWR   PORTC
    CALL    WAIT10MS
    
    DEC     COUNTDN
    JPZ     CALL_COUNTER
    JMP     REP
    
CALL_COUNTER:
    CALL    COUNTER
    JMP     START
; =====================================

; =====================================
COUNTER:
    MOVRW   UNITS
    SUBW    0X9
    JPZ     INC_TENS
    INC     UNITS
    RET
    
INC_TENS:
    MOVW    0X0
    MOVWR   UNITS
    INC     TENS
    MOVRW   TENS
    SUBW    10
    JPZ     RESET_TENS
    RET
    
RESET_TENS:
    TENS = 0
    RET        
; =====================================

; =====================================
UNITS_LOOP:
    ; DEBUG
    MOVRW   UNITS
    SUBW    0X0
    JPZ     __0
    
    MOVRW   UNITS
    SUBW    0X1
    JPZ     __1
    
    MOVRW   UNITS
    SUBW    0X2
    JPZ     __2
    
    MOVRW   UNITS
    SUBW    0X3
    JPZ     __3
    
    MOVRW   UNITS
    SUBW    0X4
    JPZ     __4
    
    MOVRW   UNITS
    SUBW    0X5
    JPZ     __5
    
    MOVRW   UNITS
    SUBW    0X6
    JPZ     __6
    
    MOVRW   UNITS
    SUBW    0X7
    JPZ     __7
    
    MOVRW   UNITS
    SUBW    0X8
    JPZ     __8
    
    MOVRW   UNITS
    SUBW    0X9
    JPZ     __9
    
END_UNITS:
    RET
; =====================================

; =====================================
TENS_LOOP:
    ; DEBUG
    MOVRW   TENS
    SUBW    0X0
    JPZ     _0_
    
    MOVRW   TENS
    SUBW    0X1
    JPZ     _1_
    
    MOVRW   TENS
    SUBW    0X2
    JPZ     _2_
    
    MOVRW   TENS
    SUBW    0X3
    JPZ     _3_
    
    MOVRW   TENS
    SUBW    0X4
    JPZ     _4_
    
    MOVRW   TENS
    SUBW    0X5
    JPZ     _5_
    
    MOVRW   TENS
    SUBW    0X6
    JPZ     _6_
    
    MOVRW   TENS
    SUBW    0X7
    JPZ     _7_
    
    MOVRW   TENS
    SUBW    0X8
    JPZ     _8_
    
    MOVRW   TENS
    SUBW    0X9
    JPZ     _9_
    
END_TENS:
    RET
; =====================================

; =====================================
__0:
    MOVW    0X08
    MOVWR   PORTB
    JMP     END_UNITS
__1:
    MOVW    0X3E
    MOVWR   PORTB
    JMP     END_UNITS
__2:
    MOVW    0X11
    MOVWR   PORTB
    JMP     END_UNITS
__3:
    MOVW    0X14
    MOVWR   PORTB
    JMP     END_UNITS
__4:
    MOVW    0X26
    MOVWR   PORTB
    JMP     END_UNITS
__5:
    MOVW    0X44
    MOVWR   PORTB
    JMP     END_UNITS
__6:
    MOVW    0X40
    MOVWR   PORTB
    JMP     END_UNITS
__7:
    MOVW    0X1E
    MOVWR   PORTB
    JMP     END_UNITS
__8:
    MOVW    0X00
    MOVWR   PORTB
    JMP     END_UNITS
__9:
    MOVW    0X06
    MOVWR   PORTB
    JMP     END_UNITS
; =====================================

; =====================================
_0_:
    MOVW    0X08
    MOVWR   PORTB
    JMP     END_TENS
_1_:
    MOVW    0X3E
    MOVWR   PORTB
    JMP     END_TENS
_2_:
    MOVW    0X11
    MOVWR   PORTB
    JMP     END_TENS
_3_:
    MOVW    0X14
    MOVWR   PORTB
    JMP     END_TENS
_4_:
    MOVW    0X26
    MOVWR   PORTB
    JMP     END_TENS
_5_:
    MOVW    0X44
    MOVWR   PORTB
    JMP     END_TENS
_6_:
    MOVW    0X40
    MOVWR   PORTB
    JMP     END_TENS
_7_:
    MOVW    0X1E
    MOVWR   PORTB
    JMP     END_TENS
_8_:
    MOVW    0X00
    MOVWR   PORTB
    JMP     END_TENS
_9_:
    MOVW    0X06
    MOVWR   PORTB
    JMP     END_TENS
; =====================================

Download and run this code. Modify it to count from 0 to 9 (easy) and from 00 to 99 (much harder).

Print this table to help you design the remaining data to make the display count from 00 to 99.

7SegCA-design.gif

 

 

 

reviseOmatic V3     Contacts, ©, Cookies, Data Protection and Disclaimers Hosted at linode.com, London