Homebrewed software to communicate with measuring device via Modbus TCP

Dear sir,
Today I commenced with "homebrewed soft" as you kindly directed me, it would be relevant after debugging and third party tool succeded with wp8025.
I created a new project in vb.net, and included the EasyModbus.dll. I also made some minimal interface, assuming only succeeding connection and operating coils. In the beginning I texted only: "Imports EasyModbus" statement.
Please kindly have a look at the screenshots below:
1.JPG
2.JPG
3.JPG
5.JPG
6.JPG

Please kindly tell me, am I heading right direction? Are there any specific particulars left beyond my attention?
Faithfully,
N. Qv.
 
I am not very familiar with Visual Basic, but as far as I can tell, yes it appears you are on the right track.

For the specific bytes to use in your request packets and the device's expected responses, please refer to the Communication Traffic window in Modbus Poll (Display->Communication...) and the Serial Send Data / Serial Receive Data in the Wellpro software.
 
Dear sir,
I started with the coding.
I tried to describe what I am intending to accomplish, writing comments rightwards to the codeline.
It has confused me with reports about errors, though this time I am trying to understand, what I am intended to do with this code.
Could you kindly have a look at the codelines, to put me on the right track?

2.JPG
3.JPG

Faithfully,
N. Qv.
 

Attachments

You have a period '.' character at the end of your Form1.vb code after the line "End Class". Delete the period and your code should compile (well actually you're not passing enough arguments to WriteSingleRegister, but you shouldn't be using that function anyway - details below).

You're trying to use the WriteSingleRegister function. This is wrong. You need to read/write Coils using the ReadCoils and WriteSingleCoil or WriteMultipleCoils functions.

You don't need a port box (with a value of 502). This is for Modbus/TCP (Ethernet). You are doing Modbus RTU (RS-485). You need a COM port dropdown box or edit box and you need to pass the serial port name (i.e. COM1) to the EasyModbus.ModusClient() call.

You also need to set ModbusClient.UnitIdentifier to the Modbus slave address of the Wellpro device (I believe this is a value of 1 from your previous screenshots).
 
Dear sir,
Having carefully read your previous post, assuming your directives given onwards differences amid Modbus TCP and Modbus Serial, dealing with accidentally typed period "." character, I slightly changed code and simplified interface intending making it as simple as possible. Combined all this, please kindly have a look at the screnshots below:
1.JPG
2.JPG
3.JPG
4.JPG
5.JPG
Though the app does run without throwing exceptions, it fails succeeding connection with the unit. I am puzzled over some issues:
1. How to pass serial port name to the EasyModbus.ModbusClient() call?
2. The codeline:
Dim ModbusClient As EasyModbus.ModbusClient=NewEasyModbus.ModbusClient(TextBox4.Text, TextBox3.Text)
defines ModbusClient, and defines the input(two text boxes) for the EasyModbus, however it remains unrevealed, how EasyModbus gets known which data is in the text boxes?
Well, I imply that TextBox4 stands for the register reference, while TextBox3 for the value to be written, but as I get for the EasyModbus it remains unexplicit, what kind of data is written into the text boxes, and how to deal with it?
3. Is the sentence "ModbusClient.WriteSingleCoil(register,value)" ok(makes sense)?

Faithfully,
N. Qv.
 

Attachments

You need to look at the API documentation for EasyModbus to determine the proper values and arguments for the properties and methods. The documentation is available here:
http://easymodbustcp.net/en/modbusclient-properties
http://easymodbustcp.net/en/modbusclient-methods

You can also find code samples here:
http://easymodbustcp.net/codesampleseasymodbustcp-net

As far as I can tell from the docs, the serial port should be a string, such as "COM3". This should be passed into the ModbusClient constructor call, i.e. ModbusClient("COM3"). You then do not need the "ModbusClient.SerialPort = " line in your code.

The WriteSingleCoil method is defined as this:
void WriteSingleCoil(int startingAddress, bool value)
I believe EasyModbus uses 0-based addressing, so you should use 0 - 7 for the coil addresses for your Wellpro module. To turn the first relay on, you would use "WriteSingleCoil(0, 1)".
 
Dear sir,
Your kind directives worked and hit instantly the target!
First of all I read API docs you kindly indexed me, then I turn my vision onwards designated code samples.
It is never mind they are written with C# use. Some moments after as you suggested I rewrite WriteSingleCoil() statement.
Please kindly have a look at screenshots and video on this topic below:

https://drive.google.com/file/d/1c-pkpzMlb8gsSndeF2DB_TCNX03EmoIm/view?usp=drive_web

1.JPG
2.JPG
3.JPG
The project files are combined into archive, please see it in COIL1.zip.
Faithfully,
N. Qv.
 

Attachments

Top