s7-1200 db array shift

dwoodlock

Lifetime Supporting Member
Join Date
Nov 2012
Location
Cincy/nKY
Posts
563
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 compare.

In my DB I have:

memory.pressure current
memory.pressure 0
memory.pressure 1
memory.pressure 2
.................
memory.pressure 9

Instead of using a move instruction for every one of these integer values at the end of every cycle is it possible to just shift everything in the db that starts with "memory.pressure"

Just trying to write the logic more efficiently. I have already written it with the 11 move instructions, but as I was doing it, I was thinking that there had to be a better way.

Thank in advance.
 
A cirlular "log"? Dont move the array, just the pointer to where you are?

But... Do you really need this? Will you have any cycle time problems if you do it "inefficiently"? If not.. Making it faster is actually inefficient, because, you are wasting time in solving something you don't have to solve... Plc's got a lot faster and "memory bigger". Use it.
 
You can do loops with indirect addressing instead of programming it by hand, but for 10 moves doing it by hand is much simpler. I'm not aware of a built in instruction like FIFO or LIFO that would shift whole arrays for you.

The Oscat library might have some source code you could adapt, but it hasn't been updated for portal yet.
 
I am newer to using DB's in programming, so I am just asking questions as I come upon them.

Thanks for all the suggestions.
 
You could do it with circular buffer. It's well known data structure. Pretty easy to implement. Tons of examples on google for other programming language.

Define your data area and buffer size. Set current value pointer to start of data address. Set current size to 0. Choose your buffer behavior, overwrite old values or dont. Google explains it better than me. It's pretty clear once you implement it in any language.
 
After messing around with this using the simulator today, I was able to find a good solution in the available instructions.

I created an Array of 10 integers in my memory DB.

"memory".Pressure[0..9]

I am then able to use the "MOVE_BLK" instruction to copy the 10 elements of that array, and then OUT them to "memory".Pressure[1]

Essentially just performing a copy and paste with an offset of 1.

Perhaps this will help someone in the future.

Thanks for all the tips.
 
Thats a good idea. I didn't know move_blk allowed the source and destination areas to overlap. I'll have to remember that. Thanks for sharing your solution!
 

Similar Topics

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...
Replies
6
Views
3,562
An interesting read for 2 hidden functions that i hadnt seen before...
Replies
2
Views
3,537
Hi, I have attached herewith one image which our programmer has been used in S7 1500 PLC. Now we need to use the same instructions in S7 1200 PLC...
Replies
4
Views
111
commentaire communiqué siemens s7-1200 avec vfd delta ? (cablage et sur tia portal )
Replies
0
Views
80
Hi, I have a 1214 on ip 192.168.0.100. This is connected to other modules through a switch on same network. I need to connect this to a company...
Replies
1
Views
140
Back
Top Bottom