1/28/2011 2:34 PM | |
Joined: 10/7/2005 Last visit: 6/3/2023 Posts: 2966 Rating:
|
Hello Plectrotion her's my take on the things that you observe, all of which is based on the assumption that variable "FUNCTION_WORD" is delcared as type POINTER (can you confirm this?): Line 1 (L P##FUNCTION_WORD): Ignore the value inAR1 column! The "L P##FUNCTION_WORD" command does NOT affect AR1 and itwill simply have any value in it that was "left" in it (e.g. what ever command last changedAR1 before this FC call). Line-2 (LAR 1): V memory is Local data (TEMP variables) of the calling Block (lets say your FC720 is called from FC10, it is the Local data of FC10) and AR1 must point to it. Reason bing is that a variable of type POINTER occupies 6 Bytes (see S7 help for POINTER format) which can not be passed on as a value directly into FC720. The compiler instaed allocates (for you invisble) TEMP variables in the calling Block (e.g. FC10 in our example) and stores the POINTER values in itbefore calling your FC720. You also see a value of 87xxxxxx in accu1 in line 1(L P##FUNCTION_WORD command). 87hex is V memory. Line-3 (L D[AR1, P#2.0]): Now that AR1 points to the start of the POINTER value (located in TEMPs in the calling Block), thiscommand loads Byte 2-5 of the POINTER which is the address (Bytes 0&1 contain the DB number). Line-4 (TAR1): This simply transfersthe value in AR1 into accu1. I hope this helps in making sense out of the logic. |
Cheers |
|
1/28/2011 3:08 PM | |
Posts: 241 Rating:
|
Thank you fritz, you are exactlycorrect and faster than I thought. |
This contribution was helpful to
1 thankful Users |
Follow us on