lab 2 jfettransfercurve
TRANSCRIPT
-
7/31/2019 Lab 2 JFETtransfercurve
1/4
Laboratory Activity 1:
PIC16F84A MicrocontrollerFaderan, Daniel Brian
Fernandez, Jose Carlos
BS Computer EngineeringAteneo de Manila University
Loyola Heights, Quezon City
I. OBJECTIVES
The goal of this experiment is to be able to explore the functions PIC16F84A Microcontroller and finally be able to
program it. The PIC16F84A should be programmed to be able to display a 4-bit output dependent on a user-controlled 2-bit
input.
II. INTRODUCTION
The PIC16F84A is a microcontroller in the PIC family. It has a total of 18 pins, 13 of which are I/O pins which we canuse, as seen in Figure 1. Using this microcontroller, we will use a total of 6 of the available I/O pins to create a circuit which uses
2 inputs in which the value is controlled from the switches of the Digital Kit provided in the laboratory which would then control4 outputs which will be noticed through the kits LEDs. Controlling the outputs will be handled by a program which will be
installed into the microcontroller.
The conditions of the program are as follows:
Input: Sw2 = 0 and Sw1 = 0, Output: LEDs = 0101
Input: Sw2 = 0 and Sw1 = 1, Output: LED values are rotating left with initial value of 0001.
Input: Sw2 = 1 and Sw1 = 0, Output: LED values are counting.
Input: Sw2 = 1 and Sw1 = 1, Output: LEDs are alternately blinking (i.e. 1001 0110)
III. METHODOLOGY
A circuit is built following the circuit diagram below:
Fig 1. PIC16F84A Microcontroller Circuit Diagram
Two RA pins(pin 17 & 18) were used as inputs whilst four RB pins(pins 6, 7, 8, 9) were used outputs during the
programming process. 2 input pins were attached to switches whilst 4 output pins were attached to LEDs. Below is the code for
the required program which was installed into the microcontroller(with comments as explanations):
//code startINCLUDE "P16F84.INC"list p=16F84
radix hex
-
7/31/2019 Lab 2 JFETtransfercurve
2/4
__config _XT_OSC & _PWRTE_ON & _WDT_OFF
PortB equ h'06' ;RB pins
PortA equ h'05' ;RA pins
status equ h'03'
trisb equ h'86'
trisa equ h'85'count1 equ h'0e'
count2 equ h'0f'
org 0x000bsf status,5
movlw 00h
movwf trisb
movlw 03h
movwf trisa
bcf status,5
start
BTFSS PortA, 0 ;check if binary value in pin 17 is either 1 or 0
goto sw
BTFSS PortA, 1 ;if pin 17 = 1, thengoto input01 ;if pin 18 = 0, goto rotating left LEDs
goto input11 ;if pin 18 = 1, goto alternately blinking LEDs
sw
BTFSS PortA, 1 ;else if pin 17 = 0, then
goto input00 ;if pin 18 = 0, goto still LEDs
goto input10 ;if pin 18 = 1, goto binary counting LEDsinput00 ;still LEDS
movlw b'0101'
movwf PortBcall delay
goto start
input01 ;rotating left LED light
movlw b'0001'
movwf PortBcall delay
movlw b'0010'
movwf PortB
call delay
movlw b'0100'movwf PortB
call delay
movlw b'1000'movwf PortB
call delaygoto start
input10 ;binary counting LEDs
movlw b'0000'
movwf PortB
call delayinc1
incf PortB
call delay
BTFSS PortB, 0
goto inc1BTFSS PortB, 1
goto inc1
BTFSS PortB, 2
goto inc1
BTFSS PortB, 3goto inc1
goto start
input11 ;alternately blinking LEDs
movlw b'1001'
movwf PortBcall delay
movlw b'0110'
movwf PortB
call delay
goto startdelay
-
7/31/2019 Lab 2 JFETtransfercurve
3/4
movlw h'ff' ;setup delay count value 1
movwf count1 ;count1 is slow counter loop1a decfsz count1,1 ;
goto labela ;still > 0
return ;count1 < 0 so get out of the delay loop
labela movlw h'ff' ;setup delay count value 2
movwf count2 ;count2 is fast counter inside count1 looploop2a decfsz count2,1 ;
goto loop2a ;still > 0 so stay in loop2
goto loop1a ;count1 < 0 go to loop1
end;//end code
IV. RESULTS & DISCUSSION
Below is the set-up for the microcontroller done according to the circuit diagram:
Fig 2. PIC16F84A Microcontroller Set-Up
Fig 2.1. Switches Designating Pin 17 & 18 With 0 Binary Value
Fig 2.2. Pin 17 = 0, Pin 18 = 0, Still LEDs Triggered
Figure 2.1 and 2.2 are samples taken from the experiments video documentary to indicate that the PIC is functioning
well and the program installed is working according to its predetermined conditions.
V. CONCLUSION AND RECOMMENDATION
The PIC16F84A is a good microcontroller to start out with because of its good number of I/O pins and wide range of
possible applications, although, it is limited to small-scale circuit technology like this lab experiment, for example. It is good for
similarly small applications and is great for laboratory practice even if programming it requires low-level programming language
like Assembly. Overall, this version from the PIC family is indeed useful.
-
7/31/2019 Lab 2 JFETtransfercurve
4/4