|
I am codding for an allan bradley micro logix 1400 plc. I'm using your class to code for the modbus tcp rtu protocol.
the problem is that the address are in the format N7 , N7:11, B3:200/0, etc. will these address work if i use them in the code or else, how am i supposed to map the adress??
|
|
|
|
|
I have stumbled upon this sample program "Modbus TCP class" and I would like to run it. What software to I need to run it? I have Visual Basic 2010 Express. Is that sufficient? I have done quite a lot of VB6 programming and have written a similar program. Any help to get me started would be most appreciated.
|
|
|
|
|
You need Visual C# to run the sample. The driver itself can run in any other .Net language
but you would not be able to debug any code if you do not have the correct .Net language
installed.
|
|
|
|
|
Thanks Stephan,
I've got it working. Now all I have to do is figure out how it works!
Regards,
John Caldwell
|
|
|
|
|
Thanks for this genius Library..
I'm using it in a great Programm to automatize Tests...
But now I found a bug I'm not able to fix...
The Code isn't able to read neated values like -10203...
Could anyone please help me fix this problem... I don't know where to find the bug..
Thanks anyway for this great snippet.. =)
|
|
|
|
|
The integer conversion is done by the sample project. The driver just returns a byte field.
Look for the function "private void ShowAs(object sender, System.EventArgs e)" and change
the code snippet
if(radWord.Checked == true)
{
if (data.Length < 2) return;
word = new int[data.Length/2];
for(int x=0;x<data.Length;x=x+2)
{
word[x/2] = data[x] * 256 + data[x+1];
}
}
into
if(radWord.Checked == true)
{
if (data.Length < 2) return;
word = new int[data.Length/2];
for(int x=0;x<data.Length;x=x+2)
{
//word[x/2] = data[x] * 256 + data[x+1];
byte[] bytes = { data[x + 1], data[x] };
word[x / 2] = BitConverter.ToInt16(bytes, 0);
}
}
Stephan
|
|
|
|
|
Is there any Modbus Class for C ?
|
|
|
|
|
C doesn't have classes. Try libmodbus.
|
|
|
|
|
When i tried to press connect button it is ok but after that when i pressed read input register button it had been given me connection lost error in Modbus tcp.
|
|
|
|
|
There is code give me error invalid address. When i try to press read input register. There is no any register value shown. My modpol utility have slave id 10 but ur code taken ur default value. Where to we give slave id value.
|
|
|
|
|
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.
|
|
|
|