Hello, I’m communicating an UR20 with a PLC through Modbus TCP where the UR is the Slave and the PLC the Master.
I’m able to send data to the different registers, control digital outputs and so on… Until there, everything is fine.
My question come to the following: I have multiple binary sensors and I want to store the state of all in one single register and only modifying a single bit for each sensor. For example:
Register address : 128
S1: bit 0 (0 or 1)
S2: bit 1 (0 or 1)
S3: bit 2 (0 or 1)
S4: bit 3 (0 or 1)
S5: bit 4 (0 or 1)
etc…
How do I read using URScript the value of each single bit to assign the value to a variable?
Variables are always Integers? Or can they be Boolean?
Thank you in advance!
Have you looked into using the URScript functions “binary_list_to_integer(l)” and “integer_to_binary_list(x)”? I believe this may be what you are looking for functionality wise.
Hi @nrivas1, nope, I’ll take a good look at it, but yeah, it could be useful for my purpose. Thank you.