S7 - BLKMOV With Area Crossing Pointers

pethoek

Member
Join Date
Apr 2009
Location
Järbo
Posts
105
In my project i use an Anybus-X gateway for exchanging data with 3rd party as a modbus slave.

Data is provided as means of PIW and PQW area and in order to used separate bits in a word i ned to somehow copy the word from PIW area to in my case a structure in a DB.

Totally i need to copy 20 bytes from PIW to my DB-Struct.

I have used any pointers before, but not so much that i can say i'm comfortable with the concept. So instead of just asking you guys of a solution, i tried to come up with one myself.

So please could anyone tell me if this will work or not.

Purpose: Copy X Bytes from PIW-area to DB-Area

Network 1
Code:
     LAR1  P##anySrc
      L     W#16#1002
      T     W [AR1,P#0.0]               // 10h for S7, 02 for BYTE
      L     #Bytes
      T     W [AR1,P#2.0]               // Repetition fctr 
      L     W#16#0
      T     W [AR1,P#4.0]               // Not a DB
      L     W#16#8000
      T     W [AR1,P#6.0]               // P-Area
      L     #Laddr                      // P-Adress to start copying from
      SLD   3                           // Byte.Bit convertion
      T     W [AR1,P#8.0]               // Byte.Bit


Network 2
Code:
      LAR1  P##anyDest
      L     W#16#1002
      T     W [AR1,P#0.0]               // 10h for S7, 02 for BYTE
      L     #Bytes
      T     W [AR1,P#2.0]               // Repetition fctr
      L     DBNO
      T     W [AR1,P#4.0]               // DB number
      L     W#16#8400
      T     W [AR1,P#6.0]               // DB-Area
      L     #DBB                        // Byte adress to start pasting
      SLD   3                           // Byte.Bit convertion
      T     W [AR1,P#8.0]               // Byte.Bit


Network 3
Code:
      CALL  "BLKMOV"
      SRCBLK :=#anySrc
      RET_VAL:=#retVal
      DSTBLK :=#anyDest



Best regards
Pethoek
 
This is from the SFC20 help text:


Description
You use SFC 20 "BLKMOV" (block move) to copy the contents of a memory area (= source area) to another memory area (= destination area).
Permissible source areas are the following:
· Parts of data blocks
· Memory bits
· Process-image partition (part process image) for inputs
· Process-image partition (part process image) for outputs
The source parameter can be a part of the data block in the load memory which is not relevant to program execution (DB compiled with the keyword UNLINKED).


Note that the P-area is not defined as process image (only I and Q are). So I would be very supprised if this will work.


I recon you will have to make a load/transfer loop in stead.

Kalle
 
The anybus device is probably on profibus, right ?

In that case, and you use the integral DP port in the CPU, you must use SFC14 and SFC15 to get the data from the PIW and PQW areas to and from your DB.
Or, if it is via a CP342-5, you have to use DP_SEND and DP_RECV blocks.
 
The Anybus is on Profinet so i only have to set it up correct in HW-Config.

Ok, so BLKMOV won't do it. OK, well, I'll do it the "hard" way then instead of using a dynamic function. Time is time, and time equals money so thanks for your suggestions.

By the way, congrats to the victory in last nights game ;) (Handbolls-VM)
 
Is there reason for you not to try it in simulator?

SFC14 and SFC15 also work with an integral Profinet port.
Even if they are named DPRD_DAT and DPWR_DAT.

Tack så mycket for komplimenten.

But there is no need for them. I tested to write the Clock-Memorybyte to a PQW address, and on the other end of the modbus network i had an ABC Communicatior set up, and when i turned on the monitor mode i could se the clockbyte nicely counting.
 

Similar Topics

Hello experts. Anyone has any idea how to make BLKMOV execute only once? I have tried with R_TRIG and (P) but it wont write to my location.
Replies
3
Views
198
Hi everyone, I have a short question about BLKMOV instruction, illustrated in the image below. I have the same piece of code in STEP 7 (ET200S)...
Replies
2
Views
2,697
Hi All, It has been a long, long time. But in times of crisis this is somewhere I hold in the highest regard for accurate and swift responses...
Replies
3
Views
4,399
Hello Folks! I have an application where I need to copy a string into various locations within a DB. So, I've set up a Function Block to accept...
Replies
3
Views
4,949
Hi, I am trying to copy a set of strings from an array in to a different DB CALL "BLKMOV" SRCBLK :=SMP#DB50.DBX ["SMS_ALM_2_POINTER"] Byte160...
Replies
2
Views
3,816
Back
Top Bottom