10-05-2007 03:14 PM
Hello NI support,
I seem to be having some trouble using the DAQmx C api and using PCI-6602 hardware.
I am trying to write a program to valididate monitor mode settings ( e.g. 1024x768 @ 60Hz, 1280x1024 @ 60Hz, etc...) using PCI-6602 and DAQmx C library. I already have a program using traditional DAQ but need to port to DAQmx. Legacy code works fine. The problem is mapping functions from traditional DAQ and DAQmx.
For ONE of my measurements, I am trying to count the number of pixels that that appear on one period of Hsync signal. If monitor was set to 1024 x 768 @ 60 Hz, then there should be AT LEAST 1024 pixel count for one period of Hsync signal and when I set to 1280 x 1024 @ 60 hz then there should be AT LEAST 1280 pixel count in one period of Hsync signal.
That is how it is working for my program using traditional DAQ library.
For my program using DAQmx the numbers I am getting seem to be off. I think I may be using DAQmx functions incorrectly.
Problem:
When I set monitor to 1024x768 and take measurement, the pixel count is about 400 - correct value should be at least 1024
When I set monitor to 1280x1024 and take masurement, the pixel count is about 50 - correct value should be at least 1280
Here is sample code.
#define
GATE_HSYNC "/Dev1/PFI26"#define
SRC_PIXEL_CLK "/Dev1/PFI15"DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
//Create period measurement
DAQmxErrChk (DAQmxCreateCIPeriodChan(taskHandle,
"Dev1/ctr1","",0.00000100,1,DAQmx_Val_Ticks,DAQmx_Val_Rising,DAQmx_Val_LowFreq1Ctr,0.000100,4,""));//Set source using pixel clock signal
DAQmxSetTimingAttribute(taskHandle,DAQmx_SampClk_Src,SRC_PIXEL_CLK ));
//Set gate using HSync signal
DAQmxSetChanAttribute(taskHandle,
"/Dev1/ctr1",DAQmx_CI_PulseWidth_Term,GATE_HSYNC,0);DAQmxStartTask(taskHandle);
while
( 1 ){
"Acquired %d samples\n",read);DAQmxErrChk( DAQmxReadCounterF64(taskHandle,BUFFER,30,data,BUFFER,&read,0));
printf(
iSamplesRead += read;
if(iSamplesRead >= BUFFER)break;
}
From attached image, the "Hsync" and "DE" signals is what I'm trying to measure using Pixel clk signal as source for each signal.
Am I using DAQmx API wrong? Should I be using different DAQmx functions? I am new to PCI-6602 hardware and DAQmx and DAQ(traditional) so any insight would be appreciated.
Thanks
glo
10-08-2007 04:57 PM
Hi glo,
You mentioned a image but I believe you did not attach it to your previous post. Also could you please verify the number of iterations of you while loop and also
what is the anticipated pixel clock rate
Looking at your code I believe the call you should make is
DAQmxSetChanAttribute(taskHandle,"/Dev1/ctr1",DAQmx_CI_Period_Term,GATE_HSYNC,0);
rather than
DAQmxSetChanAttribute(taskHandle,"/Dev1/ctr1",DAQmx_CI_PulseWidth_Term,GATE_HSYNC,0);
Also please refer to the DAQmx examples which can be found in the following location:
since you are counting the number of pulses that occur on the line, it may be more applicable to have an event counting application. There is a shipping example located at C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Counter\Count Digital Events
Hope this helps!
10-12-2007 10:29 AM
10-12-2007 11:16 AM
Hi JaceD,
Sorry for my late response and thanks for your quick reply.
I attached the image again. I am trying to count the HSync, VSync and DE signals. The expected results should be when I increase monitor resolution, the number of ticks should increase. Currently results is opposite
Current observation shows increasing monitor resolutions seems to decrease the count, which is opposite of expected results.
I tried your suggestions about using counting using digital events but the results seem to be the same.
I tried using PCI-6602 internal clk - 80MhzTimeBase instead of the pixel clock and results seem to be the same. The expected results is opposite of what I expect.
I tried to count VSync, DE signals but this shows same behaviour.
Any insight would be apprecited.
Thanks again for reply.
Cheers,
Geoff
PS. attached code again.
//Gate
#define GATE_Red "/Dev1/PFI38"
#define GATE_Green "/Dev1/PFI34"
#define GATE_Blue "/Dev1/PFI30"
#define GATE_VSYNC "/Dev1/PFI22" //Vsync
#define GATE_HSYNC "/Dev1/PFI26" //Hsync
#define GATE_DE "/Dev1/PFI18" //Data Enable
//Source
#define
SRC_PIXEL_CLK "/Dev1/PFI15"#define SRC_ICLK "/Dev/80MhzTimebase"
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
//Create period measurement
DAQmxErrChk (DAQmxCreateCIPeriodChan(taskHandle,
"Dev1/ctr1","",0.00000100,1,DAQmx_Val_Ticks,DAQmx_Val_Rising,DAQmx_Val_LowFreq1Ctr,0.000100,4,""));//Set source using pixel clock signal
DAQmxSetTimingAttribute(taskHandle,DAQmx_SampClk_Src,SRC_ICLK));
//Set gate signal that I am trying to measure
DAQmxSetChanAttribute(taskHandle,
"/Dev1/ctr1",DAQmx_CI_Period_Term,GATE_HSYNC,0);DAQmxStartTask(taskHandle);
10-12-2007 03:30 PM
Hello JaceD,
I think there might something wrong with calculations on my side. I am double checking .... 😞
Please disregard previous post for now .... unless you see something wrong with my code please let me know.
Thanks again. Cheers,
Geoff
10-18-2007 12:56 PM
//Gate
#define GATE_Red "/Dev1/PFI38"
#define GATE_Green "/Dev1/PFI34"
#define GATE_Blue "/Dev1/PFI30"
#define GATE_VSYNC "/Dev1/PFI22" //Vsync
#define GATE_HSYNC "/Dev1/PFI26" //Hsync
//Source
#define
SRC_PIXEL_CLK "/Dev1/PFI15"//#define SRC_PIXEL_CLK "/Dev1/Ctr6InternalOutput"
#define SRC_ICLK "/Dev/80MhzTimebase"
//Create period measurement
DAQmxErrChk (DAQmxCreateCIPeriodChan(taskHandle,"Dev1/ctr1","",0.00000100,1,DAQmx_Val_Ticks,DAQmx_Val_Rising,DAQmx_Val_LowFreq1Ctr,0.000100,4,""));
//Set source using pixel clock signal
DAQmxSetTimingAttribute(taskHandle,DAQmx_SampClk_Src,SRC_PIXEL_CLK));
//DAQmxCfgSampClkTiming(taskHandle, SRC_PIXEL_CLK, 1000, DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,1000); - I get -200300 error message
//Set gate signal that I am trying to measure
DAQmxSetChanAttribute(taskHandle,"/Dev1/ctr1",DAQmx_CI_Period_Term,GATE_HSYNC,0);
DAQmxStartTask(taskHandle);
// Select gate input/polarity
pGPCTR_Change_Parameter( device, timerId, ND_GATE, startInput.gate ); pGPCTR_Change_Parameter( device, timerId, ND_GATE_POLARITY, startInput.logic[startEdge] );// Select source input/polarity
pGPCTR_Change_Parameter( device, timerId, ND_SOURCE, countInput.source ) ); pGPCTR_Change_Parameter( device, timerId, ND_SOURCE_POLARITY, countInput.logic[countEdge] ) );10-19-2007 12:36 PM
Hi Geoff,
I believe that the correct property to set is DAQmxSetCICtrTimebaseSrc(TaskHandle taskHandle, const char channel[], const char *data);
The use of this function is best described in the NI-DAQmx C Reference Help file. I have provided the text below for ease of use.
Specifies the terminal of the timebase to use for the counter.
Typically, NI-DAQmx uses one of the internal counter timebases when performing counter measurements. Use this property to specify an external timebase and produce custom measurement ranges that are not possible with the internal timebases.
The location of this information in the NI-DAQmx C Reference Help is NI-DAQmx C Properties>>List of Channel Properties>>Counter Input >> General Properties >> Counter Timebase >> Source.
I hope this helps! Please let us know how this works or if you have any more questions.
10-19-2007 02:52 PM
//Gate
#define GATE_Red "/Dev1/PFI38"
#define GATE_Green "/Dev1/PFI34"
#define GATE_Blue "/Dev1/PFI30"
#define GATE_VSYNC "/Dev1/PFI22" //Vsync
#define GATE_HSYNC "/Dev1/PFI26" //Hsync
//Source
#define
SRC_PIXEL_CLK "/Dev1/PFI15"#define SRC_ICLK "/Dev/80MhzTimebase"
...
//Create period measurement
DAQmxErrChk (DAQmxCreateCIPeriodChan(taskHandle,"Dev1/ctr1","",0.00000100,1,DAQmx_Val_Ticks,DAQmx_Val_Rising,DAQmx_Val_LowFreq1Ctr,0.000100,4,""));
...
//Set source input of counter. Using pixel clock signal to measure signal of the counter's gate input
DAQmxSetCICtrTimebaseSrc(taskHandle,"Dev1/ctr1",SRC_PIXEL_CLK)
...
//Set gate input of counter. The signal I am trying to measure.
DAQmxSetChanAttribute(taskHandle,"/Dev1/ctr1",DAQmx_CI_Period_Term,GATE_HSYNC,0);
DAQmxStartTask(taskHandle);
...