Home » » PLC omron to VB through the ethernet

PLC omron to VB through the ethernet

Posted by Belajar elektro on Monday 7 November 2011

PLC omron to VB through the ethernet

In this post I'd like to share how to connect PLC omron with VB via converter serial to ethernet in this case I use MOXA, please make Vb interface below:

Write the source code below:
Private Sub Command1_Click()
Text1.Text = “”
cmd$ = “@00WR0001FFFF”
Call Checksum(cmd$, cksm$)
command.Text = cmd$ + cksm$ + “*” + Chr$(13)
Winsock1.RemoteHost = “192.168.1.100″
Winsock1.RemotePort = 2101
Winsock1.SendData command.Text
End Sub
Private Sub Command2_Click()
Text1.Text = “”
cmd$ = “@00WR00010000″
Call Checksum(cmd$, cksm$)
command.Text = cmd$ + cksm$ + “*” + Chr$(13)
Winsock1.RemoteHost = “192.168.1.100″
Winsock1.RemotePort = 2101
Winsock1.SendData command.Text
End Sub
Private Sub Form_Load()
Winsock1.Bind 8881
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Winsock1.GetData RecInfo, vbString
Text1.Text = RecInfo
Label1.Caption = Winsock1.RemoteHostIP & ” (” & Len(RecInfo) & “)”
End Sub
Public Sub Checksum(cmd$, cksm$)
For X = 1 To Len(cmd$)
cks = cks Xor Asc(Mid$(cmd$, X, 1))
Next X
cksm$ = Hex$(cks)
If Len(cksm$) < 2 Then cksm$ = “0″ + cksm$
End Sub


0 comments:

Post a Comment

Total Pageviews

AdF.ly

var popunder = true;

SYSTEM MONITORING INTERFACE

SYSTEM MONITORING INTERFACE
DISPAY CONTROLLER

Recent Comments

Introduction

Recent Posts

Blogger Tricks

RSSMicro FeedRankĀ® Results

IKLAN

Recent Post

page range

Poll

Powered by Blogger.

Followers

Blog Archive

Visual Pagerank
.comment-content a {display: none;}