modul e4160 unit 8 peripheral interface controller
TRANSCRIPT
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
1/30
PERIPHERAL INTERFACECONTROLLER
PIC
SOFTWARE
JAL Edit
IC_prog PICpgm
File_name.jalFile_name.asm
File_name.hex
HARDWARE
Desktop/laptop
PIC_Burner
PIC PIC 16f84A
PIC 16f873
WinPic800
Programmer
PIC 16f877
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
2/30
JAL declaration
include 16f873_20include jlibinclude jpic73include jprintinclude hd447804
Xtal
Types PIC
Libarary jal
Port initilise for types of pic
Libarary for LCD print
Libarary for hitachi drive LCD
LCD connection to PIC
USE PROTEUS
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
3/30
Port declaration 16f873
port_a_direction = all_outputport_b_direction = all_outputport_c_direction = all_input
Pin declaration 16f873pin_c0_direction = input
pin_c1_direction = output
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
4/30
Ex.1: LCD Display
include 16f873_20include jlibinclude jpic73include jprintinclude hd447804
port_b_direction = all_output
hd44780_clearhd44780_line1hd44780=H"hd44780=E"hd44780=Lhd44780=L"hd44780=O"delay_20mshd44780_clear
hd44780_line1hd44780=G"hd44780=U"hd44780=Yhd44780=S
hd44780_clearhd44780_line1hd44780="I"
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
5/30
Ex.2: LCD Display
include 16f873_20
include jlib
include jpic73
include jprint
include hd447804
port_b_direction = all_output
forever loophd44780_clear
hd44780_line1
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
forever loop..end loop
DIP TRACE
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
6/30
co
C7
a0
a5
bo
b7
PCB
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
7/30
Ex.3: If.. then..else..end ifinclude 16f873_20include jlibinclude jpic73include jprintinclude hd447804port_a_direction = all_outputport_b_direction = all_outputport_c_direction = all_input
forever loop
If pin_c0 == on thenpin_a0 = onhd44780_clearhd44780_line1hd44780="I"hd44780="N"hd44780=1"else
pin_a0 = offhd44780_clearhd44780_line1hd44780="I"hd44780="N"hd44780=2end if
delay_20msEnd loop
If then
else end if
If pin_c0 == on thenpin_a0 = onelsepin_a0 = offend if
Input : c0
Output : a0
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
8/30
Ex.4: Two inputs with two outputs
forever loopIf pin_c0 == off & pin_c1 == off thenpin_a0 = onPin_a1 = onhd44780_clearhd44780_line1hd44780=T"hd44780=V"hd44780= hd44780=Ohd44780=nelse end if
If pin_c0 == off & pin_c1 == on thenPin_a0 = onPin_a1 = offhd44780_clearhd44780_line2hd44780=F"hd44780=A"
hd44780=Nhd44780= hd44780=Ohd44780=N"else end ifdelay_20msEnd loop
If pin_c0 == on & pin_c1 == on then
Assignment 1: Two inputs with two outputs
Continue with two more combination of c0and c1 with different display on LCD. Usea0 and a1 as the outputs.
inputs outputs
co c1 a0 a1off off on on
off on on off
on off off on
on on off off
Inputs : c0 and c1
Outputs: a0 and a1
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
9/30
FOREVER LOOP
END LOOP
Delay_200ms
Condition 1
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
Programmapping
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
10/30
hd44780_clearhd44780_line1hd44780=F"hd44780=L"hd44780= hd44780=shd44780=y"
Delay_1sforever loopPin_a0=offIf pin_c0 == on & pin_c1 == on & pin_c2== off thenpin_a0 = onPin_a1 = offhd44780_clearhd44780_line1hd44780=T"hd44780=V"hd44780= hd44780=Ohd44780=N"else end ifIf pin_c0 == off & pin_c1 == on & pin_c2== on thenpin_a1 = onpin_a0 = offhd44780_clearhd44780_line2hd44780=F"hd44780=A"hd44780=Nhd44780= hd44780=Ohd44780=N"else end if
delay_200ms
end loop
Ex.5: Three inputswith Three outputs
If pin_c0 == on & pin_c1 == on & pin_c2 then
Assignment 2: Three inputs with 3 outputs
Continue with all combination of inputs withdifferent display on LCD.
Pin_a0 = on Pin_a2 = off Pin_a1 = off
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
11/30
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
12/30
include 16f873_20include jlibinclude jpic73include jprintinclude hd447804
port_a_direction = all_outputport_b_direction = all_outputport_c_direction = all_input
var byte satu,dua
hd44780_clearhd44780_line1hd44780="T"hd44780="E"hd44780="H"hd44780=" "hd44780="T"hd44780="A"
hd44780="R"hd44780="I"hd44780="K"hd44780_line2hd44780="D"hd44780="I"hd44780="S"hd44780="P"hd44780="E"hd44780="N"hd44780="S"
hd44780="E"hd44780="R"delay_5shd44780_clear
satu = 0dua = 0
forever loopif pin_c0 == on then
satu = satu + 1hd44780_clearhd44780_line1hd44780="T"hd44780="E"hd44780="H"
hd44780=" "hd44780="T"hd44780="A"hd44780="R"hd44780="I"hd44780="K"hd44780_line2print_decimal_3(hd44780,satu," ")
else end if
if pin_c1 == on thendua = dua + 2hd44780_clearhd44780_line1hd44780="T"hd44780="E"hd44780="H"hd44780=" "hd44780="T"hd44780="A"hd44780="R"
hd44780="I"hd44780="K"hd44780_line2print_decimal_3(hd44780,dua," ")else end ifdelay_200ms
end loop
Ex.6: Working withcounter
var byte satu,dua
satu = satu + 1
dua = dua + 2
print_decimal_3(hd44780,satu," ")
print_decimal_2(hd44780,dua," ")
Decimal point var
Destination
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
13/30
JAL Edit
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
14/30
PICPgm Develop. Programmer
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
15/30
Multi CHIP PROGRAMMER
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
16/30
WinPic800 Programmer
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
17/30
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
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
18/30
PIC PIN CONFIGURATION
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
19/30
PIC PIN CONFIGURATION
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
20/30
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
21/30
16f84ADeclare in program as inputs or outputs18 pins 13 i/o
5 pins
Port A
RA0 pin 17
RA1 pin 18RA2 pin 1
RA3 pin 2
RA4 pin 3
RB6 pin12RB7 pin13
Port B
RB0 pin6
RB1 pin7
RB2 pin8
RB3 pin9
RB4 pin10
RB5 pin11
Res
ervedforL
CD
Pin 14 VDD (+V supply)
Pin 5 GND
O S C1/C LK IN16
R B 0/ I N T6
R B17
R B28
R B39
R B410
R B511
R B612
R B713
R A017
R A118
R A21
R A32
R A 4/ T0C K I3
O S C 2/ C LK O U T15
M C LR4
U 1
P IC 1 6F8 4A
R 1
1k
Pin 4 MCLR
Pin 15 & 16 External Oscillator
OSC1/CLKIN16
RB0/INT6
RB17
RB28
RB39
RB410
RB511
RB612
RB713
RA017
RA118
RA21
RA32
RA4/T0CKI3
OSC2/CLKOUT15
MCLR4
U1
PIC16F84A
X1CRYSTAL
C1
22p
C2
22pR1
1k
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
22/30
b0
b1
b2
b3
b4
b5
b6b7
Portb
jeti
pelabuhan
Input / output
Keluar / masuk
port
pin
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
23/30
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
24/30
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
25/30
USB PROGRAMMER
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
26/30
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
27/30
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
28/30
In this PR, we will put more concernson the working principle of infraredsensor and the output from it. PICmicrocontroller and programming arenot required.IR (Infra-Red) is the typical lightsource used as a sensor in hobbyrobot to sense opaque object. Thebasic principle of IR sensor is based
on an IR emitter and an IR receiver.IR emitter will emit infraredcontinuously when you provide powersource to it. Since there is no sourceof power for IR receiver, it would notemit any light. It will only receiveinfrared if there is any. Usually we willattach the IR emitter and IR receiverside by side, and point them to a
reflective surface.
When the IR receiver receivesinfrared, it will generate voltage at itspin. The generated voltage is in therange from 0V to 5V depends on theintensity of infrared it received. Thevoltage will drop to zero if there is noinfrared received. The problem arise
where our microcontroller onlyrecognize digital input which is 0Vand 5V. If the infrared reflected isless, the receiver would probablyproduce a 2V or 3V andmicrocontroller is unable to deal withthese analog values. Thus, we needa comparator (LM324) to solve thisproblem. By using this comparator,
the output voltage from IR receiverwill compare to an input voltagethrough a variable resistor. Thecomparator able to compare bothinput voltage and generate either 0Vor 5V where we can connect it to ourmicrocontroller.
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
29/30
-
8/14/2019 MODUL E4160 UNIT 8 PERIPHERAL INTERFACE CONTROLLER
30/30
PIC
C
OMPA
RATOR
SENSOR PARAS AIR 1
SENSOR PARAS AIR 2
SENSOR PARAS AIR 3
SISTEM PENGESAN BANJIR
SWITCHING CIRCIRCUIT
SIREN
C0
C1
C2
A0
B0,B1,B2,B3,B4,B5
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