Kamis, 04 Oktober 2012

Proteus Microcontroller Project

This Proteus simulation shows alphanumeric character on a 7 segment display using a PIC16F84A micro-controller.

The schematic diagram is shown below-


The components used in the schematic are-
  • 7SEG-COM-CAT-BLUE(7 segment display)
  • 9C04021A2200FLHF3(200 ohm resistor)
  • 9C08052A1002FKHFT(10k ohm resistor)
  • BUTTON
  • CRYSTAL
  • DIPSW_4(switch 4 ports)
  • SOUNDER
  • PIC16F84A(Microcontroller)
 Connect the parts as shown in the schematic. The crystal is connected across the pin 15 and 16. The MCLR is a active low pin for reset which is connected to the +5V source with a 10k ohm series resistor. The microcontroller PIC16F84A has a two I/O ports- port A and port B. Port A will be configured as an input port and the port B will be the output port. The output signal from port B will be connected to the 7 segment display.

The microcontroller is programmed in assembly language, compiled into hex code and this hex code is burned into the microcontroller in Proteus. But first the program. The assembly program code is below-


;=========================
; setup and configuration
;=========================
    processor 16f84A
    include      <p16f84A.inc>
    __config  _XT_OSC & _WDT_OFF & _PWRTE_ON & _CP_OFF

#define Pb_sw  4    ; Port A line 4 to push button switch

porta    equ    0x05
portb   equ     0x06
;============================
;      local variables
;============================
    cblock    0x0c        ; Start of block
    J                ; counter J
    K                ; counter K
    endc
;============================================================
;                           program
;============================================================
    org    0      ; start at address 0
    goto    main
;
; Space for interrupt handlers
    org        0x08

main:
; Port A. Five low-order lines set for for input
    movlw    B'00011111'    ; w = 00011111 binary
    tris    porta        ; port A (lines 0 to 4) to input
; Port B. All eight lines for output
    movlw    B'00000000'    ; w := 00000000 binary
    tris    portb        ; port B to output
;===============================
; Pushbutton switch processing
;===============================
pbutton:
; Push button switch on demo board is wired to port A bit 4
; Switch logic is active low
    btfss    porta,Pb_sw    ; Test and skip if switch bit set
    goto    buzzit        ; Buz if switch ON,
; At this point port A bit 4 is set (switch is off)
    call    buzoff        ; Buzzer off
    goto    readdip        ; Read DIP switches
buzzit:
    call    buzon        ; Turn on buzzer
    goto    pbutton
;============================
;   dip switch monitoring
;============================
readdip:
; Read port A switches
    movf    porta,w        ; Port A bits to w
; Since board is wired active low then all switch bits
; must be negated.  This is done by XORing with 1-bits
    xorlw    b'11111111'    ; Invert all bits in w
; Mask off 4 high-order bits
    andlw    b'00001111'        ; And with mask
; At this point the w register contains a 4-bit value
; in the range 0 to 0xf. Use this value (in w) to
; obtain seven-segment display code
    call    segment
    movwf    portb        ; Display switch bits
    goto    pbutton
;================================
;  routine to returns 7-segment
;             codes
;================================
segment:
        addwf    PCL,f    ; PCL is program counter latch
        retlw    0x3f    ; 0 code
        retlw    0x06    ; 1
        retlw    0x5b    ; 2
        retlw    0x4f    ; 3
        retlw    0x66    ; 4
        retlw    0x6d    ; 5
        retlw    0x7d    ; 6
        retlw    0x07    ; 7
        retlw    0x7f    ; 8
        retlw    0x6f    ; 9
        retlw    0x77    ; A
        retlw    0x7c    ; B
        retlw    0x39    ; C
        retlw    0x5b    ; D
        retlw    0x79    ; E
        retlw    0x71    ; F
        retlw    0x7f    ; Just in case all on

;============================
;   piezo buzzer ON
;============================
; Routine to turn on piezo buzzer on port B bit 7
buzon:
        bsf        portb,7        ; Tune on bit 7, port B
        return   
;
;============================
;   piezo buzzer OFF
;============================
; Routine to turn off piezo buzzer on port B bit 7
buzoff:
        bcf        portb,7        ; Bit 7 port b clear
        return
;=============================
;   long delay sub-routine
;    (for code testing)
;=============================
long_delay
        movlw    D'200'    ; w = 200 decimal
        movwf    J        ; J = w
jloop:    movwf    K        ; K = w
kloop:    decfsz    K,f        ; K = K-1, skip next if zero
        goto     kloop
        decfsz    J,f        ; J = J-1, skip next if zero
        goto    jloop
        return       

        end

-------------------------------------------------------------------------------------------------------------

Copy the code and double click on the PIC16F84A microcontroller and then click on edit firmware and paste into the source editor.

7 segment proteus simulation





Then click on the build project icon to compile the .asm file into hex source code.

7 segment proteus simulation
7 segment proteus simulation



The VMS output should show "Compiled Successfully" as shown below-

7 segment proteus simulation
Now come back to the schematic diagram and run the simulation-

7 segment proteus simulation




By toggling ON/OFF the 4 DIP switch button the characters in the 7 segment will change.

7 segment proteus simulation

Also by pressing the button we will hear a tone from the SOUND part-

7 segment proteus simulation

1 komentar:

  1. Elektro2017: Proteus Microcontroller Project >>>>> Download Now

    >>>>> Download Full

    Elektro2017: Proteus Microcontroller Project >>>>> Download LINK

    >>>>> Download Now

    Elektro2017: Proteus Microcontroller Project >>>>> Download Full

    >>>>> Download LINK a7

    BalasHapus