From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx: synchronizing two pulse output tasks

Solved!
Go to solution

Hi Gang,

 

I need to synchronize two pulse output tasks.  I'm using the PCI-6601 counter-timer.  I need to use two tasks because the frequency of the second output must be a sub-multiple of the first.  I believe the way to do this is by using the Arm Start Trigger functionality.  I've found some information on this site about it, but the examples talked about using a "dummy" analog task, which I don't understand.  I've found no documentation on the Arm Start Trigger in the DAQmx documentation.

 

For reference here is the applicable part of my code:

 

TaskHandle DetHandle, LasHandle;

 

DAQmxCreateTask("DetPulses", &DetHandle);
DAQmxCreateTask("LasPulses", &LasHandle);

DAQmxCreateCOPulseChanFreq(DetHandle,DetChannel,
"DetChan",DAQmx_Val_Hz,DAQmx_Val_Low,0.0,
StateSettings.DetFreq,StateSettings.DetDuty);
DAQmxCreateCOPulseChanFreq(LasHandle,LasChannel,
"LasChan",DAQmx_Val_Hz,DAQmx_Val_Low,StateSettings.Delay,
StateSettings.LasFreq,StateSettings.LasDuty);
DAQmxCfgImplicitTiming(DetHandle,DAQmx_Val_FiniteSamps,
StateSettings.DetPulses);
DAQmxCfgImplicitTiming(LasHandle,DAQmx_Val_FiniteSamps,
StateSettings.LasPulses);

DAQmxStartTask(DetHandle);
DAQmxStartTask(LasHandle);

 

DAQmxWaitUntilTaskDone(DetHandle,10.00);
DAQmxWaitUntilTaskDone(LasHandle,10.00);

DAQmxStopTask(DetHandle);

 

DAQmxStopTask(LasHandle);

DAQmxClearTask(DetHandle);

 

DAQmxClearTask(LasHandle);

 

I believe that I need to insert the arm start code before the start tasks, but I don't know what device to use for the start trigger.

 

I'll appreciate all help.

 

Thanks!

 

Roger

0 Kudos
Message 1 of 7
(8,098 Views)

Hello RogerMont,

 

I found this DAQmx C# example which I think could guide you as it shows how to synchronize two boards' digital outputs and analog outputs. Documentation about Arm Start Trigger can be found in the NI-DAQmx C Reference Help, which you can get by going to Start >> Programs >> National Instruments >> NI-DAQ >>Text-Based Code Support.

 

Regards,

 

Jorge

Applications Engineer

Jorge
Applications Engineer
National Instruments
________________________________________
Certified LabVIEW Associate Developer (CLAD)
0 Kudos
Message 2 of 7
(8,091 Views)

I'm still frustrated...

 

The example is worthless.  Typical of an academic.  I've spent an hour searching the code and haven't found anything appropriate.  The example I found from 2 years ago in this forum is better.  The documentation is worthless.  it only consists of a one-line syntax diagram of the call.  Again, I figured that out from the example I found.

 

<end-of-rant>

 

I think I'm close, but what I need to know is how to trigger the arm start from one of the digital lines of the PCI-6601 board.  My code never sees the trigger.

 

Failing this another possible way of doing this is to inhibit counter clock source some way until it can be turned on by routing command.

 

Please ask around in NI for someone who has some experience in this.

 

Thanks,

 

Roger

Smiley Sad

Message 3 of 7
(8,076 Views)

Hi Again,

 

I realized the code I posted earlier doesn't have the synchronizing code I'm trying to make work, so here it is:

 

//Create DO channel for the trigger
DAQmxCreateDOChan(TrgHandle,TrgSource,"",
DAQmx_Val_ChanForAllLines);

 

//Set the Arm start Trigger for the counters
DAQmxSetArmStartTrigType(DetHandle,DAQmx_Val_DigEdge);
DAQmxSetDigEdgeArmStartTrigSrc(DetHandle,"Dev2/port0/line7");
DAQmxSetArmStartTrigType(LasHandle,DAQmx_Val_DigEdge);
DAQmxSetDigEdgeArmStartTrigSrc(LasHandle,"Dev2/port0/line7");

//Start the tasks (they won't really start until the trigger)
DAQmxStartTask(DetHandle);
DAQmxStartTask(LasHandle);
DAQmxStartTask(TrgHandle);

 

//Create the positive edge trigger
DAQmxWriteDigitalLines(TrgHandle,1,1,10.0,
DAQmx_Val_GroupByChannel,OnByte,NULL,NULL);

 

//wait until the pulse train is done
DAQmxWaitUntilTaskDone(TrgHandle,10.00);
DAQmxWaitUntilTaskDone(DetHandle,10.00);
DAQmxWaitUntilTaskDone(LasHandle,10.00);

 

