|
The ID hast to be changed in The HEader which is created in the DLL...
|
|
|
|
|
Hi,
I do a test for your "Modbus Tcp class demo". I got this error:Modbus says error:illegal data adress!
at first, I run two modbus tcp tools:"modbus Poll" and "modbus slave" ,they can connect well,and communication well. then i close "modbus poll",run "Modbus Tcp class demo",after I fill IP address.I click the Connect botton,then I got the illegal data adress error,a lot of same errors will show me, not stop, why? please help me! thanks!
|
|
|
|
|
Did you check your unit ID? Like the threads suggest below!
|
|
|
|
|
Thanks,I have slove this problem!
in the end of frmStart.cs,there is a funcction as follow:
private void Watchdog_Tick(object sender, System.EventArgs e)
{
MBmaster.WriteSingleRegister(0xFF, 0x1044, BitConverter.GetBytes((short) IPAddress.HostToNetworkOrder((short) 0xc1)));
}
it write a register 0x1044 to slave, but in my slave, this is no this register,so we have the error:illegal data adress
|
|
|
|
|
Hello,
if i run this application in debug mode each time i want to read some data i have following error:
Cross-thread operation not valid: Control 'grpData' accessed from a thread other than the thread it was created on, but with realese version works ok.
|
|
|
|
|
It maybe cause by "convertion" if you use Visual Studio greater than 2008. Build your own application with the TCP-Class, it's going to solve the problem!
|
|
|
|
|
Hi Stephanstricker! Thanks for your excelent work! Im having a problem to comunicate with my tcp modbus slave. It has the port 502 open and it keeps showing the error: "No connection could be made because the target machine actively refused it." On the other hand I used a simple application like the Modbus Test Pro software from "www.rogue-engr.com" and its able to communicate woth the slave on the same port 502 and same IP address.
I have tryed to change the port in your code to be the Web-http port configured in the slave that is 80 and it finally changes the interface to show all the other buttons, however it says another error that is "Slave timde out" and keeps opening the same error window filling up the screen with lots of equal error windows. Do you have any idea of what could be the problem? Thanks a lot for your help! Best Regards! Nuno Soutinho
|
|
|
|
|
Hello,
I have the same Problem,
can anyone help?
|
|
|
|
|
Hi everyone, for all of you who have timeout problem here is probably your answer. In fact the problem have been already explain here, if you check couple of sujet lower. You need to change your unit identifier to 1...most of the time. To do so, open the modbus tcp source code, go in the createreadheader function and createwriteheader, and change the value of the slave adress from 0 to 1. It maybe another number than 1. But most of the time it's 0 or 1.
It work for me!
Good luck
|
|
|
|
|
Hello can anyone help me to tell how to use this dll in vb. especially on how to manage event
this is what a tried.
Imports ModbusTCP
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim MBmaster As New ModbusTCP.Master("172.18.1.170", 502) Wit
End Sub
Private Sub MBmaster_OnResponseData(ByVal id As Integer, ByVal func As Byte, ByVal data As Byte()) Handles MBmaster.OnResponseData
End Sub
|
|
|
|
|
Stephan,
I would greatly appreciate any help in this area as well.
I'm trying to implement a VB GUI that will import your class properly.
|
|
|
|
|
Hi guys, you just have to add a reference in your project. Then select the tcp_class.dll. From there you should be able to create a Master...if you have any other problem, ask them here! (by the way, check the example that comes with the code, pretty well done).
|
|
|
|
|
hi all,
i'm new progammer in VC ++, i've downloaded the file but don't known what language to open the source code. It's not VC ++ project, anyone please help me.
thanks in advance.
dnqhung
|
|
|
|
|
dnqhung wrote: hi all,
i'm new progammer in VC ++, i've downloaded the file but don't known what language to open the source code. It's not VC ++ project, anyone please help me.
thanks in advance.
Hi, I don't know if it's too late to answer you, but I'll take a shot. Indeed, the code is in Csharp or C#(two ways of saying the same thing). You have two choice, either you use it as a dll as it is, or you find a Csharp IDE to modify it. (Which could be useful due to the unit_identifier problem explain above). If you have Visual Studio Express you should be able to modify it for free, or take a look on google you should find something. Once it is modify to meet your need, recompile it as a dll and then use it in VC++ as a reference.
I hope it'll help you!
|
|
|
|
|
Hi Stephen,
First of all, thanks a lot for the app, that's a good article. I'm using the ModbusTCP for communicating with IFD9506 module to control 80EH model PLC(via RS485). I was able to connect to IFD9506 from PC, but I receive "Slave Timeout" error for every Modbus function.
|
|
|
|
|
Hi,
first thanks for this code.
I have noticed a small problem which perhaps can explain some error reported (exception 2).
In your fonction the "id" is used to set the "Transaction identifier" and you set "Unit identifier"
to 0.
For me you should be able :
1) to set the "Unit identifier" let say the Modbus slave adress,
2) to manage the "Transaction identifier" which may be a frame counter different for each request frame
Regards.
|
|
|
|
|
Hi
I got this error:
Modbus says error: Slave timed out!
every time that I want to Read coil , was getting error.
My PLC is SCADA Pack.
What should I do?
Please help me.
thanks
_____________
Only God !
|
|
|
|
|
Hi, just want to say thanks to the author. Amazing job. Let me tell you, for a fisrt version...pretty bugfree. You should publish you code on other website, cause I had a hard time finding it.
Thanks again. Viva la open source
fauchon.michael@gmail.com
|
|
|
|
|
I use the code ,but it no can modify modbus node ?
flair
|
|
|
|
|
i got error with Illegal data adress!. Then i find to definition about excIllegalDataAdr at ModbusTCP.Master. It's set excIllegalDataAdr=2. Can you explain about excIllegalDataAdr?
|
|
|
|
|
hello!
I have a question about this class!
we have an project,that we called it power system,it use an simens pac3200,so I was one of the programers who must test this pac3200 whether that support the modbus tcp protocal,all I say is to ask
you if I used this class,it could write the register,couldn't it? one of our programmers design one programm that he test it can read(his programming). your class is very good,since I saw this class,I was worried if "the code project" hadn't had.
I wish your answer
|
|
|
|
|
When I downloaded the zip file given above there were no source files inside, only some assorted VS project files, the ModbusTCP.dll and the help file. I'm not sure if what I was expecting (Some sample C++ code on how to use the DLL) is supposed to be there or not.
At any rate, I was wondering if someone would be kind enough to provide me with a short bit of code that demonstrates how to implement this code into a Visual Studio C++ 2005 program. Specifically, binding an event handler to the OnResponseData event. I've done a lot of C programming but I'm fairly new to this managed code malarkey, so if someone's got a very basic example I'd be very much appreciative.
Many thanks,
Travis.
tjhowse [take that] gmail [bots] com
|
|
|
|
|
Hi,
I'm a researcher and I appreciated your code beacuse it is simple and good
for students and simple projects.
I converted the project on VS.NET2005 without problems and it already runs well!
I'd like understand if it is easy add the Modbus RTU(or serial) support using
the new serial class in the .net 2 framework.
(http://www.codeproject.com/cs/system/Serialport_COM.asp)
Please let me know if you have some ideas about it.
Thanks,
Nunzio
|
|
|
|
|
Hello Nunzio,
it is good to see that someone enjoys this code. I think it is better to do an separate class for serial modbus connection because a lot of the serial device is different. For example the serial driver for .net supports event handling. This makes the thread part of the class no longer necessary. On the other hand you have to build an CRC and a different header. IMHO it makes more sence to build a separate class for serial modbus.
Greets
Stephan
|
|
|
|
|
hello, I tried to convert your code INTO vb.net because I need the code for an application on a PDA so that it can communicate on an Ethernet network, but I with have a problem of transform the function of the event especially when one uses it in a structure yew, it asks me to use (raiseevent) but it goes to start an event but not in the structure yew, is what have you a solution for this concern thank you
mah_zouihed
|
|
|
|