From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I change the pulse width of the NI sample clock ?

Thanks John, I misunderstood what you meant there.  I will definitley try that and get back to you.  Somehow I missed the part about resolution where your wrote "You can probably use the Frequency Generator to find an acceptable frequency that gives a wide enough pulse width as well as a high enough resolution for your clocks"...

 

Sometimes in the rush to "get things done" we miss out on the most important details. 

 

Lou III

 

0 Kudos
Message 11 of 15
(1,247 Views)

 

Hello John, I don't think I can route the FrequencyOutput to be my ai\ConvertClockTimebase as per the picture below.  Did you mean sampleClockTimebase?  I am also a little confused as to what sample interval I would specify?  If I put in a 5Mz convert clock (instead of the 20MHz normal one) would I then have to adjust my "desired interval" by a factor of 4 since the NI board wouldn't know that it has a different clock?  Or would the ni board just majically detect this and my call to DAQmxcfgSampClkTiming would be the same ?  I'm a little confused here.  I do have an NI service request number and have spoken to an NI tech guy already but he was of little help.  Is there any way you could call me?  Sorry for asking as I'm sure this breaks a rule or something.

Request number is 1703495

 

6220.JPG

0 Kudos
Message 12 of 15
(1,182 Views)

Hi Lou,

 

As you've seen you can't route many things directly to the Convert Clock Timebase on M Series.  However, you may route the Sample Clock Timebase to the Convert Clock Timebase.  So I really meant both the Sample Clock and Convert Clock timebases since they have to be the same unless you want to use 20 MHz for the Convert Clock Timebase.

2011-06-28_120012.png

 

The Frequency Generator may be routed to the Sample Clock Timebase through the Trigger Bus.

 

 

In LabVIEW this would look like:

        2011-06-28_120229.png

 

 

In the C API:

 

DAQmxSetSampClkTimebaseRate(taskHandle, 5000000);

DAQmxSetSampClkTimebaseSrc(taskHandle, "/6259/FrequencyOutput");

DAQmxSetAIConvTimebaseSrc(taskHandle, DAQmx_Val_SameAsSampTimebase);

 

 

So you would need to use the Frequency Output for both timebases.  Since you tell the driver what the rate is, it should adjust the divisor for you given the frequency of your new timebase.  Just make sure that the rate is really what you think it is, the Frequency Generator can only output a few specific frequencies and will coerce the frequency if you ask for something else. 

 

 

 

Best Regards,

John Passiak
Message 13 of 15
(1,177 Views)

So good news bad news.  I have the freqout working perfectly and being spit out PFI14 but when I try and set it as my sample clock I get an error on the StartTask of -89120 (DAQmxErrorInvalidRoutingSourceTerminalName_Routing)

 

 

The code I added (to my already existing and working code) looks like this....

Do note that the AI_Task already has an analog channel setup on it. 

If I comment out the lines with the ** in them the StartTask returns an error of zero, If I run the ** steps they each return an error code of zero but the StartTask returns -89120.  Any idea?

Also, I am doing this on a USB-6221 which on the Device Routes grid actually shows that \freqout tied to \ai\SampleClockTimebase is a GREEN square which on the PCI-6220 is shown as a YELLOw square. 

 

 

 

   char freq_out_name[100];

    sprintf(freq_out_name, "/%s/freqout", Config.DeviceName);  // Config.DeviceName is Dev5
    float64 new_clock = 2500000.0F; // 2.5 MHz

 

    ni_err = DAQmxCreateTask("", &FreqOut.taskHandle);
    ni_err = DAQmxCreateCOPulseChanFreq(FreqOut.taskHandle, freq_out_name, "", DAQmx_Val_Hz, DAQmx_Val_Low, 0.0F, new_clock, 0.5F);
    ni_err = DAQmxCfgImplicitTiming(FreqOut.taskHandle, DAQmx_Val_ContSamps, 1000);
    

    ni_err = DAQmxSetCOPulseTerm(FreqOut.taskHandle, freq_out_name, GD_Info.SampleClock);

    ni_err = DAQmxStartTask(FreqOut.taskHandle);

 

 **   ni_err = DAQmxSetSampClkTimebaseRate(AI_Task, new_clock);
**    ni_err = DAQmxSetSampClkTimebaseSrc(AI_Task, freq_out_name);

**    ni_err = DAQmxSetAIConvTimebaseSrc(AI_Task, DAQmx_Val_SameAsSampTimebase);

ni_err = DAQmxCfgSampClkTiming(AI_Task,"",200.0F,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000);

    ni_err = DAQmxStartTask(AI_Task);

 

 

0 Kudos
Message 14 of 15
(1,146 Views)

I figured out my problem the call to set the sample clk needs \FrequencyOutput rather than \freqout.  This is a little confusing but I'm not complaining.  Thanks for all your help John, you've saved us some real time and money and most of all made it seemless to our own field engineers and customers.

 

ni_err = MXLib->DAQmxSetSampClkTimebaseSrc(AI_Task, "\Dev5\FrequencyOutout");

0 Kudos
Message 15 of 15
(1,141 Views)