RsLogix 500: Summing values in a buffer

quadPLC

Member
Join Date
Feb 2010
Location
Milwuakee
Posts
51
Hi guys,
Fairly new to RxLogix/PLCs here. I am currently working on a project where I have a FIFO buffer that I have populated (lets say, up to 6 values). I also have a register (number_of_elements, we shall call it) that stores a number (say, 1-6).

The value of the latter register determines how many of the elements in the buffer to add.

I figure, since I know the base address of the buffer, and have a register to use to calculate the offsets, I can calculate the sum of the first X values in the buffer. However, my problem comes with the fact that the number of ADDs I need to do will change depending on the value in the number_of_elements.

Thoughts? I have some ideas on how to do it but, per usual, they are pretty hack-ish.
 
The simplest way may to be to keep a running sum. When you insert a new number into the FIFO add it to the running sum. When you remove a number from the FIFO subtract it from the sum. See the FIFO example in the program posted here. This also avoids having to sum everything every scan.

You could also use a for/next loop but for only six values brute force will execute faster than a loop.
EQU numregs 0 CLR SUM
GEQ numregs 1 MOV N11:0 SUM
GEQ numregs 2 ADD SUM N11:1 SUM
GEQ numregs 3 ADD SUM N11:2 SUM
GEQ numregs 4 ADD SUM N11:3 SUM
ETC.
 

Similar Topics

Hi Everyone, I am not proficient in RSLogix 500 so I have a question regarding the evaluation of N7:0 data as an input. So as I understand in...
Replies
1
Views
81
I have a little bit of experience with Allen-Bradley. I have a Micrologix 1500 (RSLogix 500) and a PanelView Plus 7 (FactoryTalk View Studio ME)...
Replies
3
Views
161
buen dia. tengo una falla al pasar los tags de mi plc SLC 5 0/4 a mi panel me aparece un error Problem writing value " " to item <tag name>...
Replies
1
Views
81
Will someone please convert this logic to pdf?
Replies
2
Views
127
Hello, Haven't been on in a while. I need to generate a bit level pdf of the I/O for RSLogix 500. I can generate a report but it just shows the...
Replies
1
Views
158
Back
Top Bottom