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 KB
What'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
Similar Messages
-
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 KBColeTrain 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. -
Changing the pulse width of a counter on-the-fly - ?
I'm seeing strange behavior when trying to change the pulse width of a
counter while it is running continuously. Using the property node
I can set the DAQmx Channel Properties "Low
Time" and "High Time" when the values are
changed by the user (see attached VI). The first change is
ignored initially, but then applied when a second change is made, i.e.
the changes are applied one step late. If I read the respective
properties the values are what is set but not what is being
generated and seen on an o-scope. I added a
condition of watching the property "Ready For New Value" before applying the
change, but that doesn't alter the behavior. What am I missing?
Windows XP
LabVIEW 7.1
DAQmx 7.4.0f0
PCI-6251
Thanks,
DTL
Attachments:
GenDigPulseTrain-ChangingSpecs II.vi 104 KBAlan,
Thanks for the reply. I don't know if I explained in well in my
previous post, but I'll try to confuse again: The issue is that the
property node change is reflected on the hardware (pulse output) one
change delayed. Example: Start the VI with time value A.
The user sets the time to value B, the property node read for the time
will read value B, but the output pulse (hardware) stays at value
A. Then the user sets the time to value C, the property node read
is C, but the output is now B, and so on...
I've worked with the DAQmx Write, as the example you pointed to shows,
and it will work properly (reflect the change immediately on the
hardware). If one replaces the DAQmx Write to a Channel Property
Node it will start working as I described above (change reflected one
change delayed). Note: A subtle additional change is that I have
changed everything to Time (High, Low) instead of Frequency (Duty
Cycle, Frequency) - ?. Note 2: DAQmx Write doesn't bring
out all the properties - what if I have to use a property node?
Do I need to "double pump" the values?
FWIW,
Don -
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 -
Single Pulse Width with External Clock
I am trying to setup a 6602 counter for a single (non-buffered) pulse width measurement with an external clock. Under normal testing, the unit under test will provide the pulses, I need to measure the number of pulses during different time periods (1, 60, and 300 seconds). I want to do a pulse width measurement and I'll supply the gate signal pulse to the counter for the specific time needed.
Under normal operation, the unit under test is wired into the counter's source and the pulse is wired into the gate. For testing purposes I am using a BNC-2121. I have the counter's source wired to the Adjustable Square Wave Output and the gate wired to the Trigger output.
Here is my C++ code. I am getting a timeout error on the read and I don't know why. Any help would be appreciated.
//Create Task
DAQmxCreateTask( "task1", taskHandle );
//Create Pulse Width Channel
DAQmxCreateCIPulseWidthChan( taskHandle, // TaskHandle
szCtrName.c_str(), // Counter Name
"", // Channel Name
dMin, // Min Value
dMax, // Max Value
DAQmx_Val_Ticks, // Units
DAQmx_Val_Rising, // Gate Edge
"" ); // Scale Name
//Set the Pulse Width Terminal to the gate signal
DAQmxSetCIPulseWidthTerm( taskHandle, // TaskHandle
"", // Channel
"/CTR2/PFI38" ); // Terminal
//Set the Timebase Src to the counter's source
DAQmxSetCICtrTimebaseSrc( taskHandle, // TaskHandle
"", // Channel
"/CTR2/PFI39" ); // Terminal
//Start Task
DAQmxStartTask( taskHandle );
//***Send pulse to gate counter***
//Read Counter
DAQmxReadCounterU32( taskHandle, // Task Handle
DAQmx_Val_Auto, // Num Samps to Read
10, // Timeout
ulBuffer, // Read Buffer
1000, // Buffer Size
&lSampsRead, // Num Samps Read
NULL ); // ReservedI've setup a pulse width task in NI-MAX using the onboard clock and everything worked fine, so I know the hardware is working.
My unit under test is providing the pulses (from gyros) I need to measure. The pulses indicate the position of the unit so there are X, Y and Z axis gyros. I need to measure these pulses for specific periods of time (1, 60, and 300 seconds). For example during the 1 second measurement, the X and Y gyros should measure zero pulses and the Z axis should measure 515 gyros. During a 300 second measurement the X and Y gyros should measure < 60 and the Z axis should measure 30800.
So the gyro pulses are wired to the counter input and I am using a DIO channel from NI-6508 to provide the gate pulse. The gate signal will be high for either 1, 60, or 300 seconds depending on the test. The gyro pulses are essentially the external clock to the counter. I want to count the gyro pulses during the pulse of the gate (DIO).
To simplify the setup, I connected to BNC-2121 directly to the card. I have the adjustable clock output going to the counter input of ctr0 and the trigger signal going to the gate of ctr0. Once the task has been started and before the read ( I had a breakpoint set in the code), I would press the trigger button on the BNC-2121 and hold for approx. 1 second. I then execute the Read statement, and I always get a timeout. From my experience working with NI, I'm guessing I don't have a channel property set correctly, but its not obvious to me and I can't find an example to do exactly what I'm trying to do.
The CTR2 designation in the code was the object name of the card. I have two 6602 cards in my chassis. I was using ctr0 of the second counter card, so PFI38/39 was correct.
Again, any help would be appreciated. -
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.
-
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 -
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 -
Measure pulse frequency with 4.7 volt peak amplitude
used two shipped Measurment Studio Vb.Net 2005 Examples:
1-Example 1 : CountDigEvents "MEASURES PULSE COUNTS" and Example 2: MeasDigFrequency_LowFreq1Ctr "MEASURES PULSE FREQUENCY"
2-Example 1 works fine measuring pulse counts , however Example 2 did not recognize pulse frequency , the pulse amplitude voltage is 4.7 volt peak
3-during testing used counter ch0 channle by connecting Sorce0 and Dgnd pins to signal source.
4-using Nidaqmx 9 and MIO-16xe-10 daq
5-pulse frequency around 10 khz
QUESTION:
-please advice what to do to make frequency measures ?
ThanksHi MyKat,
Note that the connections are different for edge counting and low frequency frequency measurements with one counter. For the latter, you'll need to connect the signal to PFI 9 rather than PFI8 as you did for edge counting.
http://zone.ni.com/reference/en-XX/help/370466W-01/mxdevconsid/eseriessigcounters/
Regards,
-Jim B
Applications Engineer, National Instruments
CLD, CTD -
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 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é -
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 -
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 -
When exactly do pulse width measurements start?
I am using a PCI-6601 to measure pulse width and period of a PWM signal in LabView (DAQmx).
I use ctr0 for the period and ctr1 for the pulse width. The period is measured between falling edges. As I am interested in the high pulses, the pulse width measurement is configured to start with a rising edge.
I do a buffered measurement with continuous samples.
I use a common start trigger (ArmStart) for both tasks.
Everything works just fine, but one thing puzzles me:
My start trigger can occur at any phase of the PWM signal, so I expected the first measurements to be invalid. This is true for the period measurement, but the pulse width is always correct. It doesn't matter in what phase my trigger occurs, the first reading of the pulse width is always correct.
Can someone tell me why?This is speculation, but it's probably just that NI decided to follow slightly different rules for pulse width measurement than for some of the other counter measurements.
I've done triggered period and semi-period measurements before, but don't know that I've done triggered pulse width or frequency measurements.
For the two former cases, I know that the counter will start counting time immediately after the trigger edge. The first measurement represents the time from the trigger to the first active edge period (or semi-period) edge. It is often meaningless as you anticipated. For pulse widths, I suppose NI simply decided that the trigger will arm the counter but you also need the pulse's leading edge before you start counting to measure pulse width. So the first measurement is a true measure of pulse width and is never meaningless.
If this is true, then it may be tricky to sync / correlate the data in simultaneous measurements. For your particular app, you could get away with performing a single semi-period measurement and then calculating the periods and pulse widths. In other apps, it could get more difficult.
-Kevin P. -
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
Maybe you are looking for
-
How to achieve New Window requirement from One Web Template?
Hi Experts, I've a WebTemplate contains 2 Graphs. Each graph have one Zoom Button. My requirement is, When I click the Zoom button that corresponding Grpah should display in a New Window. I've finished all the above requirements. Since, I have One Ma
-
Lightroom 4 crashes when trying to open the slideshow module. I spent over three hours with both Adobe and Apple tech support and we know it is a permission issue but have not been able to get it solved. It started with the last upgrade to 10.8
-
I recently updated ibook in my Itunes. Now, every time I sync, I get the message that it won't update the ipod as ibook won't run in OS6. Is there any way I can revert the ibook app in itunes so it quits trying to install the current ibook app. I am
-
Uploading videos on itune but my mobile videos can't display
Uploading videos on itune but my mobile videos can't display
-
I'm on a Mac - OSX 10.4.11 Trying to get DNG 6.7 installed.
Hi - I'm on a Mac - OSX 10.4.11 Trying to get DNG 6.7 installed. Says 'sucsessfull' but big line through icon and app won't open. Previous DNG was 5.6 and was fine. Dragged it to trash to delete. and deleted trash. Then realised poss mistake an