Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I control duty cycles using compact daq digital output module 9472?

I am using compact daq chasis 9172 with thermocouple input module 9211 and output moduel 9472.  I am reading in a thermocouple reading and applying a pid controller on the heater.  I have written a program to take in the temperature reading, compare it to setpoint, then feed it into the PID.vi and output a percentage.  however, i am having trouble translating that into a duty cycle reading that i can input into the digital input module.  the output module has a range of 6 to 30V, but has no counters, so i can't do any pulse modulation with it.  what's the best way to do this?
0 Kudos
Message 1 of 4
(3,916 Views)
Hello jujuyy,

There are two ways to generate pulse trains with the NI cDAQ-9172:

1. Install the NI 9472 in slot 5 or 6, and use the general purpose counter/timers that are built into the chassis.This will let you output two continuous pulse trains or one finite pulse train per chassis. For instance, if you put the NI 9472 in slot 5, and create a pulse generation task in the DAQ Assistant on physical channel cDAQ1Mod5/ctr0, then the signal will be output on DO3 of the NI 9472. Most of the counter versions of DAQmx Write.vi have a duty cycle input.

2. Install the NI 9472 in slot 1, 2, 3, or 4, and use correlated DIO to output a waveform with the desired duty cycle. This is a bit more work, because you will need to write code to generate an array of the waveform data, then output it using hardware timed DIO synchronized to an appropriate clock (such as an AI/AO sample clock or a pulse train from a counter).

Note that if you go the second route, you can use the counter/timers in the chassis to generate a pulse train for your clock without having a module installed in slot 5 or 6. You can create a counter task using one of the internal channels cDAQ1/_ctr0, cDAQ1/_ctr1, and cDAQ1/_freqout, and then specify /cDAQ1/Ctr0InternalOutput, /cDAQ1/Ctr1InternalOutput, or /cDAQ1/FrequencyOutput as your DIO sample clock source when you call DAQmx Timing (Sample Clock).vi on the DIO task. If you use one of these internal channels, the counter task will not output to any terminals outside the chassis unless you use property nodes or the routing and/or export signal VIs.
---
Brad Keryan
NI R&D
Message 2 of 4
(3,900 Views)
I am not sure i understand how to use pulse trains for my duty cycle count.  if i am outputing a percentage of on time from my pid controller, am i suppose to use the pulse signal generated by the chasis as kind of a carrier of the on/off signal? 

also, i will need 3 independent channels of duty cycle output.  will the chasis be able to provide that? 
0 Kudos
Message 3 of 4
(3,893 Views)
If your PID controller outputs 25%, you can set the pulse train duty cycle to 25%, causing it to output logic high 25% of the time and logic low 75% of the time.

If you want three channels of PWM on a cDAQ-9172, you will need to use the second approach using DIO. It turns out that an M Series PWM example program works just fine for this: http://zone.ni.com/devzone/cda/epd/p/id/5043

To get it to run on a cDAQ-9172, I had to set "Digital Lines" to "cDAQ1Mod4/port0/line0:7", "Counter" to "cDAQ1/_ctr0" (which only shows up if you right click on the control, select "I/O Name Filtering", and enable "Internal Channels"), and "Counter Internal Output" to "/cDAQ1/Ctr0InternalOutput". The example program outputs with the same duty cycle on all of the selected lines, but you can modify the part of the program that generates the digital waveform to do separate calculations per channel.
---
Brad Keryan
NI R&D
Message 4 of 4
(3,884 Views)