Modul E4160 Unit 8 Peripheral Interface Controller

  • Uploaded by: RAJA ARIF SHAH BIN RAJA OSMAN
  • 0
  • 0
  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Modul E4160 Unit 8 Peripheral Interface Controller as PDF for free.

More details

  • Words: 1,569
  • Pages: 30
PERIPHERAL INTERFACE CONTROLLER SOFTWARE

JAL Edit

File_name.jal File_name.hex

HARDWARE

File_name.asm

Programmer

IC_prog

PICpgm

PIC

Desktop/lapto p

PIC_Burne r WinPic800

PIC

PIC 16f84A PIC 16f873

PIC 16f877

Type’s PIC

JAL declaration

include 16f873_20 include jlib include jpic73 include jprint include hd447804

Xtal



LCD connection to PIC

USE PROTEUS

Libarary jal Port initilise for type’s of pic Libarary for LCD print Libarary for hitachi drive LCD

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 include jpic73 include jprint include hd447804 

Ex.1: LCD Display

 

hd44780_clear hd44780_line1 hd44780="I"

port_b_direction = all_output



hd44780_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“ • 

Ex.2: LCD Display forever loop …….. end loop

include 16f873_20 include jlib include jpic73 include jprint include hd447804 port_b_direction = all_output forever loop hd44780_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 •

DIP TRACE

b7 a0

a5

co

bo

C7

PCB

Ex.3: If.. then..else..end if If

then

else end if

If pin_c0 == on then pin_a0 = on else pin_a0 = off end if

Input : c0 Output : a0

include 16f873_20 include jlib include jpic73 include jprint include hd447804 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 hd44780_clear hd44780_line1 hd44780="I" hd44780="N" hd44780=“1" else pin_a0 = off hd44780_clear hd44780_line1 hd44780="I" hd44780="N" hd44780=“2“ end if 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



If pin_c0 == on & pin_c1 == on then Outputs: a0 and a1 Assignment 1: Two inputs with two outputs Continue with two more combination of c0 and c1 with different display on LCD. Use a0 and a1 as the outputs. inputs co c1 off off off on on off on on

outputs a0 a1 on on on off off on off off

pin_a0 = on Pin_a1 = on hd44780_clear hd44780_line1 hd44780=“T" hd44780=“V" hd44780=“ “ hd44780=“O“ hd44780=“n“ 

else end if

 

If pin_c0 == off & pin_c1 == on then



Pin_a0 = on Pin_a1 = off hd44780_clear hd44780_line2 hd44780=“F" hd44780=“A" hd44780=“N“ hd44780=“ “ hd44780=“O“ hd44780=“N" 

else end if



delay_20ms End loop 

FOREVER LOOP

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 Delay_200ms END LOOP

Program mapping

hd44780_clear hd44780_line1 hd44780=“F" hd44780=“L" hd44780=“ “ hd44780=“s“ hd44780=“y" Delay_1s forever loop Pin_a0=off If pin_c0 == on & pin_c1 == on & pin_c2== off then pin_a0 = on Pin_a1 = off hd44780_clear hd44780_line1 hd44780=“T" hd44780=“V" hd44780=“ “ hd44780=“O“ hd44780=“N" else end if 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 

Ex.5: Three inputs with Three outputs If pin_c0 == on & pin_c1 == on & pin_c2 then

Pin_a0 = on Pin_a1 = off

Pin_a2 = off

Assignment 2: Three inputs with 3 outputs Continue with all combination of inputs with different display on LCD.





delay_200ms end loop

 

inputs c0 c1 0 0 0 0 0 1 0 1 1 0 1 0 1 1 1 1

c2 0 1 0 1 0 1 0 1

outputs a0 a1 1 1 1 1 1 0 1 0 0 1 0 1 0 0 0 0

a2 1 0 1 0 1 0 1 0

LCD On/off TV ON TV OFF FAN ON FAN OFF RADIO ON RADIO OFF LIGHT ON LIGHT OFF

include 16f873_20 include jlib include jpic73 include jprint include hd447804 port_a_direction = all_output port_b_direction = all_output port_c_direction = all_input

var byte satu,dua hd44780_clear hd44780_line1 hd44780="T" hd44780="E" hd44780="H" hd44780=" " hd44780="T" hd44780="A" hd44780="R" hd44780="I" hd44780="K" hd44780_line2 hd44780="D" hd44780="I" hd44780="S" hd44780="P" hd44780="E" hd44780="N" hd44780="S" hd44780="E" hd44780="R" delay_5s hd44780_clear

