4/22/2022 8:35 PM | |
Joined: 9/14/2021 Last visit: 1/31/2023 Posts: 99 Rating:
|
Hi, I have Uncertainties about early part of this RAMP function programming. As below:
It is claimed that the below instructions group:
only execute one time!! #flag1 is a bool temp and it used as a trick to execute one time!! I monitor that group instructions but I can not understand them. I think even the first time and after that, always it jumps to a001 label and e.g. #flag1 never set to as true. I'm not sure but these videos I attached show this matter too. I tracked RLO and STA by HOLD mode and MONITORING and it seems to be jumping always but the result of the program is correct too. What is your opinion?!! My whole program in FC411:
AttachmentAction to MONITOR.avi (499 Downloads) |
Just with a floral skirt♥♣, and nothing else |
|
4/22/2022 8:36 PM | |
Joined: 9/14/2021 Last visit: 1/31/2023 Posts: 99 Rating:
|
AttachmentAction to HOLD.avi (494 Downloads) |
Just with a floral skirt♥♣, and nothing else |
|
4/23/2022 8:07 AM | |
Joined: 10/7/2005 Last visit: 8/28/2025 Posts: 3049 Rating:
|
And therein lies the problem as TEMP variables are only valid while the FC/FB is executed. Next time the FC/FB is called, TEMP variables can have any value in them (presuming this code runs in an S7-300 or 400 as its seems to be the case here). As such the golden rule for usage of TEMP variables is: Always unconditionally write to them before you read from them. If you need to memories values between each FC call, use IN_OUT's (or better still, use an FB and STAT's if it is a fair number of variables whose values need to be memorised) |
Cheers |
|
4/23/2022 11:31 PM | |
Joined: 9/27/2006 Last visit: 9/1/2025 Posts: 12396 Rating:
|
Hello Mohammad; The only way to ensure that your instructions are only executed once when your block is executed is to use the FP instruction (in STL), to program a positive edge detection. Once the positive edge has been used, it will not execute again unless you change the bit you have selected for the FP. If you intend to program in STL I should suggest you save and study this manual, it will save you many headaches. https://support.industry.siemens.com/cs/ww/en/view/109751814 What our friend fritz was trying to tell you when he used the term "unconditionnaly" was it is imperative that before you read any TEMP value (variables marked with "#") that you write an initial value to them, since when you open your present function they still carry the temp values from the last opened block: all your blocks share the same local stack. You cannot predict what these temp values will be when you call your block, so you must start by placing initial values in each one when you open the function. Please read fritz' last paragraph and try to understand (and apply) his suggestions. Hope this helps, |
Last edited by: dchartier at: 04/24/2022 00:27:25 |
|
This contribution was helpful to
2 thankful Users |
Follow us on