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?
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.