10-24-2005 02:40 AM
10-24-2005 05:38 PM
Gabriel,
Thank you for contacting National Instruments.
If you want to measure duty cycle, one of the easiest ways to do that is with a Semi-period Measurement. Semi-period measurements measure the time between consecutive edges with the use of counters. From that you can easily determine duty cycle. There is an example that ships with LabVIEW named Meas Duty Cycle-Buffered-Finite.vi that demonstrates this. I highly recommend taking a look at this example.
10-26-2005 12:46 AM
Thanks for such a quick answer,
Unfortunately, I hardly understand the example you advised me to look at, despite the several days I spent searching. The thing is that I've just started to use Labview, and I only know the basic functions. I went through several trainings, but all quite simple. I hardly understand the point and the functioning of the blocks used in that VI. I simply tried to see if I could get it to work with my input, changing the trigger channel to "Dev1/PFI3" to which a function generator is wired... Unsuccessfully.
In part #1 of the example the operation of the "semi-period" block is described. From reading the documentation on "semi-period" blocks, I am unclear whether this block measures the "semi-period" or if it only creates a counter to measure the semi-period. Initially I assumed that it measured the semi-period, however when I try to connect my pulsed channel to the input I get an error message saying that there is no data coming from the board. In addition to that, the ”DAQmx trigger” seems to be meant to trigger on the digital channel more than the semi-period block, as it has a “trigger source” I can set to my pulsed channel.
I am also unclear about the function of the "task in" and "task out" ports. I have looked through all the documentation and help files and am still not clear on their function : what is a task ?
Basically I think I am really unclear about those DAQmx blocks I never used before (all of them unfortunately), I can just understand the way the calculation works…
Thanks for your support,
Gabriel
10-26-2005
02:36 PM
- last edited on
11-16-2025
07:16 PM
by
Content Cleaner
I am including an excerpt from the documentation for the example here, and adding notes to clarify:
Semi-period measurement differs from pulse width measurement in that it measures both the high and the low pulses of a given signal. So for every period, two data points will be returned.
II. Instructions for Running:
1. Select the Physical Channel which corresponds to the counter you want to measure duty cycle on the DAQ device.
2. Enter the Maximum and Minimum Value to specify the range or your unknown semi-periods. Additionally, you can change the input terminal where the duty cycle is measured using the channel property node. The input terminal and the trigger terminal must be the same for this example to behave as expected. [I have attached an edited version of the example that does this, so whatever pin you choose for the trigger terminal is also routed to the counter. Just connect the signal you want to measure to the PFI pin you select for the trigger.]
Note: It is important to set the Maximum and Minimum Values of your unknown semi-period as accurately as possible so the best internal timebase can be chosen to minimize measurement error. The default values specify a range that can be measured by the counter using the 20MhzTimebase. Use the Gen Dig Pulse Train-Continuous example to verify that you are measuring correctly on the DAQ device.
To answer your questions about the DAQmx VIs, I recommend taking a look at the tutorial linked below:
Learn 10 Functions in NI-DAQmx and Solve 80% of Data Acquisition Applications
10-27-2005 02:50 AM
10-27-2005
05:58 PM
- last edited on
11-16-2025
07:17 PM
by
Content Cleaner
1) This is from the documentation for that error: To wait for the samples to become available use a longer read timeout.
If the frequency of the signal you are measuring is low enough that it takes longer than the timeout specified to read the number of samples you request, this error will occur.
2) I'm not sure I fully understand this question, but I think you are asking about how dataflow works in LabVIEW. The (very) basic idea is that a VI (square icon) will not execute until all of its inputs are available. I recommend checking out the LabVIEW online introduction course online (https://learn.ni.com/learn/article/labview-tutorial).
3) The counter on your device has default pins that correspond to its source, gate, and output. I used the property node to set it to the same pin that is being used to trigger the measurement (instead of the default pin).
I think a better understanding of how to program in LabVIEW will help you to understand all of this tremendously.
10-28-2005 04:28 AM
If I am not mistaking, there is nothing about the DAQmx VIs in the six-hour course you advise me to read (which I did before starting to use Labview, basically). Anyway, I managed to reproduce the logic of the example to create a period-measuring VI, still without understanding it. I would simply expect a VI with a digital input created by my square signal generator that would output the time for every rising or falling edge. I have been trying very hard to understand the "task-structure" used here, investigating on NI's website, unsuccessfully. My using a foreign language may make it twice as difficult, and my australian colleagues are unclear as well.
1) What is a task ?
2) I integrated the example you gave me to my own VI (programmed with express VIs in a while loop), which then could not work any longer. The duty-cycle is still measured and displayed in the table, but the rest of my VI freezes. I guess it is a structure problem, however I cannot sort it out.
3) I would like to hide a part of my VI by creating a subVI, the problem being that it utilises a feedback node. To allow such wiring, I need to create a while loop in my subVI too, and then it does not work any more when I replace the lot by the corresponding VI in the global VI. Is there a solution ?
4) Why can we only choose the trigger source amongst the PFI channels, and not the basic digital channel (e.g. P0.1 etc) ?
I thought about sending you my VI, but I doubt you would appreciate as it is not your business to correct my work (which would shock you I guess anyway, as I used some tricks to bypass some difficult points, such as logging data and comments in text files named with the recording start time, that is to say when you press a push button).
Gabriel, French trainee engineer in Darwin, stuck in his project.
10-31-2005 10:05 AM
11-01-2005 03:20 AM
11-02-2005 10:51 AM
Hello All,
It looks like your issues with DAQ might be coming to an end, so I'll help out
with any LabVIEW questions you might be encountering.
It looks like you are attempting to log data with the LabVIEW measurement file
I also suggest that you read over the LabVIEW programming style guidelines (I
have attached the document to this post). Good coding practices make code
much easier to debug, easier to modify, and ultimately lead to a faster
development cycle.
Hope this helps!