Shifting an array in Logix 5000

Here is an example using Cop on a 2 dimensional array, to test the movement I am adding Time to the first DINT at array position 20

2020-05-29 00_13_15-RSLogix 5000 - T_PLC [1769-L32E 20.19]_ - [MainProgram - Data_Shift_].png
 
Resurrection warning for more info dumps.

shift.PNG

input 27 is the conveyor flag sensor watching pulses (programs are never marked well are they).

I'll add this because It was something I didn't even catch when trying to see how it was being accomplished within the program. for conveyor tracking, an item is given an array of numbers based on how many pulses it blocks a photo eye on a conveyor. while pulsing (flag and inductive prox), every pulse it will copy back and forth the same two arrays, one being a holding array. so that every pulse the data is shifted by one.

this is used to track the location of the product on the conveyor so that it can be pushed into the correct pathway as it travels down the system without using any other special vision systems.

the product id array is being populated by product passing in front of the sensor, and the information being put into the array is the code of the product. so that when the array passes the product information down the line. if it passes in front of a lane that needs that product, it will flag the lane, see the right product, and know when to push it down based on it's tracked location. Pretty smart way to track and send product IMHO, but it fits with shifting arrays for the thread.

BTW this task is a 5ms task in a large program, and it has no issues bogging down mid cycle or missing shifts.
 
Sweet!

TL;DR

It seems odd to see two possible sources of the pulse to the CPS instructions, but I am guessing that Input 27 plus the ONS instruction is the normal pulse source when the motor is running, and the other is to clear out the product ID array when the motor is not running over the course of 5s (500counts * 10ms/count; 10ms = two 5ms executions to toggle ClearArray.CU; 500 steps to turn on ClearArray.DN).

Presumably there is other logic to reset ClearArray.

Note that CPS does not copy arrays in toto (compare memcpy(3) with memmove(3)), but rather is a sequential copy of elements between arrays (cf. Example 5 here), which is why the two CPS instructions using the Conveyor_Swap temporary array is necessary to shift array elements to a higher address in the same array; only one CPS instruction would be needed if the shift were in the opposite direction, but then the element representing the most upstream position on the conveyor would be at offset 499 instead of at offset 0; the logic would work the same way, but would also be slightly more confusing to understand and debug.
 
Sweet!

TL;DR

It seems odd to see two possible sources of the pulse to the CPS instructions, but I am guessing that Input 27 plus the ONS instruction is the normal pulse source when the motor is running, and the other is to clear out the product ID array when the motor is not running over the course of 5s (500counts * 10ms/count; 10ms = two 5ms executions to toggle ClearArray.CU; 500 steps to turn on ClearArray.DN).

Presumably there is other logic to reset ClearArray.

Note that CPS does not copy arrays in toto (compare memcpy(3) with memmove(3)), but rather is a sequential copy of elements between arrays (cf. Example 5 here), which is why the two CPS instructions using the Conveyor_Swap temporary array is necessary to shift array elements to a higher address in the same array; only one CPS instruction would be needed if the shift were in the opposite direction, but then the element representing the most upstream position on the conveyor would be at offset 499 instead of at offset 0; the logic would work the same way, but would also be slightly more confusing to understand and debug.

thats accurate. instead of just trying to write 0 to clear the entire array, they just let it do it based on scan times until the count is complete. once the count is done then it will stop writing 0 to the first array and doing the array swap.

The typical way the rest of the program works is that the first array [0] is always having 0 written to it unless there is product there that the cognex cameras can grab the barcode from, so as long as there is no present product then there is no number to be put it and it automatically clears back to 0 at all times.
 

Similar Topics

Hey guys, Again, another question I have that I can't seem to find the answer in the search. I am writing a program to go along with my...
Replies
5
Views
16,254
Greetings, I am trying shift data in an array (such as Array[0] is shifted into Array[1], Array[1] is shifted into Array[2]......all...
Replies
10
Views
363
Hello Guys, I think I need to use SCL for the following task but am very weak using SCL in tia portal. I have results history data block. It is...
Replies
14
Views
3,044
Hey guys, What do you suggest for doing a shift of dints within an array like this? Thanks, Kevin
Replies
12
Views
2,585
Not sure if this is possible but thought I would put it out there. Using Rockwell Studio 5000, is it possible to shift the address of an array...
Replies
7
Views
2,102
Back
Top Bottom