Div_by_zero Posted September 28, 2015 Report Posted September 28, 2015 (edited) 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 October 6, 2015 by Div_by_zero
IO_Rack Posted October 6, 2015 Report Posted October 6, 2015 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.
Div_by_zero Posted October 6, 2015 Author Report Posted October 6, 2015 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,
Mendon Systems Posted October 6, 2015 Report Posted October 6, 2015 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
ndzied1 Posted October 6, 2015 Report Posted October 6, 2015 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.
IO_Rack Posted October 7, 2015 Report Posted October 7, 2015 Indeed, I misunderstood. ndzied1 proposes a robust solution. I like it.
panic mode Posted October 7, 2015 Report Posted October 7, 2015 yes but it may not work on every platform. what Mendon Systems proposed will work on anything.
Div_by_zero Posted October 7, 2015 Author Report Posted October 7, 2015 Thanks for the replies. Yes Mendon's solution is the best, I believe, as it is universal. Thanks again.
Div_by_zero Posted October 7, 2015 Author Report Posted October 7, 2015 (edited) 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 October 7, 2015 by Div_by_zero
michael G Posted October 8, 2015 Report Posted October 8, 2015 (edited) 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 October 8, 2015 by michael G 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now