S7-1200 Array/indexing help!

lostcontrol

Lifetime Supporting Member
Join Date
May 2009
Location
NeverSayNever
Posts
1,071
Hi,
We are developing an application on a S7-1200 that we have to use MB/TCP with.
All is working ok, but we need to transfer recipe data from the MB/TCP inerface to the PLC.
The current config has a DB with array elements inside of it..
- DB10.Array[0].x
- DB10.Array[0].y

Because of the MB/TCP interface, I have to manually assign a %MW tag & copy it into the DB array, based on my understanding.

So I have DB10.Array[0].x := MW100; (where Tag MW100 = %MW100

Ideally, I would like to be able to loop copy this of block transfer it to minimize typo errors etc, but not sure how I can do this with a %Mw100 reference.
At the moment, there are > 100 array elements that I need to copy, & is a manual process.

Do I make sense, is there an easier way?
 
Hi there!

If I understand it well, you want to copy memory words (MW) into DB word array.

You could use PEEK and POKE in a FOR loop in SCL. They read and write bytes, so you have to calculate how many do you need for your words.

Code:
FOR #index := 0 TO #nr_of_bytes_to_transfer DO
 
#value := PEEK(area:=16#83,          //16#83 bit memory
               dbNumber:=0,
               byteOffset:=#index+#byte_offset);

POKE(area:=16#84,                    // 16#84 DB area
     dbNumber:=10,                   
     byteOffset:=#index,
     value:=#value);

END_FOR;

I did not test this, so you will have to.
 
Last edited:
I've just found out that you can replace PEEK with PEEK_WORD (POKE with POKE_WORD) so you can work strait with words.
 
You could probably just use a block move as well, if you are simply moving a chunk of memory from one area to another. No need for a loop, it's just one command.
 
I've just found out that you can replace PEEK with PEEK_WORD (POKE with POKE_WORD) so you can work strait with words.
thanks! will have a look to see what I can make work.


You could probably just use a block move as well, if you are simply moving a chunk of memory from one area to another. No need for a loop, it's just one command.
This sounds easier, even though I would like to learn SCL.
So I assume it would be something like BLK_MOVE %MW20 DB20.0 #20 ?
 
Hello!

I use TIA V11 SP2 Upd5 for programming S7-1200 PLCs.

As I know, here you can have only array elements for IN and OUT of a MOVE_BLK block. Cannot use pointers as with the other S7s.

E.g. if you want to move 100 words from MW0 to MW99 into an array, how you going to input these words as an array element in MOVE_BLK?
 

Similar Topics

An interesting read for 2 hidden functions that i hadnt seen before...
Replies
2
Views
3,547
Hello all, I find myself writing some new logic and I am storing records of analog values so that it will be possible to look back on them and...
Replies
7
Views
3,178
Hello, I have a question about an encoder that has absolute measurement. Specifically, it's the Lika SMA5, which I would like to connect...
Replies
2
Views
43
Hello, I have a question about an encoder that has absolute measurement. Specifically, it's the Lika SMA5, which I would like to connect...
Replies
0
Views
26
Hi all, Currently having trouble getting a speed reference to write over modbus to an Omron M1... I can successfully write a run command and...
Replies
6
Views
261
Back
Top Bottom