Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem to measure 0% and 100% duty cycle of a PWM.

Hi,

 

I am using counters of USB-6341 to measure duty cycle of PWM just by following the example 'Meas Duty Cycle-Buffered-Finite.vi'. It works almost all the time. However, when the duty cycle of a input pwm is 0 or 100%, the DAQ can't read anything, in another word, it can't measure 0 or 100% duty cycle.

How to modify that?

 

Thank you very much 🙂

 

Nan

0 Kudos
Message 1 of 4
(8,631 Views)

What does a duty cycle of 0% or 100% mean? It means that the output never changes.

 

I do not have the VI you are trying to use but I suspect that it makes two time interval measurements, one for the low part of the pulse and one for the high part.  At 0% or 100% one of those parts does not exist so the measurement will fail. Test for 0% and 100% separately before calling the duty cycle VI.  If the signal does not change during the clock period, set the measurement output to 0% for low or 100% for high.  If it does change, call the duty cycle VI to make the measurement

 

Lynn

0 Kudos
Message 2 of 4
(8,605 Views)

Thank you for your help, it is a good suggestion.

Here is my vi.

In our project, we use a pwm with fixed frequency and changable duty cycle to control sth.

It is possible that duty cycle becomes 0 or 100% at some time.

 

Do you have some other ideas without check them first. I mean make the program for measuring 0 or 100% and programs for measuring other cycles together by using the counter.

 

Nan

0 Kudos
Message 3 of 4
(8,602 Views)

That's the thing about PWMs, you never really know if the PWM is 0% or 100%.

 

Let's say we have a 50% duty cycle, at 1/2Hz.  So low for 1 second, high for one second right?  What if we run at 1/20Hz, so low for 10 seconds high for 10 seconds.  Or is this a 0% duty cycle for 10 seconds, and a 100% for 10 seconds?

 

A true PWM read will never be 0% or 100% it will just keep waiting until the trigger is seen, and recalculate the frequency and duty cycle of it.  The solution to your problem is for you to define a duration to watch for a change, and if one isn't seen, then you can define 0% or 100% appropriatly.

 

So I would recommend taking your duty cycle like you normally are, and then at the same time watch the digital signal for however long you want, if the digital line does not change state, then output 0% if it is low and 100% if it is high and ignore what ever duty cycle you read.  But if the digital line does change state, then use the read duty cycle as the actual value.

0 Kudos
Message 4 of 4
(8,597 Views)