This is my first function block I am trying to create.
FB Variables:
FUNCTION_BLOCKDG_FBVAR_INPUTÂ Â Status_CB_InService:BOOL;Â Â Status_CB_Healthy:BOOL;Â Â Status_CB_Trip:BOOL;Â Â Status_DG_Running:BOOL;Â Â Status_DG_Fault:BOOL;Â Â Status_DG_Online:BOOL;END_VARVAR_OUTPUTÂ Â Coil_CB_InService:BOOL;Â Â Coil_CB_Healthy:BOOL;Â Â Coil_CB_Trip:BOOL;Â Â Coil_DG_Running:BOOL;Â Â Coil_DG_Fault:BOOL;Â Â Coil_DG_Online:BOOL;END_VARVAREND_VAR
ST FB Code:
IFStatus_CB_Trip=TRUE
  THENCoil_CB_Trip :=TRUE;END_IF;IFStatus_CB_InService=TRUE
  THENCoil_CB_InService :=TRUE;END_IF;IFCoil_CB_Trip=FALSEANDCoil_CB_InService=TRUEANDStatus_CB_Healthy=TRUE
  THENCoil_CB_Healthy :=TRUE;END_IF;IFStatus_DG_Fault=TRUE
  THENCoil_DG_Fault :=TRUE;END_IF;IFCoil_DG_Fault=FALSEANDCoil_CB_Healthy=TRUEANDStatus_DG_Running=TRUE
  THENCoil_DG_Running :=TRUE;END_IF;IFCoil_DG_Running=TRUEANDStatus_DG_Online=TRUE
  THENCoil_DG_Online :=TRUE;END_IF;
I have also done a visualization with buttons for the inputs and lamps for the outputs.
When I toggle the inputs, the inputs status changes, but the output status is not updating.
Appreciate if someone can tell me where I am going wrong.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2016-04-11
Originally created by: scott_cunningham
I think the first problem is your variable settings inside the IF statements. Please note that if an IF statement goes true once, your variable is set to TRUE and not set to FALSE unless you set it to false somewhere! I see a lot of your code setting variables but not resetting them.
Second, be sure your program is running! Many times I have clicked buttons in the visualization and wondered why nothing is "happening", only to see the red Stopped notice at the bottom.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is my first function block I am trying to create.
FB Variables:
ST FB Code:
I have also done a visualization with buttons for the inputs and lamps for the outputs.
When I toggle the inputs, the inputs status changes, but the output status is not updating.
Appreciate if someone can tell me where I am going wrong.
Originally created by: scott_cunningham
I think the first problem is your variable settings inside the IF statements. Please note that if an IF statement goes true once, your variable is set to TRUE and not set to FALSE unless you set it to false somewhere! I see a lot of your code setting variables but not resetting them.
Second, be sure your program is running! Many times I have clicked buttons in the visualization and wondered why nothing is "happening", only to see the red Stopped notice at the bottom.
Thanks Scott.
I did not realize I had to explicitly set the False condition - but it makes sense.