Click here to Skip to main content
12,507,058 members (64,120 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB VB.NET
Hi all,
i'm tring to create a modbus rtu master program... i found a lot of code but in C#. when i try to convert it in visual basic ( 2010) it doesn't work... the PLC doesn't answer.
i think that there is a problem with the serialport.write(
Posted 9-Aug-12 21:40pm
Member 11579366 10-Apr-15 10:03am
are you still having the same problem with Modbus rtu?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

There's nothing wrong with the serial port class between C# and VB.NET. It's the exact same code you're running no matter which language you chose.

The problem is most likely conversion problems in your BuildMessage and GetResponse code, or something those methods are calling, though I have no idea what it is because I don't know what ModBus or your PLC requires.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Given the fact you say the problematic function is serialport.write(xxx), I understand your Modbus PLC is not working with Modbus TCP, so you can be under 232 or 485...

Are you sure that the Modbus PLC you are trying to communicate to is configured to use 232?

If not you will need an adaptor from 232 to 485 in your PC.

Apart of that, it would be a good idea to get a MODBUS sniffer to attach it to your network and see what is happening with the packages that are sent/received...

Take a look at those links:[^][^][^]

I've searched "Modbus sniffer" in google to find them.

PS: keep in mind that Modbus (as almost all the fieldbusses out there) require that the addresses are well positioned... double check them.

The typical problems I encountered working with Modbus have been:

1. bad addresses.
2. resistors wrong placed.

Good luck!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160927.1 | Last Updated 10 Aug 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100