Measure pulse width of signals generated by DAQ
Eventually, I would like to:
Start a counter pulse width measurement and analog out at the same instant.
Stop the pulse width measurement with an external digital signal.
My current plan is to use a digital out on the DAQ to go to a digital input and the counter start input. The digital input will be a start trigger for the analog output. This works, except for the counter.
While trying to implement this, I tried a simpler test of just generating a digital pulse with the DAQ and wiring that to the counter inputs. That doesn't work, even though it looks fine on an oscilloscope. Then, without changing the software at all, I connect a function generator to my counter inputs, and it measures pulse widths flawlessly.
I'm actually implementing this with a Python wrapper around the DAQmx C API, but I recreated it in LabVIEW, and it behaves the same. VI attached. I have the latest DAQmx drivers.
Attachments:
meas_pulse_width_simple.vi 32 KB
screenshot.png 99 KB
ColeTrain wrote:
apaulsen,
Just a
friendly heads up, but this is more of a DAQ post and you will
generally get more replies to these types of questions by posting in
the proper forum.
That being said, try taking a look at
the Example Finder and look under the DAQmx examples at
synchronization/multifunction as this would be a good place to start
working on what you're trying to wind up doing down the road.
I am actually the OP. apaulson is my coworker, and he was logged in to the forums on the workstation from which I posted.
I
realized that it ended up in the LabVIEW forum, so I reposted on the
DAQ forum:
http://forums.ni.com/ni/board/message?board.id=40&thread.id=7185.
I understand why there is a search-to-post policy, but it's rather
unintuitive and clunky, and I got confused. IMHO, ubuntuforums.com
does this the right way and automatically searches before you submit
your post.
Anyway, I figured it out. See the other post for solution.
Similar Messages
-
Is it possible to generate a fixed frequency with variable duty cycle signals using counter/timer channels of my DAQ 700?
If yes, is there any example I could download?
If no, I am looking for a DAQ card that can handle
the job, I'd appreciate any recommendation.
Another part of my project is to read in a analog signal while generating this pulse width modulated
signal. So far I am not very lucky with one DAQ,
I am thinking of getting two. Does it sound overkill?
Please help.
ThanksCould you provide a timing diagram for your digital signal?
I am a firm believer that a digital output device such as an NI timer can create any signal, given the proper software or hardware. I once did a high speed, gated, triggered data acquisition with only a single NI timer chip on the AT MIO 16E-1. It required about 75 feet of BNC cable, more PFI wires than you can imagine, four external logic devices (AND and OR, NAND and NOR boxes) all interconnected and basically tangled. I don't think I could repeat that setup without my documentation, but the point is, it worked.
The most important thing from that example is that I used a timing diagram. These are so vital in digital IO and timer applications that its not funny.
If you can't determine ho
w to do what you need from a timing diagram, just send me a copy, let me know what the basic specs are of the DAQ 700 (how many counters, interconnect capabilities, etc) and I can try to help.
Good luck.
As far as reading the analog signal at the same time...well, look at my example. I generated the trigger/gate signal with the card, and then read in the analog data (on several channels simultaneously.) -
Using pulse width modulated signal (square wave) to control when a signal is turned on or off
Greetings All
I'm trying to use a labview created pulse width modulated signal (square wave) to control when a signal is turned on or off.
Here's my logic and graphic example:
1) The source wave signal is continuous
2) Use a PWM (square wave) created in labview to control when the signal is turned on or off
3) If PWM signal (amplitude) is greater than 0 play signal if PWM is not greater than 0 don't play signal.
I'm actually using this to step sequence / pulse several separate magnetic coils using my audio card (which has several audio output channels), I have a signal in labview played constantly. Than compare it to the PWM (square wave) which controls if the signal gets played on each separate channel or not. That way I can control which coil is on and off and in what sequence they are activated.
I couldn't find an edge detection for a square wave created in labview so I tried Limits but that doesn't seem to work unless I change the phase manually and that only goes from 1 to -1. I'm just trying to compare the PWM (square wave edges) already created by labview / play a signal if the pulse is greater than 0 and it turns off the signal if it's less than 0.
Should I be doing this another way
Tia
Message Edited by sal22 on 08-16-2009 06:09 PM
Message Edited by sal22 on 08-16-2009 06:10 PM
Solved!
Go to Solution.
Attachments:
PWM control signal block.png 23 KB
PWM control signal front.png 48 KB
pwm test.vi 36 KBGreetings,
I tried it two ways using amplitude and levels and fft spectrum. The values don't seem to update the way I need them to (basiclly showing a 0 or a 1). I compare the Y values like you recommended but they don't ever seem to update.
tia
Message Edited by sal22 on 08-19-2009 10:05 AM
Attachments:
pwm magnitude not updating.png 29 KB
pwm test.vi 41 KB -
Measure pulse width and generate pulse depends on the width
Hi,
i have a serias of pulses ... 600 micro,30 micro,30 micro (around 10 times) ........ nothing for 1 mili second ..
so i need to generate a pulse after the first pulse arrives ... (its width around 600microSecond)
1. use the first counter to measure the pulses ...
2. if arrived pulse ... 500microSecond<the pulse width<700microSeconds .... then generate pulse with second timer ....
the problem is that i dont want to use the while loop inside the labview ...
can i programm the counters to make the width calculation and if the width is bigger to generate trigger to the second counter .... ?
the hardware is 6014 sample card ....
thanks
gena
(see attached)
Attachments:
F0087TEK.JPG 27 KBHi Gena,
I am assuming you are using the DAQmx drivers in LabVIEW for your
PCI-6014. Avoiding a While loop may be difficult if you need to
perform this measurement many times and you might not know when the
signal is going to begin. Without a While loop, you'll have to
set up your timeout period long enough so the pulses will begin before
your VI stops.
With this in mind, you may want to look at some of the shipping
examples with the DAQmx driver. You can find these in LabVIEW's
Help menu by going to Find Examples. For measuring the pulse
width, browse the folders in the Example finder by going to Hardware
Input and Output>>DAQmx>>Counter Measurements>>Period
or Pulse Width. In this folder, there is the Meas Pulse Width.vi,
which measures the pulse width once and stops. You should be able
to take the pulse width measurement you get from here and check to see
if it's in your range, then output a pulse on the other counter if it
is in the range. The pulse output examples can be found in
Hardware Input and Output>>DAQmx>>Generating Digital
Pulses>>Gen Dig Pulse.vi.
Thaison V
Applications Engineer
National Instruments -
Can counter measure pulse width difference between two signals
I am interested in determining the high pulse width time that two signals have when they are in various phases between eachother.
Why don't you try one of the pulse width examples. I don't know what ADE you are using, but you can search for examples (http://www.ni.com/devzone/dev_exchange/ex_search.htm) with the key words "+pulse +width" and find several examples in different languages. This will measure the pulse width of one signal, but you can program most of the counters to do multiple tasks at the same time. Just copy the code twice and change the counter number to program counter 2 as well. If you want the ORed pulse width time, I would recommend adding a OR gate to your circuit and then feeding that into a counter.
I hope this helps.
Joshua -
Measure Pulse Width and Period Statistics
Hello,
I'm trying to solve what should be a very simple problem. I would like to measure common characteristics of a binary analog voltage input, pulse width and period. The canned pulse width/duty cycle/period VIs and express VIs use a histogram or peak to peak method on a set buffer size of data and produce one output. I would like to measure these signal characteristics over a long period of time and collect statistics on pulse width and period data (max, min, median, mean, standard deviation, etc.) to indirectly measure the eccentricity of a system. Although I am relatively inexperienced in LabView scraping off a considerable bit of rust, I did not think this task would present a challenge, but I have been stumbling around for a couple of days trying to create an array of output parameters such as pulse width so that I may calculate the statistics on all measurements.
If anyone can step me through some of the thought process to a solution or show me how to format data collection so that this can be done, I would very much appreciate the help.
Thanks,
Evan
Attachments:
Example.jpg 194 KBHi Gena,
I am assuming you are using the DAQmx drivers in LabVIEW for your
PCI-6014. Avoiding a While loop may be difficult if you need to
perform this measurement many times and you might not know when the
signal is going to begin. Without a While loop, you'll have to
set up your timeout period long enough so the pulses will begin before
your VI stops.
With this in mind, you may want to look at some of the shipping
examples with the DAQmx driver. You can find these in LabVIEW's
Help menu by going to Find Examples. For measuring the pulse
width, browse the folders in the Example finder by going to Hardware
Input and Output>>DAQmx>>Counter Measurements>>Period
or Pulse Width. In this folder, there is the Meas Pulse Width.vi,
which measures the pulse width once and stops. You should be able
to take the pulse width measurement you get from here and check to see
if it's in your range, then output a pulse on the other counter if it
is in the range. The pulse output examples can be found in
Hardware Input and Output>>DAQmx>>Generating Digital
Pulses>>Gen Dig Pulse.vi.
Thaison V
Applications Engineer
National Instruments -
soft pulse width measurement
If you are creating a pulse in software somehow, then you can use Pulse Measurements.vi that's on the Analyze>Waveform Measurements palette. This will require that the input is of the waveform data type with signal and timing information. There's several timing functions on the time & Dialog palette that you could probably use. Check out Tick Count and Elapsed Time. If you could provide more details on what exactly you need to do, we could provide more help.
-
Looking for VI to measure pulse-width on a waveform
does anyone know of a VI to measure the pulse width of a pulse trace in a waveform?
The examples to look for would be located under the DAQ >> Counters examples, and you would probably be looking for anything using the DAQ-STC chip (which is the counter chip on our E-Series board). Advanced examples that are in addition to the shipping examples can be found by searching the website as well.
Jim Cahow
Applications Engineer
National Instruments -
Measure pulse width with 4 counter simultaneously
Hello,
I am using NI PCI-6601 measure the pulse width with 4 counter simultaneously, due to only a DMA channel on this card so I selected interrupt data transfer mode to read data from PCI bus for 4 counters, but it working only for few seconds then a error message prompted:
Error -200141 occurred at DAQmx Read (Counter 1D DBL 1Chan NSamp).vi
Measurements: Data was overwritten before it could be read by the system.......(See attached picture: TestUI and Error MSG.bmp)
I know the problem caused due to system is unable to read back data from PCI6601's memory as fast as they card countered. My quesition is:
1. The timebase is 20Mhz(Sample rate), how to change the sample rate slower (like 100Khz) ?
2. Any good solutions can meet my requrement?
Attached is my source code, Test.vi is the main VI.
Thanks for your help.
Steven
Attachments:
Test.zip 557 KBWhat's more, you could include four channels in one task, so you don't need to build four task!
Attachments:
4 counters in one task.png 719 KB -
Need Help on How to Generate Pulse Width Modulation signals
Hi,
I am New in using NI board and programming using LabView. I have no idea on how to start to generate, use what function in order to create a PWM signals.
My project needs:
-PWM signals with 15kHz frequency.
-Duty cycle varrying from 0%, 25%, 50%, 75%, 100%.
-By using the generated PWM signals to control the half-bridge (MOSFETs) of boost converter and buck converter to varying the voltage of 24V battery to feed in my DC motor.
The NI board that I use is (NI - sbRIO-9642).
Can I have a clear view on what to use, how to generate, and by using what functions to generate the PWM signals.
Sorry for the inconvienient, but I really desperate for help in this. Thanks a lot. I am appreaciate it.
The attached is the circuit the half-bridge motor controller that I will used.
Attachments:
half bridge.jpg 13 KBHi Ronald,
in this thread a very similar question came up. You can use the same approach on your sbRIO.
For the frequency you gave you should use the FPGA present on the sbRIO - as is shown/discussed in that other thread! I also suggest that other thread because of the "deadtime" feature used to prevent shortcut problems when switching your MOSFETS simultanuously...
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome -
How do I measure pulse width in VeriStand 2010?
I'm using an NI PXI-6229 M Series DAQ.
I the channel set up in System Explorer and I have my input signal routed to the Gate of Counter 0. When I deploy and open the Workspace the measurement says 0 seconds although an oscilloscope shows a 7ms square wave at the terminal.
I think the problem may be that I don't have a timebase applied to the Source of Counter 0. How do I put an internal timebase on the Source? I would prefer to do so without changing any VIs and I definitely don't want to add an external frequency generator to my setup.I think that the gate terminal cannot be used in that case. You might want to try to connect the external signal to the input terminal of the counter.
Once you have rewired the external connection you will notice, that NI VeriStand might not update the frequency that often. NI VeriStand doesn't measure the frequency/period by using a frequency task. We have used a simple edge counting task that takes the upper and lower limit of the frequency to determine the update rate of the frequency value. The more accuarate the settings are, the higher is the update rate. In order to get a feasible update rate, increment the lower limit to a value that will never be below the real minimum frequency of the external signal and set the upper value to the maximum expected frequency.
Thanks,
Tom
http://www.newgistics.com -
Measure pulse width cont - failure in example? NI-DAQmx
Hello!
I tried the "PulseWidth-Buff-SampClk-Cont.c"-Example. I got the following error:
DAQmx Error: Invalid timing type for this channel.
Property: DAQmx_SampTimingType
You Have Requested: DAQmx_Val_SampClk
You Can Select: DAQmx_Val_Implicit, DAQmx_Val_OnDemand
Task Name: _unnamedTask<0>
Status Code: -200300
Here is the Example-Code:
#include <stdio.h>
#include <NIDAQmx.h>
#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
int main(void)
int error=0;
TaskHandle taskHandle=0;
int32 read;
float64 data[1000];
char errBuff[2048]={'\0'};
// DAQmx Configure Code
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateCIPulseWidthChan(taskHandle,"Dev1/ctr0","",0.000000100,0.838860750,DAQmx_Val_Seconds,DAQmx_Val_Rising,""));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"/Dev1/PFI0",1000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));
//DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"/dev1/PFI13",1.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));
//DAQmxErrChk (DAQmxCfgImplicitTiming(taskHandle,DAQmx_Val_ContSamps,1000));
// DAQmx Start Code
DAQmxErrChk (DAQmxStartTask(taskHandle));
printf("Continuously reading. Press Ctrl+C to interrupt\n");
while( 1 ) {
// DAQmx Read Code
DAQmxErrChk (DAQmxReadCounterF64(taskHandle,1000,20.0,data,1000,&read,0));
printf("Acquired %d samples\n",read);
fflush(stdout);
Error:
if( DAQmxFailed(error) )
DAQmxGetExtendedErrorInfo(errBuff,2048);
if( taskHandle!=0 ) {
// DAQmx Stop Code
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
if( DAQmxFailed(error) )
printf("DAQmx Error: %s\n",errBuff);
printf("End of program, press Enter key to quit\n");
getchar();
return 0;
What could i do?
Thanks
AndreasThe help says this:
Sets only the number of samples to acquire or generate without specifying timing. Typically, you should use this function when the task does not require sample timing, such as tasks that use counters for buffered frequency measurement, buffered period measurement, or pulse train generation.
So this line is only needed for specific applications. The counter has no sampleclock, like the analog input or the analog output, so you can not use this, but have to use implicit timing instead.
Hope this helps!
André -
Pulse width modulation signal generation for ULx
Hello,
I am trying to produce an analogue waveform (i.e square wave) with an option to control the duty cycle.
I am outputting through a Measurement Computing card, which uses the ULx user libaries.
There are many examples to do what I want using DAQmx, but all those using ULx have no option to control the duty cycle.
Can anyone help?
Thanks in advance.
Solved!
Go to Solution.Hi ben,
does your ULx hardware even support PWM outputs? Does it support counter output tasks?
It's not only the software, also the hardware needs to support your requirements!
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome -
NI 9401 pulse width measurement.
Hello,
I'm not sure I fully understand the pin-out diagram. At present I have a NI9401 in a NI 9172 chassis.
DIO0 and DIO1 are connected to light gates. I have an opto switch and I want to measure the pulse width when an object blocks passes through the slot. Can I use any of the other free input to do this?
Free inputs are, DIO2, DIO4 and DIO5.
The other I/O pins are being used as triggers.
Cheers
K
Solved!
Go to Solution.Hi Daisy,
If you open your DAQ Assistant properties, and read the Measuring Pulse Width help on the side, you'll see that "You can use the counters on your measurement device to measure pulse width. Pulse-width measurements measure the time between either a rising and a falling edge, or a falling and a rising edge." If you change the Pulse Width Setup Starting Edge setting to Falling edge and look at the picture above, you'll see that the pulse width it's measuring the width from a falling edge to a rising edge (the pulse width while the signal is low). So this measurement will go from the falling edge of your first measurement to the rising edge of your second measurement. If you want to measure the width of the first pulse (while the signal is high) you need to set your Starting Edge to Rising.
Do you know whether the width that you want to be measuring is while the pulse is high or while it's low? Starting Edge Rising and Starting Edge Falling should give you different measurements, because they're measuring different things. You should verify which result it is you want, and what it is you're trying to measure.
Hope this helps!
Emily C
Applications Engineer
National Instruments -
Pulse width measurement with FieldPoint CTR-502
I would like to measure the pulse width of a signal (ranging from 10 ms to
400 ms out of a signal with period width of about 1 second). I would like to
use a fieldpoint counter module FP-CTR-502. I could find examples on how to
measure frequency but I did not know how to alter it in order to obtain the
pulse width.
Thanks,
MartienTo measure pulse width of a fixed-period signal, you only need to use one counter, so the configuration and program would be different than the frequency measurement example. Set the count source for counter 0 to "32kHz Reference" and the gate source (and wire your signal) to "Gate Input 0." You'll also need to create a control channel to reset counter 0 (as described in the frequency example).
Your LabVIEW program should run as follows:
- When Gate Input 0 becomes true, do nothing
- When Gate Input 0 becomes false again, read then reset counter 0
- repeat
You can use FP Advise to wait for the gate to change (just like the frequency example).
Once you have the number of counts, you can divide that by the frequency (32 kHz) to calculate the "on tim
e" (pulse width) of your signal.
Regards,
Michael Shasteen
Applications Engineering
National Instruments
www.ni.com/ask
1-866-ASK-MY-NI
Maybe you are looking for
-
My grandson visited the BearShare website. Since then, the only home page that will "stick" in Firefox is http://search.bearshare.com. Repeated attempts to reset my home page have failed. After I reset the home page and close Firefox, when the progra
-
I can't find my iPhoto library???
Well it all started when I plugged in my backup drive (western digital 1TB drive) to do a time machine backup and it said the drive had to be erased and reformatted because there was a problem ( i have been using this drive for a year with Time Machi
-
Cannot open Preview software anymore.
I cannot open Preview. I get a message that "it may be damaged or incomplete". Any help will be appreciated.
-
NEW TABS DEFAULT TO BING. I DO NOT WANT BING!
i dont want new windows to open with bing.
-
Install Containers for J2EE on 9iAs release 1
Hi, Is it possible to install Oracle9iAs Containers for J2EE on Oracle9iAs Release 1? How? Thanks a lot.