TheWaterboy
Lifetime Supporting Member + Moderator
Using a PLC-5 ..
I have a need to send ASCII to a really dumb annunciation device over serial.
There were only 5 strings I ever sent so for years I have simply sent the string out the comm port using AWT and paid no attention to the feedback the device gives in return. Didn't matter and it worked great.
Now I need to be able to send many more commands and most importantly I need to buffer (Queue?) them in the PLC-5 as a few could be needed at the same time and the device will ignore subsequent commands while it processes the current one. This could take several seconds so commands are being lost. Ideally I would sent them one after the other... somehow.
If done properly I send "F" and the device will echo "f" if its happy, then I can send "001", or "002" or whatever address of the canned message I want to call.
If the device is busy it will respond to any command with "e" meaning "error" and it ignores it. I need to send the "F" then read what it responds and act accordingly. If it responds with an "e" I need to wait a second and try the "F" again till I see "f".
I have danced with the ARD and I see the device response in the ST register, but far too late to deal with it. Instead of a single "e" I have 10 of them meaning many other things are being sent before I get to reading the buffer.
If doing this out of a controllogix or some other third party add on module is better suited to this task I'm all ears. It's in a PLC5 now while that would be easiest to leave in place , I can change processors - not really a problem there, but it looks like this is handled with the same commands in every processor so what I am missing is a serial specific technique that wont be any different in another processor.
I see folks here talking to scales and other devices serially so I'm hoping someone would share some example code I can see to show me how this command/response/buffer is best accomplished.
I have a need to send ASCII to a really dumb annunciation device over serial.
There were only 5 strings I ever sent so for years I have simply sent the string out the comm port using AWT and paid no attention to the feedback the device gives in return. Didn't matter and it worked great.
Now I need to be able to send many more commands and most importantly I need to buffer (Queue?) them in the PLC-5 as a few could be needed at the same time and the device will ignore subsequent commands while it processes the current one. This could take several seconds so commands are being lost. Ideally I would sent them one after the other... somehow.
If done properly I send "F" and the device will echo "f" if its happy, then I can send "001", or "002" or whatever address of the canned message I want to call.
If the device is busy it will respond to any command with "e" meaning "error" and it ignores it. I need to send the "F" then read what it responds and act accordingly. If it responds with an "e" I need to wait a second and try the "F" again till I see "f".
I have danced with the ARD and I see the device response in the ST register, but far too late to deal with it. Instead of a single "e" I have 10 of them meaning many other things are being sent before I get to reading the buffer.
If doing this out of a controllogix or some other third party add on module is better suited to this task I'm all ears. It's in a PLC5 now while that would be easiest to leave in place , I can change processors - not really a problem there, but it looks like this is handled with the same commands in every processor so what I am missing is a serial specific technique that wont be any different in another processor.
I see folks here talking to scales and other devices serially so I'm hoping someone would share some example code I can see to show me how this command/response/buffer is best accomplished.