Universal Robots Forum

Festo CPX communication - Modbus / TCP-ip?

Hello everyone,

Quick intro, i’m Peter, age 28, living in the Netherlands, CNC machinist, cad/cam programmer, macro-b, little python experience.

I’m having a little challenge:

I want to control a Festo CPX via the FB36 module so i can use the 8I0 and pneumatic valves of the CPX.
Festo advised me to purchase this setup, after i asked them for practically the same solution as the WAGO (https://youtu.be/BY36K27-nDg). This works great but i also wanted to have some pneumatic valves.

Of course, i want to read and set single coils, exactly as in the youtube video. However, the Festo CPX system doesn’t seem to allow me to do that.

See the supported function codes:

I can only read/write 16-bit words (0 = all valves closed, 1 = valve one open, 2= valve 2 open, 3 = valve 1+2 open, 4 = valve 3 open, 5 = valve 1+3 open, 6 = valve 2+3 open etc. etc.)
This is getting a real hassle if i just want to open and close some valves for grippers and read and set some IO ports on the CPX.

Is there anyone who’s dealt with the same thing? And knows a way to either get the UR output the 16-bit values in a more user friendly way? Of should i for example let a Raspberry pi communicate between the two? As a translator or such?

Because the TCP/IP function of the CPX/FB36 terminal is slave only, just like the UR robot, that won’t work either…

I hope my questions are a bit understandable.

Thanks a lot in advance for taking the time to reply!

Using a Raspberry Pi does sound like a fun solution, however did you consider to break your 16-bit words into boolean arrays in URScript?

You can use these functions:

register_as_word = (read value here)
# register_as_word may be 11
register_as_bool_list = integer_to_binary_list(register_as_word)
# register_as_bool_list is then [True, True, False, True, False, False, False, False, False, False, False, False, False, False, False, False] = 0b0000000000001011
# Length is 16, LSB as position 0

# Now overwrite to [True, False, False, True, False, ...] = integer 9 = 0b0000000000001001
register_as_bool_list[1] = False

# Check value of e.g. 5th position
if (register_as_bool_list[5] == True):
    # do something
end

# Convert back to integer
register_as_word = binary_list_to_integer(register_as_bool_list)
(Write value back to Modbus device)

The functions integer_to_binary_list(int) and binary_list_to_integer(bool_list) are explained in the URScript Manual.

Hi jbm,

Thanks for your reply!

I have teh URScript manual, and saw the integer to binary list and the binary to integer functions, but didn’t grasped how to implement it.

https://www.festo.com/net/SupportPortal/Files/451228/CPX-FB36_2016-11a_8024075g1.pdf this is the Festo manual, from page 181 they discuss the modbus communication.

Can i run a script in the background, regardless of the state of the robot?
I think the solution is rather simple, but i just don’t really get it… I’ll see if i can get results using those two functions.

Thanks again!

By “regardless of the state of the robot”, do you mean that the script execute if there is a program playing, or not, but if there is, it don’t stop it to take control ?
In that case, I think the only way to do this from the UR interface is creating a URCap.
Because even when you send script code from a communication interface to the robot, it will stop your current program.

Urcap are plugins to integrate in the Polyscope interface, allowing you to use more tools than just UR-script, like new GUI, or background process. Although, you will need at least some Java/HTML skills, but it’s really doable.

:slight_smile:

Modbus connection is configured in robot installation, so it starts immediately when installation is loaded. If it is default installation then it will start as soon as controller is powered on.
If you set your registers up on modbus client setup tab, then communication will be online regardless of the program run state.
Program just reads and writes variables that are updated in background on controller process.

So back on the topic: did you manage to control valves by changing register value on modbus client on robot?

You need to do a little trick to read holding register (03 function code) - create modbus output register, and don’t assign any value to it.

mdi,

Thanks for your reply. indeed, that’s what i mean. So making a URCap is the way to go?
Shouldn’t be that fancy i suppose, a universal Modbus URCap? with extended functionality…

mmi,

Thanks also for your reply, i did managed to control valves by changing register values. But it’s very user un-friendly. Because i almost need an excel sheet to track all combinations of in and outputs. If i just want to skip one pneumatic gripper action for example, then i need to assign a whole different register value.
While tinkering around, i also discovered that trick, thanks though!

The tech guys from Festo might also come in, to help me control their CPX valve terminal the way i asked in the first place. Great to see your comments, i was hoping i just missed something simple, or a hidden setting somewhere.

Too bad, the new Haas UMC-750 CNC machine is coming Monday, i was hoping to have the robot completely ready before the machine arrives. Thanks again! I’ll try some more tinkering…

1 Like

Hi keizer,
did you found a way to easily controll the festo cpx with the help of the Festo support team.
We have the same hassel at the moment with the festo CPX.