Performing Statistics on Input Values

Hi, I’ve just started using Opto, as it was recommended & procured by my company for a control system project. I can not find any built-in command that allows for the calculation of the average/mean, standard deviation, and variance of some analog inputs (temperature sensing using SNAP-AIRTD).

The idea is to stop the rig when a high variance (from the mean) exists on any temperature sensor.

Has anyone done something similar, or has applied control statistics with PAC control?

You’re right, Jude, there are no built-in commands to calculate those, however, I just uploaded a subroutine that will do all those. Check out the 2nd post [B][U]in this thread on subroutines[/U][/B].

That subroutine expects you to have a table loaded with the values you want to average, etc.
Have you already figured out how to collect such a sample? Will this change over time? Do you necessarily need something that fancy? Perhaps a simple condition of “Within Limits?” would work?

Any/all you could share about the details might help us give you more options and better answers.

You may also be interested in this thread on moving averages (includes a video!) especially if you can use the built-in totalizing functions available on your I/O unit.

-OptoMary

p.s. If you need some fancier stats done, check out [U][B]this OptoNews item[/B][/U] where one of our OptoFriends as coded a variety of other functions.

Thanks OptoMary. I used the OptoTutorial_File_Management_and_FTP to [B]‘just’[/B] figure out how to collect a table loaded with the temperature values. And yes the sample will change over time as I intend to log the data for research and control purposes.

[U]Details of the Project[/U]
The purpose of the project is to research into the failure modes of cams on an 18 cylinder engine. Just before the cams fail (they don’t all fail at the same time), there’s a spike/rise in temperature.
The method entails:

  • monitoring the temperatures using 18 rtd sensors
  • calculating the mean of all 18 temperatures (they should be similar as they are lubricated from the same oil feed)
  • calculating the variance from the mean for each sensor
  • stopping the rig by cutting the drive motor power, based on either:
    - positive deviation from the mean oil
    - or a very high temperature
  • indication after trip on which cam temperature is at fault
  • review of data logs for research (I’ll be logging various data i.e. motor current, oil flow, oil level, oil pressures, motor speed. I’ll automatically stop the rig if these other sensors exceed a set limit).

The hardware (modules, controller and sensors) have been specified and purchased.

What kind of response time do you need? If it is < 100 ms, you might want to build some timing functions in your charts to keep track of how quickly they are looping. 10 ms or so should be achievable, but it depends on how your strategy is built and how fast the communication with the external devices will be.