How to move data in array instead of overwrite?

backendcode

Member
Join Date
Aug 2017
Location
brampton
Posts
249
Hello Guys, I have sensor on the conveyor and everytime when part hit that sensor, i want to know the date and time and how long part stayed there after it hit the sensor. So i wrote the following code. Link is below and It gives me what i want

https://ibb.co/h6SPdk

Now problem is everytime, when new part come. it overwirte my previous date/time and time stayed information. I know I need to move the data everytime to new cell of my array but how Can i do that?

Thanks
 
Hi, I don't know your PLC brand (I use Siemens) but you need only to put a integer variable instead of the 0 in the array index.
This variable should be incremented (+1) with a trigger. The trigger is, for example, a falling edge on the TON output. So, when the cart leave, if I well understood your process, the variable is incremented.

For sure I'm not able to understand at 100% your code (is it AB PLC?) but the concept should be correct: you need an integer variable as array index to increment every time.
Remember to put a control on that number: you want to reset it to 0 at a certain value (e.g. if variable > array dimension then variable = 0).
Hope it helps.
 
Copy info into last array element then Copy Array[1] to Array[0] for length of array -1. If your goal is to save the last 100 values. Then make your array length 101. That way you copy array 1-100 to array 0-99. All data has been shifted. It just that info is entered from the bottom of the array and shifted up.

You also can use a FAL to copy data in order. You would put your Time date as the expression. Then the destination would be Array[FALcontrol.pos] One Shot the FAL when you want to copy data. Make the length of the FAL the same as your array. The image below captures CycleTime and places it in the array CycleTimes_Hour. Once you Position reaches the end of the FAL length it will rollover and copy next value in position 0. If you need to reset the FAL you can use the (RES) to do so. This move the position back to 0. You still would have to clear the array data with another instruction.

FAL.PNG
 
Last edited:

Similar Topics

hi i have a baumer vision unit picking up a QR code this is connected to a siemens 1200 plc. i have a IB18 In the device that is the start of...
Replies
16
Views
9,315
Hi Guys I have completed a couple of applications with the Micro820 from AB so I thought I would use one for an automated test system. I have a...
Replies
12
Views
7,128
i try to move with one msg function array that i created in rslogix 5000 data type that have 1 int and one real but i have an error messege why?
Replies
1
Views
2,075
Afternoon, I have a DB in TIA Portal V16 that is optimised. I cannot change this. There is an array inside that block which consists of 3000...
Replies
9
Views
1,118
Hi, can anybody tell that how can we move floating point data from one Regiter to another register in Fatek PLC.?
Replies
0
Views
1,544
Back
Top Bottom