LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating the mean of a DAQ signal using Mathscript

I am trying to use the DAQ assistant function to send a signal to math script so that it will calculate the mean frequency as well as + and - 15% of the mean frequency. Unfortunately I don not know how I need to wire the DAQ assistant output signal to mathscript. I have used a convert to DBL and no broken wires come up but the result does not generate.

 

I think the problem is that both the time and the amplitude are contained in the DAQ output signal and mathscript needs extra coding so that I can tell it what the time input is and what the amplitude input is. Or I will need to split the DAQ signal into its amplitude and time components?

 

Does anyone know how to do this?

0 Kudos
Message 1 of 9
(5,263 Views)

First question, do you have to use Mathscript?  There are native LabVIEW functions that do what you want to do.  I'm not sure exactly what you mean by "mean frequency".

 

Second, how much data are you acquiring with the DAQ assistant?  Is it more than 1 sample?  Converting the blue dynamic datatype wire to a double will eliminate all of the data points except for 1, as well as the timing information.  You need to convert to the Waveform datatype.  From there, you can unbundle the waveform components to get the array of doubles for the acquired data points, as well as dt and T0 to feed to your Mathscript routines.

0 Kudos
Message 2 of 9
(5,251 Views)

I don't have to use mathscript but its just easier if i can have everything working from labview. I am using mathscript to receive the signal from the DAQ at 50 samples per second for approximately 40seconds - mathscript is suppsoed to take this data and calculate the frequency of the DAQ signal then the average/mean frequency as well as + and - 15% of that average and output it.

 

What function do i need to use to convert the signal to a waveform data type? I was attempting to use 'get waveform components' but a broken wire appears when I wire it in.

0 Kudos
Message 3 of 9
(5,229 Views)

The question was why use Mathscript instead of the native LabVIEW functions and you did not pay attention to the instructions. After converting to a waveform, you need to use tge Get Waveform Components to exract the Y array and dt.

0 Kudos
Message 4 of 9
(5,223 Views)

Sorry, I am using mathscript as my friend is competent in coding with it and I am new to labview so I am not aware of what functions to use to calculate the frequency of my signals. So its the easiest way for me to calculate the mean frequency.

 

Thanks for clarifying the waverform data info. I have managed to extract the y and dt from the waveform data but i for some reason math script is not picking up the time correctly when I input it. I may be using the wrong format or conversion? I am currently converting dt to a dbl then inputting it into mathscript but for some reason Mathscript is not calculating the mean so I presume that my conversion of the time is wrong? I have tried both dt and T0.

0 Kudos
Message 5 of 9
(5,213 Views)

There is no conversion required for the dt. Why don't you just attach the code?

 

p.s. The Express VI 'Tone Measurements' will return the frequency directly from the DAQ Assistant output.

0 Kudos
Message 6 of 9
(5,208 Views)

attached is the code that i am using.for some reason the data from the waveform is not being extracted properly so the mathscript code cannot calculate the correct mean frequency?

0 Kudos
Message 7 of 9
(5,182 Views)

Try this.

 

 

0 Kudos
Message 8 of 9
(5,177 Views)

Thanks for that attachment I tried it earlier but it doesn't produce the correct data. I need the mean frequency in Hz and the results I get from that are upwards of 15.

0 Kudos
Message 9 of 9
(5,175 Views)