Member Login
member
passwd
remember me on this computer.

- join now -

Search

Neat Stuff

Visit our shop for nerds in control lifestyle products.

Cool stuff
Select a topic of interest:
...and press:
Fortune
Think of your family tonight. Try to crawl home after the computer crashes.
RSS Feed
RSS feed Use this link to get an RSS feed of the Control.com article flow, for private, non-commercial use only:
www.control.com/rss
Select a Page Style
Select one of the following styles:
- BluFu
- Classic
(cookies required)
from the Automation List department...
PLC values sending to a PC
PLCs topic
advertisement
Posted by khkertje on 19 December, 2007 - 1:53 am
Hello,

I have to make a program in VB 2005 that reads short values that I send from a PLC with Modbus TCP/IP.
The PLC has an IP address and also a port number.
Does somebody have a code so I can read the values in VB 2005 so I can show that on a screen and save those values?

Thanx.

Posted by Sanjay Sheth on 21 December, 2007 - 1:01 am
Take a look at the free nModbus .NET library ( http://nmodbus.com/ ). I've used it in the past with VB 2005 to do just what you are asking.

Sanjay Sheth
http://rssgrinders.com/

Posted by Anonymoes on 4 January, 2008 - 11:40 pm

I think I need to use this code from that side:


using (TcpClient client = new TcpClient("127.0.0.1", 502))
{
ModbusIpMaster master = ModbusIpMaster.CreateTcp(client);

// read five input values
ushort startAddress = 100;
ushort numInputs = 5;
bool[] inputs = master.ReadInputs(startAddress, numInputs);

for (int i = 0; i < numInputs; i++)
Console.WriteLine("Input {0}={1}", startAddress + i, inputs[i] ? 1 : 0);
}

// output:
// Input 100=0
// Input 101=0
// Input 102=0
// Input 103=0
// Input 104=0


And I made this:


orts System.Net
Imports System.Net.Sockets
Imports System.Text
Imports System.IO

Module Module1

Sub Main()

Dim client As TcpClient = New TcpClient("192.168.131.44", 502)

'code for modbus

Dim startAddress As Short = 3000
Dim numInputs As Short = 100
Dim i As Integer = 0
'code for read inputs

If i < numInputs Then
Console.WriteLine("Input {0}= {1}")
'the rest of the code to write the values
Return
End If

End Sub

End Module


As you see there are a few things I can't find.
Can someone help me with the missing code?


From Control Engineering magazine...
Related articles from Control Engineering magazine
Above articles copyright 2008 Reed Business Information. Subject to its Terms of Use.

Your use of this site is subject to the terms and conditions set forth under Legal Notices and the Privacy Policy. Please read those terms and conditions carefully. Subject to the rights expressly reserved to others under Legal Notices, the content of this site and the compilation thereof is © 1999-2008 Control Technology Corporation. All rights reserved.

Users of this site are benefiting from open source technologies, including PHP, PostgreSQL and Apache. Be happy.

Advertisement
Our Advertisers
Help keep our servers running...
Patronize our advertisers!