Example Code

PWM Servo Control with DAQ

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Hardware

  • Data Acquisition (DAQ)

    Software

  • LabVIEW

    Driver

  • NI DAQmx

Code and Documents

Attachment

Overview

This program will allow you to create a continuous pulse train with a duty cycle that varies in accordance to an acquired input voltage using only DAQ hardware.

 

Description

In this example, You can supply the input voltage by simply wiring the selected analogue output to the corresponding analogue input and then adjust the Input Voltage dial in order to see the effects, but this "simulated" controlling voltage source can also be disabled if you wish to provide it by other external means.

 

Steps to implement or execute code

  1. Choose an Analogue Output, two Analogue Inputs and one Counter on your DAQ device for which the program can use. Wire the Analogue Output to the first Analogue Input and the Counter Output to the second.
  2. On the front panel select the chosen Analogue Output on your device within the "Simulated Source (AO)" drop down list, both Analogue Inputs (in the order mentioned above) within the "Analogue Inputs" drop down list and the chosen Counter within the "PWM Counter" drop down list.
  3. Run the program and vary the "Input Voltage" dial on the front panel. You should be able to observe the pulse width varying in accordance to the voltage.

Requirements
Software
LabVIEW 2012 or compatible
NI-DAQmx 16.0 or compatible

Hardware
cDAQ with C series Counter Input and Analog I/O or compatible DAQ devices

 

2017-10-30_16-25-35.jpg2017-10-30_16-22-40.jpg

**This document has been updated to meet the current required format for the NI Code Exchange.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.