Documentation and examples on URCap API - Profinet specific

Hello everyone,

I am looking to create a simple URCap exchanging the data over the general purpose registers using profinet (mainly input and output integer registers). However, I am having difficulties finding the way to add a signal using the API and using the added signal to exchange values. The documentation on the API I managed to find is quite sparse and justprovides the method overview, but provides no explanations of how to use even the most basic concepts like this one.

What I managed to do is set a few Modbus (I assume it is relatively similar to profinet) registers in the Polyscope installation and I then managed to read and set values from these by iterating through them and setting values based on the names of these registers. However, adding a Modbus (or a profinet) register from within the URCap (using the API) is still a mistery to me.

Regarding profinet, how would I be able to add a register (for example an integer general purpose register), tell the program which register number to select and what value to write in it, as well as selecting a certain register number and reading values from it?

To be clear, I am not talking about using the script writer to append the “read_input_integer_register” line. The point is for me to avoid writing scripts (otherwise it would be far more meaningful to simply write a script and not bother with the URCap) and instead have control using the provided Java API to be able to program more advance features and procedures.

Welcome to the pain of interacting with the registers via the API. The short answer: You’re not missing anything, it’s just not possible. There’s nothing in the API that exposes the general purpose registers that allows you to write to them. The closest you can get is being able to SEE NAMED registers (but again, you can’t actually write their values). The API does allow access to the physical IO on the controller, so if you just need to turn something On or Off, this is an option.

However, you CAN send URScript commands as the result of pressing a button in Java, which can, for the most part, accomplish what you want. Just be aware that it’s pretty laggy, especially if you try to send multiple commands quickly. See my post here for links to the classes and how to use them:

I know you say you’re not talking about using the script writer to append script lines, but really this is what you need to do (just using the above classes to do it strictly from interacting with the Java UI, not needing to run a robot program). Then you just have your button send and execute script like “set_output_integer_registerX(myValue)” and your Profinet master just looks at that particular register,

1 Like

Thank you for the quick reply and explanation.

Unfortunately the button solution isn’t applicable in my situation. I will make do with scripts for now.