|
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
|
|
|
|
|
Any planes to implement modbus slave?
|
|
|
|
|
So i can download the sample code i get it. however, the browse code button shows a bunch of documentation files that i would like to read. How do i get the"modbusTCP_class-noexe.zip"
|
|
|
|
|
Would it be possible to supply me with a version that can be opened with VB.net 2008?
|
|
|
|
|
The code should compile fine in VS2008. Just add the file
\modbusTCP_class\ModbusTCP\ModbusTCP\modbusTCP.cs
That is the complete source code for the class. You should also be able to use the DLL from \modbusTCP_class\ModbusTCP\ModbusTCP\bin\Release if you
dont want to deal with source code.
Stephan
|
|
|
|
|
Just wanted to say thanks for providing this nice open source Modbus library! It has been very useful to many, including myself. Keep up the good work.
Regards,
"Member 9273009"
|
|
|
|
|
Hi, Anybody know, how to use class in console app. I've tried to use let say Modbus.ReadHoldingRegister(12, 255, 40001, 10) But obviously it is not enought do give out resoukt, I try get out data also with ResponseData(), but without success. Nowhere i can catch instructions how use it on simple way from command line. If anybody knows describe it, please. Thanks.
|
|
|
|
|
Hello,
i would like to open the Source...
And VS2008 Pro say it was make with a newer Version..
Can you tell me with which Studio you create the Files ?
Thanks for the help...
André
|
|
|
|
|
Bonjour André, je pense qu'il vous faut VS2010 ou VS2012 pour ouvrir le project mais vous pouvez aussi creer un nouveau project dans VS2008 et y ajouter les fichiers manuellement (ou copier coller le code).
Flavien.
|
|
|
|
|
Great job!
Based on your DLL, I have created an entire framework that can be used on any .Net App (windows application).
The DLL I did gives you access to user controls such as buttons, numeric textboxes etc.
The button for example, to use it:
- Drag and drop the button from the VS toolbox.
- Set a few properties (clickable, image_on, image_off, mode, etc...)
- Set the modbus device IP address
- Set the modbus SlaveID
- Set the bit Address
(the image on the button only changes when it gets the confirmation from modbus)
All of this being done at the designer stage (from property panel). No code is required, the control can read/write to that modbus address automatically (for example, a WriteSingleCoil is sent when the button is clicked and set the "clickable").
Using that concept, the Numeric textbox read automatically the values from Modbus (Pull interval is user definable).
Another nice feature is that, if you have a lot of controls in the same page, you don’t want each control to send a request to the Modbus slave to know what value is in his Modbus address. You can disable the AutoReadvalue property and put a master object on your page that will handles the refresh of all the control with one single MODBUS call (the master object on the page send a query and then the response is passed to every controls on the page).
SO, I'd like to share that.
Send me a message so discuss it.
|
|
|
|
|
Good work.
I was busy to build something too.
Hope you can publish your code soon.
|
|
|
|
|
I didn't want to share my stuff yet as I'm not 100% happy with it yet, let me know if you're waiting for it (in which case I'll share an unstable version).
|
|
|
|
|
First of all, thanks for the code, it works great and is a real help to a Modbus noob like me. I have a small problem though...
I am requesting diagnostic data from a Wago 750 bus coupler at address 0x1050 and I get the reply "Illegal Data Address". The Wago documentation lists this address so I have no idea where to look next.
Could anyone suggest what might be the cause?
|
|
|
|
|
Ah-ha!
I found that if I enter the address as a hex number in the Modbus TCP Tester, it works but if I enter it as a decimal number, it doesn't.
The tester app doesn't say what base to use so I guessed - wrongly!
|
|
|
|
|
Would you please tell us how dıd you entered the proper data to read ınputs.
I have to read the value of X0. Whıch type of entrıes need to whıch textboxes?
|
|
|
|
|
Hello,
I'm using synchronous sockets and tested with the simulator. In my test application created thread and timer both reads different registers and coils.The reason for the timer is to read the status of motor,target reached etc...this will continuously poll the coils. The thread is used to control the actual motion.
When i request to read for coil but I received the register output in synchronous sockets.
Has any one encountered this kind of issue?
I understood that it may be due to calling in timer and thread. Any suggestion to overcome this issue?
Thanks
|
|
|
|