# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Convert dynamic data type to a numeric with specific precision

Hi,

I would like to ask how can I convert the dynamic data from DAQ to a numeric type with specific precision?

The reason I want to do this is because that I want to eliminate the noise from the data I acquired from LVDT (maxium range 0-10V and has about 0.01V noise (error)). So if I limit the significant figure of the acquired data to 2 then I can get a data without oscillation and input it into the PID VI.

Any suggestions is much appreciated!

Roy

Message 1 of 6
(163 Views)
Solution
Accepted by topic author Roy19

## Re: Convert dynamic data type to a numeric with specific precision

Hi Roy,

@Roy19 wrote:

I would like to ask how can I convert the dynamic data from DAQ to a numeric type with specific precision?

The reason I want to do this is because that I want to eliminate the noise from the data I acquired from LVDT (maxium range 0-10V and has about 0.01V noise (error)). So if I limit the significant figure of the acquired data to 2 then I can get a data without oscillation and input it into the PID VI.

Any suggestions is much appreciated!

Why is there a DDT wire at all? Why not use "simple" datatypes right from the beginning???

To reduce noise on a signal you usually apply a filter. Simplest filters are low-pass filters, aka RunningAverage. LabVIEW comes with such a function, it's called PtByPt-Mean…

You can only convert your DDT wire into datatypes using "ordinary" float values, you cannot apply rounding right here. When you really want to "limit the significant digits" of your values you should apply a rounding function after the conversion from DDT. (Be aware of limitations of floating point datatypes, especially regarding rounding to multiples of 10.)

Does your PID really react heavily on fluctuation in the 3rd decimal after decimal separator? Maybe chaning the PID gains may help here, too!

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
Message 2 of 6
(154 Views)

## Re: Convert dynamic data type to a numeric with specific precision

Hi GerdW,

Thank you so much for your reply.

1. Cause I am using DAQ Assistant so the output signal is automatically DDT. May be I should use DAQmax instead so that I can have DBL data?

2. The round function only derives integer, the only way I can think of is that times the data with 100 and do the rounding and divides 100 again, so that I can get 3 significant digits, is there any more convinient function to get a specific decimal?

Roy

Message 3 of 6
(81 Views)

## Re: Convert dynamic data type to a numeric with specific precision

@Roy19 wrote:

Hi GerdW,

Thank you so much for your reply.

1. Cause I am using DAQ Assistant so the output signal is automatically DDT. May be I should use DAQmax instead so that I can have DBL data?

2. The round function only derives integer, the only way I can think of is that times the data with 100 and do the rounding and divides 100 again, so that I can get 3 significant digits, is there any more convinient function to get a specific decimal?

Roy

I think that's actually how to do it.  More generally multiply your number by 10^x, where x is the number of desired decimal places, then divide by 10^x.  (BTW, this even works for rounding to digits to the left of the decimal place - e.g., using 10^0 will round your number to the nearest ones column; 10^-1 will round to the nearest 10's, etc.  Convenient if you want to round to, let's say, the nearest MHz.)

Bill

(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 4 of 6
(75 Views)

## Re: Convert dynamic data type to a numeric with specific precision

Hi Bill,

Really appreciated your help!

Roy

Message 5 of 6
(70 Views)

## Re: Convert dynamic data type to a numeric with specific precision

This is actually how you would compare numbers to a certain decimal place.  Multiply both numbers by 10^x, round, then do the compare!  (You don't need to divide again before compare; that just gives you FP errors.)

Bill

(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 6 of 6
(67 Views)