* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download MIT-240 Lab#7 - Analog to Digital
Electrical ballast wikipedia , lookup
Three-phase electric power wikipedia , lookup
Power inverter wikipedia , lookup
Signal-flow graph wikipedia , lookup
Pulse-width modulation wikipedia , lookup
History of electric power transmission wikipedia , lookup
Electrical substation wikipedia , lookup
Immunity-aware programming wikipedia , lookup
Variable-frequency drive wikipedia , lookup
Distribution management system wikipedia , lookup
Potentiometer wikipedia , lookup
Current source wikipedia , lookup
Power MOSFET wikipedia , lookup
Surge protector wikipedia , lookup
Alternating current wikipedia , lookup
Power electronics wikipedia , lookup
Stray voltage wikipedia , lookup
Resistive opto-isolator wikipedia , lookup
Integrating ADC wikipedia , lookup
Voltage regulator wikipedia , lookup
Voltage optimisation wikipedia , lookup
Analog-to-digital converter wikipedia , lookup
Current mirror wikipedia , lookup
Schmitt trigger wikipedia , lookup
Switched-mode power supply wikipedia , lookup
Mains electricity wikipedia , lookup
Community College of Allegheny County
Unit 7
Page #1
Analog to Digital
"Engineers can't focus just on technology; they need to develop
their professional skills-things like presenting yourself,
speaking in front of a large group and working within a
technology team."
βLaura Harmon, recent grad & system engineer at Lockhead Martin
(eeTimes 8/14/99)
Revised: Dan Wolf, 4/07/2017
Community College of Allegheny County
Unit 7
Page #2
OBJECTIVES:
ο· Understanding of A/D Resolution, offset and slope.
ο· Experience and understanding of the AD590 temperature
sensor.
ο· Use of the Arduino analog inputs.
DELIVERABLES THAT YOU MUST SUBMIT
1. Experiment #1 Graph and Table #1
2. Experiment #2 Graph and Table #2
On-Line Reading Material:
Required:
a) http://www.eetimes.com/document.asp?doc_id=1276974
b) Explanation for three types of ADC:
http://hyperphysics.phyastr.gsu.edu/hbase/Electronic/adc.html#c1
Optional:
a) Everything you wanted to know about A-D Convertors:
http://www.delftek.com/wpcontent/uploads/2012/04/National_ABCs_of_ADCs.pdf
b) https://learn.sparkfun.com/tutorials/analog-to-digitalconversion
c) http://www.allaboutcircuits.com/textbook/digital/chpt13/practical-considerations-adc-circuits/
INTRODUCTION TO THE ARDUINO ANALOG TO DIGITAL CONVERTOR:
The Arduino has six different Analog Inputs, numbered A0 to A5.
Each has a 10-bit converter with a +5V reference voltage so the
resolution is:
ππππ‘π
ππ πππ’π‘πππ =
5ππππ‘
10
2
or
ππππ‘π
ππ πππ’π‘πππ =
5ππππ‘
1023
= 4.88ππ
This means that an analog voltage between 0 and +5V will be
measured in 1023 steps of 4.88mV. It takes about 100mS (0.0001
second) to read an analog input, so the maximum sample rate is
about 10K times per second.
Community College of Allegheny County
Unit 7
Page #3
INTRODUCTION TO THE ADC590 TEMPERATURE SENSOR:
The AD590 is a 2-terminal integrated circuit temperature
transducer that produces an output current proportional to
absolute temperature. For supply voltages between 4 V and 30 V,
the device acts as a high impedance, constant current regulator
passing 1ΞΌA per degree K.
In order to convert the (1ΞΌA per degree K) constant current to a
voltage for the ADC, we will add a 1K resister as follows:
1uA / degK
+5V
AD590
Temperature sensor
1mV / degK
1K ohm
77degF = 25degC = 298uA
70degF = 21degC = 294.15uA
è 298mV @ 1K ohm load
70degF = 21degC = 294.15mV
Outputs 1mV per °C
At 25°C (298°K or 77°F), the ADC590 sensor will output 298uA
though the 1K resister. According to ohmβs law, 298uA though a
1K ohm resister provides a voltage of:
ππππ‘πππ = πΌ β π
= 0.000298 β 1000 πβππ = 0.298π = 298ππ
And each additional °K increase or decrease will result in a
corresponding 1uA change in output current from the ADC590
producing a corresponding 1mV change in voltage. Note that a
single degree Kelvin is equal in magnitude to a degree Celsius
so we can also say βfor each degree Celsius we will see a 1mV
change in output voltageβ. Figure #3 shows some key values of
temperature, voltage and current for this circuit.
Community College of Allegheny County
Unit 7
Page #4
Experiment #1 β A/D Verification:
1. Figure #1 shows an Arduino microcontroller connected to a
10Kohm, 10-turn potentiometer. This will allow us to vary
the Arduino analog input voltage from zero to 10 Volts
while monitoring the conversion process on the computer
monitor.
2. Using your class notes, design the interfaces between the
different components and create a detailed (and neat)
schematic which includes everything needed to build the
circuit.
3. Construct the circuit and attach a voltmeter or
Oscilloscope to monitor the analog input voltage. Use a
fixed +5V power supply and set the potentiometer to a midpoint. When complete, ask the instructor to review your
schematic before applying power.
4. See Figure #4. Upload the Arduino with the program named:
AnalogInput_CCAC.ino
5. Start the Arduino Serial Monitor: Tools | Serial Monitor so
that you can monitor the output of the Arduino A/D
conversion.
Note: Make sure that you do not apply more than 5.0V
to the Analog input of the Arduino. An excess voltage
will damage the Arduino.
6. Apply power and test the circuit. Set the potentiometer so
that the analog input is just about 4.88mV. The Serial
Monitor should indicate a RAW A/D count of 1 and a voltage
level of 4.88mV. If necessary, adjust the potentiometer so
that the Serial Monitor shows a RAW A/D value of 1 and an
output voltage of 4.88mV (Vin may not equal Voutput). Record
the data on Table #1.
7. Complete the rest of Table #1. Pick your own values for
the rows with blank RAW A/D cells. After each voltage
change, observe how constant the output voltage is. Does
it drift? Why? When you are done, use Excel to graph the
data with the RAW A/D value on the X-axis and the input
voltage on the Y-axis. Compute and record the slope of
this data (Y=MX+B) on the back of the graph.
Community College of Allegheny County
Unit 7
Page #5
8. On the same graph, plot the line for the perfect A/D
conversion where:
X = RAW A/D Value = 1
and Y = 4.88mV
X = RAW A/D Value = 1023
and Y = 5.000 Volts
Compute and record the slope of this data (Y=MX+B) on the
back of the graph. The offset and slope of these two plots
may not be equal. What does this mean?
9. If you were reading a wheatstone bridge/strain gauge, how
would the Arduino offset and slope error affect the strain
gauge measurements?
10. Submit your graph and Table #1 as your documentation for
this experiment.
Table #1
Voltmeter /
Oscilloscope
Serial Monitor
Input Voltage
Vin
RAW A/D Value
0
0
1
2
3
511
1023
Output in
mV
Voutput
(Offset Error)
Voltage Difference
Vin β Voutput
Community College of Allegheny County
Unit 7
Page #6
Experiment #2 β Temperature Measurement:
1. Figure #2 uses an AD590 temperature sensor as the input to
the Arduino. The AD590 generates 298uA through the 1K
resister at 25°C (77°F) resulting in 298mV applied to the
Arduino input. Every °C above or below will result in a
1mV increase or decrease in voltage. Figure #3 shows a
group of useful values.
2. Based on the 1K ohm resister value, the equation to convert
the AD590 output (in mV) to degrees F is:
π = ππ + π΅
ππππΉ = 1.8 β ππ β 459.67
3. Modify the circuit to include the ADC590 as per Figure #2
and ask the instructor to review it before you apply power.
4. Test with a couple of different temperatures and record the
results in Table #2. Plot them on an Excel graph and see
how close them are to the equation provided above.
Remember that you may have experienced an A/D converter
offset in the experiment above and the offset may still
exist.
Table #2
Voltmeter /
Oscilloscope
Input
Voltage Vin
Serial Monitor
RAW A/D
Value
Output
in mV
Voutput
Actual
Temperature
°F
Computed
Temperature
TF = 1.8 * Voutput
β 459.67
Community College of Allegheny County
Unit 7
Page #7
Optional Experiment #1:
1. Remove the wire to the Arduino analog input so the input is
left βfloatingβ. Observe the values on the Serial Monitor.
What is happening?
Optional Experiment #2:
1. The equation for the AD590 output-to-°F calculation is
given above, including the values for the slope and offset
(M and B). Calculate the values for the slope and offset
and show all of your calculations. You may find that
building a voltage (°K versus °F versus °C versus mV) table
first in MS-Excel might clarify the concepts and
calculations.
Note that the AD590 data sheet specifies that it outputs
1uA per °K so you have to switch the units to °C and °F in
order to explain the full equation.
Community College of Allegheny County
Unit 7
Figure #1 β Arduino Analog-to-Digital
+5V
10K 10-turn
Potentiometer
Arduino
MicroController
Analog In
A0
Gnd
USB
Laptop
Page #8
Community College of Allegheny County
Unit 7
Page #9
Figure #2 β AD590 Temperature Sensor
+5V
AD590
Temperature sensor
Arduino
MicroController
Analog In
A0
1K ohm
Gnd
77degF = 25degC = 298uA
70degF = 21degC = 294.15uA
è 298mV @ 1K ohm load
70degF = 21degC = 294.15mV
Outputs 1mV per °C
USB
Laptop
AD590
Community College of Allegheny County
Unit 7
Page #10
Figure #3 β AD590 Temperature Table
AD590
Output
Current
in Amps
AD590 mV
output
with 1K
ohm
Resister
Degree
Celsius
Degree
Fahrenheit
Degree
Kelvin
Calculated °F
= 1.8(mV)459.67
0.00027315
273.15
0
32
273.15
32
0.00029415
0.00029515
0.00029615
0.00029715
0.00029815
0.00029915
0.00030015
294.15
295.15
296.15
297.15
298.15
299.15
300.15
21
22
23
24
25
26
27
69.8
71.6
73.4
75.2
77
78.8
80.6
294.15
295.15
296.15
297.15
298.15
299.15
300.15
69.8
71.6
73.4
75.2
77
78.8
80.6
0.00037315
373.15
100
212
373.15
212
Community College of Allegheny County
Unit 7
Page #11
Figure #4 β Arduino Software
/*
Analog Input - Demonstrates analog input by reading an analog value
analog pin 0
on
The circuit:
Potentiometer attached to analog input 0
center pin of the potentiometer to the analog pin
one side pin (either one) to ground
the other side pin to +5V
Created by Dan Wolf, Updated on 1/21/2017
*/
int sensorPin = A0;
int sensorValue = 0;
// select the input pin for the potentiometer
// variable to store the value coming from the sensor
const byte numChar_in_Load = 10;
char AD_Reading_Str[numChar_in_Load];
char AD_Voltage_Str[numChar_in_Load];
float fAD_Voltage;
void setup() {
Serial.begin(9600);
// set up Serial library at 9600 bps
Serial.println("\n Arduino Analog-to_Digital - vJan_20_2017");
Serial.println("Uses analog input A0 \n");
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
fAD_Voltage = sensorValue * 0.00488; //convert to volt
dtostrf(sensorValue, 5, 0, AD_Reading_Str);
dtostrf(fAD_Voltage, 7, 5, AD_Voltage_Str);
(5V/1023=0.00488)
// convert to a string
// convert to a string
Serial.print("Raw A-D Value: ");
Serial.print(AD_Reading_Str); // display the RAW A-D Value
Serial.print("
");
Serial.print("A-D Voltage: ");
Serial.print(AD_Voltage_Str); // display the analog input voltage
Serial.print(" Volts \n");
delay(2000);
}
Community College of Allegheny County
Unit 7
Page #12
PRACTICE PROBLEMS:
1. You are working with a 0 to +10volt, 14-bit ADC.
a. What is the smallest voltage that it will be able to
measure?
b. What will be the RAW A-D output value when a 15mV signal
is applied to the input?
2. Refer to the Linear Technology LTC1604 ADC Converter datasheet
that is on the course website and answer the following
questions:
a. How many bits is this converter?
b. What is itsβ input voltage range?
c. How many samples per second can it accept?
3. We have an RPM sensor that must be connected to the Arduino
10-bit ADC. The RPM sensor has a range of 0 to 8K RPM via a
voltage range of 0 to +5volts.
a. What is the expected input voltage to the ADC at 3K RPM?
b. What is the RPM resolution for this application?