|
I want to poll specific register suppose only 40001.Using onresponse data it polls all the registers starting from start address to number to registers to poll.I want to poll only specific address mention in my Textbox.
|
|
|
|
|
Register 40001 means that this is a holding register with address 1 (or 0 Modbus on not quite clear on that). So what you have to do is read holding register from address 1 with length 1.
Stephan
|
|
|
|
|
Though the code is a bit too hard-coded for my taste, this application gets the job done. Thanks! You saved me so much time at work.
|
|
|
|
|
Nice job developing the Modbus library but, the downloaded file does not contain the .doc file suggested. "The class directory contains a help file (ModbusClassTCP\doc) with detailed information for every function." I do however find a .chm file but I get no data, just titles of the data I would like to view. Is there a way I could get the documentation on the library for Modbus? This would help speed development time. Thanks for your help.
AutomationBrent
|
|
|
|
|
If you dont see any content in the CHM file, do a right click on the file and select properties. Then click on the Unblock button in the top right corner. Now the content should show up fine.
Stephan
|
|
|
|
|
First this is an excellent project!
I am not very good at programming so I am trying to figure out how to modified this program where it does a continuous reading of discreet inputs without having to click the button. Just keep refreshing as changes in the module inputs occur.
Thanks
modified 18-Apr-15 11:29am.
|
|
|
|
|
Unfortunately, there is no event mode in modbus so you have to use a .NET timer object and poll the data continuously.
Stephan
|
|
|
|
|
Very nice program, thanks1
|
|
|
|
|
Thank you for all the work done and efforts put in writing this code and article.
I downloaded the source , compiled and run it. I am able to connect to the Modbus TCP gateway through which I am trying to communicate with a Modbus RTU device.
However , in the sample program given herewith , I am able to only connect to gateway , but no data sent-received. I am able to get data in ModScan32 tool, that means there is no issue in hardware setup. Please help.
Also, I tried to write a piece of code on my own using the MOdbusTCP class , there I am able to connect and send but unable to receive the data. Which function/method I need to call or is called to receive the data?
|
|
|
|
|
I can read coils but not registers seams the ID of the Response is not seeing the 3 valve letting the case statement breakout correctly. Any Ideal were to start?
|
|
|
|
|
it might be helpful if you post the piece of code you're talking about and the inputs you had, and possibly what slave device/type you were talking to
|
|
|
|
|
Seam to have been a usb Ethernet port causing the problem.
|
|
|
|
|
hello
i get below image error after a period of time.
http://upload.tehran98.com/upme/uploads/0bf200d188ee8a401.jpg
What should I do to solve this problem ؟
|
|
|
|
|
i'm too, who can help ...?
|
|
|
|
|
I'm working on my own project and this code helps me a lot. By the way why didn't you add float support on the project? Sometimes reading data on word is not enough, i'll try to add float, if i did, I will share with you. Thanks.
|
|
|
|
|
I have a project. and I need to collect data from about 200 devices at the same time by modbustcp & c#. Could you give me some advices?
thanks!
|
|
|
|
|
I am new to modbus / tcp / socket programming. what I need is, I want to pass 0 or 1 value to the hardware unit from my program. And whenever I will give 0 or 1 the unit understands and will work accordingly. This is an electronic device which has port address and ip address . How to do this any ideas ? can u suggest me some samples or what exactly is to be used .
thanks in advance.
|
|
|
|
|
The second line in the function CreateReadHeader should convert a UShort not a Short.
id values above 32768 throw an exception.
Since the id is a USHORT (0 to 65535) the converstion should handle larger numbers.
Dim _id() As Byte = BitConverter.GetBytes(CUShort(id))
|
|
|
|
|
I am checking this project out and so far so good.
I don't see an option for swapping the Endian.
It didn't work out of the box with the Modbus devices I currently have as the hi & low bytes are swapped within each 16 bit word.
Also, it appears there is no time out for a comm failure with Async operation. Why couldn't a timer be added that fires the Timeout exception when no response has been received?
And finally, it would be nice to have a companion Modbus Slave project. Any plans on implementing that?
|
|
|
|
|
I have successfully used this code in a simple C++ Console app and now wish to use it in an MFC app, but came up against the following problem when I tried to add a private member to a class, eg.;
#using "ModbusTCP.dll"
class CModule
{
public:
private :
ModbusTCP::Master MBmaster;
};
I get the following error;
c:\xxx\Module.h(108): error C3265: cannot declare a managed
may not declare a global or static variable, or a member of a native type that refers to objects in the gc heap
c:\xxx\Module.h(108): error C3076:
Is there a simple way around this problem (or will I have to rewrite the ModbusTCP C# code in C++? Eeek!).
Any help would be really appreciated.
|
|
|
|
|
This was noted once already in an older comment... The first two bytes of the modbus/tcp header are typically used as a message transaction identifier, not as a place for the slave unit address. This allows the master to correctly identify a given response as the correct response for a specific request. The transaction id should change with each request (typically it just increments). Without a way to match up the response with the request it is possible to use the wrong response, and therefore the wrong data. Consider this scenario where a timeout occurs:
Request 40001
timeout
Request 40001
response (to first 40001 request)
Request 40002
response (to second 40001 request)
If the messages contain a transaction Id then the above scenario wouldn't use the wrong data since the second response to 40001 would not match the transaction Id of the request for 40002.
When implementing this logic with message retries, I would suggest you use a new transaction Id for each 'first' request; keep the transaction Id the same for any retries. Wrap the transaction Id at 255 back to zero.
|
|
|
|
|
Hi thank you for your project, it's very usefull for my current project. But I'm working on a Web application with ASP.NET MVC.
I met a problem. I think I do instructions before the ReadCoils function had finished to exchange data, because I have to refresh the view (web page) twice to have the good states of the relays. I would like to know if is it possible to ensure the end of the ReadCoil communication and DO NOT execute any instruction while that? (It's not a problem if I have to wait a little more ).
One more information : If I put a breakpoint just after the ReadCoils function, I have no troubles, but there are without breakpoints !
I hope I was clear enough and sorry for my bad english.
Thanks by advance.
Best Regards,
Rhyz.
|
|
|
|
|
I have not tried this with ASP.NET yet. If you call the function block synchronously you should have the data right after the function call. Is there any chance you can try this with a C# program?
Stephan
|
|
|
|
|
How I Can create Modbus TCP slave appliction? In your code source i can't find class to creating and using Modbus Slave device.
Thank you for your help!
|
|
|
|
|
I am sorry but this is a modbusTCP master only.
Stephan
|
|
|
|