Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

External clock - analog out 6225 + NI_DAQmxbase

I have a little acquisition/output routine in c (OS X, PCi-6225) that requires an external 10kHz clock + trigger. For testing, I have been using
clockSource[] = "OnboardClock"
 for both input and output tasks.
I have a 10Khz clock coming in on PFI1,   when I set
clockSource[] = "/Dev1/PFI1"
the output task fails but the input task works.
Below are  the relevant snippets, I have tried combinations of trigger and clock edge choices.

Thanks
Alex


#include <stdio.h>
#include "idl_export.h"        /* IDL external definitions */
#include "NIDAQmxBase.h"
#include <stdio.h>


// Timing parameters
    char        clockSource[] = "OnboardClock";
    uInt64      samplesPerChan = 2500;
    float64     sampleRate = 10000.0;

// Triggering parameters
    char        triggerSource[] = "/Dev1/PFI0";
    uInt32      triggerSlope = DAQmx_Val_RisingSlope;


//**** SETUP OUTPUT ******

 // Channel parameters
    char        outputChan[] = "/Dev1/ao0";
   
    // Data write parameters
    float64     outputData[bufferSize];
    int32       pointsWritten;

   if (!DAQmxBaseCreateTask("",outputTask))
       {
        DAQmxBaseCreateAOVoltageChan(*outputTask,outputChan,"",min,max,DAQmx_Val_Volts,NULL);
        DAQmxBaseCfgSampClkTiming(*outputTask,clockSource,sampleRate,DAQmx_Val_Falling,DAQmx_Val_FiniteSamps,samplesPerChan);
        DAQmxBaseCfgDigEdgeStartTrig(*outputTask,triggerSource,triggerSlope);
//        fprintf(fp,"  pointer to outputTask = %i, value of outputTask = %i \r\n",outputTask, *outputTask);
    }

int arm_digitizer_natural(TaskHandle *inputTask,TaskHandle *outputTask,float64 *writeArray,float64 *readArray )
{   

    int32 i;
       double input,output =0;
    char errorstr[512];
    uInt32 errBuffCount;

    // Data write parameters
    uInt64      samplesPerChan = 2500;
    float64     data[bufferSize];
    int32       pointsWritten;
    float64     timeout = 900.0;
   
    // Data read parameters   
    int32 pointsToRead = (uInt32)2500 *25;
    int32 pointsRead;
    int32 readResult;
   

    DAQmxBaseStartTask(*outputTask);   
    DAQmxBaseWriteAnalogF64(*outputTask,samplesPerChan,0,timeout,DAQmx_Val_GroupByChannel,writeArray,&pointsWritten,NULL);
    DAQmxBaseStartTask(*inputTask);
    readResult = DAQmxBaseReadAnalogF64(*inputTask,pointsToRead,timeout,DAQmx_Val_GroupByChannel,readArray,pointsToRead,&pointsRead,NULL);
    DAQmxBaseStopTask(*inputTask);
    DAQmxBaseStopTask(*outputTask);
   
     
    return 1;
}

 
0 Kudos
Message 1 of 3
(3,073 Views)
Hi,

What is the actual error that you get?  Is there an error number associated with the error that you receive. 

clockSource[] = "OnboardClock"
 for both input and output tasks.
I have a 10Khz clock coming in on PFI1,   when I set
clockSource[] = "/Dev1/PFI1"

Are you using both the commands in the same program?  I am assuming you meant triggerSource for the PFI1 line.

Once you give me a few more details on the error that you are receiving, I will be able to help you better.

Regards,


Raajit L
National Instruments
0 Kudos
Message 2 of 3
(3,023 Views)
Hi-
Thanks for replying.Chris Kinvig at NI Apps got back last week and pointed out that I started the task before writing data to the output. Once I reversed those lines, it worked. That worked before with an internal clock, but not an external one. I'll admit that writing to the output buffer , then starting the task is inherently more sensible, but why did it work before ? Doesn't matter, it's fine now.
thanks
Alex


0 Kudos
Message 3 of 3
(3,019 Views)