For some reason I thought there would be a pretty well developed solution for this as I don't think this is an unusual request, but my searches so far have turned up nil. As I see it there's 3 ways to go about this:
1) Data over Modbus - This should work and I would think to be the easiest, but as you can see from the other thread I'm still stuck.
2) Data messaging through open socket - It seems the Dataman camera can be configured to open a socket on a client and send telegrams via ASCII strings. I think this would certainly work but sounds pretty labor intensive to get a robust solution going without any example to start with as a foundation.
3) Getting the data via FTP - The dataman camera can also be setup as an FTP server and can write the result data to a text file.
Has anybody else gone down this road before? If not, can you at least let me know which solution sounds most straightforward? I'm not familiar with the SysSockets.lib functions that would probably be necessary for #2, and would still need to find a library to make #3 happen. Input is appreciated, I'm just trying to decide how hard I want to work to make #1 function correctly.
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is not possible in a PLC, as the PLC has cycle times > 5 ms, it will never keep up the camera.
you will need to have a PC type, and a program to catch your camera, codesys is meant for control of contacts, and movements.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Do you mean option #2 is not possible? Of course the Modbus options should be possible, its a protocol intended for PLC <-> field device communication.
I suppose I should elaborate about my setup. There isn't any handling of triggering or anything required (all done by camera IO). All it needs to do is listen on a port to receive a 14 character string, I've tested it with a simple Java program and it works well. Is this something the SysLibSockets.lib cannot do?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
receiving a string is no problem.
there are several types and libs for the same many types of codesys plc, so stay with manufacturer or use oscat.de lib.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The PLC target is CoDeSys PLCWinNT / RTE (haven't chosen, using both in demo), so I'm trying to use it with the SysLibSockets.lib. The closest example I've been able to find is this one, but it's a send command and the libraries aren't the exact same:
Reading through the documentation, it seems I need to use 3 functions, "SysSocketCreate", "SysSocketAccept", and "SysSocketRecvFrom" (for UDP), but I need to an object for the datatype SockAddr, but it doesn't appear to be defined by the library.
The first thread I posted says there's CoDeSys V2.3 examples under the customer downloads link on the CoDeSys site, but the link is broken and I have not yet found them, any help?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
IF NOT FirstPass THEN
CameraSockAddr.sin_family:=SOCKET_AF_INET;
CameraSockAddr.sin_port:=23;
CameraSockAddr.sin_addr:=STRING_TO_UDINT('10.224.68.230'); !!! This is a problem!
diSocketHandle:= SysSockCreate(
diAddressFamily,
diType,
diProtocol);
FirstPass:=TRUE;
END_IF
IF diSocketHandle <> SOCKET_INVALID THEN
xSocketIsOpen:=TRUE;
diErrCode:= 0;
ELSE
xSocketIsOpen:=FALSE;
diErrCode:=1;
END_IF
Result is a -1 value for diSocketListen, but I'm sure it won't work because the value for the sin_addr variable of my CameraSockAddr object is '10'. I don't understand how to properly convert an IP address to a UDINT, any help here?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I found the function "SysSockInetAddr", and have used that to convert the string ip address into a UDINT, so I think that obstacle is handled. But still, SysSockRecFrom function returns -1. I'm wondering what I should be setting the diFlags value to.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is still kicking my butt. Reading through the documents I have found that there is a sequence, depending on the client/server and UDP/TCP.
For a UDP Server, I need to create the socket, bind the socket to the socket address, then receive the data. Right now, the binding function returns a false value, here's how I have my SockAddress data structure set:
IF Created AND NOT Bound THEN
Bound:=SysSockBind(
diSocket:=diSocketHandle, ( returned from SysSocketCreate )
pSockAddr:=ADR(CameraSockAddr),
diSockAddrSize:=SIZEOF(CameraSockAddr));
END_IF
If I go the TCP route I cannot create a socket at all, not sure why, but that would explain why I never got the TCP Modbus libraries working.
In the one document there's an example of a "UDPServer" function block. Seems much more self explanatory, but that doesn't come in with the SysLibSockets.lib
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Which worked almost out of the box. For whatever reason the UDP didn't work even though I had the camera set to UDP (it worked with TCP), and the TCPClient worked regardless of the UDP/TCP setting on the camera. Works pretty flawlessly, thanks for the feedback and hopefully this helps somebody in the future.
-Nate
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
For some reason I thought there would be a pretty well developed solution for this as I don't think this is an unusual request, but my searches so far have turned up nil. As I see it there's 3 ways to go about this:
1) Data over Modbus - This should work and I would think to be the easiest, but as you can see from the other thread I'm still stuck.
2) Data messaging through open socket - It seems the Dataman camera can be configured to open a socket on a client and send telegrams via ASCII strings. I think this would certainly work but sounds pretty labor intensive to get a robust solution going without any example to start with as a foundation.
3) Getting the data via FTP - The dataman camera can also be setup as an FTP server and can write the result data to a text file.
Has anybody else gone down this road before? If not, can you at least let me know which solution sounds most straightforward? I'm not familiar with the SysSockets.lib functions that would probably be necessary for #2, and would still need to find a library to make #3 happen. Input is appreciated, I'm just trying to decide how hard I want to work to make #1 function correctly.
Thanks
And option 4, would be to use RS-232. This is feasible with my hardware, but I thought it wouldn't be much different/easier than option #2.
This is not possible in a PLC, as the PLC has cycle times > 5 ms, it will never keep up the camera.
you will need to have a PC type, and a program to catch your camera, codesys is meant for control of contacts, and movements.
Do you mean option #2 is not possible? Of course the Modbus options should be possible, its a protocol intended for PLC <-> field device communication.
I suppose I should elaborate about my setup. There isn't any handling of triggering or anything required (all done by camera IO). All it needs to do is listen on a port to receive a 14 character string, I've tested it with a simple Java program and it works well. Is this something the SysLibSockets.lib cannot do?
receiving a string is no problem.
there are several types and libs for the same many types of codesys plc, so stay with manufacturer or use oscat.de lib.
OK, that's what I thought.
The PLC target is CoDeSys PLCWinNT / RTE (haven't chosen, using both in demo), so I'm trying to use it with the SysLibSockets.lib. The closest example I've been able to find is this one, but it's a send command and the libraries aren't the exact same:
http://forum.codesys.com/viewtopic.php?t=1433
I've been referring to these documents, but they aren't good for examples:
http://www.researchgate.net/publication/262198350_CoDeSys_and_Ethernet_communicationThe_concept_of_Sockets_and_basic_Function_Blocks_for_communication_over_Ethernet._Part_1_UPD_ClientServer
http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CB8QFjAA&url=ftp%3A%2F%2Fftp.moeller.net%2FAUTOMATION%2FDOWNLOAD%2FMANUALS%2FENGLISH%2FSOFTWARE%2FXSOFT_PROFESSIONAL%2FXSoftSysLibs%2Fdirectory%2520Pdf%2520files%2Fsyslibsockets.pdf&ei=DOiTVfKxFYGqyASRiZ8Y&usg=AFQjCNE1LkAEdf_mHPVGk6O7rnhXlVq19w&bvm=bv.96952980,d.aWw&cad=rja
Reading through the documentation, it seems I need to use 3 functions, "SysSocketCreate", "SysSocketAccept", and "SysSocketRecvFrom" (for UDP), but I need to an object for the datatype SockAddr, but it doesn't appear to be defined by the library.
The first thread I posted says there's CoDeSys V2.3 examples under the customer downloads link on the CoDeSys site, but the link is broken and I have not yet found them, any help?
I'm definitely getting close, not sure I actually need SysSockAccept. Here's what I have:
VAR
CameraSockAddr: SOCKADDRESS;
END_VAR
( code )
IF NOT FirstPass THEN
CameraSockAddr.sin_family:=SOCKET_AF_INET;
CameraSockAddr.sin_port:=23;
CameraSockAddr.sin_addr:=STRING_TO_UDINT('10.224.68.230'); !!! This is a problem!
diSocketHandle:= SysSockCreate(
diAddressFamily,
diType,
diProtocol);
FirstPass:=TRUE;
END_IF
IF diSocketHandle <> SOCKET_INVALID THEN
xSocketIsOpen:=TRUE;
diErrCode:= 0;
ELSE
xSocketIsOpen:=FALSE;
diErrCode:=1;
END_IF
diSocketListen:=SysSockRecvFrom(
diSocket:=diSocketHandle,
pbyBuffer:=ADR(Result),
diBufferSize:=14,
diFlags,
pSockAddr:=ADR(CameraSockAddr),
diSockAddrSize:=SIZEOF(CameraSockAddr));
END_PROGRAM
Result is a -1 value for diSocketListen, but I'm sure it won't work because the value for the sin_addr variable of my CameraSockAddr object is '10'. I don't understand how to properly convert an IP address to a UDINT, any help here?
I found the function "SysSockInetAddr", and have used that to convert the string ip address into a UDINT, so I think that obstacle is handled. But still, SysSockRecFrom function returns -1. I'm wondering what I should be setting the diFlags value to.
This is still kicking my butt. Reading through the documents I have found that there is a sequence, depending on the client/server and UDP/TCP.
For a UDP Server, I need to create the socket, bind the socket to the socket address, then receive the data. Right now, the binding function returns a false value, here's how I have my SockAddress data structure set:
CameraSockAddr.sin_family:=SOCKET_AF_INET;
CameraSockAddr.sin_port:=23;
CameraSockAddr.sin_addr:=sysSockInetAddr('10.224.68.230');
And my logic for the binding:
IF Created AND NOT Bound THEN
Bound:=SysSockBind(
diSocket:=diSocketHandle, ( returned from SysSocketCreate )
pSockAddr:=ADR(CameraSockAddr),
diSockAddrSize:=SIZEOF(CameraSockAddr));
END_IF
If I go the TCP route I cannot create a socket at all, not sure why, but that would explain why I never got the TCP Modbus libraries working.
In the one document there's an example of a "UDPServer" function block. Seems much more self explanatory, but that doesn't come in with the SysLibSockets.lib
Hey Guys,
Finally, digging harder, I found this example:
l viewtopic.php?t=133 l
Which worked almost out of the box. For whatever reason the UDP didn't work even though I had the camera set to UDP (it worked with TCP), and the TCPClient worked regardless of the UDP/TCP setting on the camera. Works pretty flawlessly, thanks for the feedback and hopefully this helps somebody in the future.
-Nate