|
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
|
|
|
|
|
I am not sure if I understand correct what the problem is. Keep in mind that coils are actually digital outputs. Discrete inputs are digital inputs. So when you read coils you read back digital outputs.
Stephan
|
|
|
|
|
The issue is in WriteSyncData method, sending command function and received buffer function command is not matching. How do we ensure that the command we send is actually what we receive?
byte sendFunc = write_data[7];
tcpSynCl.Send(write_data, 0, write_data.Length, SocketFlags.None);
result = tcpSynCl.Receive(tcpSynClBuffer, 0, tcpSynClBuffer.Length, SocketFlags.None);
if (sendFunc != tcpSynClBuffer[7])
System.Diagnostics.Trace.WriteLine("Command and Response are not matching inside Master.WriteSyncData" + "Send Func : " + sendFunc + "Response : " + tcpSynClBuffer[7]);
It happens that we wanted to readsinglecoil but what we receive is previous call's(writesingleregister) output. It looks TCP synchronization issue. Is there any time delay to send the next command?
|
|
|
|
|
Hello..
I have a problem when trying to Read and Write address more than Integer limit (32767).
On function CreateReadHeader and CreateWriteHeader There is a problem when convert Start Address to byte, in this line of code :
(this is VB conversion code. from here: http://hadiscada.blogspot.com/2013/07/modbus-sample-vb-engllish-version.html[^])
Dim _adr As Byte() = BitConverter.GetBytes(CShort(IPAddress.HostToNetworkOrder(CShort(startAddress))))
data(8) = _adr(0)
data(9) = _adr(1)
I solved my problem with this edited code :
data(8) = startAddress \ 256
data(9) = startAddress Mod 256
Thanks..
modified 17-Sep-13 5:14am.
|
|
|
|
|
|
First of all, thanks for such a good working and kind sharing it with the community.
I had a quick investigation on the class file, saw some things that are needed to be considered
more precisely.
First one:
What MSDN says is "The asynchronous BeginReceive operation must be completed by calling the EndReceive method. Typically, the method is invoked by the callback delegate." Check it from http://msdn.microsoft.com/en-us/library/dxkwh6zw.aspx
There is no such call to EndReceive in OnReceive callback.
Second one:
This design pattern will work perfectly, if you receive the whole message from the slave at once (in one transaction).
But what if you don't get the whole message from the slave at once? This is very common situation in
tcp/ip communication that you can get your data, lets say 100 bytes data as 40,40 and 20 bytes, in two or three or more parts.
So in OnReceive, received length should be checked against to requested or sent length from slave then BegingReceive should be recalled
for the remaining part of the message. So you can be sure that received message is in completed status.
Or am I mistaken?
|
|
|
|
|
I agree with the first point and I added EndSend and EndReceive to the code. Fragmentation appears mostly when you exceed the Ethernet MTU size of 1500 bytes. Since modbusTCP only allows 255 bytes of data we should be well below this. I ran a quick test and after several hours and more than a thousand frames there was not a single fragmentation. I know its not 100% clean but I would have to change code quite a bit for this change.
Stephan
|
|
|
|
|
To make the class more flexible for all kind of physical connection types, not only for ethernet,
I still think that fragmentation should be considered too.
Please imagine that, if application would be required to gather information scattered on a very large field connected with
gprs based network or even through adsl line. I can not imagine all right now. But since it is a tcp then why not?
Cheer
|
|
|
|
|
Hi Stephan, so i got your example to work great and I am trying to use the dll for my own project.
I am trying to use asp.net and make a website I can go to that will essentially do exactly what your application does (just the read registers portion) but for the web. I have gotten to the point where it connects and I use the method ReadHoldingRegister which works fine but I have no idea how to get the data sent back. I'm not sure I can use your custom event handler to detect if data is sent back. I am pretty new to C# so maybe it is simple and I don't know yet but thought I would ask this question to see if you have a good idea on how I might resolve this issue.
Thanks so much!
Jeff
|
|
|
|
|
Jeff,
I am sorry but I dont know how to handle events in ASP. The issue is that you load the ASP page and then it just sits there. The modbus driver will send a callback when new data arrives but I dont know how an ASP web page can receive that.
Stephan
|
|
|
|
|
Hi, Stephan!
I'm not good in c#, but I need some programm for write/read data to my PLC Siemens Simatic S7 1200. Now I use your sample. But I need program, where I can just enter IP and read first two holding registers and write only first holding register (in "word" format). Can you help me?
Best regards!
p.s. Sorry for my english, I'm from Russia
|
|
|
|