LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

measuring frequency with cRIO max 15kHz do I need to use the FPGA main or the RT main ?

Hello to you all,

I need to measure a frequency with a maximum frequency of about 15 kHz. 

 

 

(1) I did read some examples, this one explains how to use the FPGA main:

https://www.ni.com/en/shop/compactrio/do-more-with-labview-fpga---c-series-digital-modules-using-com...

 

(2) But when I do read this one:

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P8sWSAS&l=nl-NL

I can read the text:

"Timed Loop structures are always SCTLs when used in an FPGA VI."

and I can read

"Functions that take longer than one tick, such as analog I/O functions or any functions that wait cannot be used inside the SCTL"

 

I think I must misread the text because (1) does not correspond to (2). I also read about the code being implemented in the RTmain. apparently this gives more options for the timed loop. I find it hard to get a better understanding at which speeds I could use the RT main.

 

 

My questions:

(a) For which measurement speeds is it okay to use the RT main? 

(b) If possible when would you choose the FPGA main to implement the frequency measurement 

(c) Can some-one please give me an example, I have Labview 2018 so I am not able to view examples of newer versions.

 

thanks !

 

 

 

 

 

 

 

0 Kudos
Message 1 of 9
(1,613 Views)

Neither*.

 

This kind of measurement is best done with DAQ hardware rather than polling-based code.  A simple DIO module should provide you an interface into the cRIO chassis counters and LabVIEW provides shipping examples you can try out to do frequency measurement with a counter.  You would run this example as RT code, though the exact same code could run under Windows with a simpler cDAQ chassis and DIO module too.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy coming to an end (finally!). Permanent license pricing remains WIP. Tread carefully.
0 Kudos
Message 2 of 9
(1,585 Views)

Depending on your cRIO model, you can choose a different mode. Take Your First Measurement in LabVIEW Real-Time (Data Logging)

The scan engine is the easiest but only has a sampling rate of up to 1kHz. DAQmx can sample much faster but is only limited to cRIO-904x/5x.

-------------------------------------------------------
Control Lead | Intelline Inc
Message 3 of 9
(1,532 Views)

Hello Kevin,

 

Thank you for the reply! I did read the info on the link you gave. 

 

I try to imagine how it works from a hardware point of view. The C type card in the cRIO sends its data over a SPI bus to the FPGA if I would use the code on the FPGA or when I use the Real time scan.

 

When using NI-DAQmx the data is send over the SPI bus directly to the CPU.  Doesn't this increase the load of the CPU significantly?  Or is the real counting done somewhere else, secretly on the IO card? If I would take a simple microcontroller then there are hardware counters already available on the chip it self and it is probably already on the IO card. So why send  a lot of raw data over the SPI bus to a CPU? I wonder and ask because I find it hard to get a idea of the performance how much CPU load will be needed etc.To put it in another way, what speeds can be achieved with DAQmx is there a rule of thumb?

 

 

Its_Me_0-1707238106628.png

 

 

0 Kudos
Message 4 of 9
(1,463 Views)

Thank you for the reply! Why can it only be used on the cRIO-904x/5x is there some special hardware? like hardware counters or something else ? 

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

Only the 904x/905x contain a DAQmx ASIC and allow the DAQmx driver to access the C modules directly.

The 903x series for instance is for many aspects similar but without that DAQmx ASIC and there is no way to access the C series modules through DAQmx functions. Only scan engine or direct FPGA access is an option on them.

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 9
(1,452 Views)

Thank you Rolf

Now it starts to make sense 🙂 

So for the Ni-9048 I could use DAQmx because they added a ASIC, 

However I also have got an Ni-9074.

 

Both cRIO's need to measure a frequency with a maximum of about 15 kHz. So I think if I must add some frequency measurement code to the FPGA of the Ni-9074 I can probably (almost) copy past it to the Ni-9048.

 

Is there a example how to do this? In the starting post I do describe some issues I did ran into and I did not solve them yet.

 

Thanx for the help !

0 Kudos
Message 7 of 9
(1,407 Views)

The 9074 is a very old chassis, containing a PPC CPU and running VxWorks as Realtime OS. It's still a fairly capable controller but it is NOT supported after LabVIEW 2019 and the according CompactRIO version 19.6. https://www.ni.com/en/support/documentation/compatibility/21/ni-hardware-and-operating-system-compat...

 

Your confusion is most likely related to the fact that your first link talks about digital IO modules while your second link talks about analog input. Not at all the same!

 

With (at least the high speed) digital IO modules like the 9401, you can perfectly put the according IO nodes inside a SCTL. Your issue is most likely that for your 15kHz I/O rate for the digital IO, you will actually have to do some extra code inside the loop to slow down the actual sampling by for instance only really reading a new measurement every 100st iteration or similar.

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 8 of 9
(1,398 Views)

Hello Rolf thank you again for the great help!

 

I am aware the 9074 is kind of old, it is kind of hard to get new hardware where I work though. If I would know a company with the amount of cRIO's like the amount of lego that fits in my sock I would really consider working there. 🙂

 

You are correct I did mis about the analog input in the text, did not mis it once but even twice. thank you for telling me!

 

what do you think about this code? Would you change things to make it better?

 

All true

Its_Me_0-1708615557971.png

 

 

All false:

Its_Me_1-1708615619607.png

 

p.s I am aware I need to do some extra to get from the Puls count to the frequency.

 

 

 

 

 

 

 

 

 

 

 

 

0 Kudos
Message 9 of 9
(1,292 Views)