Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Each 10ms, measuring the Freq of variable freq (High/Low freq) PWM signal

I'm receiving a PWM signal on a 6602 car counter. I want to measure the freq of this signal every 10 ms. This signal has variable  frequency from low to high that can change every 10 ms.  The examples in the LabView help (...Counter Measurement-> Digital Frequency) deal only with high freq, low freq and large range each situation with some pre-configurations. My measurement is blind except that I know my maximum frequency of 5000 Hz and the dyty cycle of the signal  being always constant at 50%.

 

1) How to change LabView examples to fullfill my needs?

2) Can I detect and time stamp rising and falling edges and theb use the following formula?

        

       T(falling)[i]- T(rising)[i-1]

       ---------------------------------- = 50%

      T(rising)[i] - T(rising)[i-1]

              How to take advantage of the above formula (if it is correct)?

 

Thank you for your help;

 

KizKas.

0 Kudos
Message 1 of 5
(4,310 Views)

Hi KizKas,

 

If you take one of the examples like Meas Dig Frequency-Buffered-Cont-High Freq 2 Ctr.vi and you change it to use 1 counter low frequency. With this configuration using "implicit" timing you are using the 80MHz timebase to measure the frequency between the edges of one period of the signal you're trying to measure. This means that if you have a 5kHz signal (approximately) then you're giong to be getting a frequency measurement loaded into the buffer every ~.2ms. So, if you're looking to check for the frequency every 10ms you'll call the DAQmx read VI and you'll get about 50 frequency measurements, so you could do some processing to that data to see how the frequency changes over each 10ms span. 

 

Chris W

0 Kudos
Message 2 of 5
(4,301 Views)
Chris;

Thank you for the reply.

What I have done is to use the NI example ...../Period or Pulse Width/Meas Pulse Width.vi

I'm using a timed loop which run every 10 ms. Using the example, I have put "DAQmxCreate Channel" and "DAQmx Clear Task" outside of the loop. Only the "DAQmx Read" is inside the loop.
Since this "DAQmx Read" gives me the pulse width and knowing that my duty cylce is 50%, I immediately compute the period and then obtain the frequency.

Do you think this is a good aproach?

Thank you.

KizKas.
0 Kudos
Message 3 of 5
(4,299 Views)

I think that method is fine if it works for you, however, there is some uncertainly based on the fact that your duty cycle may not be exactly 50%. If you do a full period measurement, instead of a pulse width measurement, and invert the measurement (if it is units of seconds) then you will have basically the exact same thing that the frequency measurement does. I would suggest this, but if you are ok with some possible jitter in the duty cycle then your method seems fine.

 

Chris W

0 Kudos
Message 4 of 5
(4,289 Views)

I forgot to mention, however, that the timing for this call to the DAQmx read VI that is being called inside your timed while loop is processor dependent. I know you have set the timed loop to execute with a period of 10ms but because this is not (or I'm assuming it's not) an RT system, you will not get a deterministic 10ms period for your loop. Check out this Knowledgebase article, it describes what I'm talking about.

 

Chris W

0 Kudos
Message 5 of 5
(4,285 Views)