Totaling long string of integers

ilikbeer

Member
Join Date
Oct 2004
Location
Defiance, Ohio
Posts
101
Have a Micrologix 1400
Have a lot of integers I am moving in to FIFO to do average speeds on
Found out from reading a Q/A from Bernie Carlton how to make the "Long Word" so I should now be able to get a very close average to actual machine speed, that is if I could add enough integers together.
Is there a better way, in RSLogix to add a bunch of integers together, other than using compute, which did not allow enough, in my opinion.
I have all the values in N11:10 thru N11:28 but would like to go even further out if its possible.
Probably a simple instruction, that I am missing, but help would be appreciated.
Thanks
 
If you're careful, you can clear your sum and your FIFO on startup.

Then add each sample to your LINT sum as it is recorded, FFU (unload the oldest) from the stack, then take the unloaded value and subtract it from the sum, then FFL the new sample onto the stack.

Then divide the sum by the number of samples in the FIFO.

This method can give you whacky results if you don't do it exactly right, but working with integers, it should be a very solid method for you.
 
Thanks for the reply!

The averaging I am using is working fine and gets me close to the actual number I just want to get closer with a larger sample.
Isn't there a way to have all the integers in "N11:10 thru N11:50" add together?
Or am I missing what you are already telling me.
 
The advantage to the method I described is that it will work with a larger number of samples without much modification.

Here's my method again written out a little better:
SUM-long integer (32 bits)
OLDEST-integer value that is unloaded from the FIFO
SAMPLE-newest data

1. On first scan, or startup of the process, clear all the FIFO data and the SUM. Use a FLL (Fill FIle) with a source of zero, a destination to the first address in the FIFO file and a length of whatever you need for the application. CLR the SUM (or MOVe 0 to it). CLR the FIFO control position.

2. Take a sample at the appropriate interval. If the FIFO is DN and not EMpty, then unload the oldest value (FFU) to OLDEST, and subtract it from the SUM.

3. FFL the SAMPLE into the FIFO.

4. Add SAMPLE to SUM.

5. DIVide the SUM by the number of samples.

Now, it might be desirable to have an accurate average before you even have fifty sample accumulated, so you can use the FIFO control word position as your divisor so if you only have summed 5 samples, you will divide by five.

See attached example...
 
If the process generally runs at the same rate, you "prefill" the buffer with the old average on the first scan and load the SUM register with the average times the buffer size.

Then you are always working with a full buffer and are always dividing the sum by the same value.
 

Similar Topics

I have Allen Bradley plcs, I have had Circuit breakers and other automation equipment in the past. There's no solid buyers local. How much do you...
Replies
2
Views
202
I have a question. I work in a very large plant and this one (of many hundreds of control cabinets) contains one 5580 (1756-L83E), two 1756-L73...
Replies
6
Views
202
Hi to everybody. I need to read the first 12 characters of the message that a barcode reader sends to the ascii card (1734-rs232 ascii) and I...
Replies
8
Views
725
Hello all. This is a very lonnnnnnng shot but worth a try. I have an OMS Group Impact100 metering machine. At this customer it blows foam into 3d...
Replies
0
Views
185
Anybody have a recent experience becoming a UL508A panel shop? If so, how long did it take from initial contact to being able to apply stickers...
Replies
3
Views
1,232
Back
Top Bottom