First, make sure you have installed the supporting NI-DAQmx driver software version. If you are using a USB DAQ device, a green or blue LED light should turn on when the device is recognized by your host PC. Open Measurement & Automation Explorer and confirm that the device appears under Devices and Interfaces. Select the Self-Test button and confirm that the device passes.
The push button should have two terminals. Connect one of the terminals to P2.0 and connect the second terminal to 5 V.
This tutorial uses a speaker plugged into a two conductor (mono) phone jack. Two wires were soldered to the two terminals and one connected to ground, another to AO0, according to the diagram on the phone jack. Follow the diagram on your phone jack to connect the terminals to the analog output channel and ground.
For our application, we want to emit an audio frequency on command. To do this, we set up a program that creates and configures a physical digital input and analog output channel, waits for a digital trigger to occur, and then writes a frequency to the speaker. When we are done emitting the frequency, we want to be able to stop the program, clear the tasks, and release the resources. The basic flow of the program is in the following diagram.
Instead of building this entire application, we’re going to use one of the example programs included with your DAQ device. You can find the location of these example programs for your specific OS by visiting ni.com/info and typing in daqmxexp. We are going to modify a LabVIEW voltage output example called Voltage – Continuous Output.vi, which demonstrates how to continuously regenerate analog output data that is configured by the user. This example also incorporates digital triggering, so we do not have to add this to our code.
Copy the example program from its original location into your personal folder, so that modifications to your program do not overwrite the original example.
The first thing that you should notice in your program is the comments that designate sections of the code. In this example, there are five sections in the code: Channel Settings, Timing Settings, Trigger Settings, Waveform Settings, and Output. Documenting your code as you make changes is a best practice that allows your code to be read and understood.
Follow these steps to modify the example or open the finished program attached to this tutorial.
To run the program, select the run arrow. Compress the push button and hear an audio tone emitted from your speakers. Select Stop on the UI to stop the program.The mark LabWindows is used under a license from Microsoft Corporation. Windows is a registered trademark of Microsoft Corporation in the United States and other countries.
Collaborate with other users in our discussion forums
A valid service agreement may be required, and support options vary by country.