04 - Analog Input

Embed Size (px)

Citation preview

  • Lesson 4 will focus on learning how to write analog input programs in LabVIEW.

    National Instruments Corporation 1 DAQ & SC Course Instructor Manual

    We will start by talking about considerations you must make when you are trying to sample an analog input signal. Then, you we will learn how to program an analog input acquisition using DAQmx VIs.

  • Explain to students how a sampled signal is really just a discrete array of sampled

    National Instruments Corporation 2 DAQ & SC Course Instructor Manual

    values.

  • When we are acquiring an analog signal we are taking a signal that is continuous

    National Instruments Corporation 3 DAQ & SC Course Instructor Manual

    with respect to time (infinite amount of points), and converting it into a series of discrete samples (finite amount of points). The samples are taken at a rate referred to as the sampling rate. We will learn how to set the sampling rate in software later. The faster we sample, the more points we will acquire, and therefore the better our representation of the signal will be. If we dont sample fast enough we will experience a problem known as aliasing. We will learn about aliasing next.

  • The sampling rate is the rate at which we acquire samples, but it is also the rate at

    National Instruments Corporation 4 DAQ & SC Course Instructor Manual

    which the Analog to Digital conversion takes place. As you can see in the top graph, our signal is adequately sampled we see the shape and frequency of the signal. When a signal is not adequately sampled, aliasing can occur. That is, the signal can be misrepresented, as seen in the bottom graph. With a sampling rate that is too low, we will not be able to adequately represent our signal. This is referred to as aliasing.

  • The Nyquist Theorem is a rule we can follow to prevent aliasing our signal. The

    National Instruments Corporation 5 DAQ & SC Course Instructor Manual

    Nyquist Theorem states that you must sample at greater than 2 times the maximum frequency component of your signal to accurately represent the frequency of the signal. Notice that the Nyquist Theorem only deals with accurately representing the frequency of the signal. It doesnt mention anything about properly representing the shape of our signal. In order to properly represent the shape of your signal you must sample between 5 - 10 times greater than the maximum frequency component of your signal. Next we will illustrate the Nyquist Theorem with various examples.

  • The Nyquist Theorem will only tell us how fast to sample if we know the frequency

    National Instruments Corporation 6 DAQ & SC Course Instructor Manual

    of the signal we are trying to measure. Often we are not completely sure of the signal we are measuring (that is why we are measuring it). However, we do know how fast our device can sample. So we need a definition of the Nyquist Theorem that will let us calculate the frequency we can correctly measure based on the sampling rate. To do that we need to define a term known as the Nyquist Frequency. The Nyquist Frequency is defined to be half of our sampling frequency. The Nyquist Frequency is the largest frequency we can correctly measure at a given sampling rate. To illustrate, we will go through an example. Assume we are trying to measure a 100Hz signal. According to the Nyquist Theorem we must sample at 200Hz or greater to correctly represent our signal. What if we only know our sampling rate? Assume we have a sampling rate of 200Hz. What is the largest frequency we can correctly represent according the the Nyquist Theorem? It is 100Hz. Therefore 100Hz is our Nyquist Frequency. With a sampling rate of 200Hz, we will only be able to correctly represent the frequency of signals that are equal to or less than 100Hz. So, the definition of the Nyquist Frequency is just another way of stating the Nyquist Theorem. What happens if we try to measure a frequency above our Nyquist Frequency? All frequencies above the Nyquist Frequency will alias according to the following formula:alias frequency = |(closest integer multiple of sampling frequency - actual

    signal frequency)|where | | is the Absolute ValueWe will examine examples of this formula on the following page.

  • Assume you are measuring a 100Hz sine wave. First we will try sampling our

    National Instruments Corporation 7 DAQ & SC Course Instructor Manual

    signal at exactly 100Hz. Keep in mind that the signals shown above are theoretical approximations. It is often very difficult for both the signal and this sampling rate to be at exactly the same frequency. According to the Nyquist Theorem 100Hz is not fast enough to correctly represent the frequency of our signal. If our signal frequency is exactly 100Hz and we are measuring at exactly 100Hz we will get a straight line. So we are obviously not correctly representing either the shape or the frequency of our signal. Therefore the Nyquist Theorem and our guideline for shape both hold true. Keep in mind that the signals shown above are theoretical approximations. It is often very difficult for both the signal and the sampling rate to be at exactly the same frequency. Now let us sample our signal at 200Hz. Note that this is exactly twice the frequency of our signal, so according to the Nyquist Theorem this is just fast enough to correctly represent the frequency of our signal. However, it is not fast enough to correctly represent the shape of our signal. If our signal is exactly 100Hz and if we sample at exactly 200Hz we will get the triangle wave shown above. Notice that the 100Hz sine wave and the triangle wave have different shapes, but the same frequency. So the Nyquist Theorem and our guideline for shape still hold true. Finally, we will sample our signal at 1kHz. Since we are sampling at 10 times our frequency, we should be able to accurately represent both the frequency and shape of our signal. As you would expect, our sampled signal does look like a sine wave, and it has the same frequency as our measured signal. So the Nyquist Theorem and our guideline for representing the shape of our signal both hold true.

  • Often a real-world analog signal has many frequency components. Often times these frequency components are greater than our Nyquist Frequency. So what happens when we try to measure a

    National Instruments Corporation 8 DAQ & SC Course Instructor Manual

    components are greater than our Nyquist Frequency. So what happens when we try to measure a signal with frequency components higher than our signal frequency? We will get a misrepresentation of our signal frequency known as an alias. As we learned earlier a formula exists to help us determine the frequency of our alias. The formula is:alias frequency = |(closest integer multiple of sampling frequency actual signal frequency)|where | | is the Absolute ValueLet us go through a concrete example to illustrate the use of this formula. Assume we have a signal with frequency components of 25Hz, 70Hz, 160Hz, and 510Hz. Our sampling rate is 100Hz. Therefore our Nyquist Frequency is 50Hz, and any frequencies above 50Hz will appear as an alias. So in our example we will correctly measure the 25Hz frequency component, but the 70Hz, 160Hz, and 510Hz frequency components will all alias. We will use the above formula to determine what frequencies our aliases will show up at. First let us calculate the alias frequency for our 70Hz signal. The closest integer multiple of the sampling frequency to 70Hz is 100Hz so the formula will look as follows:F2 = |100 - 70| = 30HzTherefore the 70Hz component of our signal will show up at 30Hz.Now let us repeat the procedure for the remaining two components of our signal. The closest integer multiple of the sampling frequency to 160Hz is 200Hz so the formula will look as follows:F3 = |200 - 160| = 40HzTherefore the 160Hz component of our signal will show up at 40Hz.The closest integer multiple of the sampling frequency to 510Hz is 500Hz so the formula will look as follows:F4 = |500 - 510| = |-10| = 10HzTherefore, the 510Hz component of our signal will show up at 10Hz.

  • Now that we know all about the Nyquist Theorem, the Nyquist Frequency, and how our signal will alias if we violate the Nyquist Theorem, a question comes to mind. How can we

    National Instruments Corporation 9 DAQ & SC Course Instructor Manual

    signal will alias if we violate the Nyquist Theorem, a question comes to mind. How can we prevent aliasing? Two ways exist to prevent aliasing of our signal: oversampling and filtering. Oversampling is simply the act of sampling faster than we need to. By oversampling we can increase our Nyquist Frequency and prevent the higher frequency components of our signal from aliasing. Oversampling is only a viable solution if your Analog-to-Digital Converter can go fast enough to achieve the sampling rate you need. Another option is filtering. The proper filter choice is a low pass filter. Low pass filters are designed to only pass frequencies below the cutoff frequency of the filter. As you can see above an ideal low pass filter will eliminate any frequency above the cutoff. So we would simply use a filter with a cutoff frequency equal to our Nyquist Frequency. However, real-world filters do not eliminate all frequencies above the cutoff. Instead, a real-world filter has a transition region that will still pass part of the signal at frequencies above the cutoff. As you can see both oversampling and filtering have their drawbacks. However, using the two in tandem provides an excellent solution. A real-world filter will help limit the sampling rate that we need for our Analog-to-Digital Converter, and oversampling will help us to compensate for the transition region of our filter.

    So we would need to set our sampling rate equal to twice the frequency at the end of the filters transition region, thus making our Nyquist Frequency equal to the frequency at the end of the filters transition region. With this setup we are accurately sampling everything below the Nyquist Frequency, and we know the cutoff frequency of the filter, so we can eliminate any frequencies that are passed in the transition region. Now we will do an exercise that will illustrate the concepts we have just learned.

  • National Instruments Corporation 10 DAQ & SC Course Instructor Manual

  • The DAQmx Read Function makes reading data easy. To use this VI, place the

    National Instruments Corporation 11 DAQ & SC Course Instructor Manual

    function on the block diagram and with the operating tool, select the signal type, if it is a single or multiple channel reading, if it is a single or multiple sample reading, and if you want to return the data as a waveform or double datatype. When multiple channels or multiple samples are returned, the data type will be a double array.

  • Common Questions from Students:

    National Instruments Corporation 12 DAQ & SC Course Instructor Manual

    How do you transfer channels and tasks that I created on one computer to a different computer? Why would I want to programmatically create a channel or task instead of using the DAQ Assistant?

  • We already learned about the main components of a DAQ device in Lesson 2.

    National Instruments Corporation 13 DAQ & SC Course Instructor Manual

    However, the number and arrangement of the components on the device will depend on the DAQ device you use. The architecture of the device will affect how we sample our signal. National Instruments DAQ devices that perform analog input can have one of two main architectures. The first architecture is shown in the top of the diagram. This architecture consists of one multiplexer, one instrumentation amplifier, and one Analog-to-Digital Converter (ADC). Notice that ALL of our input channels must share one ADC. Using only one ADC makes this architecture very cost effective. This architecture is used on most E-Series and M-Series devices. The one ADC architecture for all channels is used for Interval and Round-Robin Sampling. We will discuss Interval and Round-Robin Sampling later in this lesson. The other possible architecture is shown in the bottom of the diagram. This architecture consists of an instrumentation amplifier, and an ADC for EACH channel. This architecture is used on the S-Series family of devices. While this architecture is more expensive than using one ADC for ALL of your channels, it does allow us to perform Simultaneous Sampling. We will discuss Simultaneous Sampling later in this chapter.

  • Now that we are familiar with the two possible architectures for our device, we will

    National Instruments Corporation 14 DAQ & SC Course Instructor Manual

    learn some terminology that is commonly used when discussing the sampling of a signal.Sample ClockDuring each cycle of the sample clock, one sample for each channel is acquired. Acquires one sample for every channel we have specified. For example, if we were acquiring data on three channels, we would acquire three total samples.Sample RateNumber of scans per second. Sample ClockClock that controls time interval between samples.AI Convert ClockClock that causes A/D conversions to take place.

  • Now that we know the architecture and some sampling terminology, we will discuss

    National Instruments Corporation 15 DAQ & SC Course Instructor Manual

    the different ways we can sample a signal. The first and most common is Interval sampling. Interval sampling uses the one ADC for ALL channels architecture that is found on most E-Series and M-Series devices. So we need to share one ADC between all of our channels. To accomplish this, interval scanning uses both a sample clock and the AI convert clock to control the multiplexer. We will walk through an example to illustrate how the scan clock and channel clock interact. Assume we are acquiring data on two channels. First, the sample clock signals the start of a set of samples to be read. The multiplexer has connected our first channel to the ADC. Our AI convert clock will pulse once. When the AI Convert Clock pulses we will acquire one point off of our first channel. Before the AI Convert Clock pulses again, the multiplexer will connect our second channel to the ADC. Then the AI Convert Clock will pulse again and we will take one point off our second channel. The scan clock will pulse again and the cycle continues. The scan clock is in charge of determining how often we take a scan of all our channels. The AI Convert Clock is in charge of actually taking the samples. Since we use both clocks, we are able to scan our channels in a relatively short period of time. In the example above we are taking a scan every second, but the lag between points is only 5 s as determined by the period of the channel clock. So for the cost effectiveness of having only one ADC, we can achieve near-simultaneous sampling.

  • Round-robin sampling also uses the one ADC for ALL channels architecture.

    National Instruments Corporation 16 DAQ & SC Course Instructor Manual

    However, the difference is that we only have the AI Convert Clock to control our acquisition. So now the channel clock is in charge of both starting the scan, and determining the time between samples. In the previous example, we started a set of sample readings every second, and we took samples on two different channels. We will impose the same requirements on our example above. Since we only have one clock, all of our points have to be evenly spaced apart. The only way to do that is to have an AI Convert Clock rate of 1 samples/second. The difference is that our sample duration is now 0.5 seconds instead of 5 s. With interval sampling points on separate channels are not taken very far apart in time. However, with round-robin sampling our samples can be very far apart in time. While round-robin sampling is simpler because it only uses one clock, it is only to be used when the time relationship between signals is not important. Round-robin sampling is only found on National Instruments Legacy (Traditional NI-DAQ) devices.

  • As we just learned, if the time relationship between your signals is important you

    National Instruments Corporation 17 DAQ & SC Course Instructor Manual

    could use interval sampling, but sometimes interval scanning does not preserve the time relationship between signals to a tight enough tolerance. In that case, you will want to use simultaneous sampling. Simultaneous sampling uses one ADC for each channel so they can all be sampled at the same time. While this is a more expensive architecture than that for interval scanning, it does eliminate the lag between channels that is caused by having to share the ADC between all your channels. Since every channel is sampled at the same time, only a scan clock is needed to determine the rate at which your channels are sampled. Let us compare all three types of sampling by determining the phase shift we will see when we sample four 50kHz signals at a rate of 200kHz. With interval sampling all of the samples have to be evenly spaced so we will experience a 15 s delay between the time of the sample on channel 0 to the time of the sample on channel 3 . This corresponds to a 270 degree phase shift. With interval scanning, let us assume we have a 5 s AI Convert Clock time. Again, we will experience a 15 s delay between channel 0 and channel 3. With simultaneous sampling we will experience a 3 nanosecond delay between channel 0 and channel 3. This corresponds to a 0.054 degree phase shift. As you can see simultaneous sampling provides a great advantage in preserving the time relationship between signals, albeit at a higher cost. The S-Series DAQ family can perform simultaneous sampling.

  • A buffer is a temporary storage in computer memory for acquired or generated

    National Instruments Corporation 18 DAQ & SC Course Instructor Manual

    samples. Typically this storage is allocated from your computer's memory and is also called the task buffer to distinguish it from the intermediate buffer. For input, a data transfer mechanism transfers samples from your device into the buffer where they await your call to the Read function/VI to copy them to your application. For output, the Write function/VI copies samples into the buffer where they wait for the data transfer mechanism to transfer them to your device. Analog output will be discussed later in this course.

    We will study two different data transfer mechanisms finite and continuous. First, we will begin with a general overview of how the data transfer flows starting from the point of acquiring the data and then using the data in LabVIEW.

  • During a DMA Transfer, data collected via the I/O connector is first placed in the

    National Instruments Corporation 19 DAQ & SC Course Instructor Manual

    During a DMA Transfer, data collected via the I/O connector is first placed in the onboard memory (FIFO). The ASIC arranges for the data transfer through the PCI Bus to the pre-allocated location in the PC RAM. Applications such as LabVIEW can then take data out of this location to perform analysis or stream to disk.

    Remember that PCI bus is shared among different devices in the system and it transfers data in bursts. The maximum burst rate is 32 bit x 33 MHz = 132 MB/s.

    We rely on the PCI bus bandwidth when transfer data from the data acquisition device to the PC RAM. If the rate of data to the onboard memory is faster than the rate of data transferred out through the PCI bus, then the onboard memory will report an overflow. The larger the onboard memory, the less dependency we have on the PCI bus bandwidth since we can hold more data while waiting for the PCI bus to burst it out.

    To maximize efficiency, the ASIC transfers data through the PCI Bus in packets of 4 Bytes each. So, at any given time, there could be at most 3 bytes waiting to be transferred to the PC Memory.

  • You can set the buffer size in two different ways. The first is using the DAQ

    National Instruments Corporation 20 DAQ & SC Course Instructor Manual

    Assistant. As shown above, the samples to read defines the buffer size.

  • At first the concept of a finite buffer in computer memory might not be concrete

    National Instruments Corporation 21 DAQ & SC Course Instructor Manual

    enough. To help you out with the concept of a buffered acquisition we will move from buffer theory to bucket theory. Think of your PC buffer as a bucket that you are filling with water. We will call it the PC bucket. The size of the bucket is the same as the size of our buffer. The rate at which we fill the bucket is the same as our samples per channel per second rate. When the bucket is full of water we will dump it out into our LabVIEW bucket so it can be displayed on the front panel.

  • The other method you can use to set the buffer size is to use the DAQmx VIs.

    National Instruments Corporation 22 DAQ & SC Course Instructor Manual

    The Timing VI, which we will very frequently use, allows you to set the buffer by setting the input terminal entitled number of samples per channel.

    The Configure Input Buffer and Configure Output Buffer VI also allow you to set the buffer size. In this class, we will be using the Timing VI to set the buffer.

    When doing circular buffering, which we will discuss later in this lesson, it is important to always set the buffer size to an even number.

  • When using the DAQmx Read VI, we can read back a set number of samples from

    National Instruments Corporation 23 DAQ & SC Course Instructor Manual

    the buffer by setting the number of samples per channel terminal. If this terminal is unwired or set to -1, DAQmx will automatically determine how many samples to read. For a finite acquisition, DAQmx uses the Read All Available Samples property to determine how many samples to read. This property specifies whether the read operation should read all samples currently available in the buffer or wait for the buffer to become full before reading. This setting is only used when the input to number of samples per channel terminal is -1.

  • We have already learned how to acquire one point at a time. Now we will take the

    National Instruments Corporation 24 DAQ & SC Course Instructor Manual

    next step and learn how to acquire multiple points at a time.

    Hardware-timedIn a hardware-timed acquisition, the rate of acquisition is controlled by a hardware signal such as the sample clock or AI Convert Clock. A hardware clock can go much faster than a software loop, so you can sample a higher range of frequencies without aliasing your signal. A hardware clock is also more accurate than a software loop. A software loop rate can be thrown off by a variety of actions such as the opening of another program on your computer. A hardware clock is not susceptible to such distractions.

    BufferedA buffered acquisition can acquire multiple points with one call to the device. The points are taken from the device and placed in an intermediate memory buffer before they are read in by LabVIEW.

  • This program performs a finite, buffered analog input acquisition and plots the data on a graph.With a finite buffered acquisition, LabVIEW specifies how many points to acquire and at what

    National Instruments Corporation 25 DAQ & SC Course Instructor Manual

    With a finite buffered acquisition, LabVIEW specifies how many points to acquire and at what rate to acquire them. Timing then becomes the responsibility of the DAQ device.

  • Now that we have mastered a finite buffered acquisition, we will move on to a

    National Instruments Corporation 26 DAQ & SC Course Instructor Manual

    continuous buffered acquisition. The main difference between a finite buffered acquisition and continuous buffered acquisition is the number of points that are acquired. With a finite buffered acquisition we acquire a set number of points. With a continuous buffered acquisition we can acquire data continuously. The flowchart for a continuous buffered acquisition is shown above. The flowchart is the same as a buffered flowchart for the first three steps. We set the buffer size, configure timing, start the task, and begin reading. At this point the continuous buffered acquisition flowchart strays from the buffered acquisition flowchart. Since we are acquiring data continuously we also need to be reading data continuously. Therefore we have DAQmx Read VI in a loop. The loop is done when either an error occurs, or the user stops the loop from the front panel. If we are not done, we will continue to read data. If we are done we will go to DAQmx Stop Task to unassign our resources and display any errors with either the Simple or General Error Handler.

  • Now that we understand how to program a continuous operation, we can examine how the PC buffer and the LabVIEW buffer are operating. A continuous operation is much more

    National Instruments Corporation 27 DAQ & SC Course Instructor Manual

    PC buffer and the LabVIEW buffer are operating. A continuous operation is much more difficult, because we are still using a single buffer, but now we are acquiring more data than that buffer can hold. To accomplish this we will use what is often called a circular buffer. A circular buffer is a variation on a regular buffer. The only difference is that when we get to the end of a circular buffer, instead of stopping, we start over at the beginning. Again we will start with the PC buffer that was allocated by the number of samples per channel in the DAQmx Timing VI. When our acquisition is started the PC buffer will start to fill with data. We are now in the while loop with DAQmx Read VI. Assume that we have set our number of samples per channel to read to between 1/4 and 1/2 of our PC buffer size. When the number of samples per channel in the PC buffer is equal to the number of samples per channel to read we will transfer that many samples from the PC Buffer to the LabVIEW buffer with DAQmx Read. DAQmx Read will set a flag called the current sample number so it continues reading from where it left off, similar to the way you would use a bookmark. Meanwhile, the PC buffer is still filling up with data. We will continue to take data from the PC buffer to the LabVIEW buffer with Read VI while the PC buffer is being filled. When the end of data mark reaches the end of the PC buffer the new data will be written at the beginning of the buffer. The difference between the end of data mark and the current read mark is equal to the available samples per channel (or backlog).As you can see we must continue to read the data out of the buffer fast enough to prevent the end of data mark from catching up to the current read mark. When this happens the new data will overwrite the old data and we will get an error. We will discuss some common errors that are encountered when performing a continuous buffered acquisition and how to avoid those errors in a moment.

  • As you can see a continuous buffered acquisition is more complicated than a

    National Instruments Corporation 28 DAQ & SC Course Instructor Manual

    buffered acquisition. To help simplify the concept of a continuous acquisition we will return to our bucket theory. For a continuous acquisition we must add another parameter. The size of our PC bucket is still the size of the PC buffer, and the rate at which water flows into the bucket is still the Samples per Channel per Second rate. However, now we are turning on the water and walking away, but we dont want the bucket to overflow. When the PC Buffer Overflows, you lose data. Therefore, we must drain the bucket. The rate at which we drain the bucket is the same as the number of samples to read in the DAQmx Read VI. The amount of water that hasnt been drained from the bucket is called the available samples per channel (or backlog). As you can see we will need to drain the bucket as fast or faster than it is filling. We can also deduce that increasing the size of the bucket will only prolong the inevitable overflow of the bucket if we are not draining it fast enough.

  • When using the DAQmx Read VI with a continuous acquisition, if we leave the

    National Instruments Corporation 29 DAQ & SC Course Instructor Manual

    number of samples per channel terminal unwired or set to -1, DAQmx reads the total number of samples available in the buffer, unless that value is less than the value in the table. In that case, DAQmx uses the value listed in the table for the number of samples to read.

  • Now that we understand the flowchart of a continuous buffered acquisition we will

    National Instruments Corporation 30 DAQ & SC Course Instructor Manual

    examine a continuous buffered acquisition in LabVIEW. The VI is very similar to a buffered acquisition with the following changes: DAQmx Read VI has a while loop around it. The available samples per channel (backlog) is being monitored.Since we are continually sending data into the buffer it is important to monitor the number of unread samples in the buffer to see if we are emptying the buffer fast enough. If the number of available samples per channel is increasing steadily you will most likely overflow your buffer and receive an error. The while loop with Read VI can either be stopped by the user with a button on the front panel, or by an error in the Read VI such as a buffer overflow. After the while loop stops we clear all the resources and display our errors.

  • There are two main places when data transfer errors can occur. These can occur

    National Instruments Corporation 31 DAQ & SC Course Instructor Manual

    There are two main places when data transfer errors can occur. These can occur when the onboard memory of your DAQ devices overflows an overflow error.

    The other most prominent error location occurs in your computers memory and is called an overwrite error you are not reading for the PC buffer fast enough.

    We will now discuss each of these two errors in more detail.

  • The other error you could receive when performing a continuous buffered

    National Instruments Corporation 32 DAQ & SC Course Instructor Manual

    acquisition involves overflowing the FIFO on the board. It is not as common as overwriting the PC buffer, but it also is not as easy to fix. The root cause of the error is not being able to empty the FIFO fast enough. The FIFO relies on either DMA or IRQ to transfer the data from the FIFO to the PC buffer. When the FIFO isnt being emptied fast enough you only have a few options to avoid the error. The first is to make sure you are using DMA to transfer your data if it is available. DMA is much faster than IRQ and can help out significantly. The second option is to decrease the samples per channel per second rate. The third is to purchase a device with a larger FIFO. However, this may only delay the problem and not solve it. A better solution is to purchase a computer with a faster bus to help expedite the data transfer from the FIFO to the PC buffer. Since the overwrite is caused by your system not transferring the data off the device fast enough, not much more can be done.

  • The most common error you will encounter when performing a continuous buffered

    National Instruments Corporation 33 DAQ & SC Course Instructor Manual

    acquisition is the Overwrite error. It means that you have let the end of samples mark catch up to the current sample number and have thus overwritten your data. The root of the problem is caused by the fact that we are not reading data from the PC Buffer fast enough. Several options exist to help us avoid the error, however not all may apply to your situation and some options are better than others. The first option is to increase the buffer size using the DAQmx Timing VI. As we saw with our bucket diagrams, increasing the buffer size will not solve the problem if we are not emptying the buffer fast enough. However, it will help if we have set the number of samples per channel to read higher than 1/2 of our buffer size. Another option is to decrease the samples per channel per second rate (sampling rate). This will slow down the rate that data is being sent to the buffer. Often this is not an option, because we want a certain sampling rate. Increasing the samples per channel to read will help us to empty the buffer fast enough. Just keep in mind that if you set the number of scans to read too high, you will be sitting in the Read VI waiting for the number of scans in the buffer to equal the number of samples per channel to read while you could be removing data if your samples per channel to read were set lower. Remember the guideline for setting your samples per channel to read at 1/4 to 1/2 of your buffer size. Another option is to make the Read VI itself faster by having it return a double array instead of a waveform. Also as a general rule, try to avoid slowing down your loop with unnecessary analysis.

  • This exercise also includes streaming to disk with the Measurement Report Express VI.

    National Instruments Corporation 34 DAQ & SC Course Instructor Manual

  • Use this slide as a refresher from Lesson 2. Point out that the DAQmx Trigger VI is

    National Instruments Corporation 35 DAQ & SC Course Instructor Manual

    a polymorphic VI that allows us to easily select the trigger configuration that we wish to use digital edge, digital pattern, analog edge, or analog window. The next exercise will teach us how to begin analog input acquisition based off a digital edge.

  • National Instruments Corporation 36 DAQ & SC Course Instructor Manual

  • 1. C

    National Instruments Corporation 37 DAQ & SC Course Instructor Manual

    2. D

  • 3. B

    National Instruments Corporation 38 DAQ & SC Course Instructor Manual

    4. B

  • 5. True

    National Instruments Corporation 39 DAQ & SC Course Instructor Manual

    6. a, b, and c