Detect CoDeSys runs in simulation mode

george13
2021-12-26
2021-12-30
  • george13 - 2021-12-26

    Hi all, is it possible to detect that the program runs in the simulation mode in CoDeSys 2.3 rather than on the PLC?

    Why I need this?
    I own WAGO PLC 750-880 and I am using the SysRtcGetTime() function to read the PLC clock. As you know it doesn't work in the simulation mode, therefore I am using RTC() function block to simulate the clock by providing a certain date.

    Any ideas are welcome!

     
  • i-campbell

    i-campbell - 2021-12-28

    in v3.5 there is a pragma

    {IF defined (IsSimulationMode)}
      // simulation code
    {ELSE}
      // normal code
    {END_IF}
    

    I am not sure if that existed already in V2.3, try it

     
    πŸ‘
    1
    • george13 - 2021-12-30

      Thanks a lot for a hint! When I first saw your reply I hoped this is it, but... unfortunately it doesn't work since CoDeSys v2.3 says this pragma is not supported. Not only IsSimulationMode, but also the IF statement.

      You inspired me to check the CoDeSys help docs and I found that it supports a few use cases for other pragmas:

      It looks like it is time for a costly upgrade to e!COOCKPIT...

       
  • eschwellinger

    eschwellinger - 2021-12-30

    or use PFC100 & CODESYS.

     
    πŸ‘
    1

Log in to post a comment.