Pengetahuan Dasar Membuat Master Modbus RTU dengan VB.net

Pengetahuan Dasar Membuat Master Modbus RTU dengan VB.net

vbmastermodbusrtu

Langkah Langkah Membuat master Modbus RTU  dgn VB Net

-Buat  Project VB Net baru

-Buat Form spt pada gambar diatas

-simpan project

-copy file library pccontrolwordpress.dll ke folder  bin\debug  (di folder project disimpan)

-add reference  arahkan ke file pccontrolwordpress.dll

-untuk mendapatkan file library pccontrolwordpress.dll bisa di download di https://drive.google.com/open?id=0BzD886yEhaFrWTcxa1NTSnVINmc

untuk membuat objek modbus ketik di bagian paling atas

Dim objcounter As pcontrolWordpress.ModbusRTU = New pcontrolWordpress.ModbusRTU

untuk melihat class modbusRTU dan method2 yg ada dilibrary  pccontrolworpress.dll klik menu object browser .

untuk Kode pada vb net

Imports pcontrolWordpress.Modbus
Public Class Form1
Dim objcounter As pcontrolWordpress.Modbus = New pcontrolWordpress.Modbus
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For Each COMString As String In My.Computer.Ports.SerialPortNames ‘ Load all available COM ports.
ComboBox1.Items.Add(COMString)
Next
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If objcounter.Open(ComboBox1.Text, 19200, 8, 0, IO.Ports.StopBits.One) = True Then
LabelStatus.Text = objcounter.counterStatus
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If objcounter.Close Then
LabelStatus.Text = objcounter.counterStatus
End If
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim data(6) As Short

If objcounter.ReadMultipleRegisters(Convert.ToByte(txtAlamatSlave.Text), 0, 6, data) = True Then
For i = 0 To 5
ListBox1.Items.Add((40001 + i).ToString + ” = ” + data(i).ToString)
Next i
LabelStatus.Text = objcounter.counterStatus
End If

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim data(1) As UShort

data(0) = Convert.ToUInt16(txtNilaiReg.Text)

If objcounter.WriteMultipleRegisters(Convert.ToByte(txtAlamatSlave.Text), Convert.ToUInt16(txtStartReg.Text), Convert.ToUInt16(txtQtyReg.Text), data) Then
LabelStatus.Text = objcounter.counterStatus
End If

End Sub
End Class

penjelasan  tentang dasar modbus  anda bisa lihat di video tutorial DVD 3.

hasil eksekusi program diatas antara lain

mastermodbusrtuhasil

 

 

About pccontrol

Berisi Tutorial Menggunakan PC untuk mengontrol Peralatan dengan cara mudah & praktis.

Posted on 17/11/2016, in Daftar isi. Bookmark the permalink. Leave a comment.

Komentar ,Saran atau Pertanyaan

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: