Survey

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts

Buck converter wikipedia, lookup

Voltage optimisation wikipedia, lookup

Immunity-aware programming wikipedia, lookup

Switched-mode power supply wikipedia, lookup

Mains electricity wikipedia, lookup

Schmitt trigger wikipedia, lookup

Oscilloscope types wikipedia, lookup

Analog-to-digital converter wikipedia, lookup

Opto-isolator wikipedia, lookup

Transcript
```Laboratory Exercise 14 – Analog to Digital Conversion (A/D or ADC)
One of the most widely used features of computer interface systems is the ability to change an
analog voltage in the “real world” into a digital representation (a binary number) inside the
computer. This seems kind of strange if you think about it, since analog signals contain much
more precise information than do the digitized copies. This was a real bone of contention among
audio enthusiasts that originally resisted the whole digital recording revolution, based on the
assertion that digital recordings would always be inferior to analog ones. This argument has
subsided somewhat with the advent of 32 and 64 bit digitizers that produce voltage increments
(and hence sound differences) smaller than the typical human’s relative perception. The same
battle happened with digital photography. The real advantage of digitization is that the signal is
“frozen in time” allowing it to be stored virtually forever, and/or analyzed with any number of
sophisticated data treatments. This is also very enabling for control applications, where the
computer can make decisions based on a continuously variable signal input or inputs, or even on
the time rate of change of those inputs.
Simple Analog to Digital Conversion
Again, we’ll start with the most basic function of the board, changing an input (DC) voltage into
a digital number.
Circuit Exercise 1 –
To use the programmable gain/range feature on the PMD, you have to be in the differential input
mode. Differential in this case means the difference between two inputs, which are adjacent
screw terminals on the PMD. As far as I know, the only way to put the PMD into the differential
mode is to run Instacal (under Measurement Computing in the Start menu). Double click on the
PMD board in the tree structure and select the 4 Differential option under No. of Channels
dropdown. (It should already be in that mode, but we need to make sure). Click OK and exit
Instacal.
Connect the Analog Ground on terminal 3 of the PMD to the ground of your breadboard using a
fairly permanent connection. Next, connect terminal 3 to terminal 2 with a short jumper wire. It’s
a little tricky, but you can get the screw terminals to hold onto two wires. On the breadboard of
your trainer, set up a simple voltage divider circuit that can generate approximately +5 to –5
volts, continuously variable. Test the voltage divider on the breadboard using the DMM before
you connect to the screw terminal board for the A/D. Set the voltage for the middle of the range
(near zero volts). Connect the output of the voltage divider to Analog Input 0 (terminal 1) on the
PMD.
The PMD in Differential input mode is a 12 bit A/D. With the range set to +/- 5 volt bipolar,
what is the expected digital value for the zero volt input?
The better A/D boards, like the good D/A boards, provide for multiple voltage ranges, which can
generally be selected in software. Sometimes the individual channels can have different gains,
which is very useful when you have some big signals and some small signals. Usually there are
some unipolar (e.g., 0-5 volts) and some bipolar (e.g., -5 to +5 volts) voltage ranges. All of the
ranges are produced by amplification or attenuation, and/or DC shifting of the signal, using
analog circuitry that we’ve seen already. The number range (number of bits) of the digitizer is
usually fixed. The PMD offers a number of different ranges (in the differential mode – only one
in the single ended mode, for some reason) from 0.1 to 20 V, all of which are bipolar.
Did you get the result that you predicted in the question above?
Run the VI 16 times (same input voltage) and report the average and standard deviation to 2
decimal places.
How many bits are there in the conversion now?
Run a few more input voltages, spanning the range from low to high (positive and negative) and
record the results below.
Analog Vin
Predicted Digital Out
Measured Digital Out
Comment on the absolute accuracy of the conversion.
Comment on the linearity of the conversion. (Run a linear regression).
Before you close AnalogIn, save it to the desktop or a file on your thumb drive. You’ll use it
later.
Now we’ll investigate the utility of using other input ranges to measure smaller signals. Put the
voltage from your adjustable circuit near the middle of the range (near 0 volts). Hook up the
DMM to the signal so that you can monitor the voltage directly. Adjust to 0.000 on the DMM.
Open the AnalogInRange VI from the website, make sure that maximum and minimum voltages
are set for the +/-5 volt range, and run the VI.
What is the data value for 0.000 V?
Change the input voltage to 0.100 V and rerun AnalogInRange.
What is the data value for 0.100 V?
Change the input voltage back to 0.000 V and rerun AnalogInRange, this time selecting the
+/-1 volt range by entering the maximum and minimum voltages before you run the VI. Change
the input to 0.100 V and run the VI again at the 1 V input range.
What were the data values for 0.000 and 0.100 V?
What is the resolution you measured for each of the two ranges?
What is the smallest voltage increment you could see with a single measurement? What is the
smallest voltage increment you could see with an average of 16 measurements?
Programming Exercise 1
We’re going to simulate the operation of an oscilloscope (or more precisely, a device called a
transient digitizer) using the analog to digital converter. Again, the advantage of capturing the
data this way is that it can be saved for post-processing (or just saved). Note: this section can be
a little short on details of how to do things. If you need help, ask the instructor - or just try things.
You can’t hurt anything while programming (although you can when you start hooking up to
external circuits if you aren’t careful – remember to establish ground first!)
1. Open the Labview program (under Start) and open a new blank VI. Click on the block
diagram window.
2. Right click to bring up the Functions palette and choose Select a VI… near the bottom of the
palette. Select AnalogIn from wherever you saved it above and click in the middle of the
blank block diagram to drop it in. Save this new VI with a filename that is meaningful to you
(like PMDscope).
3. Open the Tools palette and change to the wiring tool. Hover the tool over the right side of the
AnalogIn and verify that there are outputs for the data value and voltage.
4. Create a While loop (in Functions palette, under Structures) around all of your existing icons
(make it kind of big). With the wiring tool, create a Control for the Stop icon in the lower
right corner of the loop.
5. Within the loop, open the Functions palette and select the Wait icon from the Time flyout.
Create a control for the “milliseconds to wait” input and go to the Front Panel and set it for
1000 (~1 point per second).
6. While on the Front Panel, Right Click and select a Waveform Chart from the Graph flyout.
7. Go back to the diagram and connect the chart to the DataValue output of the Analog In icon,
making sure the graph is inside the While loop.
8. Pop back to the Front Panel and run the module. Simulate a signal by varying the voltage
using your adjustable voltage divider circuit. You can turn off the routine any time you want
using your “Stop” switch, or leave it running virtually forever.
Do you see the results of your changes to the input signal on the chart display immediately? Or
can you see the “lag” time between a change and the resulting change in the chart?
How continuous does the signal seem? You can test this by giving a slowly but continuously
varying signal and see if it gives a smooth curve or “steps”.
9. Try changing the value of the “milliseconds to wait” control to verify that you can take data
faster and slower than 1 per second.
Can you get to a data acquisition rate where the data does look continuous?
If you set the “millisecond to wait” to zero, about how many samples does the program take in a
second? Or do a minute and divide by 60.
A “Wrinkle in Time”
I’m assuming that the answer you got above was some number of hundreds of samples per
second. If you look at the specs for the PMD, you’ll see that they claim a conversion rate of 50
kSa/s (50 thousand samples per second) is the maximum rate. What’s going on, were they just
lying? The problem is that the connection between the board and the computer (the USB) is not
fast enough to keep up with the speed of the digitizer, and you become limited by the
communications between the computer and the PMD. If you want to sample data really fast and
get that data into the computer really fast, you need a faster communication protocol. The fastest
version that I know of at present is to plug the digitizer into the PCI bus interface of the
computer, which makes the communication between the computer and the interface be as fast as
any communication within the computer – sort of the practical limit for these types of things. If
you have NO idea what I’m talking about here, don’t sweat it – that’s why this text is blue.
So how do you get the PMD to operate up near that theoretical spec of 50 kSa/s? The answer is
you let the digitizer run for a while (without communicating with the computer) and then you
transfer a whole bunch of data as fast as you can. This leads to gaps in the data (clearly) while
the communication is taking place. It also means that the PMD has to be able to store
information – i.e., it has to have some RAM (random access memory). These days, RAM is
pretty cheap, so this isn’t as big a deal as it used to be. However it still limits the size of the
“block” of information that can be accumulated and stored for future transport to the computer
and means that true “real time” data acquisition isn’t really possible.
Programming/Circuit Exercise 2
First use your scope to set up the function generator to give a sine wave at about 100 Hz with
voltages which never exceed +5 or –5 volts. Then plug this signal into your A/D input channel,
making sure to connect the grounds first.
Download and open the adfast VI. Run it, using 100 for the number of samples input. Click the
STOP button after a few cycles show up on the “scope”.
The program may take a little while to stop. In general, it is a good idea to provide a “soft” stop
like we’ve done with the while loop, rather than using the Stop Sign symbol on the VI to stop
execution. The latter can leave the PMD in some odd states.
How many cycles of the sine wave do you see?
How many points are there per cycle of the sine wave?
What is your measured sampling frequency of the PMD?
Are there any apparent distortions, or does the sine wave appear to be reproduced with fidelity?
Rerun the VI. Note that it looks like the scope, with the current trace being displayed on the
graph. But it doesn’t appear to have the all important triggering function, right?
How do you know it isn’t triggering?
Try running another program while this one is running. Can you again see the effect of Windows
sharing time between applications? Describe the effects you see - if you see any “weirdness”.
Right-click on the graph and choose Export on the flyout and export to excel. Excel will open
with the data. This is the coolest addition in an update (from LV 8.6 to 2010) to a program that I
ever saw.
Build a graph with a correct X axis (time in seconds or milliseconds) assuming that the points are
all spaced by the same amount and paste it below.
In fact, we know that points taken at the maximum collection rate aren’t usually all spaced by the
same time, a limitation that makes it more difficult to take “fast” data with these devices. There
are operational modes of the device that are more conducive to this type of work, but they are a
bit more complicated to set up and use. Most of the time when A/Ds are used in Chemistry, they
are measuring DC or very slowly changing signals.
If you’re curious about how you make the scope function we built here have the “triggering”
function built in, so that you can really simulate an oscilloscope, download and open the
Adscope VI. This one needs a trigger input, which you can supply using the digital clock output
from the trainer, wired to the trigger input on pin 18 of the PMD. When you run this VI, it is hard
to tell that it is actually doing anything, since you are constantly writing the same graph over and
over again. Try changing the frequency a bit to see what happens. You can also go to the block
diagram to see what has to be different about the “software” for the triggered mode. Basically
you just have to add an AInOptions input VI and select triggered input. Pretty easy.
Real World Example
The digital scope example is just one possible application of the A/D in the chemistry lab. Try to
give a concrete example which relates to a measurement you do in Your research lab. Or that
would be applicable to one of the teaching labs you have done in your studies.
Revised 5/23/2013 DBA
```
Related documents