Discussion:
6255 gated external sample clock for use with an ai task
(too old to reply)
anderssd
2008-07-11 16:40:16 UTC
Permalink
I have an application written in ansi C that will create an NI task that will run a continueous collection of several AI lines at a set collection rate (see CollectionRate below).  This is a simplified version of the setup of the ai task:
 
      ni_rc = DAQmxCreateTask (                  "",                     // name assigned to the task                  &ai_task);   // reference to the task created in this function
      for (i = 0; i < ai_channels; i++)      {            /* Create an NI AI voltage channel.             */         if (ai_ptrs[i].chan_num >= 0)         {            char  chan_name[MAX_STRLEN];  // NI channel name, e.g. "Dev1/ai2"
            //             long     chan_num = ai_ptrs[i].chan_num;
            sprintf (chan_name, INPUT_CHANNEL_FORMAT, deviceName, chan_num);            ni_rc = DAQmxCreateAIVoltageChan (                        ai_task,                // task to which to add the channel                        chan_name,              // names of the physical channels to use                        "",                     // name(s) to assign to the created virtual channel(s)                        terminal_config,        // differential vs. single-ended                        (double) devsupp_ai_channels[chan_num].volts_min,   // minimum voltage expected                        (double) devsupp_ai_channels[chan_num].volts_max,                        (long) DAQmx_Val_Volts, // units in which to generate voltage (unscaled)                        "");                    // name of a custom scale         }      }      ni_rc = DAQmxCfgSampClkTiming (      
S_Hong
2008-07-14 22:40:07 UTC
Permalink
Hi anderssd,
If you would like to set up a gated external clock, you can look into the some of our DAQmx shipping examples which shows you exactly how to set that up. The DAQmx ANSI C examples are installed with your DAQmx drivers and should be under C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Counter\Generate Pulse. The example we are particularly interested in is Dig Pulse Train Cont-Pause Trig. This example allows you to generate a continuous pulse train using a counter and have a pause trigger. This can effectively be used to gate your clock, however, you would need to make an external connection from your external signal to one of the PFI lines.
I hope this helps,
anderssd
2008-07-15 13:40:10 UTC
Permalink
Thanks:
In point of fact for my application the DAQmxSetDigLvlPauseTrig* (DAQmxSetDigLvlPauseTrigSrc & DAQmxSetDigPatternPauseTrigWhen) are a better fit.  For my case I will use a line (PFI9) as the source of the pause trigger and use the PFI7 as the source clock.
 
 

Loading...