Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

6255 gated external sample clock for use with an ai task

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 (
                  ai_task,           // task reference
                  "",                           // clock source terminal (internal clock)
                  (double)CollectionRate,       // sampling rate in hz
                  (long) DAQmx_Val_Rising,      // rising edge of clock signal is active
                  (long) DAQmx_Val_ContSamps,   // continuous sampling
                  1ULL);                        // samples per channel to acquire
      ni_rc = DAQmxStartTask (ai_task);
 
 
Now I need to use an external sample clock.  That part will be easy just change the DAQmxCfgSampClkTiming statement to:
 
            ni_rc = DAQmxCfgSampClkTiming (
                        ai_task,           // task reference
                        CLOCK_SOURCE,                      // clock source terminal e.g. PFI7 or RTSI2...
                        MAX_COLECTION_RATE,           // maximum sampling rate in hz
                        (long) DAQmx_Val_Rising,      // rising edge of clock signal is active
                        (long) DAQmx_Val_ContSamps,   // continuous sampling
                        1ULL);                        // samples per channel to acquire
 
However I also need to have the external clock GATED by a second external signal.  I am sure given the capabilities of the card and the DAQmx software In can be done but how?  Do I need to set up a second task with a counter (as a divide by 1).  The clock input and gate to the counter will be from a hardware terminal and use the counter output as the CLOCK_SOURCE?
0 Kudos
Message 1 of 2
(2,610 Views)
0 Kudos
Message 2 of 2
(2,597 Views)