Sign in to follow this  
Followers 0
RalphW

Data smoothing with CPM2A

10 posts in this topic

Greetings, I have 2 questions, one specific, and the 2nd more general… Specifically: CPM2A, AVG instruction. What governs the sample period? I’m running an application where I want to “smooth” out my reported machine RPMs. I want to sample the max samples, i.e. 64, but I can’t determine what the sample rate the instruction is using. The book doesn’t say and I’m assuming it’s program scans, but I need to be sure. In general: I really need to filter out sudden spikes and drops in a value. The closest I have found with the CPM2A is averaging it out, but my confusion on the sample rates makes me want more. Are there any better "data smoothing" routines? I need to avoid sudden jumps while still maintaining the responsiveness (within 1/2 - 1 sec) of the system. Thanks, Ralph

Share this post


Link to post
Share on other sites
Ralph The sampling is per PLC scan for the AVG function. Unfortunately, you cannot manually control the sampling. You could use indirect addressing to log samples into consecutive memory area, then sum the data and divide by the number of samples to create your own controlled sampling averaging. Once you had this, you could examine the data before you put it in the averaging to see if it was within the acceptable range, and toss it away if it is not. You would want to keep track of how many consecutive samples were thrown away to determine when to consider the samples as good, not just anamolies.

Share this post


Link to post
Share on other sites
You could also toss away the highest and lowest before doing the averaging calculation.

Share this post


Link to post
Share on other sites
Thanks, That answered my main questions... I wound up writing my own so I could adjust the sample rate. Working well so far. Thanks again. Ralph

Share this post


Link to post
Share on other sites
My question is Why are you getting sudden spikes/drops ?????

Share this post


Link to post
Share on other sites
I'm activating cushioned hydraulic cylinders. I'm measuring the fact that the attachment on the cylinder has "grabbed" something and I using a pressure switch to see the spike in the pressure indicating that I now need to stop the cylinders. If I put a large enough pressure switch to mask out the initial pressure spike that I see from pushing the cylinder off of the cushions I don't always see the grab portion. Putting in a "debounce" on the pressure switch doesn't always filter out the spikes. I settled on a 0.1 second, 64 sample, running average to filter it out. It's working in tests, but hasn't been put into production. Ralph

Share this post


Link to post
Share on other sites
I'm not a CPM2A user so I'm not sure if the math instructions available. See below for one such filter for analog values. Filtering.txt Edited by Mickey

Share this post


Link to post
Share on other sites
Wow that seem great to smoothen values . CPM2 dont allow ST but that could be done with ladder. Thx i am sure i will use it one of these day.

Share this post


Link to post
Share on other sites
I had the exact same requirement to smoth out signals from a flowmeter to show on a small HMI. The [AVG] instruction is about as useful as... I dunno, Paris Hilton (utterly useless) when your intuition tells you it ought to be ideal to use. The reality is to write yer own. By the way, that algoritm: FV=FV+C(NV-FV) is excellent. Edited by MuttsNutts

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0