LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Frequency Measurement using NI 9401

Hi everyone!

 

I am relatively new to Labview and i want to make a SubVI for frequency measurement using cDAQ9185 with the NI 9401 counter module. Besides frequency measurement, i measure pressure and temperature as well in an extra task, which is working well already (NI 9208 and 9217). For the frequency measurement a turbine-sensor is used which delivers a square signal to the NI 9401 and the frequency measurement already works within the NIMAX, using a new task (using the same tasks for both measurements is not possible). The frequency task works only with the settings shown in the following figure ("Ein Wert auf Anforderung", i dont know the exactly english wording because my installation was done in german, probably this is something like "one value on request")

NImax_mb.png

I have already read a related post, but that didnt help me much. In my opinion there is no task used i this case and just the modules digital counter input is used directly.:

https://forums.ni.com/t5/LabVIEW/Measure-frequency-from-flow-turbine-using-NI-9401-error-amp/m-p/324...

 

My current SubVI for frequency measurement is shown here:

 

SubVI_Frequ.png

 

The main program looks like that (red circle is the frequency measurement with following mean value calculation). The parallel measurement with task1 works perfectly:Main_program.png

So the main questions are the following:

1) The CreateChannel-VI needs a counter input but doesnt need the task, it is optional. So do i have to use something else than CreateChannel-VI or do i just add the digital input channel as shown above? I cant run the program for testing because of issues described as follows:

 

2) For temperature and pressure measurement mean values are created which are the actual wanted values and they are saved afterwards. The time period is therefore set to 10 sec. For mean value calculation, the shown SubVI is used (see above, 4). I want to do this for the frequency measurement also. But for mean value calculation, a waveform signal is needed which i dont get from the choosen ReadVI (1 Channel -1 Sample) in the frequency SubVI. How can i handle this?

I should also mention, that there is an additional loop for the whole program, where values are just continuously shown on screen (with update every 0,5 sec) when "measurement" is inactive. If "measurement" is activated, the meanvalue over 10 sec is saved.

 

3) Is there a time delay between these two parallel measurements because of two different tasks and if yes, how much is it? Or are both tasks performed simultaniously? Actually i could live with a delay of less than 1 second.

 

Hopefully someone can help my along with my problem(s) and give me some advices or an example VI.

Please tell me if any further information is needed.

 

Thanks a lot in advance,

Chris

0 Kudos
Message 1 of 7
(1,344 Views)

Hi Chris,

 


@turbochris86 wrote:

My current SubVI for frequency measurement is shown here:

 

SubVI_Frequ.png


Why do yu need to create and kill the task inside this subVI? Why not create the task once before your measurement loop and kill it once after the loop?

 

On your questions:

1. You don't need to ive a task name/reference, but you need to define the channels within the task…

 

2. You can build your own arrays! Use a shift register in your measurement loop…

 

3.Sure there is a "time delay"! Those tasks run in parallel, but they aren't synchronized. The "delay" will be smaller than your loop iteration time…

 

On your images:

You seem to avoid error handling at all. Don't you need to handle errors?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 7
(1,329 Views)

Thank you GerdW for your suggestions!

 

The error handling hasnt been considered yet, but probably will be later on. Yes you are right, it would be better to kill the task after the loop, thanks.

 

Depending my questions:

1) alright, everything clear

2) shift register is a nice function which i didnt know until know, but its not working in this case i guess, because of the following reason: I have set the measurment time for samples in task1 to 10 seconds, where the meanvalue is built from afterwards. I want to do the same with frequency measurement in task2, but with shift register i just can set a number of values, where the array is built from, if i got it right!? Furthermore my measurement loop is on the outest "level", so i don´t know how to applay shift register anyway (See figure).

 

main_program_2.png

Any idea?

 

3)Alright, thank you

 

Thanks for your help!

Chris

 

0 Kudos
Message 3 of 7
(1,273 Views)

Hi Chris,

 


@turbochris86 wrote:

2) shift register is a nice function which i didnt know until know, but its not working in this case i guess, because of the following reason: I have set the measurment time for samples in task1 to 10 seconds, where the meanvalue is built from afterwards. I want to do the same with frequency measurement in task2, but with shift register i just can set a number of values, where the array is built from, if i got it right!? Furthermore my measurement loop is on the outest "level", so i don´t know how to applay shift register anyway (See figure).

 

Any idea?


Did you notice those Training resources on the header of this LabVIEW board?

I would suggest to learn the LabVIEW basics when you just discovered the shift registers!

You can place the shift register on your outer loop and the shift register can store an array with a variable amount of elements…

 

Btw. you would more/better help when you would attach real code instead of just some images of smaller parts of your block diagrams!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 7
(1,269 Views)

Hi GerdW,

 

thanks for your reply. I think you missunderstood my question depending the shift registers. What i wanted to say is, that i dont know how to use the shift register in a way, where i can fill an array with the incoming values over a timeperiode of 10 seconds? I want to achieve, that for both measurements the same amount of time (10 s) is used. You find main program and frequencyVI attached.

 

btw:

"Learning the basics" is a nice suggestion and is what i am actually doing but isn´t very helpful to solve my problem. I thought i would get a more specific answer. If i had found a solution in the resources, i would not ask silly questions here.

 

Best regards

Chris

 

Download All
0 Kudos
Message 5 of 7
(1,242 Views)

The function "Mean (pt by pt)" would be an easy way to get a moving average from your constant sample rate analog data.  Just set the sample length to 10x the sample rate to do averaging over 10 seconds worth of samples.

 

Your frequency data presents a more difficult problem.  The interval between samples is determined by the (possibly varying) frequency you're planning to measure.  So you can't know ahead of time how many frequency samples it takes to represent a 10 second span.  And that probably won't be a constant number within a given test run either.

 

You might want to try doing Edge counting while using the the AI sample clock as the sample clock for the counter task.  Then you'd get a whole bunch of badly quantized individual frequency estimates, but they'd be easy to average across 10 seconds, and the average over that span of time measured that way might be a good enough measurement to be useful.

 

Your original method (implicit timing, 1-counter freq measurement) can give you great precision for the individual intervals but your desire to average over 10 seconds would require some careful data management and algorithm programming.  If you're pretty new to LabVIEW, this part might be difficult to get right and also difficult to detect the difference between truly right and almost right.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 6 of 7
(1,229 Views)

Thank you Kevin for your detailed answer. You totally nailed the problem i am facing, perhaps this was not entirely clear from the previous posts. Now i have an idea of possible options which i can apply to my case.

Thank you for your help!

0 Kudos
Message 7 of 7
(1,188 Views)