Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Measure external clock frequency

Hello,

I'm using a PCI-MIO-16E-4 to DAQ using an external clock (crank shaft encoder).  I also need to determine the rate of the external clock (i.e. determine the rotational speed).

As suggested in previous posts I am trying to feed the external clock signal (PFI7) into a counter (Ctr0).

The code I am trying to use:

    DAQmxConnectTerms("/Dev2/PFI7","/Dev2/Ctr0Gate",DAQmx_Val_DoNotInvertPolarity);

    DAQmxCreateTask("measure_n",&taskHandle);
    DAQmxCreateCIPeriodChan(taskHandle,"/Dev2/Ctr0","",min,max,DAQmx_Val_Seconds,DAQmx_Val_Falling,DAQmx_Val_LowFreq1Ctr,0.000001,4,NULL);
    DAQmxStartTask(taskHandle);

however, this fails with:

Specified route cannot be satisfied, because it requires resources that are currently in use by another route.
Property: DAQmx_CI_Period_Term
Property: DAQmx_CI_Period_StartingEdge
Source Device: Dev2
Source Terminal: PFI9

Required Resources in Use by
Source Device: Dev2
Source Terminal: PFI7
Destination Device: Dev2
Destination Terminal: Ctr0Gate

Task Name: measure_n

Status Code: -89137

Is it possible to measure the external clock rate using DAQmxConnectTerms or do I need to physically jumper the external clock into Ctr0?

Thanks in advance, Ben.

0 Kudos
Message 1 of 5
(3,557 Views)
Hi Ben,
 
Why can't you connect the signal whose rate you want to mesure (sample clock?) directly to the gate of the counter, instead of routing it internally through PFI7?
 
BTW which is the previous post that you are referring to? Can you post a link to that.
BR
0 Kudos
Message 2 of 5
(3,550 Views)
Thanks for your help Kal.
 
Do you mean to replace the DAQmxConnectTerms statement with DAQmxSetCIPeriodTerm(taskHandle, "Dev1/ctr0","PFI7").
 
I was hoping to connect the external sample clock to the gate of the counter using software rather than a jumper wire in hardware.
 
Just to be clear - this DAQ task runs in parallel with another DAQ task that uses the external clock on PFI7 to acquire analog data, so I need to double up the usage of the signal.
 
Thanks, Ben.

Message Edited by benbrown on 09-28-2007 05:11 AM

0 Kudos
Message 3 of 5
(3,548 Views)

Ben,

I'm not very sure whether you can replace the DAQmxConnectTerms statement with DAQmxSetCIPeriodTerm(taskHandle, "Dev1/ctr0","PFI7"). But just give it a try. I can't verify it here as I don't have any hardware with me. But in case doesn't that works I guess the only other option will be to use the jumper.

Message Edited by Kal.... on 09-28-2007 08:28 AM

BR
0 Kudos
Message 4 of 5
(3,527 Views)
Ben,

I would highly recommend replacing the DAQmxConnectTerms with the DAQmxSetCIPeriodTerm.  The first function call connects the terminals until you either explicitly disconnect the terminals or reset the board.  The DAQmxSetCIPeriodTerm does not reserve this connection beyond the lifetime of the task and will avoid a number of errors.  Furthermore this allows DAQmx to handle any indirect routing that is necessary.  Some pins must route through internal subsystems and can cause errors when using the DAQmxConnect Terms.  The error you got is one of these possible errors.

Regards,

Neil S.
MIO PSE

Message Edited by Neil S. on 10-01-2007 10:59 AM

Message 5 of 5
(3,490 Views)