I want to set a global memory in a POU SFC diagram and reset it in a POU Ladder but it won't work. It works fine when both POUs are Ladder but not when one of them is SFC, why?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2015-10-09
Originally created by: scott_cunningham
I don't think the problem is because of SFC directly. My feeling is the two programs - are stomping on each other about this global variable. Maybe because of execution order, or.... Many things are built up and occur behind the scenes with SFC, even for a basic one step program. Try a simple one step SFC program and a simple one line LD with the one global variable and step through the program with the debugger to see what you find.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for your answer. It seems like the SFC POU keeps setting the global memory even though the Step is no longer active and will continue doing so until a reset of the memory is activated within the same SFC POU. Is this something I just have to accept or is there any configuration I can do to changes this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
First of all I agree with you that this is not what you would expect, but ...
It is a general advise not to use Global Variables when this can be avoided and if you use them, don't write to them from multiple POU's (only write in one and read in all).
With very small applications this is not so very important, but the bigger the application, the more problems you will get to keep the application stable.
I'm not sure what the best solution is for your specific application, but an idea could be to read the state of Vaning1 in your SFC and then reset gmHissNer in the SFC.
Maybe others have better suggestions...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2015-10-09
Originally created by: scott_cunningham
Yes, controlling a global variable from more than one program is a general thing to avoid as this makes debugging very difficult. You may be best to move away from S/R on variables that many POUs access. You can make a program that runs in your PLC_PRG as a replacement for your global variable, which controls the state based on information from the SFC and the LD. Something like:
You will need to make VAR_OUTPUTS in the SFC program (output true when in step 0) and the LD program (true when vaning). In you main PLC_PRG, add a line/rung call to: HissNer(SfcInStep0:=SFC.outputvar, LdVaning:=LD.outputvar). Now, you don't need gmHissNer... you can just use HissNer.xTrue instead. You can see what is used to determine TRUE/FALSE - much simpler for troubleshooting and testing.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I want to set a global memory in a POU SFC diagram and reset it in a POU Ladder but it won't work. It works fine when both POUs are Ladder but not when one of them is SFC, why?
Originally created by: scott_cunningham
I don't think the problem is because of SFC directly. My feeling is the two programs - are stomping on each other about this global variable. Maybe because of execution order, or.... Many things are built up and occur behind the scenes with SFC, even for a basic one step program. Try a simple one step SFC program and a simple one line LD with the one global variable and step through the program with the debugger to see what you find.
Thank you for your answer. It seems like the SFC POU keeps setting the global memory even though the Step is no longer active and will continue doing so until a reset of the memory is activated within the same SFC POU. Is this something I just have to accept or is there any configuration I can do to changes this?
First of all I agree with you that this is not what you would expect, but ...
It is a general advise not to use Global Variables when this can be avoided and if you use them, don't write to them from multiple POU's (only write in one and read in all).
With very small applications this is not so very important, but the bigger the application, the more problems you will get to keep the application stable.
I'm not sure what the best solution is for your specific application, but an idea could be to read the state of Vaning1 in your SFC and then reset gmHissNer in the SFC.
Maybe others have better suggestions...
Originally created by: scott_cunningham
Yes, controlling a global variable from more than one program is a general thing to avoid as this makes debugging very difficult. You may be best to move away from S/R on variables that many POUs access. You can make a program that runs in your PLC_PRG as a replacement for your global variable, which controls the state based on information from the SFC and the LD. Something like:
You will need to make VAR_OUTPUTS in the SFC program (output true when in step 0) and the LD program (true when vaning). In you main PLC_PRG, add a line/rung call to: HissNer(SfcInStep0:=SFC.outputvar, LdVaning:=LD.outputvar). Now, you don't need gmHissNer... you can just use HissNer.xTrue instead. You can see what is used to determine TRUE/FALSE - much simpler for troubleshooting and testing.