Hi all !
I am fairly new to CodeSys v2.3.9.26 and need a little help with using the OSCAT libraries.
What I want to do is to control to a few FESTO Vision-cameras by either Modbus or Telnet from a Kontron HMI-PLC through TCP/IP.
I have added the oscat network lib in Codesys library manager. To understand how to use these oscat libs i planed to take a look at the demo code. All I see in the DEMO-folder is alot of program names like “MB_SERVER_DEMO (PRG)” and its function block. I have read in this forum that the demo-code should be copied into your project. I dont see any demo code besides the variable declarations? Nor do I know howto copy the demo-code into my project.
Also, if I “rebuild all” codesys gives 110 errors in the oscat lib, these error comes from the demo-code. Does this mean that the demo-code must be deleted before I can use the network lib? If so, how do I delete the demo-code? I havent be able to find any way to edit the oscat lib, as in remove the demo-code, or see the actual real programming behind the FB:s. Note that Ive never made a lib or FB myself so I might be unaware of something really basic on how to deal with libraries.
If I understand this correctly “MB_SERVER (FB)” is what I should use to talk Modbus to the cameras? In order to do that I will also need “IP_CONTROL” from what I read in the .PDF ?
I added both of them to a POU, but besides that I am not sure what to do to get them working?
check the needed librarys (library.jpg)
In your picture you have oscat.lib
That one i could not find, so i downloaded the oscat basic for codesys 2 from oscat.de downloadpage.
exclude all demo objects from build
I found no way select that demo-folder for exclusion, so I deleted it and its objects.
compile the library
These seems to be very big libs. It refuses to compile due to too many POUs. More than the PLC:s default value of 1024. I changed that to 2048 just to see if it would compile, and it did. 1034 POU:s reported. Tho I dont know if the PLC will crash if I change the number of POU:s or if i can keep it at 2048?
Another way would be to delete not needed stuff in the oscat basic lib? I assume i can do that the same way as with the demo code in network.lib
Not sure what safely can be deleted and what to keep, its a huge lib.
open your project
import the oscat librarys
import the module “MODBUS_SERVER_DEMO.EXP”
I see you added the IP_CONTROL2 so I assume thats the one i want
now you can edit the demo module
How do I add the IP-adress 192.168.0.198 as a double word to the FB IP_CONTROL2 ?
Cant find any instructions on how to convert it.
>5. compile the library
These seems to be very big libs. It refuses to compile due to too many POUs. More than the PLC:s default value of 1024. I changed that to 2048 just to see if it would compile, and it did. 1034 POU:s reported. Tho I dont know if the PLC will crash if I change the number of POU:s or if i can keep it at 2048?
Another way would be to delete not needed stuff in the oscat basic lib? I assume i can do that the same way as with the demo code in network.lib
Not sure what safely can be deleted and what to keep, its a huge lib.
“oscat_basic_micro_332.lib” - Perfect, POU dropped to 343.
I thought the PLC would be Server, and the Cameras (will have three cameras total) slaves. It seemed logical that the PLC acted as Server and sent configuration data to the three slaves (cams). But I have no previous experience with Modbus and Visioncameras, so you are surely right that it is the three Cam:s that are Servers then.
I have replace the Server demo-code with demo MB_CLIENT.
There is an instruction asking for the IP to the Modbus TCP-server. To start with I will enter one of the camera’s IP there.
I will read the 50 pages manual ‘Modbus_Messaging_Implementation guide’ to gain a better general understanding of how Modbus works. Thanxs for the link.
The MODBUS Serial Line protocol is a Master-Slaves protocol. Only one master (at the same time) is connected to the bus, and one
or several (247 maximum number) slaves nodes are also connected to the same serial bus. A MODBUS communication is always
initiated by the master. The slave nodes will never transmit data without receiving a request from the master node. The slave nodes
will never communicate with each other. The master node initiates only one MODBUS transaction at the same time.
modbus tcp = client/server model
client →
← server
The MODBUS TCP messaging service provides a Client/Server communication between devices connected on an Ethernet TCP/IP network.
This client / server model is based on four type of messages:
• MODBUS Request,
• MODBUS Confirmation,
• MODBUS Indication,
• MODBUS Response
A MODBUS Request is the message sent on the network by the Client to initiate a transaction,
A MODBUS Indication is the Request message received on the Server side,
A MODBUS Response is the Response message sent by the Server,
A MODBUS Confirmation is the Response Message received on the Client side
Ahh, I see! The way you explain Modbus Serial is the way I thought it works. I had no idea that Modbus TCP is different from Modbus Serial. I thougt it was the same thing. Very good info, interesting to say the least
Time to hook up the first camera and see what settings it got inside.
Next I think its time to have a go at that vmap stuff
Basically if that works.. (!) then they should be able to communicate… i think ;D
Hi, dont know what happend to my first account “Anders” The username doesnt work
Also the site says i am on an blocked ip-range so I should contact ‘us’ to register.
The problem is… there is no email adress to write to ‘us’ so how are people supposed to do that? :
Anywayz, back to the real problem & solution!
This afternoon we got it working!!!
I skipped the vmap-idea and will read/write directly to specific registers in the camera. That supposedly generates less traffic on the network, and seems simpler too.
I went through the trouble to re-register just to thank you properly for all your help Peewit. I dont think I’d get it working without your assistance, surely not this fast. So I just wanted to let you know it is very much appreciated.
Hi Tobias,
The first account still doesnt work, but this second one does so its good
I would have expected admins to read my first post, and from the content decide if its spam or genuine? Thats usually how it works from what I understand. But with 90%(!) spammers you might need to cut corners I suppose.
I use spam1@ as an account I can ‘throw away’ if it starts to pop in spam. I wasnt sure about this site so better to be on the safe side. Seems we both had the same idea ;D
but there is still a little question:
what is the difference between “R_ADDR” and “R_DATA_ADR”
i dont know what i have to put in there.
i want to read some registers (FC = 3) of an Pilz Pnozmulti.