This VI allows the user to dynamically update the duty cycle in order to change the position of the servo on the fly.
This VI was created and tested on an NI M Series DAQ card for the purpose of controlling a servo motor that operates at a frequency of 50 Hz and varies its position relative to the duty cycle (or pulse width) of the signal.
NI LabVIEW 8.5 or compatible
NI DAQmx 8.6.1 or compatible
Most DAQ cards with Counter I/O
Steps to Implement or Execute Code
1. Select the desired counter output physical channel.
2. Set your initial frequency and duty cycle.
3. Run the VI.
4. Change the duty cycle and press the 'Update Duty Cycle' button to trigger update.
Block Diagram Steps
1. The DAQmx Create Channel.vi to creates and configures the counter output frequency task to generate a pulse train of a user specified frequency and duty cycle. 2. The DAQmx Timing.vi to sets the mode to continuous and the timing to be implicit (i.e. does not require sample timing since it is a counter task for pulse train generation). 3. Start the task. 4. Enter the True case to update the duty cycle upon user selection. The False case simply passes through the task and error wires. 5. Stop the task. 6. Dynamically reconfigure the duty cycle of the pulse train. 7. Restart the task. 8. Exit the while loop if an error occurs or upon user selection, and then clear the task and handle errors.
**This document has been updated to meet the current required format for the NI Code Exchange.**