Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

why is this vi giving the wrong time output?

Solved!
Go to solution

I have an NI 9401 and I found this example, in the Labview 2011 help, that I understand should measure pulse width.  I have a photo sensor with transistor output that outputs 12mVDC in the low state, and ~3700mVDC in the high state.  When I run this vi, (I added the WHILE loop to the original example) and I operate my photo sensor manually, which means that there are hundreds of ms in between rising or falling edges,  the output is a few microseconds?  Why does it display such a short pulse width? I am using cDAQ 9174.  I would expect the difference in time between successive rising or falling edges to be in the hundreds of ms,  not a few microseconds.

0 Kudos
Message 1 of 11
(6,612 Views)

Hi dav2010-

 

It might have something to do with the voltage output levels of your sensor.  According to the 9401 specifications, VIL is 800mV (well above the 'low' output of your sensor), but VIH is 2V.  Since your 'high' state is in the transistion region, the readings may be unpredictable.  You might need to amplify and/or level-shift your signal to see better results with the TTL-compatible inputs.

 

Hopefully this helps-

Tom W
National Instruments
0 Kudos
Message 2 of 11
(6,607 Views)

Hi Tom,

Thanks a lot for chiming in.  I am not sure about your suggestion, though, because the online "Detailed Specifications" show the Low VIL to have 0.8V MAX input, and they put the input range starting at 0V.  As I read it, I don't need to exceed 0.8V on the LOW input; in fact, as I read it, I need to make my system anything less than 0.8V and greater than 0.  See http://sine.ni.com/ds/app/doc/p/id/ds-86/lang/en

Instead,  I think the 0.8V is a max, not a min.  Do you agree?

Thanks,

Dave

 

0 Kudos
Message 3 of 11
(6,603 Views)

Hey Dave-

 

You're right- I misread your 3700mV as 700mV.  Your sensor does seem like it should be compatible with the minimum VIH as quoted.

 

Do you have another measurement device (perhaps an oscilloscope) to probe the signals as supplied to the 9401 to check for noise or other anomalies?  If you are using your 9401 in a current-generation cDAQ chassis you may want to consider configuring trigger filtering for your channels to avoid spurrious change counts.  You can find the applicable filtering settings in the DAQmx Channel Property Node.  I attached a screenshot of some slight modifications that will allow you to sample repeatedly with filtering enabled:

 

ctrDigFilt.png

 

 

Tom W
National Instruments
0 Kudos
Message 4 of 11
(6,593 Views)

Hi dav2010,

 

I agree with Tom's modifications. Also, for future reference, we have a wealth of examples already in LabVIEW that you might find useful.

 

They are available in LabVIEW by opening the "Example Finder" under Help >> Find Examples. For instance, a continuous pulse width measurement VI has already been created and can be found through this finder by looking under Hardware Input and Output >> DAQmx >> Counter Measurements >> Period or Pulse Width >> Meas Pulse Width-Buffered-Cont.vi. This example would use your input signal to determine the sample rate. 

 

Best regards,

Matt J - NI Tools Network
0 Kudos
Message 5 of 11
(6,590 Views)

Thanks, Tom.   I'll study this one, and see if I can figure out if I can use it to solve our problem.

Dave

0 Kudos
Message 6 of 11
(6,582 Views)

Where does one find "DAQmx Channel Property Node"?  It is not a terminal on my "Create Channel" DAQmx box...I am totally confused.  And the yellow box with three rows and TRUE constant wired to it...where is this found????

 

Thanks,

0 Kudos
Message 7 of 11
(6,563 Views)

Hi dav2010,

 

The property node referred to here is found in your functions palette under "Measurement I/O >> DAQmx - Data Acquisition >> DAQmx Channel Property Node.vi". This property node is the yellow box you are referring to. After creating it and wiring in the task output from your CI task, click on the text under the property node name and navigate through the drop-down box by looking at "Counter Input >> Pulse Width >> Digital Filter >> Enable". Then, use the edges of the node to expand it down. This will give you access to the second property shown in the screenshot above.

 

Best regards,

Matt J - NI Tools Network
0 Kudos
Message 8 of 11
(6,556 Views)

Hey Dave-

 

The yellow box is the property node you're looking for.

 

You can find it on the DAQmx palette, conveniently right next to some of the other top-level functions:

 

chanProp.png

 

From there, you'll want to wire up your task and error wires and then browse through the levels to find the digital filtering properties that I mentioned. 

Tom W
National Instruments
0 Kudos
Message 9 of 11
(6,554 Views)

 Thank you VERY much.  I see what this is now, and I think that I have it wired correctly..BUT, I am getting no response when I run the program.  I have attached the code here. 

 

I can see the transition using the test panel in MAX, but, it doesn't show up in my filter vi.  Any ideas?  By the way, the values in MAX do not make sense either...for example, in one rotation of the wheel, which has 3 reflective strips on it, the count in MAX will jump from 18 to 30, or 7 to 21, or 0 to 15...impossible numbers to get for one revolution of the wheel.  I don't think it is related to the background because I am also monitoring the voltage from the sensor with a Agilent 34401 DMM, and I don't see any phantom voltage spikes...

 

the vi "measure_pulse_width_with_filter" does not show any response when running, but, the vi "Meas Dig Period-Low Freq 1 Ctr" does show a period measurement.  What is wrong with the filter vi???

 

 

Dave

0 Kudos
Message 10 of 11
(6,548 Views)