Showing results for 
Search instead for 
Did you mean: 

Soft timing for measurement of duty cycle

I am using the DAQcard-DIO-24 and a digital output accelerometer for a project, and I can acquire data successfully, but fail to measure the duty cycles which indicate the acceleration. As the input are boolean values, I have tried several methods to convert them into the form that I can measure the duty cycle directly, such as a square wave, but it doesn't work. When I try the "Timing and Transition", it gives:
Possible reason(s):
Analysis:  The amplitude of the waveform is zero, so the histogram method cannot be used.
I also read the example "Meas Duty Cycle-Buffered-Finite", but it seems the DIO-24 card can only do the soft timing, so it may not be suitable for this application. I am wondering whether there is another way to measure the duty cycle. Can anyone please help me? Thanks a lot.
0 Kudos
Message 1 of 12
The DIO-24 is really not appropriate for timing measurements. Since it is software timed, the absolute best you will be able to do is one sample every msec and even that is not entirely reliable. If don't need resolution better than several milliseconds, then you can probably get something to work. Your best bet would be to use a counter/timer board. An analog acquisition would also work.
0 Kudos
Message 2 of 12
Hi Dennis,
Thanks for rapid reply. Fortunately, this application does not requrie high resolution. But is there any measurement method based on the software only or it is compulsory to have a counter/timer board involved? Sorry about the question as I'm fresh to LabVIEW.
0 Kudos
Message 3 of 12

If you want to use software timing, then sample for x amount of time and create an array of Booleans. Search the array for the first Boolean true. Then search the array for the first Boolean false after the index value of the first True. The duty cycle is the array index number of the false minus the array index value of the true times the sample rate.

Message Edited by Dennis Knutson on 04-28-2006 08:24 AM

0 Kudos
Message 4 of 12
Thanks for detailed reply. This method is helpful, and based on your suggestion, I am thinking about whether I can use a certain number of samples instead of  time, ie to generate for example 500 samples once using DAQ assistant. But when I select "N samples" acquisition model, the output of DAQ assistant change to 1-D array of digital waveform instead of boolean values. I have tried to convert the digital waveform into an array so that I can use the soft timing method, unsuccessfully. Is it possible to do this?
The reason for this modifiaction is DIO-24 only supports the on demand sample model, where I can not control the sample rate. So probably I can calculate the duty cycle by dividing the number of value 1 sampe from the total sample number of 1 period.
Thanks for being patient.

Message Edited by YangLi on 04-28-2006 10:48 PM

0 Kudos
Message 5 of 12
Fortunately I finally get the 1-D waveform converted to a boolean array (as below), but it seems there is only one element in the array instead of 500, which is the sample number of DAQ assistant where I set the acquisition model to "N samples". Can anyone please tell me the problem and how to generate an array with the element number equal to the sample number? Thanks a lot.

Message Edited by YangLi on 05-01-2006 05:14 AM

0 Kudos
Message 6 of 12
You won't be able to do buffered DIO on that DAQCard.  This is probably going to be your best best.  Take a look at the pic I attached.  You will want to go 1 Sample on Demand, and use timing in the loop to control the acquisition. 
The reason that you are only getting 1 boolean out is that you are only acquiring 1 piece of data. 
-Jeff P.
0 Kudos
Message 7 of 12

Hi Jeff,

Thanks for reply. I will modify it, but I can't find your attached pic...Smiley Sad



0 Kudos
Message 8 of 12

Hiii, Dennis

            I am facing the same problem, i want to measure duty cycle of generaed D/O for single channel of low frequency and we do not have the 24 DIO, we are generating it only on the single channel so we do not have the array of the digital signals, then what should we do? please suggest us something.



0 Kudos
Message 9 of 12
Create the array by repeatedly sampling one channel.
0 Kudos
Message 10 of 12