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

auf Adressen gemappte IOs

heiwil
2015-08-21
2015-09-07
  • heiwil - 2015-08-21

    Hallo Zusammen,
    bei Codesys V2 konnte man mit
    SIZEOF(Var)
    herausbekommen, ob Var (BOOL) mit AT auf einen IO gemappt ist. SIZEOF liefert dann 0, bei nicht gemappten BOOL-Variablen kommt eine 1 zurück.

    Bei Codesys V3 liefert SIZEOF nun immer eine 1.

    Gibt es Alternativen?

    Heiko Wilke

     
  • heiwil - 2015-09-07

    Hallo Zusammen,
    Dank Lenze Support haben habe ich nun eine Lösung:
    Es gibt eine interne Funktion __VARINFO, die als Ergebnis einen Typ __SYSTEM.VAR_INFO ausgibt. Der Typ beinhaltet eine Variable vom Typ MEMORY_AREA

    VAR
      bInput AT %IX1.0: BOOL;
      vVarInfo: __SYSTEM.VAR_INFO;
    

    ...
    END_VAR

    ...
      vVarInfo := __VARINFO(bInput);
      IF vVarInfo.MemoryArea = __SYSTEM.MEMORY_AREA.MEM_INPUT THEN
        ;
      END_IF
    ...
    

    Heiko Wilke

     

Log in to post a comment.