Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

ASCII programming within CoDeSys

robw
2006-05-31
2006-05-31
  • robw - 2006-05-31

    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.

     
  • RikeR - 2006-05-31

    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.

     

Log in to post a comment.