7/29/2011 10:57 AM | |
Joined: 11/18/2010 Last visit: 8/5/2022 Posts: 523 Rating: (31) |
Dear Experts, i am facing one problem when executing Below S7 300 program in brief i have made two FC1 and FC2 called in OB1 in this FCs i have taken (temp2) temperary variable with same name. as per ideal condition Status of FC1 temp variabel cannot affect FC2 temp variable wheather it has same name. in my case these is not happening when i am set temp2 variable in FC2 it will affect FC1 Program please see below test program. i don't know valid reason.please help on it. Thanks, Viral patel
AttachmentTest2123.zip (64 Downloads) |
7/29/2011 2:04 PM | |
Joined: 4/24/2006 Last visit: 5/27/2024 Posts: 8657 Rating: (1154) |
Hi, Please have a look at these threads: /tf/WW/en/Posts/37330 /tf/WW/en/Posts/4871 In the case of test project: In FC2 you can make TEMP2 high (It's first local address) and then in FC1 the first local address has value 1 and Output will be high. How bigger the program and use of TEMP variable, you will not know the status of Local Address. So before using a TEMP variable you should initialize it in start of FC. To be sure it has a certain value. Always be careful with TEMP variables Best regards, Wizard |
Last edited by: Wizard at: 7/29/2011 2:14 PM |
|
7/29/2011 2:16 PM | |
Joined: 3/18/2008 Last visit: 12/8/2023 Posts: 1750 Rating: (270) |
Dear Wizard, Thanks a lot for your reply. i think the post you mention which firmly explains the difference between STAT & TEMP Variable. But here the case is different. Temp. Variables are used in two different FC & their status are reflecting in both FC's in ablove case. If possible please tellus how to intialize Temp Vairable before using the Program as you mentioned in your previous reply. Thanks in advance. |
Last edited by: Amit_86 at: 7/29/2011 2:17 PMVANDE MATARAM..... |
|
7/29/2011 2:22 PM | |
Joined: 11/18/2010 Last visit: 8/5/2022 Posts: 523 Rating: (31) |
hi, as per your 2nd above given thread it is clearly mension then when you execute any FC temp variable status is lost then what is the actual problem in my program. is there any perticular reason !!!! Viral patel |
7/29/2011 2:32 PM | |
Joined: 8/31/2005 Last visit: 5/21/2024 Posts: 2197 Rating: (326) |
The temp variables are only definded inside a FC or FB. Even if you define a variable with the same name in a other FB/FC is still is a different variable! I corrected your program (FC1 and FC2) by using a global variable (in DB1) Better is it to use the IN and OUT areas of the FB/FCs. You can see it in OB1 and FC3 It copies m0.1 to O124.1
The first access to a temp variable should be a writing one. If you read first (like temp2 in your FC1) the value may be 1 or 0, it is not defined. AttachmentTest2123_1.zip (51 Downloads) |
Last edited by: miami at: 7/29/2011 2:32 PM |
|
This contribution was helpful to1 thankful Users |
Follow us on