Div_by_zero

best way to filter an analog reading

11 posts in this topic

I wasn't quite sure how to write the subject line. I'm not necessarily trying to "filter" an analog input (or rather, an analog input scaled into engineering units) as I've already done that, but rather I want it go go up and down in 5 integer increments and not 1 integer increments on the HMI. Currently, the input is scaled into a float, and everything to the right of the decimal point is thrown out in the HMI, so it goes up and down by 1, or as little as 1 I should say. What is a good way to code it so that it goes up and down by 5, or whatever I chose? I'm displaying a parts-per-million value which is often 25,000 or more, so an increment of 1 is annoying to watch on the screen, and in my application quite silly, actually. Thanks for any help here! (For what it's worth, I'm running an AutomationDirect "Click" PLC and a C-More EA9 series HMI.) Edited by Div_by_zero

Share this post


Link to post
Share on other sites
How is it incrementing currently? I don't have the software installed at the moment but I believe the C-More screens have a feature to 'Increment' or 'Decrement' via a push button. If this is the case, I think you can adjust this feature to increment or decrement by a set value. If the PLC is performing the Increment / Decrement, then replace it with an ADD / SUB by 5.

Share this post


Link to post
Share on other sites
Hi IO, I think I may have been vague in my original post. What I am working with is the numeric display of a value, not a numeric input of a value. I am trying to get rid of fluctuations. Thanks,

Share this post


Link to post
Share on other sites
Well .... I can't help with that specific hardware, but here's the long and painful way to do it. 1) Divide the scaled value by 5. (assuming it's an integer, if not convert it to an INT first) 2) Convert the result to float. 3) Multiply by 5 and display that value.
1 person likes this

Share this post


Link to post
Share on other sites
I'm not sure what instructions are available in that PLC but if you have a modular division function (sometimes called MOD) then you can take the (value - (value MOD 5)) and you will get increments of 5. The modular division gives a remainder of the division so when you subtract the remainder, you essentiall round down to the next multiple.

Share this post


Link to post
Share on other sites
Indeed, I misunderstood. ndzied1 proposes a robust solution. I like it.

Share this post


Link to post
Share on other sites
yes but it may not work on every platform. what Mendon Systems proposed will work on anything.

Share this post


Link to post
Share on other sites
Thanks for the replies. Yes Mendon's solution is the best, I believe, as it is universal. Thanks again.

Share this post


Link to post
Share on other sites
OK a bit more on this, sorry. If I take a real number, say: 15249.3 divide it by 5: 3049.86 convert it to an INT: 3049 multiply it by 5: 15245 That "works", but really what I want is 15250, that would be properly rounded. We effectively truncated as opposed to rounded. Any way to do that in a PLC? Thanks again! Edited by Div_by_zero

Share this post


Link to post
Share on other sites
After you divide by 5 and before you convert it into an INT add 0.5 to the real Eg divide it by 5: 3049.86 *** ADD 0.5 : 3050.36 convert it to an INT: 3050 Edited by michael G
1 person likes this

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