Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

Advanced Instrumentation and

Experimental Methods
Module code DME 811

Dr Riaz A Mufti
(B.Sc, M.Sc Eng (UK), PhD (UK), CEng (UK), MIMechE (UK), P.E (PEC))

Analog Input
Sampling Signals
• To acquire an analog signal, you must first convert an analog signal into its digital
representation. In practice, this is implemented by using an analog-to-digital (A/D) converter.
• Consider an analog signal x(t) that is sampled every Δt seconds. The time interval Δt is
known as the sampling interval or sampling period. Its reciprocal, 1/Δt, is known as the
sampling frequency, with units of samples/second.
• Each of the discrete values of x(t) at t = 0, Δt, 2Δt, 3Δt, etc., is known as a sample. Thus,
x(0), x(Δt), x(2Δt), ..., are all samples.
• The following figure shows an analog signal and its corresponding sampled version. The
sampling interval is Δt. The samples are defined at discrete points in time.
Sampling Signals
• Individual samples are represented by: x[i] = x(it), for i = 0, 1, 2, …
• If N samples are obtained from signal x(t): X = {x[0], x[1], x[2], …x[N-
1])
• The sequence X = {x[i]} is indexed on i and does not contain sampling
rate information
Sampling Considerations

• Actual analog input signal is


continuous with respect to time
• Sampled signal is series of
discrete samples acquired at a Actual Signal
specified sampling rate
• Faster we sample the more our
sampled signal will look like our
actual signal
• If not sampled fast enough a
problem known as aliasing will
occur Sampled Signal
Aliasing
• Sample rate – how often an A/D conversion takes place
• Alias – misrepresentation of a signal
Adequately Sampled

Aliased Due to Undersampling Aliasing effects


of an improper
sampling rate
Nyquist Theorem

You must sample at greater than 2 times the maximum


frequency component of your signal to accurately represent
the FREQUENCY of your signal.

NOTE: You must sample between 5–10 times greater than the
maximum frequency component of your signal to accurately
represent the SHAPE of your signal.
Nyquist Example

Aliased Signal

100Hz Sine Wave Sampled at 100Hz

Adequately Sampled
for Frequency Only
(Same # of cycles)
100Hz Sine Wave Sampled at 200Hz

Adequately Sampled
for Frequency and
Shape
100Hz Sine Wave Sampled at 1kHz
DAQmx Read Function
1. Select Settings

Single or Single or Return data as


Signal Type Multiple Multiple waveform or
Channels? Samples? double (array)
type?
2. Verify Settings
GOAL

 Analog
 1 Channel
 1 Sample
 Waveform

ni.com/training
DAQmx Read Function
1. Select Settings

Single or Single or Return data as


Signal Type Multiple Multiple waveform or
Channels? Samples? double (array)
type?
2. Verify Settings
 Analog
 1 Channel
 1 Sample
 Waveform
Buffered Analog Input

• Buffer – temporary storage in computer memory for


acquired or generated data
• Data transfer mechanism transfers samples from your
device into the buffer where they await your call to the
DAQmx Read VI to copy them to your application
− Finite Transfer
− Continuous Transfer
Data Transfer for an Input Operation
Onboard FIFO Memory • During a DMA (Direct Memory Access) Transfer,
data collected via the I/O connector is first placed in
the onboard memory (FIFO). The ASIC
(application Specific Integrated Circuit)arranges for
the data transfer through the PCI Bus to the pre-
DATA allocated location in the PC RAM. Applications
such as LabVIEW can then take data out of this
Input location to perform analysis or stream to disk.
Rate
ASIC PC ADE (Application)
Transfer Buffer Memory
Rate
PCI Bus

RAM
• 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 LabVIEW
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.
Finite Buffered Acquisition Theory
Bucket Theory
Think of your PC buffer as a
bucket that is filling up with water
Data – Buffer size = size of the bucket
– Sample rate controls how fast water flows into
the bucket
– When the bucket is full you dump it into a
another bucket (LabVIEW buffer)
PC Bucket
Setting the Buffer Size for Finite Acquisition

DAQmx VIs:
− Timing VI
o Number of samples per channel
equals the buffer size
» Typically only used for finite
operations
o Does not affect number of samples
read at any one time
Configuring the Number of Samples to Read
Number of samples per channel input:
• If left unwired or set to -1, NI-DAQmx automatically determines
how many samples to read, based on the task configuration
• For finite acquisition, if the input is unwired or -1, NI-DAQmx
uses the Read All Available Samples property to determine how
many samples to read
Finite Buffered Acquisition
• Perform a hardware-timed, finite buffered acquisition
• Highly recommended for most applications
• Set the buffer size, sampling mode, sampling rate, and number
of samples to read per channel

Configure buffer,
sampling mode,
and rate

NSamp = Multiple Samples

You might also like