Step7: Transfer array to I/O area

Join Date
May 2009
Location
Halmstad
Posts
41
Okay folks, this is (hopefully) the last question from me for a while :p

I've got this 32 byte array of bytes I wish to write to the I/O area. SFC20 can't do the job though, anyone got any suggestion how to move the whole array? Of course I could transfer the data byte by byte, but there gotta be some better way?

The thing is this I/O area migh vary between 4, 8, 16 and 32 byte. And of course, if the I/O area is only e.g. 8 bytes, I only want to transfer 8 bytes to the I/O area.

Thanks
 
Why dont you say what is wrong with BLKMOV ?

Is the i/o connected via onboard DP or PN ? Then use SFC14/SFC15.
Is the i/o connected via a CP342-5 ? Then use FC1/FC2 DP_SEND/DP_RECV.
Is the i/o in the rack, and part of the proces image (i.e. IB255 or lower for example) ? Then SFC20 BLKMOV will work.
Is the i/o in the rack, but not part of the proces image (i.e. IB256 or higher for example) ? Then there is no easy way, you have to resort to pointer code.

This is in SCL:
Code:
FUNCTION DBtoPQ_MOV : VOID
// copy indirectly from a DB to Peripherial outputs
// Jesper M. Pedersen (2009)
// notice: NOT TESTED
VAR_INPUT
    DB_no : BLOCK_DB ;
    DB_start_byte : INT ;
    PQ_start_byte: INT ;
    no_of_bytes: INT ;
END_VAR

VAR_TEMP
    i : INT ;
    dbi: INT ;
    pqi: INT ;
END_VAR

FOR i:= 0 TO (no_of_bytes - 1) BY 1 DO
    dbi:= DB_start_byte + i ;
    pqi:= PQ_start_byte + i ;
    PQB[pqi]:=DB_no.DB[dbi] ;
END_FOR ;
END_FUNCTION

edit: Changed the loop to take into account that we humans start with "1" when counting stuff.
 
Last edited:
@manmeetvirdi: That is correct.

@JesperMP: The I/O is connected to the PLC via onboard PROFINET
I will try SFC 14/15 out, looks like this could be the solution.

Thanks
 
So you have array[1 .. 32] of byte, that you wish to transfer to periphery area?

Then JesperMP made code for you, hes transferring byte by byte, but if you have always bytelenght divisionable by four, you can do the transfer doubleword by doubleword also to speed it up little.
 
Hi there
You can try this
Code:
      L     4                           //   I/0 area length (4,8,16,32) 
      T     MW    90                    //   where it is stored

      L     MW    90                    // if I/0=4, then 4-2=2 and then 4+2=6 
      L     2
      -I    
      L     MW    90
      +I    
      SLD   3
      LAR1                              //AR1 points to 6.0
      OPN   DB    16

      L     MW    90
j1:   T     MW    90
      L     DBB [AR1,P#0.0]
      T     PQB [AR1,P#0.0]

      TAR1  
      L     P#2.0                       //decrement AR2 by 2.0
      -D    
      LAR1  
      L     MW    90
      LOOP  j1
Give a look to array defined in DB

db16.JPG
 
Last edited:
ooppss...
better one
Code:
  OPN   DB    16
      LAR1  P#0.0

      L     MW    9                //no of I/O bytes
j2:   T     MW    90
      L     DBB [AR1,P#0.0]
      T     PQB [AR1,P#0.0]
      +AR1  P#2.0
      L     MW    90
      LOOP  j2
Inspired from JesperMP code:D
 
Last edited:

Similar Topics

Hey! I'm trying to transfer an array of Int to a DB I created using SFC22. The code I am using for the transfer is this: datasize is the array of...
Replies
13
Views
5,061
Another one for Simon! This is related to the BLOCK_DB question in as much as it's the same program. I need to pass over the Cell address in the...
Replies
4
Views
3,898
Hi, Just wanna pick some brains here. Problem: PLC1: S7-315 with CP343 PLC2: S7-414 with CP443 PLC1 contains 12 DB's that needs to be tranferred...
Replies
3
Views
2,021
Hey guys, I need help I have a floating key copy of step 7 pro v11 I would like to transfer to my other laptop but I don't have the original cd...
Replies
9
Views
3,457
I am Having Trouble copying MultiProject files from my Laptop,(#1) to my external Harddrive, then to my other Laptop,(#3). I do the same thing/s I...
Replies
6
Views
3,107
Back
Top Bottom