Hi everyone, not a native PLC programmer here, just an engineer trying to make the thing work.
I have a sensor that I'm working with that communicates over RS-232. However, due to limited number of inputs in the PLC, I'm using a communication device (RTA Automation's 435NBX) to send/receive the communications from the sensor. Basically it converts the RS-232 message to a string and writes it to a string variable in the PLC. I have a string variable ST1 for incoming messages (from the sensor) and another variable ST2 for outgoing messages (to the sensor).
I have to send a few commands to the sensor to set it up for measuring, i.e. 'mode 1' (response: ok), 'calc method 1' (repsonse: "ok"). Then I send a command "measure" and the sensor responds back "measuring" then "calculating" and then "idle" once the measurement is completed. Once complete, I send a "read" command and it tells me the number that I want to display to the user.
My question is how to approach this from a programming standpoint. Is there a common method used for sending/receiving a series of commands? The only data I want to display on the HMI is the final number, but I feel that I need to make sure the sensor comes back with the "ok" response before sending the next command. I think I can use a bunch of compare, and move commands but that kind of seems cumbersome and I'm just wondering if there is a more straightforward method.
Thanks!
I have a sensor that I'm working with that communicates over RS-232. However, due to limited number of inputs in the PLC, I'm using a communication device (RTA Automation's 435NBX) to send/receive the communications from the sensor. Basically it converts the RS-232 message to a string and writes it to a string variable in the PLC. I have a string variable ST1 for incoming messages (from the sensor) and another variable ST2 for outgoing messages (to the sensor).
I have to send a few commands to the sensor to set it up for measuring, i.e. 'mode 1' (response: ok), 'calc method 1' (repsonse: "ok"). Then I send a command "measure" and the sensor responds back "measuring" then "calculating" and then "idle" once the measurement is completed. Once complete, I send a "read" command and it tells me the number that I want to display to the user.
My question is how to approach this from a programming standpoint. Is there a common method used for sending/receiving a series of commands? The only data I want to display on the HMI is the final number, but I feel that I need to make sure the sensor comes back with the "ok" response before sending the next command. I think I can use a bunch of compare, and move commands but that kind of seems cumbersome and I'm just wondering if there is a more straightforward method.
Thanks!