To download NI software, including the products shown below, visit ni.com/downloads.
This example shows how to change a duty cycle using the NI-DAQ™mx Channel Property Node.
Description-Separate-2NI-DAQmx requires that when you update the duty cycle of a pulse train, you must update the frequency at the same time. To do this, create a NI-DAQmx Channel Property Node by going to Functions Palette»Measurement I/O»DAQmx-Data Acquisition»DAQmx Channel Property Node.
On the DAQmx Channel Property Node, right-click Property and select Change to Write. Expand the DAQmx Channel Property Node to have two inputs. Create a CO.Pulse.DutyCyc AND CO.Pulse.Freq property by right-clicking Property»Select Property»Counter Output»Pulse»Frequency and select Duty Cycle. Repeat the last step for the second property and select Frequency.
Create a new control for the duty cycle and the pulse frequency. Pass the new value for the duty cycle, as well as the desired frequency (even if it has not changed) to the property node. Since LabVIEW will execute a property node in a top-down manner, the duty cycle must be modified before the frequency value is changed.
The duty cycle can also be changed using the DAQmx Write VI when the instance of the VI is set to Counter Freq 1Chan 1Samp. To do this, place a DAQmx Write VI on your block diagram by going to Functions Palette»Measurement I/O»DAQmx-Data Acquisition»DAQmx Write.vi. From the pull-down menu of the DAQmx Write VI, select Counter»Single Channel»Single Sample»Frequency.
Then create three controls for the task, frequency and duty cycle and wire them to the DAQmx Write VI.
See the Attachments section for examples on how to to perform both of the above methods using event structures.
Changing the duty cycle on-the-fly is not possible with simulated DAQmx devices and will result in an error:
Error -200557: Specified property cannot be set while the task is running.
Set the property prior to starting the task, or stop the task prior to setting the property.
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.