when i have cooperation with robots and machines or robots with robots i use digital output. For example when the first robot enters the cooperation area sets a digital output on and it is always on untilt it exits that area. the other robot waits for that specific output to be off and then goes into that area and when it does it sets another digital output on so that the first robot will not enter.
it is very simple it works fine and it is very secure for the machines
This is not secure way. Not because it doesn't have syncronization. In this example robots might be in that part of the cycle that both of them would like to go to cooperation area and they have just checked the signal that another one is not in that same area. Then they would crash. Secure way is more complicate.
Let's say you have robots 1 and 2 and they have shared area x where both of them want to work. You need 3 outputs and 3 inputs and 1 boolean for each robot.
1 bit output for sending signal which tells that robot wants to go to area.
1 bit output for sending signal which tells that "I am currently on forbidden area"
1 bit output for sending signal "it is ok, that you will go to area, I wont"
1 boolean for remembering that another robot is asking to go to area, but we haven't acknowledge that yet.
similar inputs to outputs
1. First robot 1 checks that input area_x_acknowledge_rob1=FALSE and boolean area_x_allowed=TRUE. Then robot 1 request with signal which tells that robot 1 wants to go to area. (area_x_request_rob1=TRUE)
2. After receiving request robot 2 checks that itself is not in that area and itself request for same area is FALSE. After that it sets internal boolean (area_x_allowed) false, and sends feedback for robot1 that request is ok with signal (area_x_acknowledge_rob1=TRUE)
3. After that robot 1 will notice that both it's request to area and acknowledge from another robot is TRUE, so it will set area_x_not_reserved_rob1=FALSE (area is actually reserved) and drops area_x_request_rob1=FALSE.
4. After that robot 1 can freely work in area.
5. When robot 1 leaves from area it just sets area_x_not_reserved_rob1=TRUE (area is not reserved for rob1 anymore, rob2 it is your turn if needed).
During the time when area_x_not_reserved_rob1=FALSE (area reserved to robot 1) robot 2 can set it's internal boolean area_x_allowed=TRUE. Always before requesting you have to check that both area_x_not_reserved=TRUE (area not reserved for rob1) and internal variable area_x_allowed=TRUE.
I hope I got all trues and falses right. Programming this is easier than explaining.
Using this method you can make secure communicating with multiple robots and multiple areas. If you have a lot of robots, things get quite confusing anyway. Addition to this I would also make different signals for working envelope. Safe state of the signal should always be FALSE, so if your profibus goes down you can be sure that robot wont expect anything.