Copy Any I/O to DB Siemens S7

Jim.M

Member
Join Date
Dec 2008
Location
Sweden
Posts
77
Hello, How can i copy an I/O area from ex profibus/profinet to My FB instance DB via a spcified number. I want to have an input pin on the block where i can just typ start adress on tha I/O!!?!

Some help would be really nice../:oops:
 
Usually LD will take care of any questions pertaining to pointers. I'll try to have a go at it.

#In_Adr is an INPUT parameter to an FC or FB.
The below code should work in inputs in the process image. Not sure if it works also for inputs outside the process image (Peripherial inputs).

Code:
      L     #In_Adr
      SLD   3                  // push 3 bit positions, to fit word address to pointer format.
      LAR1  
 
      L     IW [AR1,P#0.0] 
      // do something with the 1st input word.
 
      L     IW [AR1,P#2.0]
      // do something with the 2nd input word.
 
      L     PIW [AR1,P#2.0]     // sample access to peripherial input address.

edit: Changed SLW 3 to SLD 3. Should not be so critical, only if the input adress is a very high one which is unlikely.
 
Last edited:
So the Pointer here points att the specified I/O area.. But where does it transfer the data to my local data in my instance DB.

Can i simply change this if i also want to write to I/O area
 
Last edited:
Quick and dirty would be to do like this:

L IW [AR1,P#0.0]
T #DriveInputWord1 // setup in FB declaration
L IW [AR1,P#2.0]
T #DriveInputWord2 // setup in FB declaration

edit: I think it should also be possible to build an ANY pointer and transfer the whole area between I-area and IDB-area in one go with SFC14.
But here I am not so sure how to create the ANY pointers. I could do it but it would take me some time to read up on it.
This would be a job for ANY-Pointer-man (LD !) ;)

You can also write to outputs like this:

L #Out_Adr
SLD 3
LAR1

L #DriveOutWord1
T QW [AR1,P#0.0]
 
Last edited:
edit: I think it should also be possible to build an ANY pointer and transfer the whole area between I-area and IDB-area in one go with SFC14.
]

If I remember correctly, the SFC14 (and 15) only works with consistent IO areas with lengths of 3, 5+ bytes.

You could dechiper an any-pointer to copy from any area using L/T instructions. It should be several examples (mainly made by LD) in the plctalk archive.

Kalle

In your Step7 help function, you'll find a description of the format of the anypointer.
And here's also some info:
http://www.plcdev.com/book/export/html/624
 
Last edited:
If I remember correctly, the SFC14 (and 15) only works with consistent IO areas with lengths of 3, 5+ bytes.
True.
In case you just need to transfer 1,2 or 4 bytes, you just use a simple load and transfer instruction.
L IBx
T byte
L IWx
T word
L IDx
T doubleword

L byte
T QBx
L word
T QWx
L doubleword
T QDx
 

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,714
Gents, I have a DB, that is an array of a UDT. This UDT has got a combination of INT's and REAL's. When an action is completed, I want to move...
Replies
11
Views
4,244
How do I move one byte of data in an array to a UDT that is one byte in length. AB would be a slam dunk on this with a simple Copy instruction...
Replies
22
Views
5,409
I am tying to find a way to copy 10 words from my input area into a structure I have mapped out for my device. What is the best/simplest way to...
Replies
5
Views
2,160
Hello! Is it possible to copy pointer's pointing address to any variable at Siemens step7? I mean I have pointer address to db block with...
Replies
14
Views
15,562
Back
Top Bottom