PRINSIP DASAR ANTARMUKA
By : Sunny Arief SUDIRO
1
Prinsip Dasar Antarmuka Handsaking Handsaking Hardware Suatu teknik untuk peraturan alir data ke seberang suatu alat menghubung atas pertolongan isyarat yang laksanakan oleh kawat terpisah. terpisah Handsaking Software Transmisi data ekstra pada suatu saluran dalam rangka mengendalikan alat yang mengirimkan data di dalam arah yang lain pada saluran. Karena suatu EIA-232 koneksi, alat-alat ini mengirimkan Control-S dan Control-Q karakter untuk stop dan start transmisi. transmisi
2
Protokol Protokol merupakan satu set peraturan dan prosedur untuk bertukar-tukar data dari satu terminal dengan terminal lainnya. Hal ini dapat kita bedakan antara protokol dengan handsaking, karena fungsi protokol hanya mengatur signal yang diperoleh melalui proses handsaking. Namun keduanya y merupakan p salingg mendukungg dari proses komunikasi pada sebuah interfacing.
3
3 alasan l yang perlu l diketahui dik t h i mengenaii protokol y y y
Kode dari melakukan; "protokol keselamatan"; "protokol p akademis“ Format etiket yang diamati oleh header pada suatu status Aturan menentukan transmisi dan format data
4
Bus Interfacing Path atau buses yang digunakan untuk melewati berbagai informasi pada sistem berbasis komputer, sehingga dapat membawa pengaruh pada kerja sistem secara keseluruhan dan kinerjanya.
5
Protokol Timing Buses Asynchronous y y Synchronous y Synchronous Utilizing a wait State y
6
Delay pada Transaksi Bus Logic g Delayy 2. Capasitive Delay 3 Transit Time Delay 3. 1.
7
Logic Delay Disebut juga Propagation delay y Waktu yang dibutuhkan saat mengeluarkan (output) elemen digital untuk menswitch dengan input. y Gate TTL ~ 3 – 6 ns y Skew: perbedaan antara 2 sinyal yang berasal dari sumber yang sama atau bersamaan. y
8
Skew Coused by logic delays
9
Capacitive Delay y
Disebabkan oleh p pemuatan capacitive p pada output suatu elemen logic.
10
Propagation delays vs load capacitance
11
Transmit Time Delay Waktu yang dibutuhkan untuk sinyal digital, bergerak sepanjang jalur transmisi. y Transmit time delay per unit panjang, tp (ns) adalah sebanding dengan≤LC. L : Induktansi per unit panjang C : Kapasitansi per unit panjang Nilai tp : Κ2ns/ft y
12
Another A th Introductory I t d t Interfacing I t f i & Electronics : Case in Paralel Port
13
Overview y
This ppresentation covers a basic introduction to interfacing with the parallel port p p and just j enough g electronics to keep you from damaging your p computer.
14
Interfacing Overview Computer p
Interface
Peripheral p
•Wires •ICs •Resistors •Capacitors •Transistors Transistors •Connectors
•LEDs •Motors •Lights •Robots •Joystick Joystick •Music Box
15
What Ports Can We Interface? Parallel Port (AKA Printer Port) y Serial Port ((AKA RS232)) y Keyboard Port y USB y
We will concentrate on the Parallel Port 16
Identifying the Parallel Port It’s the female connector with 25 pins p y “DB25” y
Can be on a card
17
Three Main Invisible Electrical P Properties i y
Voltage,V,Volts ◦ Provides the “push”
y
Current,, I,, Amperes p ((Amps) p) ◦ Flow of Electrons ◦ Amount of Current is dependent on Voltage and Resistance
y
Resistance, R, Ohms (6) ◦ Limits the amount of current
18
Safe Current & Voltage Levels y
Voltage: 30 V ◦ Voltages inside a computer do not exceed 12 V, except at the power supply and power switch on older computers, which are at 120 V. V Be careful in these areas!
y
Current: 5 mA ((0.005 Amperes) p )
19
Current Is the flow of electrons y Direction depends p on convention y
Electron Current Flow (-) to (+) Conventional Current Flow (+) to (-)
20
Ohm’’s Law Ohm “Current (I) is proportional to Voltage (V) and inversely proportional to Resistance (R)”
V I= R
V = I×R
V R= I 21
Oh ’s Law Ohm’ Ohm L & Power P Wheel Wh l
Reproduced by permission of Tony van Roon, 2002 http://www.uoguelph.ca/~antoon 22
Kirchhoff’’s Laws Kirchhoff y
Kirchhoff’s Voltage Law ◦ “The sum of the voltage drops equals the applied voltage”, or… ◦ “The sum of the voltage drops around a closed loop equals zero” ◦ Used in series circuits
y
Kirchhoff’ss Current Law Kirchhoff ◦ “The current entering a junction must equal the current leaving the junction junction” ◦ Use in parallel circuits. 23
Light Emitting Diodes (LEDs) y y y y y
A type of diode designed to emit light C be Can b visible bl or IR 2 V voltage drop T i ll draws Typically d 20 mA A (0.020 (0 020 A) Schematic Symbol…
24
Resistors y
Can be rated by… ◦ Resistance ((Ohms, 6)) ◦ Tolerance (% of nominal value) ◦ Power Rating (Watts)
y
Schematic Symbol…
25
Resistor Types
26
Resistor Colour Code
Reproduced by permission of Tony van Roon, 2002 http://www.uoguelph.ca/~antoon
27
Resistor Colour Code Example
1st band: orange = 3 2nd band: orange = 3 3rd band: red = 2 (i.e. 102) 4th band: gold = 5%
33 x 102 = 3300 6 = 3.3 k6 28
Resistor Power Ratings
29
Series Circuits One current p path, therefore the current is the same everywhere y Total ota resistance es sta ce iss the t e sum su of o the t e individual resistances y
RT = R1 + R 2 + ...
30
Parallel Circuits More than one current path p y Total current is the sum of the individual cu e ts currents y
IT = I 1 + I 2 + ...
31
Parallel Port Specifications y
Output p Voltage g ◦ 0V for “low” g ◦ 5V for “high” ◦ TTL (Transistor-Transistor Logic)
y
Output Current Limitation ◦ 10-15 mA (careful!)
32
Parallel Port Pinout
Graphic from http://www.doc.ic.ac.uk/~ih/doc/par/ 33
Output Table Pin # 2 3 4 5 6 7 8 9
Label D0 D1 D2 D3 D4 D5 D6 D7
Bit Value 20 = 1 21 = 2 22 = 4 23 = 8 24 = 16 25 = 32 26 = 64 27 = 128 34
Input Table Pin # 15 13 12 10 11
Label S3 S4 S5 S6 /S7
Bit Value 23 = 8 24 = 16 25 = 32 26 = 64 27 = 128
35
Interfacing an LED Circuit D0 D1 D2 D3 D4 D5 D6 D7
36
Understanding the LED Circuit The parallel Th ll l port output iis 5V y A standard red LED needs ~20 mA and drops about 2 V y A resistor is needed to “drop” the excess voltage y
37
Doing the Math VR = VT − VLED From Ohm’s Law
VR R = IR
= 5−2 = 3V
IR = ILED = 20 mA Currents equal in a series cct
From Kirchhoff’s Voltage g Law
VT = VR + VLED VR R = IR 3V = 0 . 020 A = 150 Ω 38
Motor Control 9V
D0
B
2N3904
C E M
TIP31
(A stepper motor would require more outputs) 39
High Hi h C Current C Controll DC Voltage Source
Relay
y
Use a relay
40
The Programming Pr rammin
41
Turing: Preparing for Interfacing Turingg is alreadyy prepared p p for interfacingg with the parallel port y No op preparation epa at o necessary! ecessa y! y
42
Turing: Turning On the LED y
Parallelput(value) y Parallelput(1) turns on the 1 bit
( ) (D0) y
Parallelput(255) turns on all bits
(D0 D7) (D0-D7)
43
Turing: Turning Off the LED y
Parallelput(0)
44
Turing: Flashing the LED loop parallelput (1) delay (250) parallelput (0) delay (250) end loop
45
Turing: LED Walking loop % loops up for i : 0 .. 7 parallelput (2 ** i) delay (500) end for % loops down for decreasing i : 6 .. 1 parallelput (2 ** i) delay (500) end for end loop
46
Java: Preparing for Interfacing y
y y y y
Download http://www.geocities.com/Juanga69/parport/par port-win32.zip Extract the parport folder to your classes folder C Copy parport.dll dll to you bi bin ffolder ld import parport.ParallelPort; P ll lP ParallelPort l 1 = new ParallelPort lpt1 P ll lP (0x378); (0 378)
47
Java: Output ParallelPort lpt1 = new ParallelPort(0x378); int byteVal = 255; lpt1.write(byteVal); System.out.println("Output to port: " + byteVal);
48
JJava: Input p ParallelPort portIn = new ParallelPort (0x378); int in; in = portIn.read (); System.out.println (in + " is currently being input.");
49
J Java D Delay l M Method h d private pri ate static void oid dela delay (int mS) { t try { Thread.sleep (mS); } catch (Exception e) { ; } } 50
Delphi: Preparing for Interfacing Download io.dll from h // kh d http://geekhideout.com/downloads/io.dll /d l d / dll y Copy into project folder y
51
Delphi: Output procedure PortOut(Port : Word; Data : Byte); stdcall; external 'io 'io.dll'; dll'; procedure TForm1.Button1Click(Sender: TObject); begin PortOut(888,1); end;
52
Delphi: Input function PortIn(Port:Word):Byte; stdcall; external 'io.dll'; procedure TForm1.Button3Click(Sender: j ); TObject); var InValue : Byte; begin InValue := PortIn(889); label1.Caption := IntToStr(InValue); end;
53
D l h D Delphi Delay l P Procedure d procedure xSleep(milliseconds: LongInt); var iTemp : Longint; Begin iTemp:= GetTickCount + milliseconds; while GetTickCount < iTemp do A li ti Application.ProcessMessages P M End;
54
Assembler: Output MOV DX,0378H MOV AL,n OUT DX,AL
Where n is the value you want to output.
55
W b Resources Web R http://www.epanorama.net/circuits/paralle p p p l_output.html y http://www.lvr.com/jansfaq.htm ttp://www. v .co /ja s aq. t y http://www.doc.ic.ac.uk/~ih/doc/par/ y http://www.southwest.com.au/~jfuller/del http://www southwest com au/~jfuller/del phi/delphi1.htm y
56
Textbook References y y
Computer Engineering: An Activity-Based Approach (Holt) Networks, Interfaces and Integrated Circuits (Holt)
57
M i! Merci
58