Omron PLC talk To VB

Need the Tutorial VB 6.0 Talk to Omron

tutorial in word format and Visual Basic 6.0 Project

Please donate to my paypal


After donate contact my email at mhdyasseen@yahoo.com

I will send the tutorial to your email

in this post I'd like to share about how to make PLC talk to the Visual Basic, and Then make Monitoring the condition of machine or PLC .Visual basic can Read and Write data to the PLC by send message to PLC and PLC send back the responds to the Visual Basic. Connection between PLC and VB used Serial communication Port or Host Link , below the connection diagram between PLC and PC (VB):


We have program PLC below:

e have program PLC below Image description

I want to monitoring the condition of bit 01.00 or 11.00 on VB, and I want to set the setting value timer and monitoring the current value on VB.

  1. Rung no 0 the timer activated by bits 10.00, and the set value store at Register D1
  2. Rung no 1 contact T000 activated coil 11.00 and 01.00
  3. Rung no 2 Move present value of T000 to register D2
  4. rung no3 move register CIO 11 to register D3
  5. Register D0 for set value timer
  6. Register D1 for monitoring timerĂ¢€™s present value
  7. Register D2 for monitoring condition bit 11.00

make the VB interface below:

Image description

Write the Source code below:

Dim data ‘General Declaration
Private Sub kirim()
Dat$ = data
l = Len(Dat$)
A = 0
For I = 1 To l
Opo$ = Mid$(Dat$, I, 1)
A = Asc(Opo$) Xor A
Next I
FCS$ = Hex$(A)
If Len(FCS$) = 1 Then
FCS$ = “0″ + FCS$
End If
DatTX$ = Dat$ + FCS$ + “*” + Chr$(13)
MSComm1.Output = DatTX$
End Sub

Private Sub Command1_Click()
Timer2 = False
Timer3 = True
End Sub

Private Sub Command2_Click()
Timer2 = False
Timer4 = True
End Sub

Private Sub Form_Load()
MSComm1.CommPort = 1 ‘(port PC comm1,tapi tergantung PC anda)
MSComm1.Settings = “9600, e, 7, 2″ ‘(harus sama PC dan PLC)
MSComm1.PortOpen = True
End Sub

Private Sub input_data_Click()
Timer2 = False
dm1 = Len(Text1.Text)
If dm1 = 4 Then
Timer1 = True
Else
jawab = MsgBox(“SALAH MASUKIN DATA BEGO LOH!!(masukkan 4 digit data)” & vbCrLf & _
“MAU INPUT ULANG DATA ?”, vbYesNo + vbQuestion + vbDefaultButton1, “”)
If jawab = vbYes Then
Text1.Text = “”
Text1.SetFocus
Else
End If

End If
End Sub
Private Sub Timer1_Timer()
bil = 1
Do
data = “@00WD0001″ & Text1.Text
kirim
bil = bil + 1
Loop Until bil = 8
Timer2 = True
Timer1 = False
OK = MsgBox(“Data Input Sukses”, vbOKOnly, “”)
End Sub

Private Sub Timer2_Timer()
data = “@00RD00010003″
kirim
Text4.Text = MSComm1.Input
Text5 = Mid(Text4.Text, 19, 1)
Text2 = Mid(Text4.Text, 12, 4)
Text3 = Mid(Text4.Text, 8, 4)
cek1 = Text5.Text
If cek1 = “1″ Then
Shape1.BackColor = &HFF&
Line1.BorderColor = &HFF&
Line2.BorderColor = &HFF&
Line3.BorderColor = &HFF&
Line4.BorderColor = &HFF&
Else
Shape1.BackColor = &H404040
End If
End Sub

Private Sub Timer3_Timer()
bil = 1
Do
data = “@00WR00100001″
kirim
bil = bil + 1
Loop Until bil = 8
Timer2 = True
Timer3 = False
End Sub

Private Sub Timer4_Timer()
bil = 1
Do
data = “@00WR00100000″
kirim
bil = bil + 1
Loop Until bil = 8
Timer2 = True
Timer4 = False
End Sub