ISE 370: Industrial Automation and Control LabVIEW DAQ Project #1 (P27-Lab) Lab Objective: To create a VI that acquires a single sample on (1) analog input channel. You have been elected by your engineering team to develop a VI that can test a new line of +4 Volt power supplies. Build a VI that can take one reading of the output voltage to verify that the power supply works correctly. 1. Use the analog output of your DAQ device to simulate a +4 V power supply: a. Launch MAX b. Devices & Interfaces c. R-Click on the DAQ device & choose Test Panel (PCI 6025E – Device 1) d. Click the Analog Output tab on the test panel e. Select DC Voltage for the Output Mode f. Enter 4 V for the DC voltage g. Set Channel Selection to 0 h. Update Channel i. Wire Analog Output (0) to Analog in (1) j. Return to LabVIEW 2. Build the Voltage Source Tester VI (See Block Diagram for Single Sample Acquisition) > AI Samples Channels samples the signal attached to the specified channels & returns the measured data. > Index Waveform Array allows you to select a waveform out of an array of waveforms. > Get Waveform Components returns the specified waveforms elements. > Index Array returns an element or sub-array at the specified index of the array. Because AI Sample Channels returns an array of waveform data types, you must index the array using the Index Waveform Array VI. The Index Waveform Array VI returns a single waveform cluster. Normally, the waveform cluster contains (3) parts: a data array (Y), a starting time (t0), & a time between data points (dt). Here, AI Sample Channels acquires only one data point; therefore, it only outputs a waveform data type with a data array (Y) & a starting time (t0). The Get Waveform Components VI separates these components & displays them on separate indicators. Although AI Sample Channels only acquires (1) point, the waveform data type returns that point as a 1-D array (Y). Therefore, the data array (Y) is indexed because the Voltage meter only accepts a single point. 3. Make sure Device is set to the appropriate number of your device. Enter 1 for the DAQ channel name. RUN & Demo. Meter should display 4Volts. SAVE for future use. -1- ISE 370: Industrial Automation and Control LabVIEW DAQ Project #2 (P27-Lab) Lab Objective: To create a VI that produces a +3.0 signal on Analog Output (0) on your DAQ Signal Module. Your engineering team now needs you to develop a VI for the engineering office. You have been given a new fan for the office. You will use an analog output channel on your DAQ device to control the power to the servomotor on the fan. The speed of the servomotor is proportional to the voltage with which it is driven. As the input voltage increases, the speed of the motor increases. 1. Wire connect Analog Output (0) to Analog Input (1) 2. Build VI (see Single Point Generation) > AO Update Channel writes a specified value to an Analog Output channel 3. Set the controls: > Value: 3.0 4. Save, Run Continuous, & Leave Open. 5. Open the Voltage Source Tester VI from Project #1. 6. Set Controls on the Front Panel: > DAQ Channel Name: 1 7. Run the Voltage Source Tester. You should see +3V appear on the meter. -2- ISE 370: Industrial Automation and Control LabVIEW DAQ Project #3 (P27-Lab) Lab Objective: To acquire a waveform using a Single-Point Acquisition. Your engineering manager has placed you in charge of a special project to test a new line of sine wave generators that are built to produce a sine wave with a range of +/- 1 V. 1. Connect the sine wave from the Function Generator on the DAQ Signal Accessory to analog input (1). 2. Build the Sine Wave Generator Tester (See Block Diagram for Continuous Single-Point Acquisition). 3. Save it as “Sine Wave Generator Tester”. 4. Enter the correct number for your DAQ device in the Device control. 5. Select the correct virtual channel (configuration) for the DAQ Channel Name. 6. Adjust the chart’s range to display +1 to –1 V. 7. Run & Explain. (Change the frequency). Why does the waveform on the graph look so rough? Remember that the shape of a signal will be incorrect if the signal isn’t sampled at least five times faster that the maximum frequency. Is your sampling rate fast enough to produce the correct shape? The sampling rate of the acquisition is determined by how fast the while loop runs. You are taking only one point each time through the while loop. This method is not the most efficient way to acquire data. Acquiring (1) data point at a time slows down the while loop. This method slows down the sampling rate, which causes the rough-looking signal. Note: This set-up would work for a DC signal because you don’t need a fast sampling rate to acquire a slow changing signal. -3- ISE 370: Industrial Automation and Control LabVIEW DAQ Project #4 (P27-Lab) Lab Objective: To acquire a waveform using a buffered configuration. The results from the first Sine Wave Generation Tester convinced you that you need to build a better tester. You want to see the difference between hardware-timed & software-timed acquisitions. You remember that LabVIEW only needs to communicate with the DAQ device once to acquire multiple points of data. LabVIEW can tell the DAQ device how many points to acquire & at what rate to acquire them. Timing then becomes the responsibility of the DAQ device. In a hardware-timed acquisition, the next sample is acquired when the clock pulses again. The clock on the DAQ device is not divided between samples & it can sample at high speeds. In contrast, with a softwaretimed acquisition, the task of acquiring a data point is placed on the computer’s CPU. If another program is launched on the computer, the CPU suddenly has a lot to do before it can tell the DAQ device to acquire the next sample. 1. Connect the sine wave from the function generator on the DAQ Signal Module to Analog Input (1). 2. Build the Sine Wave Generator Tester (Buffered VI). AI Config. VI > Configures an analog input operation for a specified set of channels. This VI configures the hardware & allocates a buffer for a buffered analog input operation. AI Start VI > Starts a buffered analog input operation. This VI sets the scan rate, the number of scans to acquire, and the trigger conditions. The VI then starts the acquisition. AI Read VI > Returns data from the buffer. AI Clear VI > Clears the analog input task associated with task-ID in. Simple Error Handler > Determines whether an error occurred. It contains a database of error codes & descriptions, from which it creates a description of the error & displays a dialog box (optional). Note: When using a virtual channel, the Device & Input Limits controls are not necessary because these parameters were set when the virtual channel was created. 3. After setting the controls, go to the Operate menu & select MAKE CURENT VALUES DEFAULT. 4. Run, Save, Explain. -4- ISE 370: Industrial Automation and Control LabVIEW DAQ Project #5 (P27-Lab) Lab Objective: To demonstrate Aliasing ( a misrepresentation of signal frequency that is caused by under-sampling the signal) & the effects of sampling rate on an Input Signal. 1. Wire the Sine Wave from the function generator to Analog Input (1). 2. Turn the frequency adjust knob as low as possible. 3. Place the Frequency Range on 100 Hz – 10 kHz. 4. Build the Sampling Rate & Aliasing VI. Note: This VI acquires a sine wave and calculates its power spectrum. A power spectrum is a way to measure the frequencies present in a signal. The VI then graphs the signal (time) and the power spectrum (frequency). 5. Set Device & Channel. 6. Set Sampling Rate to 1,000 Hz. 7. Run, Save, & Explain. (Try reducing sampling rate to 500 Hz, to 250 Hz, explain results) The x coordinate of the peak you see on the Frequency plot represents the frequency of the DAQ Signal Accessory sine waveform. Adjust Frequency unit plot peak appears at 200 Hz. The Nyquist frequency is one half of the sampling rate. In this case, with a sampling rate of 1000 Hz, your Nyquist frequency is 500 Hz. The sampling rate is sufficient to measure the frequency of the signal (200 Hz). Also, notice that the sampling rate is (5) times the frequency of the signal you are sampling, so this sampling rate is also sufficient to capture the shape of the signal. Increasing the sampling rate to (10) times the measured signal makes the waveform on the Time plot look smoother. -5- ISE 370: Industrial Automation and Control LabVIEW DAQ Project #6 (P27-Lab) Lab Objective: To create a VI that will measure frequency using a counter. Your office has acquired a special treadmill for after hours exercise. You are requested to create a VI to measure the frequency at which a runner’s feet touches the pressuresensitive platform so each runner will be able to find their ideal pace. Counters operate with Transistor-To-Transistor (TTL) compatible signals. The definition of a TTL compatible signal is: 0V – 0.8V = Logic Low, 2V – 5V = Logic High, Maximum Rise/Fall Time = 50 ns. Digital lines can set or monitor the state of a digital line. Counters, however, are not only concerned with the state of the signal but also with the transition from one state to another. A counter can detect rising edges, a transition from Logic Low to Logic High, and falling edges, a transition from Logic High to Logic Low. Two important parameters related to sensing rising and falling edges are the rise/fall time & the minimum pulse width. The rise/fall time is a measure of how quickly the signal transitions from low to high, or high to low. In order for counter to detect the edge, the transition must occur within 50 ns of less, as defined by the specifications for a TTL compatible signal. A minimum delay is needed from the time when a counter detects a rising or falling edge until it can detect another rising or falling edge. This delay is known as the minimum pulse width.The DAQ device has a minimum pulse width of 10 ns for both the source & the gate. A counter has (4) main components: a count register, a source, a gate, and an out. Count Register stores the current count of the counter. Source is an input signal that can change the current count stored in the count register. The counter looks for either rising of falling edges on the source signal. Whether a rising or falling edge changes the count is software-selectable. Gate is an input signal that determines whether an active edge on the source will change the count. Counting can occur when the gate is high, low, or between various combinations of rising and falling edges. Gate settings are made in software. Out is an output signal that generates pulses or series of pulses, otherwise known as a pulse train. The output signal is TTL-compatible. When you measure a pulse, the signal you are trying to measure is used as the gate. The source is a time-base of known internal frequency. You use the known frequency of the timebase & the value of the count register to determine characteristics of the gate pulse such as pulse period, pulse width, or frequency. -6- ISE 370: Industrial Automation and Control LabVIEW DAQ Project #6 (P27-Lab) You will be forced to use (2) counters to perform the measurement on a high frequency signal. The first counter (0) is set-up for single pulse generation. Counter (0) provides a pulse of known width to use as the gate of the other counter. The other counter (1) is set up for pulse width measurement. The gate for counter (1) is the pulse of known width generated by counter (0). The source counter (1) is the signal you are trying to measure the frequency of. Source Frequency = Count / Pulse Width To measure the frequency of the source signal, you simply take the count of counter (1) and divide it by the known pulse width of the pulse you generated on counter (0). You cannot avoid any synchronization errors in counter measurements so the count for counter (1) could still be off by +/- 1. Example: You try to measure a 5 MHz signal. You generate a pulse of 800 ns to gate the counter that is performing pulse width measurement. Because of synchronization error, you could measure an incorrect frequency of : (5) / (800 ns) = 6.25 MHz or (3) / (800 ns) = 3.75 MHz The error is still on the order of megahertz. How can you improve measurement? Increase width of the pulse you generate for the gate. Next, try using a gate with a width of 2 s instead of 800 ns. You should get a count of 10,000,000. (10,000,001) / (2 s) = 5,000,000.5 Hz or (9,999,999) / (2 s) = 4,999,999 Hz Now your measurement error is only 0.5 Hz. Continued increases in the width of the gate signal will continue to decrease the error, as long as you make sure to keep the gate width short enough to prevent the counter from rolling over (counter limit). -7- ISE 370: Industrial Automation and Control LabVIEW DAQ Project #6 (P27-Lab) 1. Connect the square wave from the function generator to the source of counter (1). Connect Out of counter (0) to the gate of counter (1). Counter (0) will produce a pulse of a known length. 2. Build the Frequency Measurement VI. > Measure Frequency VI > Measures the frequency of a TTL signal on the specified counter’s SOURCE pin by counting positive edges of the signal during a specified period of time. In addition to this connection, you must wire the counter’s GATE pin to the OUT pin of counter-1. This VI is useful for relatively high frequency signals, when many cycles of the signal occur during the timing period. > Unbundle by Name > To add an element 3. Set Frequency Range to 100 Hz – 10 kHz. Turn the know down. 4. Set Counter to (1) & Gate Width to (1). 5. Save, Run, & Explain. The Gate Width determines how long the square wave is sampled. With a Gate Width of (1), the VI counts how many pulses the square wave produces in (1) second. The number of pulses divided by the Gate Width transfers directly to frequency. (Example, there were 120 pulses in (1) second. If the Gate is 5 seconds, the frequency is the number of pulses divided by 5: Frequency = # of Pulses/Gate Width. For high frequencies, a longer gate period produces more accurate results. -8-