Technical Forum

STEP 7 Additional Software

How to copy data block in SCL

Thread Starter: prasad.sawantdesai   Started: 7/5/2013 10:49 AM   Replies: 20

« Previous thread Next thread »
123» Page 1 of 3 (21 items)
  7/5/2013, 10:49 AM
Joined 9/27/2012
Last visit: 12/4/2014
Posts: 53
Rating:
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Dear Experts,

How to copy data block in SCL?sad
 
For example I have data block of 1000 bytes and I need to copy 240 bytes consecutively in a separate data block(240 Byte).
Thanks in advance..

Regards,
Prasad Sawantdesai
Top
  7/5/2013, 10:56 AM
Joined 1/28/2009
Last visit: 12/18/2014
Posts: 4908
Rating:
Rated: Excellent [4.24 out of 5 / rated 752 time(s)]. (752) 
Users with special expertise supervising conferences
Rated: Excellent [5 out of 5 / rated 1 time(s)]. (1) 
prasad.sawantdesai wrote:
Dear Experts,

How to copy data block in SCL?sad
 
For example I have data block of 1000 bytes and I need to copy 240 bytes consecutively in a separate data block(240 Byte).
Thanks in advance..

Regards,
Prasad Sawantdesai


BLKMOV in SCL

Solution from Smiffy:



Best regards
Hamid Hosseini
Top
Thank you for this post from:
  7/5/2013, 1:51 PM
Joined 9/27/2012
Last visit: 12/4/2014
Posts: 53
Rating:
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Dear hdhosseini,


Thanks for the quick answer. It worked well...Rnf:lblSmileyTooltip_

Thank you so much.

Regards,
Prasad
Top
  2/17/2014, 7:47 PM
Joined 11/19/2013
Last visit: 6/23/2014
Posts: 353
Rating:
Rated: Excellent [5 out of 5 / rated 3 time(s)]. (3) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
new question is splittet to  Do you have this code but then for a s7-1200 plc (1214C).

Best regards / viele Grüße
GrasserF
Top
  10/17/2014, 1:48 PM
Joined 11/29/2011
Last visit: 12/18/2014
Posts: 317
Rating:
Rated: Excellent [4.38 out of 5 / rated 21 time(s)]. (21) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Hi, 

how do you define the ANY parameters if you want to copy data from a shered DB to a LOCAL varible?

Cheers:

It is a forum to share experience.

If I get help I use "Thank" and "Rate", to pay respect to the one spend time to help me. I suggest we all do that.

MicroMan
Top
  10/17/2014, 3:06 PM
Joined 12/16/2012
Last visit: 12/18/2014
Posts: 131
Rating:
Rated: Excellent [4.71 out of 5 / rated 7 time(s)]. (7) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Hi

I think that in the case of a LOCAL you have to write 0 in the DBNumber and 16#86 in the MemoryArea, but it has to be tested.

http://masteca.com/home/?lang=en
Top
Thank you for this post from:
  10/17/2014, 3:08 PM
Joined 1/17/2007
Last visit: 12/18/2014
Posts: 1047
Rating:
Rated: Excellent [4.44 out of 5 / rated 225 time(s)]. (225) 
Users with special expertise supervising conferences
Rated: Excellent [5 out of 5 / rated 2 time(s)]. (2) 
Similar to the above. You simply point the destination ANY pointer of your local variable.
The code below should give you some ideas.
Some points of note about the code.
i) In the form presented here it can only handle a maximum DB size of 8192 bytes. I can provide a solution that gets round this limit, but it nakes the code a bit harder to understand. If you want this option then tell me.
ii) The BLKMOV function will only copy as many data bytes as the destination variable will hold, REGARDLESS of how many bytes are specified at the COPY_LEN input. So in this example as we are copying to an integer, only 2 bytes will be copied.


Programming today is the race between software engineers building bigger and better idiot proof programs, and the universe producing bigger and better idiots.

So far, the universe is winning...
Top
Thank you for this post from:
  10/17/2014, 5:26 PM
Joined 11/29/2011
Last visit: 12/18/2014
Posts: 317
Rating:
Rated: Excellent [4.38 out of 5 / rated 21 time(s)]. (21) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
HI, 

Thanks. That was brilliant!

Cheers:

It is a forum to share experience.

If I get help I use "Thank" and "Rate", to pay respect to the one spend time to help me. I suggest we all do that.

MicroMan
Top
Thank you for this post from:
  10/20/2014, 10:16 AM
Joined 11/29/2011
Last visit: 12/18/2014
Posts: 317
Rating:
Rated: Excellent [4.38 out of 5 / rated 21 time(s)]. (21) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
HI, 

I have one last question. 

I found the "Type" description in the Hans Berger book, under Indirect Adressing ANY pointers chapter. It make sense now. But there is one last thing about byte address.LSB, MSB.

In the case I copy bits organized into words I change the type to 16#04, but what is the significance of the ByteAddressMSB/LSB?


  1. pAnySRC.S7Code := 16#10;  
  2. pAnySRC.DataType := 16#02;  
  3. pAnySRC.Length := COPY_LEN;  
  4. pAnySRC.DBNumber := 1;  
  5. pAnySRC.MemoryArea := 16#84;  
  6. pAnySRC.ByteAddressMSB := 0;  
  7. pAnySRC.ByteAddressLSB := INT_TO_WORD(BYTEADDR * 8);  


Thanks for the briliant help!
Cheers:

It is a forum to share experience.

If I get help I use "Thank" and "Rate", to pay respect to the one spend time to help me. I suggest we all do that.

MicroMan
Top
  10/20/2014, 11:24 AM
Joined 1/17/2007
Last visit: 12/18/2014
Posts: 1047
Rating:
Rated: Excellent [4.44 out of 5 / rated 225 time(s)]. (225) 
Users with special expertise supervising conferences
Rated: Excellent [5 out of 5 / rated 1 time(s)]. (1) 
They are the memory address to be referenced.
It is bit-wise addressed - that being it uses 1 address per bit. So address 0 = byte 0, address 8 = byte 1. That is the reason for the *8 as BLKMOV can only work with byte alligned addresses.

So to give you a 0-65535 address range with byte addressing you will need 16-bits, but as it is bitwise addressing you actually need a 19-bit address (65536 * 8 = 524280 = 2^19 = 19 bits).
If you look at Mr Berger's book page 412, you will see that the address pointer actually consists of 19 bits spread over 3 bytes (with 5 bits unused). So have split this down into a low address word and a high address byte.
The low address (ByteAddressLSB) handles the address range of 0-2^14-1 = 0 - 16383
The high address (ByteAddressMSB) handles the address range of 2^14 - 2^16 = 16384 - 65535.
So I have been a bit lazy as I have not bothered with the highest 3 bits of the address (the MSB) as it is very rare that you need to access addresses over this number (16383) in a DB.
The foolproof way would be to bit shift your byte address left by 3 (ensuring that the vacated bit positions are zero filled) and then split the resultant address into a word and and a byte thus:-
Address : DWORD;
Address := MyAddress * 8;
ByteAddressMSB := Address AND 16#0700; // Only take bottom 3 bits of 3rd byte (bits 16-18)
ByteAddressLSB := Address AND 16#FFF8; // Only take bits 3-15 (stripping out the bit address)

Programming today is the race between software engineers building bigger and better idiot proof programs, and the universe producing bigger and better idiots.

So far, the universe is winning...
Top
Thank you for this post from:
123» Page 1 of 3 (21 items)
Actions