Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Assigning PFI lines to counter

Have anybody out there used "DAQmxSetCIFreqTerm" function on CVI before for PCI6221 DAQ card?

 

Hiren Patel
0 Kudos
Message 11 of 27
(2,868 Views)
Ok, so ignore my previous post.  The second parameter is the channel name parameter that was used with the DAQmx Create Channel function.  If you left it blank, i.e. "", you can leave the second parameter blank.  The third parameter is the PFI line that you want to route the signal to.  You will need to use syntax like "/Dev1/PFIx".  Sorry about the confusion.
-Alan A.
0 Kudos
Message 12 of 27
(2,859 Views)
Alan,
Thanks for the input. I have tried this but it still do not want to work. Here is my function I am trying to use, look at it and tell me what I am doing worng here.
 
int readFrequency(short sample)
{
 int32 sampleRead,
    samples;
 float64 freqRead[1024],
     freqReadAve;
 int i;
 freqReadAve = 0.0;
 samples = (int32) sample;
 DAQmxCreateTask ("", &freqTask);
 DAQmxCreateCIFreqChan (freqTask, "Dev1/ctr0", "", 2.0, 600000.0,
          DAQmx_Val_Hz, DAQmx_Val_Rising,
          DAQmx_Val_LowFreq1Ctr, 5, 4, "");
 
 DAQmxCfgImplicitTiming (freqTask, DAQmx_Val_FiniteSamps, samples);
/DAQmxSetCIFreqTerm(freqTask, "/Dev1/PFI8", "/Dev1/PFI8");
 DAQmxStartTask (freqTask);
 DAQmxReadCounterF64 (freqTask, samples, 2.0, freqRead, 1024, &sampleRead, 0);
 DAQmxStopTask (freqTask);
 DAQmxClearTask (freqTask);
 for(i = 0; i < sampleRead; i++)
  freqReadAve += freqRead[i];
 
 measuredFreq = (double)freqReadAve / --i;
 return 0;
}
Hiren Patel
0 Kudos
Message 13 of 27
(2,855 Views)
Alan,
Thanks for the input. I have tried this but it still do not want to work. Here is my function I am trying to use, look at it and tell me what I am doing worng here.
 
int readFrequency(short sample)
{
 int32 sampleRead,
     samples;
 float64 freqRead[1024],
     freqReadAve;
 int i;
 freqReadAve = 0.0;
 samples = (int32) sample;
 DAQmxCreateTask ("", &freqTask);
 DAQmxCreateCIFreqChan (freqTask, "Dev1/ctr0", "", 2.0, 600000.0,
          DAQmx_Val_Hz, DAQmx_Val_Rising,
          DAQmx_Val_LowFreq1Ctr, 5, 4, "");
 
 DAQmxCfgImplicitTiming (freqTask, DAQmx_Val_FiniteSamps, samples);
/DAQmxSetCIFreqTerm(freqTask, "/Dev1/PFI8", "/Dev1/PFI8");
 DAQmxStartTask (freqTask);
 DAQmxReadCounterF64 (freqTask, samples, 2.0, freqRead, 1024, &sampleRead, 0);
 DAQmxStopTask (freqTask);
 DAQmxClearTask (freqTask);
 for(i = 0; i < sampleRead; i++)
  freqReadAve += freqRead[i];
 
 measuredFreq = (double)freqReadAve / --i;
 return 0;
}
Hiren Patel
0 Kudos
Message 14 of 27
(2,855 Views)
Alan,
Thanks for the input. I have tried this but it still do not want to work. Here is my function I am trying to use, look at it and tell me what I am doing worng here.
 
int readFrequency(short sample)
{
 int32 sampleRead,
      samples;
 float64 freqRead[1024],
     freqReadAve;
 int i;
 freqReadAve = 0.0;
 samples = (int32) sample;
 DAQmxCreateTask ("", &freqTask);
 DAQmxCreateCIFreqChan (freqTask, "Dev1/ctr0", "", 2.0, 600000.0,
          DAQmx_Val_Hz, DAQmx_Val_Rising,
          DAQmx_Val_LowFreq1Ctr, 5, 4, "");
 
 DAQmxCfgImplicitTiming (freqTask, DAQmx_Val_FiniteSamps, samples);
/DAQmxSetCIFreqTerm(freqTask, "/Dev1/PFI8", "/Dev1/PFI8");
 DAQmxStartTask (freqTask);
 DAQmxReadCounterF64 (freqTask, samples, 2.0, freqRead, 1024, &sampleRead, 0);
 DAQmxStopTask (freqTask);
 DAQmxClearTask (freqTask);
 for(i = 0; i < sampleRead; i++)
  freqReadAve += freqRead[i];
 
 measuredFreq = (double)freqReadAve / --i;
 return 0;
}
Hiren Patel
0 Kudos
Message 15 of 27
(2,856 Views)
Alan,
Thanks for the input. I have tried this but it still do not want to work. Here is my function I am trying to use, look at it and tell me what I am doing worng here.
 
