I’m not too familiar with the pac control instruction set so before I head down a particular path, I’d like to know from the community if there is an easier way.
I am using an R2 controller with a 2 analog input; one represent voltage, the other current and I need to monitor a moving average of the resistance (v/i). Calculating the resistance is done, but I’m not sure about creating the average. This is what it looks like I need to do… (this is not a question about how to implement a moving average, its about how to implement one in the controller)
Create a table variable and an index
Add a resistance value to the table using the Move To numeric Table Element instruction
Increment the index and reset to 0 if the table is full
Get the table total by looping through each value the divide the total by the number of elements in the table.
Again, I am not very familiar with the instruction set so am wondering if there are any built instruction to do what I am trying the do, or do I need to handle everything ‘manually’?
thanks for your time