Is there a simple way to send a string to a PLC using Modbus, using URScript?
Here is what doesn’t work:
modbus_add_signal(PLC_IP_Address, 255, 20, 3, “PLC_PartNumber”, True)
modbus_set_signal_update_frequency(“PLC_PartNumber”, 0)
modbus_set_runstate_dependent_choice(“PLC_PartNumber”, 0)
modbus_set_output_register(“PLC_PartNumber”, “test”)
That gives me an error because it wants a word-length unsigned integer instead of a string. I guess I would need to do something like this:
modbus_add_signal(PLC_IP_Address, 255, 20, 3, “PLC_PartNumber0”, True)
modbus_set_signal_update_frequency(“PLC_PartNumber0”, 0)
modbus_set_runstate_dependent_choice(“PLC_PartNumber0”, 0)
modbus_add_signal(PLC_IP_Address, 255, 21, 3, “PLC_PartNumber1”, True)
modbus_set_signal_update_frequency(“PLC_PartNumber1”, 0)
modbus_set_runstate_dependent_choice(“PLC_PartNumber1”, 0)
word0 = < somehow convert the letters “te” into the correct ASCII encoded word-length integer >
word1 = < somehow convert the letters “st” into the correct ASCII encoded word-length integer >
modbus_set_output_register(“PLC_PartNumber0”, word0)
modbus_set_output_register(“PLC_PartNumber1”, word1)
This seems rather complex - I would think there’d be an existing function for this sort of thing. If not, then at least tell me how to convert a string into an encoded word-length integer so I can piece it together.