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

Error result in simple ST 'IF Else' result

bernie-bbq
2021-07-31
2021-08-01
  • bernie-bbq - 2021-07-31

    Hi, The result of a simple IF Else command is incorrect. I know this seems impossible but seeing is believing. Image attached. The variables have been set correctly; one WORD 'GVL.AC_Watts' and one BOOL 'GVL.AC_Running'. Why is the BOOL showing 'TRUE' when clearly 71 > 100 is 'FALSE'

     
  • i-campbell

    i-campbell - 2021-07-31

    project please. and simulation mode or downloaded to plc? which ide version?

     
    • bernie-bbq - 2021-07-31

      Hi,

      I have attached the project (- API keys:) This is an early development
      stage and u will soon see I am no real programmer, (an Elec Eng by
      profession)... self taught in coding. IDE Codesys for RPI single core.
      3.5 SP 17. The jpg was taken off the application when running on the RPI
      with all field devices working ie Modbus kWhr meters. Note I am somewhat
      stuck with the 32 Bit floating input from the House kWhr meter so I am
      doing a bit of a fudge there. (It measures the total import / export power
      to the house from the grid. I have not got a kWhr meter for the solar
      inverter as I am hoping to access it by another API over my local network.
      (Fronius playing dumb with that and haven't provided the API key promised
      in their promotions.)I did not think to test the program in Simulation
      prior to your email, but it turns out to have the same result. Thanks for
      your interest / help.

      Bernie_BBQ

      On Sat, 31 Jul 2021 at 21:41, i-campbell forge@codesys.com wrote:

      project please. and simulation mode or downloaded to plc? which ide
      version?


      Error result in simple ST 'IF Else' result
      https://forge.codesys.com/forge/talk/CODESYS-V2/thread/5c0265af58/?limit=25#2a7d


      Sent from forge.codesys.com because you indicated interest in
      https://forge.codesys.com/forge/talk/CODESYS-V2/

      To unsubscribe from further messages, please visit
      https://forge.codesys.com/auth/subscriptions/

       
  • Fless

    Fless - 2021-07-31

    take a look in your Program Modbus

    IF  GVL.AC_Running := TRUE THEN
        AC_PWR_Use := GVL.AC_Watts;
    END_IF
    

    you wanted to check GVL.AC_Running = TRUE but you set it to true.

    to avoid such mistakes simply use statements like

    IF xRunning THEN
        ...;
    END_IF
    
    IF NOT xRunning THEN
        ...;
    END_IF
    
     
    πŸ‘
    1

Log in to post a comment.