int readFrequency(short sample)
{
 int32 sampleRead,
       samples;
 float64 freqRead[1024],
     freqReadAve;
 int i;
 freqReadAve = 0.0;
 samples = (int32) sample;
 DAQmxCreateTask ("", &freqTask);
 DAQmxCreateCIFreqChan (freqTask, "Dev1/ctr0", "", 2.0, 600000.0,
          DAQmx_Val_Hz, DAQmx_Val_Rising,
          DAQmx_Val_LowFreq1Ctr, 5, 4, "");
 
 DAQmxCfgImplicitTiming (freqTask, DAQmx_Val_FiniteSamps, samples);
/DAQmxSetCIFreqTerm(freqTask, "/Dev1/PFI8", "/Dev1/PFI8");
 DAQmxStartTask (freqTask);
 DAQmxReadCounterF64 (freqTask, samples, 2.0, freqRead, 1024, &sampleRead, 0);
 DAQmxStopTask (freqTask);
 DAQmxClearTask (freqTask);
 for(i = 0; i < sampleRead; i++)
  freqReadAve += freqRead[i];
 
 measuredFreq = (double)freqReadAve / --i;
 return 0;
}
Hiren Patel
0 Kudos
Message 16 of 27
(2,856 Views)
Alan,
Thanks for the input. I have tried this but it still do not want to work. Here is my function I am trying to use, look at it and tell me what I am doing worng here.
 
int readFrequency(short sample)
{
 int32 sampleRead,
        samples;
 float64 freqRead[1024],
     freqReadAve;
 int i;
 freqReadAve = 0.0;
 samples = (int32) sample;
 DAQmxCreateTask ("", &freqTask);
 DAQmxCreateCIFreqChan (freqTask, "Dev1/ctr0", "", 2.0, 600000.0,
          DAQmx_Val_Hz, DAQmx_Val_Rising,
          DAQmx_Val_LowFreq1Ctr, 5, 4, "");
 
 DAQmxCfgImplicitTiming (freqTask, DAQmx_Val_FiniteSamps, samples);
/DAQmxSetCIFreqTerm(freqTask, "/Dev1/PFI8", "/Dev1/PFI8");
 DAQmxStartTask (freqTask);
 DAQmxReadCounterF64 (freqTask, samples, 2.0, freqRead, 1024, &sampleRead, 0);
 DAQmxStopTask (freqTask);
 DAQmxClearTask (freqTask);
 for(i = 0; i < sampleRead; i++)
  freqReadAve += freqRead[i];
 
 measuredFreq = (double)freqReadAve / --i;
 return 0;
}
Hiren Patel
0 Kudos
Message 17 of 27
(2,856 Views)
Alan,
Thanks for the input. I have tried this but it still do not want to work. Here is my function I am trying to use, look at it and tell me what I am doing worng here.
 
int readFrequency(short sample)
{
 int32 sampleRead,
         samples;
 float64 freqRead[1024],
     freqReadAve;
 int i;
 freqReadAve = 0.0;
 samples = (int32) sample;
 DAQmxCreateTask ("", &freqTask);
 DAQmxCreateCIFreqChan (freqTask, "Dev1/ctr0", "", 2.0, 600000.0,
          DAQmx_Val_Hz, DAQmx_Val_Rising,
          DAQmx_Val_LowFreq1Ctr, 5, 4, "");
 
 DAQmxCfgImplicitTiming (freqTask, DAQmx_Val_FiniteSamps, samples);
/DAQmxSetCIFreqTerm(freqTask, "/Dev1/PFI8", "/Dev1/PFI8");
 DAQmxStartTask (freqTask);
 DAQmxReadCounterF64 (freqTask, samples, 2.0, freqRead, 1024, &sampleRead, 0);
 DAQmxStopTask (freqTask);
 DAQmxClearTask (freqTask);
 for(i = 0; i < sampleRead; i++)
  freqReadAve += freqRead[i];
 
 measuredFreq = (double)freqReadAve / --i;
 return 0;
}
Hiren Patel
0 Kudos
Message 18 of 27
(2,856 Views)
Alan,
Thanks for the input. I have tried this but it still do not want to work. Here is my function I am trying to use, look at it and tell me what I am doing worng here.
 
int readFrequency(short sample)
{
 int32 sampleRead,
          samples;
 float64 freqRead[1024],
     freqReadAve;
 int i;
 freqReadAve = 0.0;
 samples = (int32) sample;
 DAQmxCreateTask ("", &freqTask);
 DAQmxCreateCIFreqChan (freqTask, "Dev1/ctr0", "", 2.0, 600000.0,
          DAQmx_Val_Hz, DAQmx_Val_Rising,
          DAQmx_Val_LowFreq1Ctr, 5, 4, "");
 
 DAQmxCfgImplicitTiming (freqTask, DAQmx_Val_FiniteSamps, samples);
/DAQmxSetCIFreqTerm(freqTask, "/Dev1/PFI8", "/Dev1/PFI8");
 DAQmxStartTask (freqTask);
 DAQmxReadCounterF64 (freqTask, samples, 2.0, freqRead, 1024, &sampleRead, 0);
 DAQmxStopTask (freqTask);
 DAQmxClearTask (freqTask);
 for(i = 0; i < sampleRead; i++)
  freqReadAve += freqRead[i];
 
 measuredFreq = (double)freqReadAve / --i;
 return 0;
}
Hiren Patel
0 Kudos
Message 19 of 27
(2,856 Views)
Sorry I hit the TAB to many times
Hiren Patel
0 Kudos
Message 20 of 27
(2,857 Views)