Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Counting Edges and Frequency from the Same Measurement Device

Solved!
Go to solution

Hi, I have a LED open collector tied to my gas meter that sends out pulses as my gas meter dial turns. I then convert the number of pulses into a gas reading. This gives me the total amount of gas that I have used, but I also need to measure the frequency of the pulses to determine a gas flow rate. I am running at a very low firing rate so my frequency from the open collector is very low (less than 1 Hz).

 

I am using a cDAQ-9178 with a NI-9401 module inserted into slot 8. The open collector sends pulses of 5VDC, and I am putting the 5V+ wire into terminal 14 and the 5V- wire into terminal 1. I am also counting pulses on a WattNode Pulse meter for my power draw. It sends out pulses of 5VDC, and  those wires are inserted into 16 (+) and 3 (-) of the 9401 module. If I only set up my code to count the number of pulses for each measuring device then everything works fine. Once I try and also measure the frequency of the open collector I run into issues.

 

I was initially trying to read my frequency from the same physical channel, but that didn't seem to work because the counter was first in line and hogging up the resources for the frequency signal. My next step was to daisy chain the signal from the open collector in terminals 14 and 1 to 17 and 4. After doing this I couldn't read a signal at all, edge counting or frequency. So now I am asking for guidance here. When I tried daisy chaining the wires I used ctrl0 & PFI0 for my counter and ctrl2 & PFI2 for my frequency measurement. 

Download All
0 Kudos
Message 1 of 5
(3,850 Views)

I can't offer specific help about the cDAQ hardware or wiring specifics.  Just that if you have counters capable of doing buffered freq measurement, you can accomplish this with 1 counter task.

 

As you take buffered freq measurements, you can just keep track of the total # samples you've read and that's your pulse count.  Actually, add 1 to the # samples to get the count b/c it takes 2 pulses to define the 1st freq sample.  (This is true on newer hardware -- older hardware *might* give you a nonsense freq sample on the 1st pulse representing the time from task start to 1st pulse.   Older hw definitely behaves this way for period measurement, I'm not sure if it's the same with freq measurement.)

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 2 of 5
(3,829 Views)

Thanks Kevin_Price for the prompt response. That's a good idea and I had played around with trying to do something along those lines, but I am new to programming with DAQmx and couldn't figure out how to accumulate my samples as I read the frequency. Using one of the NI examples (attached for reference) of a buffered frequency measurement I am able to read my frequency, but can not figure out how to accumulate a count of my samples from the same task out. Any advice would be great. Thank you.

0 Kudos
Message 3 of 5
(3,812 Views)
Solution
Accepted by M_Blaylock33

I can't save all the way back to LV 7 like you posted, so I'm attaching a screenshot snippet.

 

All I've done to your example is:

- change to 1 counter freq method for your low freq range

- accumulate all freq data using "Build Array" in concatenate mode

- taking the size of the cumulative array as the total # pulses

 

For future reference, using "Build Array" in a While loop like this isn't generally preferred.  But it can sometimes get the job done and helps to illustrate the main idea without making extensive mods.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 4 of 5
(3,808 Views)

Thank you for your assistance! That worked like a charm. The only thing I need to do now is apply a filter to the data coming in since I'm still getting counts after my gas meter has stopped moving (probably just noise in the line). 

0 Kudos
Message 5 of 5
(3,790 Views)