Help with Clearing an array in CCW

Tim114

Member
Join Date
Apr 2018
Location
Cookeville
Posts
2
Hello all,
I'm working on my first project with an Allen Bradley Micro 810 using the connected components workbench. Everything is going well so far, but I've
reached a point where I can't seem to progress.

I am using a load cell(amplified) and a set of TON blocks to create an array with known time steps and recorded load cell values for each step. The Array is a DINT[0..100] and seems to be working fine. The problem I need to solve is that every cycle it needs to reset to zero initial value to be able to store new values from the load cell.

Since the COP command does not seem to be implemented in this build of CCW, I was trying to use a MOV to replace the terms of the Load_Cell_Array with an equivalent array of zeros. I have not succeeded in this and found an article on the Allen Bradley knowledgebase(#531939) that suggests using structured text to iteratively replace each Load_Cell_Array value with zero.

I do not yet know how to fix this using ST. I've cobbled together some code that I will paste below, but it shows several errors when I try to build.

If anyone has has a similar experience or has some input on this I would greatly appreciate it.

Thanks in Advance
-Tim




"
PROGRAM Zero_Array
VAR
i : DINT;
VarInput1 : DINT[0..100];
END_VAR;

FOR i := 0 TO 100 BY 1 DO;
VarInput1 := 0;

END_FOR ;

END_PROGRAM;
"

where 'VarInput1' is a connection point on the function block you select 'Load_Cell_Array'
 
Well your almost there, just some tweaking.

Make sure your "Load_Cell_Array" is GLOBAL, DINT, [0..100].

Now create a UDFB for Structured Text, and create the "i" index variable as DINT, within the function block scope

Place this code in the function block

FOR i := 1 TO 100 BY 1 DO
Load_Cell_Array := 0;
END_FOR;

Build (Should be error free)

Now anytime you want to clear the Load_Cell_Array just place this "ClearArray" function block on your ladder rung and it will clear the array.

I hope this helps.

ClearArray.jpg
 
Thanks for the input. It built correctly.
I had missed the part about creating a local variable in the custom block for i : DINT

build errors.jpg
 
Last edited:

Similar Topics

I have an old Sentry Palletizer (S/O Number 3007 / Serial Number 1172) that has lost its program as the backup battery died years ago. I can...
Replies
0
Views
86
Hello, I need to write the following program in Ladder language, but I could not integrate the Fibonacci sequence into the ladder. Can you help...
Replies
22
Views
458
this a program to send data to barcode printer I want to integrate a new printer in a new machine and i wanted to adapt the old prgram on it but I...
Replies
4
Views
172
So i've been at this for a long while, i have Citect Scada 2018, i have full access to everything but i can't seem to find any option or...
Replies
0
Views
64
Hi all, hope you are having a great day, I am in need of your help to create a AOI or program that does this kind of job: I have a IO Link...
Replies
26
Views
554
Back
Top Bottom