Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate two digital pulse trains on 6259

I've got one pulse gen working but now am trying to run a 2nd simultaneous pulse gen. I can get either one to run but not both. The setup is use ctr0 with 80MHzTimebase trigger and output on pfi4 for one pulse gen and the other uses ctr1 with 80MHzTimebase trigger and output on pfi3. Is there any limitation in the USB-6259 preventing this? Here is the code: (I did also try setting up both counters in one task and that didn't work either....) The continuous pulse do not need to be sychronized.

 

//---------------------------------------------------------
int CniDAQ::NiDaqSetPulseGen(TaskHandle *taskHandle, char * chnl,
            char * ctr, float64 freq, float64  duty,
            uInt32 initDelay, uInt32 edge, const char triggerSource[])
{
    int32   error=0;
    int numSamples=5;

    DAQmxErrChk (DAQmxCreateTask("", taskHandle));
    DAQmxErrChk (DAQmxCreateCOPulseChanFreq(*taskHandle, ctr,"",
            DAQmx_Val_Hz,DAQmx_Val_Low,0,freq,duty));

    // re-assign pin   
    DAQmxSetCOPulseTerm(*taskHandle, ctr, chnl) ;         

    DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(*taskHandle,triggerSource,edge));
    DAQmxErrChk (DAQmxCfgImplicitTiming(*taskHandle,DAQmx_Val_FiniteSamps ,numSamples));
    DAQmxErrChk (DAQmxSetStartTrigRetriggerable(*taskHandle, 1));

    DAQmxStartTask(*taskHandle);

Error:
    return error;
}
//----------------------------------------------------------

 

It gets called twice with different taskHandle, ctr and chnl

1. ctr= /Dev1/ctr0 chnl= /Dev1/pfi4, taskHandle= taskHandle1

2. ctr= /Dev1/ctr1 chnl= /Dev1/pfi3, taskHandle= taskHandle2

 

   Thanks for your help,

   Brian

 

0 Kudos
Message 1 of 2
(5,508 Views)

Well I figured it out. It's always simple once you see the answer.....

 

//--------------------------------------------------------------------------------------------
int CniDAQ::NiDaqSetPulseGen(TaskHandle *taskHandle, char * chnl, char * ctr, float64 freq, float64  duty,
        uInt32 initDelay, uInt32 edge, const char triggerSource[])
{
 int32   error=0;
 int numSamples=5;

 DAQmxErrChk (DAQmxCreateTask("", taskHandle));
 DAQmxErrChk (DAQmxCreateCOPulseChanFreq(*taskHandle, ctr,"",DAQmx_Val_Hz,DAQmx_Val_Low,0,freq,duty));

    // re-assign pin...   
 DAQmxSetCOPulseTerm(*taskHandle, ctr, chnl) ;         

 DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(*taskHandle,triggerSource,edge));
 DAQmxErrChk (DAQmxCfgImplicitTiming(*taskHandle,DAQmx_Val_ContSamps ,numSamples));

 DAQmxStartTask(*taskHandle);

 

   // TO DO: calling code later stops & clears taskhandle and resets pin-out.

 

Error:
 return error;
}

0 Kudos
Message 2 of 2
(5,497 Views)