12/2/2011 4:53 AM | |
Joined: 10/7/2005 Last visit: 9/23/2023 Posts: 2987 Rating:
|
Hello Giuliano69 I fear there is a bit of a misunderstanding,so let me start by clarifying a few things first: What you need to be mindful of is the amount of offset you can add via the +AR1 or +AR2 commands. These only take accu 1 low into account and as such have a limitof4096 bytes (to be precise 4095.7 is the highest number you can add via the +AR1 or +AR2 command). In fact, if you use "+AR1 P#x.y" as a one line command, the editor won't allow you to use aan "x.y" value that exceeds "4095.7" If you however do"L P#x.y" "+AR1" with values between4096.0 and 8192.0 you will in fact subtract from AR1 as below: "L P#4096.0" "+AR1" subtracts 4096 bytes fromAR1 "L P#4097.0" "+AR1" subtracts 4095 bytes from AR1 "L P#8191.0" "+AR1"subtracts one byte from AR1 "L P#8192.0" "+AR1" is a zero sum game. "L P#8193.0" "+AR1" adds one byte toAR1 While the above seems"nasty",this behaviour can be "exploited" to subtract from AR 1 (since there is no "-AR 1" command). Anyway, attached is a screendump with some comments which shall help in making sense out of the above. As for your logic: L L#34816 // offset inside DB to be read SLW 3 // pointer shift conversion LAR2 // address loading change the "SLW3" to a "SLD 3" and it will be ok. Twolast (important) things: 1.) AR2 is used by FB's to hold the multi instance offset adress and you must be very careful when using AR2 in an FB (ideally avoid AR2 all together in a FB) 2.) If you want your FB to be multi instance capable you must take the AR2 based multi instance offset adressinto account. Have a look at the FAQ collection below for more on this: STEP 7 -- Creating S7 programs -- Indirect Addressing I hope this helps |
Cheers |
|
12/2/2011 8:44 PM | |
Joined: 4/30/2007 Last visit: 3/9/2023 Posts: 231 Rating:
|
Here the S7 file ... P.S.:Does someone knows if is possible upload more than one file? AttachmentHugedb.zip (42 Downloads) |
Follow us on