Micro820 REAL variables rounding

5 posts in this topic

Hi at all! A little brief to understand my situation...

I'm creating a new project with an analog input (4-20mA) to determine the level of a tank.

The instrument send me a value that correspond 4mA => 0% and 20mA => 100%. With the AI_Conditioner UDFB from RA

i can correctly rescale the mA value to a %. 

Then I need to "estimate" the volume of that tank, so with radius and lenght i can calculate it (no problem so far).

But after that, the value is too much variable (the 4-20mA is not very stable)...

So to resolve I can accept to rounding to the nearest 20...
But, how can I do?
There is already an UDFB made for it?

Thank you at all!

Share this post

Link to post
Share on other sites

Your 4-20mA signal is varying too much, correct?  The analog input is scaled from 4-20mA to 0-100%; the overall scaled value bounces significantly.  There may be a rounding UDFB, but I am not aware of one.

My suggestion...either average the scaled analog register or timed move of the scaled analog register.  A free-running timer that moves the scaled analog value to another register after one-shot event of the timer being done, before you reset the timer.  We often pursue this "debounce timer" method with proximity sensors to insure they are ON for time before accepting their state.

Lastly, a wise guru on a similar post suggested a great idea that often gets overlooked...filtering.  Logix allows for some I/O points to have filtering functions that can be enabled.  I am not familiar with the Micro820 to know if it has this ability (typically in Controller Tags, look at the default TAG.FEATURE to find the filter parameter.  Filtering the analog signal will do similar as adding a debounce timer.

Edited by kaiser_will

Share this post

Link to post
Share on other sites

Hi kaiser_will,

thank you for your answer! I've try to check the Micro820 tag feature but I think that it doesn't have the "filtering" options...

So I think that rounding the volume result will be the simpliest choice... but I don't know exactly how to do it...

Share this post

Link to post
Share on other sites

I'm not familiar with the Micro820, but I assume the ANY_TO_DINT instruction will round off a Real value.

CalcVol_REAL / 20.0 = TempVol_REAL


TempVol_DINT x 20 = RoundedVol_DINT

1 person likes this

Share this post

Link to post
Share on other sites

Sorry for delay of my answer...

For now I try another solution...

Thank you at all for your answers but if someone can tell me anyway how to rounding a value... Thank you!

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