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

Dear jschulze,

At my possession there is another device. This is PLC with RS-485, RS-232 Ethernet and USB ports. This PLC runs under Windows CE OS. And its desktop is available from CER-Host. Is there a chance that the small software we have developed in Win10 Visual Studio 2010, could run under WinCE and interact with WP8025ADAM module? Could I create another topic, concerning this activity? I can write more detailed on this PLC some times afterwards in another topic or here.

Yours faithfully,
N. Qv.
 
Dear jschulze,
I want to migrate to another computer(this is not connected to PLC, wp8025adam and doesn't have VS Studio 2010 I was referring to). But I have lost login and password for this forum.
How do I recover my login and password on this forum?
To have them then input on another machine.
Faithfully,
N.Qv.
 
Good morning dear sir,
Thank you sincere for valuable advices!
After resetting the password, I finished with migration to PC which is directly linked to WINCE powered PLC and wellpro module.
The PLC I am up has reach set of ports, 16 discrete inputs and GPRS modem.
Please have a look at the pictures below:
1a.JPG
2a.JPG
4a.JPG
1.JPG
2.JPG
3.JPG

4.JPG

From your kindly directions on possible developing of apps which targets compact net framework on plc, I read the article you've indexed me, it seems there is a chance of creating some app, testing it on the PC in simplified development environment (SDE), and then finally testing it on the PLC. This was inspirational article for me.
Since the PLC does have 2xRS485 ports, there is just a chance of possible connection with wellproadamRS485 module.
Can you kindly take me to ideas of undertakings to be launched while having intention of making deal among PC, PLC and wp8025 module?
Faithfully,
N.Qv.
 
I'm sorry, but I don't think i can help you any further on this. WinCE is far outside my expertise.

Perhaps another member that has experience with WinCE can help you.

In the meantime, I recommend searching the internet for examples and "Hello World" style tutorials you can follow for developing WinCE applications in .NET.
 
Dear sir,
As you kindly replied me WinCE is far outside beside your expertise, though the directions you provided were valuable and hit the target!
The main my problem is getting properly directed, and therefore general, and even vague directives helps me anyway.
First of all, I found out that VS2010 doesn't include Emulators of compact devices and compact net frameworks.
Thus I installed VS2005. During custom installation, I did notice it installed Win CE Emulator, and compact frameworks 1.0 and 2.0.
Then I created new project for smart device to be run under win ce 5.0 or later version and target compact framework 2.0.
This inspired me to make similar application we've already created with use of Easy Modbus library. I referenced Easy Modbas inside the project, but it doesn't work. The possible reason is that library is designed for x86 processors and net 4, while the created project targets 2.0 compact framework and ARM processors. Thus I wrote a letter asking whether they have Easy Modbus for compact framework: http://easymodbustcp.net/en/?pcf=1#contact
As you indexed me I created the new project "Hello World" application that works fine in the emulators, please have a look:
2.JPG
The next step of my intention is to deploy "Hello World" onto actual device my PC is connected to. I've heard of "Active Sync" but have not tried it yet.
If there are any general directives or suggestions, comments please kindly let me know.
Faithfully,
N. Qv.
 
As I said, I won't be able to provide much help with the WinCE side of things or how to run an app on real hardware, but regarding the Modbus library, I think you'll need to find a different Modbus library besides EasyModbus that targets the .NET compact framework.

Have you tried doing an internet search for "Modbus .NET compact framework WinCE"?

Here are a few results I found performing this search.
https://www.modbusdriver.com/doc/mbusmaster.net/index.htm
https://ingeardrivers.com/modbus-net-2-1-class-library-for-visual-studio-developers/
https://www.nuget.org/packages/IToolS.Modbus/
 
Dear sir,
Concerning the first link you kindly provided me in post #116 Field Talk .NET library article I liked it much and understood its idea.
The fact that deployment of the native library must be done manually, puzzles me. The article is very valuable for me. But I cannot find the link to download the Field Talk .NET library itself. Where can I find it?
The 2nd link assumes that it has trial version to free use, so I moved to 3rd link.
There are certain versions to download on the 3rd link, the problem is which I actually need to download?
The mentioning that IToolS.Modbus 3.5.58 assures compatibility with Windows CE inspires me greatly!
Faithfully,
N.Qv.
 
I am in no way affiliated or can provide support on the Modbus libraries that I linked in my previous post. I was merely providing them as examples of the results I got when performing an internet search for "Modbus .NET compact framework WinCE" .

I suggest you contact the developers of those libraries with specific questions on how to download and use their libraries.
 
Dear gentlemen,
I'm writing here to share my humble experience of developing some initial app for the actual WinCE 6.0 device with use of Visual Studio 2005. I do not intend to try get involved you in my research, but simply share with you my thoughts, actions and outcome.
The link below refers to tutorial on development the smart device applications:
https://drive.google.com/file/d/1w_V_BywmMs-mnaABc7An4HRFTZ6m37B-/view?pli=1
The objective I am on now, is establishing connection with actual wince6.0 device with VS2005.
It is mentioned in numerous forums, that Active Sync must be installed development PC alongside with VS2005 to provide connection.
The problem is Active Sync cannot be installed on Win10 or even on Win7. Once I intended to install it, the OS rejected it. To install it I was going to migrate my activities on WinXP PC.
To connect from VS2005 to actual WinCE device I reflexed on what that Active Sync does that enables VS2005 to get connected?
1. On the developing PC \Program Files x86\Common Files\Microsoft Shared\CoreCon\1.0\Target\wce400\armv4i copy the files to your device Windows folder:
Clientshutdown.exe , ConmanClient2.exe, CMaccept.exe , eDbgTL.dll , TcpConnectionA.dll.
2. Then turn your device on, launch CER-host to get connected, on the device launch Start-->Run the command conmanclient2.exe.
3. Then launch your VS2005, procced Tools-->Options-->Device Tools--->Devices, choose WindowsCE Device-->Properties-->Configure, toggle the control to Use specific IP address, in my case I input 192.168.15.58 and hit OK. Also keep in mind to index correct 'Default output location on device' , in my case it is Windows folder.
4. Return to the desktop of your device, launch Run---->Browse for the file cMaccept.exe and execute it.
5. Within 3 minutes proceed Tools--->Connect to device. The outcome is below:
1.JPG

Faithfully,
N. Qv.
 
Dear jschulze,
I am writing just to share my joy with you while having some progress on Hello World application build for actual device!
As you kindly suggested in post #114, I resumed my intentions on making 'Hello World' device app in VS2005, connecting the studio with actual device and debugging and deploying app onto device.
There were issues during deployment on actual device, it reported on errors many times, but today I installed Compact NET Framework 2.0 onto my computer, and it led to fulfilment of the objective, thank Goodness!
4.JPG
5.JPG The version of Compact .NET Framework remains still unrevealed, since the search of the entry on Registry Editor:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETCompactFramework did not succeed.
Also the application in \Windows folder on actual device 'cgacutil.exe' does not exist, which could reveal the version of NET CF.
Maybe someone deliberately removed them, who knows.
Furthermore I gonna seek for the NETCFv2.wce.ARMV4i.cab file, copy it and install onto the device. Allegedly it runs on NETCFv1, while I am targeting NETCFv2 in the designed application.
Among the development VS2005 environment there are bunch of tools like: Remote File Viewer, Remote Registry Editor, Remote Heap Walker etc, they seem very valuable to me.
Faithfully,
N. Qv.
 
Top