12.03.2016 Views

Komunikasi Data dan Interface

Sarana Pendidikan Teknologi Aceh 2016-2020

Sarana Pendidikan Teknologi Aceh 2016-2020

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Pada protokol RS232 perlu dilakukan setting agar port komunikasi dapat saling<br />

dihubungkan, yaitu meliputi:<br />

<br />

<br />

<br />

<br />

<br />

Nomor Port Comm,<br />

Baud Rate,<br />

parity,<br />

data bits,<br />

stop bits.<br />

‣ Akses RS-232<br />

Berikut merupakan contoh program untuk akses data RS-232 melalui program<br />

Visual Basic:<br />

Private Sub Form_Load ()<br />

' Buffer to hold input string<br />

Dim Instring As String<br />

' Use COM1.<br />

MSComm1.CommPort = 1<br />

' 9600 baud, no parity, 8 data, and 1 stop bit.<br />

MSComm1.Settings = "9600,N,8,1"<br />

' Tell the control to read entire buffer when Input<br />

' is used.<br />

MSComm1.InputLen = 0<br />

' Open the port.<br />

MSComm1.PortOpen = True<br />

' Send the attention command to the modem.<br />

MSComm1.Output = "ATV1Q0" & Chr$(13) ' Ensure that<br />

' the modem responds with "OK".<br />

' Wait for data to come back to the serial port.<br />

Do<br />

DoEvents<br />

Buffer$ = Buffer$ & MSComm1.Input<br />

Loop Until InStr(Buffer$, "OK" & vbCRLF)<br />

' Read the "OK" response data in the serial port.<br />

' Close the serial port.<br />

MSComm1.PortOpen = False<br />

End Sub<br />

160

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!