satu = 0 dua = 0

forever loop

if pin_c0 == on then

satu = satu + 1 hd44780_clear hd44780_line1 hd44780="T" hd44780="E" hd44780="H" hd44780=" " hd44780="T" hd44780="A" hd44780="R" hd44780="I" hd44780="K" hd44780_line2

print_decimal_3(hd44780,satu," ")

else end if

Ex.6: Working with counter var byte satu,dua satu = satu + 1 dua = dua + 2

Destination

if pin_c1 == on then

dua = dua + 2

hd44780_clear hd44780_line1 hd44780="T" hd44780="E" hd44780="H" hd44780=" " hd44780="T" hd44780="A" hd44780="R" hd44780="I" hd44780="K" hd44780_line2 print_decimal_3(hd44780,dua," ") else end if delay_200ms

end loop

print_decimal_3(hd44780,satu," ") print_decimal_2(hd44780,dua," ")

Decimal point

var

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

CRYSTAL

C2 22p

U1 R1 1k

9 10 1 2 3 4 5 6 7

OSC1/CLKIN OSC2/CLKOUT MCLR/Vpp RA0/AN0 RA1/AN1 RA2/AN2 RA3/AN3/VREF+ RA4/T0CKI RA5/AN4/SS

PIC16C73B

RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7 RC0/T1OSO/T1CKI RC1/T1OSI/CCP2 RC2/CCP1 RC3/SCK/SCL RC4/SDI/SDA RC5/SDO RC6/TX/CK RC7/RX/DT

21 22 23 24 25 26 27 28 11 12 13 14 15 16 17 18

D0 D1 D2 D3 D4 D5 D6 D7 7 8 9 10 11 12 13 14

1 2 3

22p

X1

4 5 6

VSS VDD VEE

C1

RS RW E

LM016L

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 15

Port A

RA2 – pin 1

RB2 – pin8

RA3 – pin 2

RB3 – pin9 RB4 – pin10 RB5 – pin11

Reserved for LCD

RA0 – pin 17 RB0 – pin6 RA1 – pin 18 RB1 – pin7

RA4 – pin 3

Pin 4 – MCLR

Port B

4

17 O S C 1 /C L K IN R A0 18 O S C 2 /C L K O U T R A 1 1 R A2 2 M C LR R A3 3 R A 4 /T 0 C K I R B 0 /IN T R B1 R B2 R B3 R B4 R B5 R B6 R B7 P IC 1 6 F 8 4A

Pin 15 & 16 – External Oscillator C1 22p

X1

RB6 – pin12 RB7 – pin13

CRYSTAL

U1

C2 22p

16 15

R1

4

OSC1/CLKIN OSC2/CLKOUT MCLR

1k

RA0 RA1 RA2 RA3 RA4/T0CKI RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7

PIC16F84A

17 18 1 2 3 6 7 8 9 10 11 12 13

6 7 8 9 10 11 12 13

pin

jeti

b0 b1

Keluar / masuk

b2 b3 b4 b5 b6 b7

Port b

Input / output

pelabuhan

port

USB PROGRAMMER

In this PR, we will put more concerns on the working principle of infrared sensor and the output from it. PIC microcontroller and programming are not(Infra-Red) required. is the typical light IR source used as a sensor in hobby robot to sense opaque object. The basic principle of IR sensor is based on an IR emitter and an IR receiver. IR emitter will emit infrared continuously when you provide power source to it. Since there is no source of power for IR receiver, it would not emit any light. It will only receive infrared if there is any. Usually we will attach the IR emitter and IR receiver side by side, and point them to a reflective surface.

When the IR receiver receives infrared, it will generate voltage at its pin. The generated voltage is in the range from 0V to 5V depends on the intensity of infrared it received. The voltage will drop to zero if there is no infrared received. The problem arise where our microcontroller only recognize digital input which is 0V and 5V. If the infrared reflected is less, the receiver would probably produce a 2V or 3V and microcontroller is unable to deal with these analog values. Thus, we need a comparator (LM324) to solve this problem. By using this comparator, 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

C1

A0

PIC

SENSOR PARAS AIR 2

COMPARATOR

SENSOR PARAS AIR 1

SWITCHING CIRCIRCUIT

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

SIREN

Related Documents


More Documents from ""