The issue is that arm start never triggers even though I have physically put a high on that terminal.  

 

I'll appreciate all help.

 

Thanks,

 

Roger

0 Kudos
Message 4 of 7
(8,071 Views)

Hi Again,

 

I should also note that I've tried an alternative syntax:

 

DAQmxCfgDigEdgeStartTrig(...)

 

That does the same thing.  It creates no errors, but never triggers.

 

I still think that I'm not doing something right.  If anybody has experience with syncing tasks on a PCI-660x I'd really like to hook up with them.

 

 

Thanks!

 

Roger

Smiley Indifferent

0 Kudos
Message 5 of 7
(8,063 Views)

Hi Roger,

 

I have wrote a piece of example code (using C) based on this LabVIEW example, which I assume is the one you were looking at. It shows how to use the ArmStartTrigger to trigger two Counter output tasks using a dummy Analog Input task as trigger.

 

    /*********************************************/
    /*/ DAQmx Configure Code
    /*********************************************/
    DAQmxErrChk (DAQmxCreateTask("",&taskHandleCtr0));
    DAQmxErrChk (DAQmxCreateTask("",&taskHandleCtr1));
    DAQmxErrChk (DAQmxCreateTask("",&taskHandleAnlg));

    /*Set the ArmstartTrigger for Counter 0*/
    DAQmxErrChk (DAQmxCreateCOPulseChanFreq(taskHandleCtr0, "Dev1/ctr0","",DAQmx_Val_Hz,DAQmx_Val_Low,0,rate,0.5));
    DAQmxErrChk (DAQmxCfgImplicitTiming (taskHandleCtr0,DAQmx_Val_FiniteSamps,sampsPerChanToAcquire));
    DAQmxErrChk (DAQmxSetArmStartTrigType(taskHandleCtr0, DAQmx_Val_DigEdge));
    DAQmxErrChk (DAQmxSetDigEdgeArmStartTrigSrc(taskHandleCtr0, "/Dev1/ai/StartTrigger"));
    
    /*Set the ArmstartTrigger for Counter 1*/
    DAQmxErrChk (DAQmxCreateCOPulseChanFreq(taskHandleCtr1, "Dev1/ctr1","",DAQmx_Val_Hz,DAQmx_Val_Low,0,rate,0.5));
    DAQmxErrChk (DAQmxCfgImplicitTiming (taskHandleCtr1,DAQmx_Val_FiniteSamps,sampsPerChanToAcquire));
    DAQmxErrChk (DAQmxSetArmStartTrigType(taskHandleCtr1, DAQmx_Val_DigEdge));
    DAQmxErrChk (DAQmxSetDigEdgeArmStartTrigSrc(taskHandleCtr1, "/Dev1/ai/StartTrigger"));

    /*Set the "Dummy" AI task. This will trigger the ArmstartTrigger for the two Counters*/
    DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandleAnlg,"Dev1/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
    DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandleAnlg,"",10000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,1000));


    /*********************************************/
    /*/ DAQmx Start Code
    /*********************************************/
    DAQmxErrChk (DAQmxStartTask(taskHandleCtr0));
    DAQmxErrChk (DAQmxStartTask(taskHandleCtr1));
    DAQmxErrChk (DAQmxStartTask(taskHandleAnlg));

 

I hope you find this helpful.

 

Regards.

 

Jorge
Applications Engineer
National Instruments
________________________________________
Certified LabVIEW Associate Developer (CLAD)
0 Kudos
Message 6 of 7
(8,030 Views)
Solution
Accepted by RogerMont

Hi Jorge and All,

 

I appreciate the effort you made on my behalf.  The simplist answer turned out to be using the correct syntax to specify the terminal name where the arm start trigger specification can find the digital trigger edge.

 

I'm using one of the digital outputs as the trigger (not shown in the code segment):

 

>>>>

//Set the Arm start Trigger for the counters
DAQmxErrChk(DAQmxSetArmStartTrigType(DetHandle,DAQmx_Val_DigEdge));
DAQmxErrChk(DAQmxSetDigEdgeArmStartTrigSrc(DetHandle,TrgTerm));
DAQmxErrChk(DAQmxSetArmStartTrigType(LasHandle,DAQmx_Val_DigEdge));
DAQmxErrChk(DAQmxSetDigEdgeArmStartTrigSrc(LasHandle,TrgTerm));

<<<<

 

The variable "TrgTerm" contains an array of char like "/Dev1/PFI0"  The "EUREKA" discovery is that the this requires a leading slant character to work.  In the other DAQmx functions that I've used this has not been needed.

 

All this consternation has been for lack of a single "/" character.  It would be well to add this to the DAQmx knowledgebase somewhere.

 

Best Regards,

 

Roger 

 

Message 7 of 7
(8,026 Views)