Accessing I/O in step7

Join Date
May 2009
Location
Halmstad
Posts
41
Hey all!

I'm trying to write a FB where I need to transfer 32 byte of I/O data to an array in the FBs DI. The code I am using is this:

Code:
      LAR1  P##pSrc
      L     W#16#1002
      T     W [AR1,P#0.0]
      L     #bDataLen
      T     W [AR1,P#2.0]
      L     0
      T     W [AR1,P#4.0]
      L     #LADDR_IN
      L     2                     
      +I    
      SLD   3
      L     DW#16#81000000
      +D    
      T     D [AR1,P#6.0]

      LAR1  P##pDest
      L     W#16#1002
      T     W [AR1,P#0.0]
      L     #bDataLen
      T     W [AR1,P#2.0]
      L     DINO
      T     W [AR1,P#4.0]
      L     #bDataLen
      SLD   3
      L     P##abInputData
      +D    
      T     D [AR1,P#6.0]

      CALL  "BLKMOV"
       SRCBLK :=#pSrc
       RET_VAL:=#iReturn
       DSTBLK :=#pDest
bDataLen is the length of the are to be copied (input parameter)
LADDR_IN is the logical start address of the module (input parameter)
abInputData is the array where I want the data to be stored

I only get 0's as input data, even though I know there should be data. After some investigation, I found the data I requred in byte PIB512. My question is: How do I translate this into an Any pointer? As the memory area 16#80 only is "I/O area", how do I know where my input I/O are located and where my output I/O are are located?

[Edit]
I also need to transfer from another array to the output I/O
[/Edit]
 
Last edited:
Using #80 as the area pointer accesses the peripheral I/O directly, rather than going through the process image/output. Reading from the area will read inputs, writing to the area will write outputs.

Are you also checking the return value from SFC20 to ensure it completes without error ?

Change your #81 to #80

Is this function block being called as a multiple instance or does it have it's own instance DB ?

Code:
      L     P##abInputData

produces a relative address, not an absolute one.
 
The CPU I am using is currently a CPU319-2 PN/DP, but this FB has to be working on most (if not all) CPUs.

So if I understand you correctly, the address specified in the HW configuration (in this case input start address 512 and output start address 512) means when I read area 80, it will be somewhat equal to reading 81 and writing to 80 will be somewhat equal to wrting to 82?

Yes, I am checking the return vlaue from the SFC 20, just thought it would be irrelevant to my problem here

This block has it's own instance DB.

What is the difference between peripheral I/O and process image/output? Shouldn't the peripheral I/O be copied to the process image/output? Sorry if my question is stupid, just that I havn't really much experience with these, more advanced stuff...

[Edit]
Is there a better way to retreive the address of abInputData? Could working with this relative address cause any problems?
[/Edit]

Thanks
 
Last edited:
So if I understand you correctly, the address specified in the HW configuration (in this case input start address 512 and output start address 512) means when I read area 80, it will be somewhat equal to reading 81 and writing to 80 will be somewhat equal to wrting to 82?


When you use 80 is for periphery. 81 is for Inputs and 82 is for outputs

If i remember well

Periphery is written immediatly.
Inputs the proces takes a proces image of the inputs before it starts on the program cyclus.
Outputs are writen after the cyclus
 
Oh yeah you have normally PIW and PQW.
I think
80 only defines P not the I/Q
So what LD means is when you use 80 for reading you use PI
When you use 80 for writting you use PQ.
There for you can't read PQ neither write PI
 
Normally, in most cases, Analog information is used outside process image area (area of io that is at the beginning of scan read to PI and at the end written from PI to io). It depends on processor what is the max byte amount that fits inside PI.

The area that does not fit in PI is called periphery area.

That periphery area is where 80 points as its only possible to write to output modules and read from input modules compiler knows what to do, 81 and 82 point to process image, as they are areas inside cpu memory, its atleast theoretically possible to write to input area and read from output area. No point to do that(atleast of i know) but in theory.

This access PI:
l IW 4
This access Periphery:
l PIW 300

Access to periphery area is made when the instruction is processed, so its "instant" but the instruction itself takes little longer to go trough.
 
Last edited:

Similar Topics

A scale module the PLC communicates with feeds back a double word (DBD) that contains status information: 32 defined status bits. In this case it...
Replies
3
Views
4,876
Hi all, I am having issues accessing my Cimplicity software - the site code changed after re-install and I am no longer able to attain a new key...
Replies
10
Views
169
For the past few day, I have had problems accessing the Rockwell Knowledgebase. When I try to access it (and I do have a TechConnect Support...
Replies
7
Views
406
Hi, Small issue i've really been beating myself up over today. I've been working with Panelview panels for years. Currently working on an older...
Replies
1
Views
589
Dear experts, I have the following setup: CPU-313C (6ES7313-5BF03-0AB0 V2.6) + CP343-1 (6GK7343-1EX30-0XE0 V2.0) communicating with Siemens PC...
Replies
7
Views
2,703
Back
Top Bottom