11/20/2009 12:04 PM | |
Posts: 90 Rating: (0) |
[schnippschnapp] LAR1 P#DBX 128.0 LAR2 P#DBX 128.0
Order No./ Description Component Version Rack: 0
Order No./ Description Component Version Rack: 0
AttachmentS7_STAT_Error.zip (72 Downloads) |
Last edited by: Denker at: 11/21/2009 2:40 AMLast edited by: Denker at: 11/20/2009 5:00 PMLast edited by: O_Moderator at: 11/20/2009 2:25 PMnew subjuect after splitting from /tf/WW/en/Posts/37330#top Last edited by: Denker at: 11/20/2009 1:06 PM |
|
11/21/2009 10:29 AM | |
Joined: 10/7/2005 Last visit: 7/15/2024 Posts: 3009 Rating: (1053)
|
Nice one Denker and easily fixed by NOT using AR2 in an FB (or make sure you save AR2 first, use it and then restore it before you again access any of its IN, OUT, IN_OUT and/or STAT variables). More useful info on this matter can be found here: Which operations overwrite the content of ACCU or registers in STEP 7? I hope this helps |
Cheers |
|
This contribution was helpful to1 thankful Users |
11/21/2009 7:46 PM | |
Posts: 90 Rating: (0) |
Dear fritz, First of all, congratulations for your Expert status here in forum, you deserve it! About my issue, thank you again for the help, now it is clear for me. It is a little stranger for me, would be better if AR2 could be used as AR1, I think. I think sometimes is not possible "save AR2 first, use it and then restore it before you again access any of its IN, OUT, IN_OUT and/or STAT variables)". In the case of my program code (copy two bytes from DB20 to DB21 -as shown previously), how could I do it in a FB, saving AR2 before access other local variable (IN, OUT, IN_OUT and/or STAT)? Any suggestion ? I only know how to dothis using onlyAR1 orTEMP variable... Best regards, Denker |
11/22/2009 11:13 AM | |
Joined: 10/7/2005 Last visit: 7/15/2024 Posts: 3009 Rating: (1053)
|
Hello again Denker it would indeed be nice if AR1&2 would be completely free for the user and not at all be used by the OS (I could even find use for an "AR3" sometimes), but considering what nice things can be done with the AR's I won't complain too much. As for your specific question about being able to use a STAT for the loop counter AND use/change AR2 in your loop, I'm afraid to say that you are out of luck. Having said that, Ialways use TEMP's for the LOOP counter and never had the need to use a STAT for it (the loop starts and finishes within the Block's execution so a TEMP will do, which is the case in your example logic too). Assuming you use a TEMP for the LOOP counter, your "save the AR2" based logic could look like this: TAR2TEMP_DWORD// Store AR2 in TEMP DWORD LAR2 P#DBX 128.0
|
Cheers |
|
11/22/2009 9:07 PM | |
Posts: 90 Rating: (0) |
Hello, Thanks again for the very usefulanswers and suggestions ! Greetings, Denker |
Follow us on