Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

semi period measuremen​t with an external clock

Hello

I am trying to make PWM (2ms width) measurement with a counter (PCIe-6363), but with external clk (1MHz) to make 1 measurement (high time/low time) every 100ms

This ext clock is create with another counter.

 

With the code below,  i have the error:

NON-FATAL RUN-TIME ERROR:   "ihm.c", line 100, col 5, thread id 0x000004E0:   Library function error (return value == -200527 [0xfffcf0b1]). Requested values of the Minimum and Maximum properties for the counter channel are not supported for the given type of device.  The values that can be specified for Minimum and Maximum depend on the counter timebase rate. Property: DAQmx_CI_Min Corresponding Value:  100.0e-6  Property: DAQmx_CI_Max Corresponding Value:  5.0e-3  Property: DAQmx_CI_SemiPeriod_Units Corresponding Value: DAQmx_Val_Seconds  Property: DAQmx_CI_CtrTimebaseSrc Corresponding Value: /Dev2/PFI8 Option: 1 Property: DAQmx_CI_CtrTimebaseRate Corresponding Value:  100.0e6 Property: DAQmx_CI_Min Value Must Be Greater Than:  20.0e-9 Property: DAQmx_CI_Max Value Must Be Less Than:  42.949673 Option: 2 Property: DAQmx_CI_CtrTimebaseRate Corresponding Value:  20.0e6 Property: DAQmx_CI_Min Value Must Be Greater Than:  100.000000e-9 Property: DAQmx_CI_Max Value Must Be Less Than:  214.748365 Option: 3 Proper

 

Here is the code:

 

char tcExtClockName [256] = "/Dev2/PFI8";

 

// [ctr1] Create a CO with pulse train triggered by PCO (on PFI2)
 DAQmxErrChk ( DAQmxCreateTask ("TaskPulseTrain", pTaskHandle2))
 DAQmxErrChk ( DAQmxCreateCOPulseChanFreq (*pTaskHandle2, "Dev2/ctr1", "", DAQmx_Val_Hz, DAQmx_Val_Low, 0.0, 1.0e6, 0.5))
 DAQmxErrChk ( DAQmxCfgImplicitTiming (*pTaskHandle2, DAQmx_Val_FiniteSamps, 2000))
 DAQmxErrChk ( DAQmxCfgDigEdgeStartTrig (*pTaskHandle2, ACQ_CLOCK, DAQmx_Val_Rising))
 DAQmxErrChk ( DAQmxSetTrigAttribute (*pTaskHandle2, DAQmx_StartTrig_Retriggerable, TRUE))

 
  //DAQmxConnectTerms ("/Dev2/Ctr0Source", "/Dev2/PFI8", DAQmx_Val_DoNotInvertPolarity);


 // [ctr0] Create task measure PWM
 DAQmxErrChk ( DAQmxCreateTask ("TaskMesurePWM", pTaskHandle))
 DAQmxErrChk ( DAQmxCreateCISemiPeriodChan (*pTaskHandle, "Dev2/ctr0", "Demi-période", 0.0001, 0.005, DAQmx_Val_Seconds, ""))
 DAQmxErrChk ( DAQmxCfgImplicitTiming (*pTaskHandle, DAQmx_Val_ContSamps, 100))
 
 DAQmxErrChk (DAQmxGetChanAttribute (*pTaskHandle, "", DAQmx_CI_CtrTimebaseSrc, tcTemp, 256))
 DAQmxGetChanAttribute (*pTaskHandle, "", DAQmx_CI_SemiPeriod_Term, tcTemp, 256);
 
 DAQmxErrChk (DAQmxSetChanAttribute (*pTaskHandle, "", DAQmx_CI_CtrTimebaseSrc, tcExtClockName, sizeof(tcExtClockName)))
 DAQmxErrChk (DAQmxSetChanAttribute (*pTaskHandle, "", DAQmx_CI_CtrTimebaseRate, 1.0e-6, sizeof (double)))
 
 DAQmxErrChk (DAQmxGetChanAttribute (*pTaskHandle, "", DAQmx_CI_CtrTimebaseSrc, tcTemp, 256))
 DAQmxErrChk (DAQmxGetChanAttribute (*pTaskHandle, "", DAQmx_CI_CtrTimebaseRate, &lfRate, sizeof (double)))

 

 

If someone can explain me how to use an external clk for this kind of measurement?

Thanx

 

0 Kudos
Message 1 of 1
(5,347 Views)