Dear community,
I am trying to measure the rotational speed of a test assembly by the PFI0 input.
My test assembly provides a rotational synchronous pulse (one pulse per revolution) which I feed (via an opto-coupler) to the PFI0 input of a DAQ board. I have checked this signal and it is a very clean rectangular signal (period 275 ms, pulse width 15 ms, low voltage 40 mV, high voltage 4.4 V, rising time 6 µs, falling time 8 µs, bouncing-free).
I have set up the program to measure the frequency of the PFI0 input between the rising edges of the signal. The program code is shown below. I am using Microsoft Visual Basic .NET 2003 and NIMS V7.1.
With a NI PCI-6220 DAQ board I have no problems. It is giving the rpm values as I expect them.
However, with a DAQCard-6062E I have problems to get the right rpm values. Many times the reading is correct and gives a reading of 3.63/s (corresponding to the period of of the input signal of 275 ms). But quite often I get readings of 3.84/s (corresponding to the low-period of the signal which is 275 ms - 15 ms = 260 ms) and 66.6/s (corresponding to the high-period of 15 ms).
It seems as if the DAQCard does not care about the rising edge condition, but often measures between any two edges (rising or falling).
Sometimes I even get the error message -200140: "Two consecutive active edges of the input signal occurred without a counter timebase edge. Use a faster counter timebase."
The behaviour could be explained if I would use a bouncing input signal to the DAQCard. But as explained above the input signal is very clean, not too fast, and the same configuration works perfectly on a PCI-6220.
Is there anything I might have overlooked?
I have tried to apply an input filter on the PFI0 input. But obviously this feature is not supported on the DAQCard-6062E.
Any help is much appreciated.
The attached ZIP file includes the source code as well as oscilloscope hardcopies of the rot.sync. signal.
Best regards,
Detlef
I am using Microsoft Visual Basic .NET 2003 and NIMS V7.1.
Initialization sequence for the rpm measurement:
Dim mCounterTask As Task
mCounterTask = New Task("ciTask")
mCounterTask.CIChannels.CreateFrequencyChannel( _
"/Dev1/ctr0", "", 1.2, 500, CIFrequencyStartingEdge.Rising,
CIFrequencyMeasurementMethod.LowFrequencyOneCounter,
0.001, 32, CIFrequencyUnits.Hertz)
mCounterReader = New CounterReader(mCounterTask.Stream)
mCounterReader.SynchronizingObject = Me
mCounterTask.Control(TaskAction.Verify)
mCounterTask.CIChannels.Item(0).FrequencyTerminal = "/Dev1/pfi0"
mCounterCallback = New AsyncCallback(AddressOf subCounterInCallback)
Sequence for reading the rpm measurements:
'callback routine for rpm-measurement
Private Sub subCounterInCallback(ByVal ar As IAsyncResult)
Dim dblFreq As Double
Try
dblFreq = mCounterReader.EndReadSingleSampleDouble(ar)
txtResult.Text = Format(dblFreq, "#,##0.000")
Debug.WriteLine("Freq" & vbTab & Format(dblFreq, "#,##0.000"))
mCounterReader.BeginReadSingleSampleDouble(mCounterCallback, Nothing)
Catch ex As DaqException
txtError.Text = ex.Message
Debug.WriteLine(ex.Message)
cmdStart_Click(Nothing, Nothing)
End Try
End Sub