Você está na página 1de 30

PERIPHERAL INTERFACE PIC

CONTROLLER

SOFTWARE HARDWARE

File_name.jal Desktop/lapto
JAL Edit
File_name.asm p
File_name.hex

Programmer
PIC_Burne
r

PIC 16f84A
IC_prog PICpgm WinPic800 PIC
PIC 16f873

PIC 16f877
Type’s PIC
JAL declaration
Xtal
include 16f873_20
include jlib Libarary jal

include jpic73 Port initilise for type’s of pic

include jprint Libarary for LCD print

include hd447804
Libarary for hitachi drive LCD

LCD connection to PIC

USE PROTEUS
Port declaration 16f873
port_a_direction = all_output
port_b_direction = all_output

port_c_direction = all_input

Pin declaration 16f873


pin_c0_direction = input
pin_c1_direction = output
include 16f873_20
include jlib

Ex.1: LCD Display include jpic73

include jprint

include hd447804

 port_b_direction = all_output
hd44780_clear 

hd44780_clear
hd44780_line1

hd44780_line1

hd44780="I" hd44780=“H"

hd44780=“E"

hd44780=“L“

hd44780=“L"

hd44780=“O"

delay_20ms

hd44780_clear

hd44780_line1

hd44780=“G"

hd44780=“U"

hd44780=“Y“

hd44780=“S“


include 16f873_20
include jlib
Ex.2: LCD Display include jpic73
include jprint
include hd447804
port_b_direction = all_output

forever loop forever loop


…….. hd44780_clear
hd44780_line1

end loop hd44780=“H"


hd44780=“E"
hd44780=“L“
hd44780=“L"
hd44780=“O"
delay_20ms
hd44780_clear
hd44780_line1
hd44780=“G"
hd44780=“U"
hd44780=“Y“
hd44780=“S“
delay_50ms
end loop

DIP TRACE
b7

a0

a5

co bo

C7

PCB
Ex.3: If.. then..else..end if
include 16f873_20
include jlib
If then include jpic73
include jprint
include hd447804
else end if port_a_direction = all_output
port_b_direction = all_output
port_c_direction = all_input

forever loop
If pin_c0 == on then
pin_a0 = on If pin_c0 == on then
pin_a0 = on
else hd44780_clear
pin_a0 = off hd44780_line1
hd44780="I"
end if hd44780="N"
hd44780=“1"
else
pin_a0 = off
hd44780_clear
hd44780_line1
hd44780="I"
Input : c0 hd44780="N"
hd44780=“2“
end if
Output : a0
delay_20ms
End loop
Ex.4: Two inputs with two outputs
Inputs : c0 and c1

 forever loop
 If pin_c0 == off & pin_c1 == off then
pin_a0 = on
If pin_c0 == on & pin_c1 == on then Pin_a1 = on

hd44780_clear

hd44780_line1

Outputs: a0 and a1 hd44780=“T"

hd44780=“V"

hd44780=“ “

Assignment 1: Two inputs with two outputs hd44780=“O“

hd44780=“n“

Continue with two more combination of c0 


else end if

and c1 with different display on LCD. Use  If pin_c0 == off & pin_c1 == on then
a0 and a1 as the outputs. Pin_a0 = on
Pin_a1 = off

hd44780_clear

hd44780_line2

inputs outputs hd44780=“F"

hd44780=“A"

co c1 a0 a1 hd44780=“N“

hd44780=“ “

off off on on hd44780=“O“

hd44780=“N"

off on on off  else end if


delay_20ms
on off off on End loop

on on off off
FOREVER LOOP Program
Condition 1 mapping
If ….. Then
Else ….
End if

Condition 2
If ….. Then
Else ….
End if

Condition 3
If ….. Then
Else ….
End if

Condition 4
If ….. Then
Else ….
End if

Delay_200ms
END LOOP
hd44780_clear
hd44780_line1
Ex.5: Three inputs

hd44780=“F"

hd44780=“L"

with Three outputs


hd44780=“ “

hd44780=“s“

hd44780=“y"

Delay_1s

