I was wondering if anybody has a sample programming showing the sequencing of ascii comms within a PLC over RS232 to a slave. We need to monitor for a EOT command and then send a "STX our data ETX". However we then need to monitor return data and depending on this data send a different value back to slave.
We are mainly interested in the sequencing and methods of comparison and interested in any ideas that may help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The standard.lib provides function(block)s for string handling. I guess the function you are looking for is FIND.
Zitat:
FIND
Provided by standard.lib.
FIND searches for a partial string within a string.
The input variable STR1 and STR2 are type STRING, the return value of the function is type STRING.
FIND(STR1, STR2) means: Find the position of the first character where STR2 appears in STR1 for the first time. If STR2 is not found in STR1, then OUT:=0.
Example in IL:
LD 'abcdef'
FIND 'de'
ST VarINT1 ( Result is '4' )
Example in FBD:
Example in ST:
arINT1 := FIND ('abcdef','de');
Please note: String functions are not "thread safe": When using tasks, string functions may only be used in a single task. If the same function is used in different tasks, there is a danger of overwriting.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I was wondering if anybody has a sample programming showing the sequencing of ascii comms within a PLC over RS232 to a slave. We need to monitor for a EOT command and then send a "STX our data ETX". However we then need to monitor return data and depending on this data send a different value back to slave.
We are mainly interested in the sequencing and methods of comparison and interested in any ideas that may help.
The standard.lib provides function(block)s for string handling. I guess the function you are looking for is FIND.