Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I use multiple digital channels on a 9474 when generating a pulse train on a 9172?

Solved!
Go to solution

I am using a 9172 with a 9474 module in slot 6.  I want to generate 1 PWM signal but, I need to be able to supply up to 4 Amps.  I have a solution but, I am not sure it is the best way to do it.  I am basically starting and stopping the task and changing the output pin in my start up routine.  DAQmx does not disconnect the old pins when it connects the new ones so, I am able to run 1 signal through the 4 outputs.

 

 

/*********************************************/
// DAQmx Configure Code
/*********************************************/
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateCOPulseChanFreq(taskHandle,"cDAQ1Mod6/ctr0","",DAQmx_Val_Hz,DAQmx_Val_Low,0.0,1.00,0.50));
DAQmxErrChk (DAQmxCfgImplicitTiming(taskHandle,DAQmx_Val_ContSamps,1000));
DAQmxErrChk (DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,NULL));

/*********************************************/
// DAQmx Start Code
/*********************************************/
DAQmxErrChk (DAQmxSetCOPulseTerm(taskHandle, "cDAQ1Mod6/ctr0", "PFI0"));
DAQmxErrChk (DAQmxStartTask(taskHandle));
DAQmxStopTask(taskHandle);
DAQmxErrChk (DAQmxSetCOPulseTerm(taskHandle, "cDAQ1Mod6/ctr0", "PFI1"));
DAQmxErrChk (DAQmxStartTask(taskHandle));
DAQmxStopTask(taskHandle);
DAQmxErrChk (DAQmxSetCOPulseTerm(taskHandle, "cDAQ1Mod6/ctr0", "PFI2"));
DAQmxErrChk (DAQmxStartTask(taskHandle));
DAQmxStopTask(taskHandle);
DAQmxErrChk (DAQmxSetCOPulseTerm(taskHandle, "cDAQ1Mod6/ctr0", "PFI3"));
DAQmxErrChk (DAQmxStartTask(taskHandle));

 

 

 

Is this the best way to do this with my current hardware?  Also, am I able to switch the 4 amps using this method?

 

Thanks,

 

C.P.

0 Kudos
Message 1 of 6
(4,815 Views)
Solution
Accepted by topic author ClutchProgrammer

Hi C.P.,

 

DAQmxSetCOPulseTerm() only accepts a single signal, but DAQmxExportSignal() accepts multiple signals, so here's a more straightforward way to do the routing:

DAQmxErrChk(DAQmxExportSignal(taskHandle, DAQmx_Val_CounterOutputEvent, "/cDAQ1Mod6/PFI0:3"));

DAQmxErrChk(DAQmxStartTask(taskHandle));

 

Brad

---
Brad Keryan
NI R&D
0 Kudos
Message 2 of 6
(4,810 Views)

Hi C.P.,

 

Brad's suggestion is probably better for your routing.  There is a small hazard if you're tying the output lines together (as depicted in the manual); the routes will be made sequentially, so you'll briefly be driving some of the channels while the others are not yet routed.   It would be best if you could use a start trigger to start the actual PWM toggling after all the lines have been routed; if they're all driving low while signals are routed, there's no possibility that you'll short-circuit channels to eachother dangerously.

 

Regards,
Kyle

Message 3 of 6
(4,806 Views)

I haven't used the export signal function before.  Does it route the signals when it is called?  If so do I need a start trigger or do I just need to wait before calling the StartTask function?

 

Thanks

CP

0 Kudos
Message 4 of 6
(4,793 Views)

Hi C.P.,

 

DAQmxExportSignal() don't take effect until you commit the task, which normally happens when you call DAQmxStartTask(). It's actually a wrapper function for various property setter functions like DAQmxSetExportedCtrOutEventOutputTerm(), DAQmxSetExportedSampClkOutputTerm(), etc.

 

Since your counter output task won't start toggling the counter output until you call DAQmxStartTask(), I don't think you need a start trigger. However, you should be careful about matching the counter's idle state to the previous DIO state of the 9474. If the 9474's outputs are low and the counter was previously used to generate pulses with idle state = high, then the routing I described will temporarily drive some PFIs high and others low, which is bad when they are wired together. Likewise, if the 9474's outputs are high and the counter's idle state is low, the opposite will happen.

 

Brad

---
Brad Keryan
NI R&D
Message 5 of 6
(4,783 Views)

Brad,

 

Okay,  I think I understand how it works now.  So, I should be okay if I commit the task before calling the StartTask function.

 

Thanks for your help,

CP

0 Kudos
Message 6 of 6
(4,780 Views)