Siemens S7. Copy Array To Array

MarkNightingale

Lifetime Supporting Member + Moderator
Join Date
Sep 2010
Location
In The VAT Shed
Posts
740
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 the contents of array 1 into array 2, and then copy array 2 into array 3, and so on.

I am using a BLK_MOVE, and I only seem to be copying the first INT.

Is there a way to copy the entire array to a different array in the same DB?

Cheers

Mark

Array Copy.png
 
Morning,

Attached is the array DB and the UDT.

LD, Would I have to do use that code for each copy from one array to another. I am going to be copying 40 UDT's, so could be quite a lot of code.

I will carry on playing this morning.

Cheers

Mark

DB600.png UDT.png
 
My code snippet loads the array element values before and after the block move to show that the block move has functioned correctly. Your ladder is correct. When you say 'seems to be copying the first int' you need to put some test data into your arrays and know what happens.


Do you not have SCL available?
 
In the screenshot in post 1, the pointer address is not displayed at the 1st BLKMOV at SRCBLK.
I wonder if something has gone wrong at the time of writing the code.
Were you editing the Mash_Enzy_Dose_Records DB at the same time ?
When you opened FC321 for adding the BLKMOV code, were both Enzyme_Dosing_UDT and Mash_Enzy_Dose_Records saved and closed ?

Try to start all over.
Also, as LD asks, if you have SCL it will be much easier to put in a FOR loop rather than writing 50 individual BLKMOV's in Ladder.
Something like
Code:
FOR i:= 49 to 0 DO
  "Mash_Enzy_Dose_Records".Record[i+1] :=  "Mash_Enzy_Dose_Records".Record[i] ;
END_FOR ;
And that is all !
 
Hi LD,

I have been playing around this morning.

I have got a DB, that is the live running data. This is DB500.

I try to BLK_MOVE this DB into the first part of my array DB600[0].

This is the part that isn't working.

When I put values into DB600[1], these are copied into DB600[2].

I might have to make my live values DB600[0], unless there is a way to copy DB500 into DB600[1].

I hope that makes sense.

Cheers

Mark
 
Hi LD,

I have been playing around this morning.

I have got a DB, that is the live running data. This is DB500.

I try to BLK_MOVE this DB into the first part of my array DB600[0].

This is the part that isn't working.

When I put values into DB600[1], these are copied into DB600[2].

I might have to make my live values DB600[0], unless there is a way to copy DB500 into DB600[1].

I hope that makes sense.

Cheers

Mark
Post your code.
Anyway it is easy. The data in DB500 must be defined by the same UDT as the data in DB600.
 
Hi Jesper,

Thanks for that for loop. Makes things a whole lot easier.

Just a quick question. How would I make that code run once when an input goes high?

Sorry for the basic questions, I'm an AB guy.

Cheers

Mark
 
In the below code I assume that "some_DB".livedata is the data in DB500 defined by the same UDT.

Code:
IF input AND NOT input_mem THEN
  "Mash_Enzy_Dose_Records".Record[0] := "some_DB".livedata ;
  FOR i:= 49 to 0 DO
    "Mash_Enzy_Dose_Records".Record[i+1] :=  "Mash_Enzy_Dose_Records".Record[i] ;
  END_FOR ;
END_IF ;
input_mem := input ;

edit: Using UDTs to organize your data makes life a lot easier.
SCL is also very well suited to tasks like this.
Also, the use of UDTs should be familiar for someone working with AB, and Siemens SCL is very similar to AB ST.
The SCL editor and testing of code in STEP7 Classic is a bit clunky, but still much better than trying to do this in Ladder.
 
Last edited:
Thanks for all your help Jesper and LD.

Everything is now working as expected.

I got rid of the 'Live' DB and wrote my live data to array [0].

It was then a simple case of using the FOR loop to copy my arrays.

Again, thanks for your time and help.

Cheers

Mark
 

Similar Topics

Hi All, I am currently writing a new function in SCL, And I have a array at 300 bytes (tmpArray[0..299] OF Bytes) to this function. Questions...
Replies
3
Views
3,428
I am just picking up Siemens Step-7 after years of RsLogix, and I am shocked i cant do the most simple things with arrays. This has screwed up...
Replies
21
Views
23,124
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,696
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,392
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,155
Back
Top Bottom