If pin_c0 == on & pin_c1 == on & pin_c2 then forever loop

Pin_a0=off

If pin_c0 == on & pin_c1 == on & pin_c2== off then


pin_a0 = on

Pin_a0 = on Pin_a1 = off Pin_a2 = off Pin_a1 = off

hd44780_clear

hd44780_line1

hd44780=“T"

Assignment 2: Three inputs with 3 outputs hd44780=“V"

hd44780=“ “

hd44780=“O“

Continue with all combination of inputs with hd44780=“N"

else end if

different display on LCD. If pin_c0 == off & pin_c1 == on & pin_c2== on then
pin_a1 = on

pin_a0 = off

hd44780_clear

hd44780_line2

hd44780=“F"

hd44780=“A"

hd44780=“N“

hd44780=“ “

hd44780=“O“

hd44780=“N"

else end if

delay_200ms

end loop

inputs outputs LCD
c0 c1 c2 a0 a1 a2 On/off
0 0 0 1 1 1 TV ON
0 0 1 1 1 0 TV OFF
0 1 0 1 0 1 FAN ON
0 1 1 1 0 0 FAN OFF
1 0 0 0 1 1 RADIO ON
1 0 1 0 1 0 RADIO OFF
1 1 0 0 0 1 LIGHT ON
1 1 1 0 0 0 LIGHT OFF
include 16f873_20
include jlib
forever loop
include jpic73
include jprint
include hd447804
if pin_c0 == on then
satu = satu + 1 Ex.6: Working with
counter
hd44780_clear
port_a_direction = all_output hd44780_line1
port_b_direction = all_output hd44780="T"
port_c_direction = all_input hd44780="E"
hd44780="H"
hd44780=" "
var byte satu,dua hd44780="T"
hd44780="A"
hd44780="R"
var byte satu,dua
hd44780_clear
hd44780_line1 hd44780="I"
hd44780="T" hd44780="K"
hd44780="E" hd44780_line2
print_decimal_3(hd44780,satu," ")
satu = satu + 1
hd44780="H"
else end if
hd44780=" "
hd44780="T" dua = dua + 2 Destination
hd44780="A"
if pin_c1 == on then
hd44780="R"
hd44780="I" dua = dua + 2
hd44780="K" hd44780_clear
hd44780_line2 hd44780_line1
hd44780="D" hd44780="T" print_decimal_3(hd44780,satu," ")
hd44780="I" hd44780="E"
hd44780="S" hd44780="H"
hd44780="P" hd44780=" "
hd44780="E" hd44780="T" print_decimal_2(hd44780,dua," ")
hd44780="N" hd44780="A"
hd44780="S" hd44780="R"
hd44780="E" hd44780="I"
hd44780="R" hd44780="K"
delay_5s hd44780_line2
hd44780_clear print_decimal_3(hd44780,dua," ")
satu = 0 else end if
Decimal point
dua = 0
delay_200ms var
end loop
JAL Edit
PICPgm Develop. Programmer
Multi CHIP PROGRAMMER
WinPic800 Programmer
SERIAL CABLE CONNECTIONS
Pin Name I/O Description

1 CD I Carrier Detect

2 RxD I Receive Data

3 TxD O Transmit Data

4 DTR O Data Terminal Ready

5 GND - System Ground

6 DSR I Data Set Ready

7 RTS O Request to Send

8 CTS I Clear to Send

9 RI I Ring Indicator
PIC PIN CONFIGURATION
PIC PIN CONFIGURATION
LCD1
LM016L

C1

VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
22p

1
2
3

4
5
6

7
8
9
10
11
12
13
14
X1
CRYSTAL
C2

22p

U1
9 21
OSC1/CLKIN RB0/INT
R1 10 22
OSC2/CLKOUT RB1
1 23
MCLR/Vpp RB2
24
1k RB3
2 25
RA0/AN0 RB4
3 26
RA1/AN1 RB5
4 27
RA2/AN2 RB6
5 28
RA3/AN3/VREF+ RB7
6
RA4/T0CKI
7 11
RA5/AN4/SS RC0/T1OSO/T1CKI
12
RC1/T1OSI/CCP2
13
RC2/CCP1
14
RC3/SCK/SCL
15
RC4/SDI/SDA
16
RC5/SDO
17
RC6/TX/CK
18
RC7/RX/DT
PIC16C73B
16f84A 18 pins 13 i/o Declare in program as inputs or outputs

