Siemens Step-7 :- Array copy

SirLightBulb

Member
Join Date
Jun 2008
Location
Coventry
Posts
11
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 much of my design.

Its so fundemental, I can't believe there is not an answer out there.....so can I crib :oops:

I have a 100 element array of Integers.

I want to
copy A[99] to A[100],
copy A[98] to A[99]
down to
copy A[1] to A[2].
HOW?


My "sin" is that I want to mimic product moving down a machine, and tracking any "reject reason" as is moves.

I am looking now at using LAR and pointers, but reference so far is a bit cryptic. I will continue to battle, unless (y)(y)

I was alsoshocked to discover I could not do things like A[x] := y;

Its standard with rsLogix with CPY statement.

Off Topic
In "research" I see SCL is an option (a lovely one, again built into RsLogix). Is this an add on or separate?
 
Hi Sir Bulb

I think 95% of this problem is human nature rather than machine or technology.
You must have 101 examples of things that shock you that you can do in RSLogix that you apparently can't do in Siemens.
I'll bet every experienced Siemens user here has a 102 examples of things that shock them about the apparent shortcomings of RSLogix.

I don't think there's enough information for a definitive answer to your requirement at this stage.
How about the Siemens system function SFC20 "BLKMOV". That allows you to pick up a big lump of data and drop it in to a new location. One hundred integers? Easy. Or rather, ninety-nine integers, and then slot in a new value in location 0 (or 1?). I don't think I'd look towards individually moving 99 integers one-by-one in sequence unless there's a added purpose we don't know yet.

More info in = better advice out :)
 
SCL is an add on.

Where is the array - static data or global db ?

Example implementation attached using global db's
 
Last edited:
Hi Sir Bulb

I just took things like
A[x] := Y;
would be standard.
What is point of arrays if
A[2] := Y; is all you can do.


Perhaps easier way to explain is via diagram. (hopefully attached)

I could do each element individually with ten element array, but 100?, 1000?

L D[AR2,P#0.0]

Thanks for example.
When I looked at "BLKMOV" I could not work out
a) The size of data to transfer
b) Whether I could use source and destination the same.
I think you have explained both.......Off to play :)

I think rung 1 says "Move 99 Integers, starting at 0 to temporary array starting at 1.

I suspect I may get away with one move, to same destination if I want to do 99->98 etc rather than 98->99. I am guessing the latter would initialise an array to the value contained in 99.

Array.jpg
 
No, you cant do that. Read blk moves help.

Im sure we all agree with you that it would be nice to do indexes in ladder too, but for now it's SCL only. Btw, SCL is as much part of step7 as ST is part of rslogix.

STL can be used to index too, but its little harder.
 
Last edited:
Example:
Code:
      CALL  SFC   20
       SRCBLK :=P#DB25.DBX 60.0 WORD 8
       RET_VAL:=MW124
       DSTBLK :=P#DB110.DBX 102.0 WORD 8
Start adress for source is DB25.DBX 60.0.
Length of data to be copied is WORD 8
Same for destination.

SCF20 copies top to bottom.
So if you want to move things down, you'll have to use a temp block.
Example:

Code:
     CALL  SFC   20
       SRCBLK :=P#DB1.DBX 0.0 WORD 100
       RET_VAL:=MW124
       DSTBLK :=P#DB2.DBX 2.0 WORD 100

     CALL  SFC   20
        SRCBLK :=P#DB2.DBX 0.0 WORD 100
        RET_VAL:=MW126
        DSTBLK :=P#DB1.DBX 0.0 WORD 100
You can use source and destination in the same block, but there are specifics you need to be aware of if the ranges overlap.
 
Maybe standard block FC85 (FIFO - a First In First Out) shift register will be able to do what you require. It will allow you to load a datablock with a value on a trigger (say a 'product present' sensor) and then index the value through the datablock (maybe on a conveyor clock pulse or machine clock pulse) and then you can interrogate the datablock at a given address which should correspond to a physical place on the conveyor/machine.

Is it something like this that you're after or have I misunderstood.?
 
Thanks again. (upTown)
I think FC85 may do the job if I was using standard memory. My array is in a datablock.

What I am trying to do (and think I have a verbose solution thanks to other help) is basically a shift-function, but rather than shifting bits I am shifting Integers
 
Please excuse my terminology. Pretty new to Siemens and still cant get head round concept of address based systems, rather that symbolic based I have been spoilt with for 30 years.

What did I mean.....tricky :)
Basically, accessing memory areas like M0.0,MB1,MW2 (standard memory)
as opposed to DBs......ie, memory I dont (or should not) need to know about its address. Where does DBx exist?.........I dont care.

As for problem "in hand". I have developed some code that "does the job".
What I think I need to do is have a massive comment in DataBlock saying "Dont move or increase size" as calls to SFC20 use absolute addresses.
I also intend to put the arrays (illogically) at the top of DB as then I can add other fields when required.

Is there anyway I can state
p#DB_xxx.Tracker[0]
rather than
P#DB1.DBX 6.0 DWORD 199

I doubt it, so OTT comments needed.
 
... but rather than shifting bits I am shifting Integers

Yep, FC 85 will shift integers as LD has demonstrated. It's really easy to implement. You can use another block (FC84?? May be wrong. But there's another block that will set up the size of the shift register etc).

I've used the FC85 before for similar stuff and I think it's worth you looking in to it.

Each address in the Datablock will then correspond to a real world position.

So... if the product fails inspection at DW20, load in a 99 into the shift register.

At DW80 (where the rejector is) do a comparison and if DW80 is equal to 99 then fire the rejector etc etc..
 
Yes, this is possible. I'll post an example later.

If you can I owe you 🍺......make that 🍺🍺

I have just re-organised my Datablock and all references needed modifying. (plus some references to a UDT within DB lost symbol, but kept original address).

I do suspect I have a bit of learning curve to know tricks and what to avoid.

All I am trying to do, is implement (at simplest level) a product tracker.
eg
A[12] = Product Detect
A[29] = Product Test.
A[38] = Product reject.

Its even an indexing machine and not even continuous!!
 
Missed your reply UpTown.....EXACTLY what I want to do.

I know its familiarity, but AB had CPY(src,dest,size).
Only buggeration was array was backwards (machine started at 100, and ended at 0). To do "logically" you ended up with a pre-initialised array to the value at location 0!

I (ALSO) just cant believe
Tracker[TP_FailVision] := Tracker[TP_FailVision] OR RR_VisionFault;
is not possible.
ie...... mark the product "bad" if at the Tapping_point of the vision system it fails the test.
 

Similar Topics

Good Morning. I would like to know how you can convert a string to a barcode from string to char. Basically my reader barcode reading puts me in...
Replies
1
Views
2,052
Hey i have a array [1..10] that holds an other array with [1..10] real I wonder if there is an easy way to compare those 100 values? I want to...
Replies
3
Views
6,486
Good Morning, Hoping someone with some Siemens experience can give me a hand with this one. Customer has a S7-200 cpu, which has a 6GK7...
Replies
0
Views
265
I'm just trying to figure out the right method of adding a DO card to an existing rack. It's not the *next* open slot, but I have to move the AO...
Replies
5
Views
567
Hi Siemens Experts, I am hoping someone can shed some light on my issue. I have uploaded the code from a S7-300 (317-2PN/DP) using Step 7...
Replies
9
Views
707
Back
Top Bottom