Adding values in an array

I want to total all the values in an array, and apart from the CPT function I have tried he FAL function as per picture. It works but subsequent enabling of the tag toggletag obviously adds to the existing total which I dont want to do. Any ideas?

FAL.JPG
 
Yes, there several methods to do this. Most obvious would be to use the "done" bit. Use the FAL DN bit to disable the Toggletag. When FAL is "Done", a FAl DN XIO instruciton disables the FAL rung, leaving the "Total" value set.

Then, you probably would want to add some way to reset the FAL, maybe on the First Scan.
 
Yes, that is exactly what you need to do. Turn off the FAL instruction, once your value is stored in the "Total" memory location, so that it NEVER changes again. That is what you said you wanted, correct?

Another method is simply to insert a One-shot instuction after the ToggleTag XIC, so that FAL only operates one time.

That is, if your original assumption was correct, that you only want FAL to operate once, then quit.
 
You need to zero out 'total' before you run the FAL. I don't remember how an FAL configured in ALL mode operates anymore. It may finish in one scan or it may take more than one scan. Either way, try this thought:

Have a bit that triggers the FAL (let's call it 'trigger'). You will need some control over this bit. I THINK the FAL is edge sensitive so you just need to pulse the FAL and it will run to completion. In a branch around the FAL, put an OTU of 'trigger'


On the .DN bit of the FAL, move 'total' to 'saved_total' and clear 'total' IN THAT ORDER. Also, set 'trigger' using an OTL (assuming you want to run the FAL as fast as allowable).

You will need to put a normally open of S:FS in parallel with the normally open of 'trigger' to get the thing started when you start the PLC.

Hope this helps.

Keith
 

Similar Topics

Is there a work around to storing numbers larger than 16,777,215 ? I was adding 1 to the value of L9[0] and putting the result into L9[0]. Add 1...
13
Replies
3,990
Views
Hi All, I want to take values from a DB say four separate values of db100.dbw10 + db100.dbw12 + db100.dbw14 + db100.dbw16 and add them...
3
Replies
2,045
Views
Hello I'm intermediate programmer who is wondering if somebody is able to point me in the right direction in getting a few values in a readable...
17
Replies
9,413
Views
Hi, There is a compare block being used 1100 times to compare variables to a constant value -999. The problem is that the GE is changing the -999...
2
Replies
2,697
Views
Hi there, I have an expression N24:[N24:0], which places a value in data file N24, these values are indexed with reference to N24:0 according to...
2
Replies
3,900
Views
Top