5 pins Pin 14 – VDD (+V supply)

Pin 5 – GND
R1
1k
U1
16 17
O S C 1 /C L K IN R A0
15 18
O S C 2 /C L K O U T R A 1
1

Pin 4 – MCLR
R A2
4 2

Port A Port B
M C LR R A3
3
R A 4 /T 0 C K I
6
R B 0 /IN T
7
R B1
8
R B2
9
R B3
10
R B4

RA0 – pin 17 RB0 – pin6


11

Reserved for LCD


R B5
12
R B6
13
R B7
P IC 1 6 F 8 4A

RA1 – pin 18 RB1 – pin7


RA2 – pin 1 RB2 – pin8
Pin 15 & 16 – External Oscillator
RA3 – pin 2 RB3 – pin9
RB4 – pin10
RA4 – pin 3 C1

RB5 – pin11 22p

X1
CRYSTAL

RB6 – pin12 C2 16
15
U1
OSC1/CLKIN RA0
17
18
OSC2/CLKOUT RA1
R1 1
RA2
22p 4 2

RB7 – pin13
MCLR RA3
3
1k RA4/T0CKI
6
RB0/INT
7
RB1
8
RB2
9
RB3
10
RB4
11
RB5
12
RB6
13
RB7
PIC16F84A
pin jeti b0
b1 pelabuhan port
b2
Input / output

Port b
b3
Keluar / masuk b4
b5
b6
b7
USB PROGRAMMER
In this PR, we will put more concerns
on the working principle of infrared When the IR receiver receives
sensor and the output from it. PIC infrared, it will generate voltage at its
microcontroller and programming are pin. The generated voltage is in the
not(Infra-Red)
IR required. is the typical light range from 0V to 5V depends on the
source used as a sensor in hobby intensity of infrared it received. The
robot to sense opaque object. The voltage will drop to zero if there is no
basic principle of IR sensor is based infrared received. The problem arise
on an IR emitter and an IR receiver. where our microcontroller only
IR emitter will emit infrared recognize digital input which is 0V
continuously when you provide power and 5V. If the infrared reflected is
source to it. Since there is no source less, the receiver would probably
of power for IR receiver, it would not produce a 2V or 3V and
emit any light. It will only receive microcontroller is unable to deal with
infrared if there is any. Usually we will these analog values. Thus, we need
attach the IR emitter and IR receiver a comparator (LM324) to solve this
side by side, and point them to a problem. By using this comparator,
reflective surface. the output voltage from IR receiver
will compare to an input voltage
through a variable resistor. The
comparator able to compare both
input voltage and generate either 0V
or 5V where we can connect it to our
microcontroller.
B0,B1,B2,B3,B4,B5

SISTEM PENGESAN BANJIR


C0
SENSOR PARAS AIR 1

COMPARATOR
C1 A0
SENSOR PARAS AIR 2
SWITCHING CIRCIRCUIT

PIC
SIREN
C2
SENSOR PARAS AIR 3

C0 = ON & C1 = OFF & C2 = OFF, LCD DISPLAY = AMARAN , A0 = ON


C0 = ON & C1 = ON & C2 = OFF, LCD DISPLAY = BAHAYA, AO = ON
C0 = ON & C1 = ON & C2 = ON, LCD DISPLAY = PINDAH , A0 = ON
C0 = OFF & C1 = ON & C2 = ON, LCD DISPLAY = SENSOR 1 ROSAK
C0 = ON & C1 = OFF & C2 = ON, LCD DISPLAY = SENSOR 2 ROSAK
C0 = OFF & C1 = OFF & C2 = ON, LCD DISPLAY = SENSOR 3 ROSAK

C0 = OFF & C1 = OFF & C2 = OFF, LCD DISPLAY = NORMAL

Você também pode gostar