S7 word copy pointer problem

spaderkung

Member
Join Date
Aug 2007
Location
South Sweden
Posts
389
Hi!

I use the following code (from FC) to copy words between DBs given an word offset address and nbr of words to copy. But I found out it fails for byte adresses 4096 and above and I don't see why.

L #i_SourceDB
T #iDB
OPN DB [#iDB]
L #i_DestDB
T #iDB
OPN DI [#iDB]
LAR1 P#DBX 0.0
L #i_SourceElementsOffset
SLD 4
+AR1
LAR2 P#DIX 0.0
L #i_DestElementsOffset
SLD 4
+AR2

L #i_NbrOfElements
LA: T #iLoopCount
L W [AR1,P#0.0]
T W [AR2,P#0.0]
+AR1 P#2.0
+AR2 P#2.0
L #iLoopCount
LOOP LA
SET
SAVE
 
+AR1: The integer (16 bit) to be added to the contents of AR1 is specified by the value in ACCU 1-L. Values from -32768 to +32767 are permissible.


Code:
LAR1  P#DBX 0.0
      L     #i_SourceElementsOffset
      SLD   4
      +AR1  
      LAR2  P#DIX 0.0
      L     #i_DestElementsOffset
      SLD   4
      +AR2

Could it be that you try to add a number larger than an integer with ar1

try this

Code:
l P#DBX 0.0
L     #i_SourceElementsOffset
SLD   4
+D
LAR1

L  P#DIX 0.0
L     #i_DestElementsOffset
SLD   4
+D
LAR2
 

Similar Topics

This feels like a simple, elementary question, but I am a Siemens novice and know there are experts here. My S7-1500 project (TIA Portal v17) has...
Replies
10
Views
2,712
Hi, I'm still at the beginning of my journey with TIA, and am doing something for which I'm sure there must be a better way than writing each bit...
Replies
7
Views
2,741
Hi all, Straight up question: I'm using TIA Portal and an S7-1200, and wanting to do a straight bitwise copy of all the data in a Word to put it...
Replies
16
Views
20,087
Good evening Hope I can get a little help with this one :) When I scroll true my DB and find a certain value, I would like to copy the actual...
Replies
5
Views
2,328
Hi, I'm starting with the ladder logic programming and I want to enssure if the following bitwise operation is correct or not. I want to...
Replies
2
Views
1,707
Back
Top Bottom