Download 2-4 Course notes - Earlston High School

Survey
yes no Was this document useful for you?
   Thank you for your participation!

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

Document related concepts

Resistive opto-isolator wikipedia , lookup

Heterodyne wikipedia , lookup

Control system wikipedia , lookup

Public address system wikipedia , lookup

Fault tolerance wikipedia , lookup

Multidimensional empirical mode decomposition wikipedia , lookup

Hendrik Wade Bode wikipedia , lookup

Immunity-aware programming wikipedia , lookup

Opto-isolator wikipedia , lookup

Analog-to-digital converter wikipedia , lookup

Transcript
Analogue to Digital Conversion
The microcontroller can only process digital (high/low) signals. However in many
practical applications analogue quantities, such as light intensity or temperature, need
to be tested.
An Analogue-to-Digital Converter (ADC) is a device which can convert analogue
quantities into digital signals. An 8-bit ADC can generate a digital signal in the range
0 to 255 (i.e. one byte). ADC's are available as separate integrated circuits, or may
even be 'built into' the microcontroller to give it 'on-board' ADC capabilities. With the
Stamp Controller system an external 8-bit ADC integrated circuit is used.
Voltage Reference
ADCs are designed to process analogue signals within a certain range. The
maximum voltage signal that can be processed by an ADC is called its reference
voltage. A common reference voltage for an 8-bit ADC is 2.55V, so the ADC can
measure signals in the range 0 to 2.55V. Therefore the 8-bit ADC device will
generate an 8-bit value directly equivalent to the voltage signal applied.
Technological Studies: Systems and Control Students’ Notes (H) Outcome 4
1
Signal Conditioning
SIGNAL
AMPLIFIER
Analogue sensors, such as the thermistor (temperature sensor), may not directly
produce a suitable signal for use with the ADC. Therefore it is often necessary to use
a signal amplifier circuit so that the input signal can be 'conditioned' to the input
range of the ADC (0 to 2.5V). An operational amplifier, configured as a voltage
amplifier, is commonly used for this task. The following example shows how the gain
of the operational circuit is typically calculated.
Example:
A temperature sensor is to be used to monitor the temperature of a factory furnace.
Experimentation has shown that the temperature sensor produces a linear output
signal, reading 0V at 0º Celsius and 1.53V at a temperature of 200º Celsius. The
maximum operating temperature of the furnace is 1000º Celsius. The maximum
voltage that may be fed into the ADC is 2.55V
Draw a circuit diagram of a suitable signal conditioning system based on operational
amplifiers.
Solution:
1) Calculate the maximum input signal, which is at 1000º Celsius.
Signal at 200º = 1.53V
1000º is equal to 5 x 200º
Therefore maximum signal is 5 x 1.53V = 7.65V
2) Calculate the gain required from the op-amp circuit.
Input Signal = 7.65V
Required output signal = 2.55V
Therefore Gain = output / input = 2.55 / 7.65 = 0.33
Technological Studies: Systems and Control Students’ Notes (H) Outcome 4
2
3) Draw circuit diagram of a voltage amplifier circuit with gain set to 0.33
15k
+12V
5k
10k
+12V
10k
_
_
+
+
-12V
-12V
0
Gain of –3
Gain of -1
Inverting Amp
Inverting Amp
Technological Studies: Systems and Control Students’ Notes (H) Outcome 4
3
Multiplexers
ADC integrated circuits are relatively expensive to construct. When it is necessary to
record more than one analogue signal a 'multiplexer' can be used to prevent the need
for multiple ADC circuits. The multiplexer can be physically 'built into' the ADC
integrated circuit, or can be provided by a completely separate integrated circuit.
MULTIPLEXER
Vs1
TO ADC
Vs2
The multiplexer functions in a similar manner to a rotary switch connecting each of
the analogue channels in turn to the ADC. Therefore the multiplexer 'selects' which
sensor is connected to the ADC at any one time. As only one sensor is connected to
the ADC at any one time the whole system is slower than using a separate ADC for
each sensor. However modern microcontrollers operate very quickly, and so the cost
saving usually outweighs the increased processing time.
Data Logging
Data loggers are used in a wide range of applications from flight recorders on aircraft
to life support systems in incubators for premature babies.
The frequency at which signals are recorded is called the sample frequency. A high
frequency rate would be used to record a very fast changing signal over a small period
of time - for instance when measuring the electrical activity of the human heart. A low
frequency rate would be used when a slow changing signal is measured over a long
period of time - for instance monitoring the temperature of a green house over a week
period.
As data loggers are generally small, portable and battery operated, the data is often
stored electronically in EEPROM integrated circuits. This means the data is retained
when the batteries are removed, but can also be updated easily when required. Data
loggers can be left unattended for long periods of time, and are ideal for hostile or
remote environments measuring variations in industrial and weather monitoring
situations.
Once a data logging experiment is complete, it is obviously necessary to be able to
retrieve the data for analysis. In more basic systems the data may just be printed out
directly as a simple table, but in more advanced systems it is common to 'upload' the
data to a personal computer for mathematical analysis and/or graph generation in a
spreadsheet application.
Technological Studies: Systems and Control Students’ Notes (H) Outcome 4
4
The Data Logger Module
1
CS
2
CLOCK
3
DATA
4
CS
CLK
DI
DO
93LC66
+ 5V
VCC
NC
ORG
VSS
8
7
6
5
2K2
The data logger module contains a 512 byte EEPROM integrated circuit. In practical
terms this means that up to 512 8-bit ADC readings can be stored in the EEPROM.
The data logger module also contains the electronic connectors necessary to link a
serial computer cable, so that the data stored in the EEPROM can be uploaded to a
personal computer for analysis.
The EEPROM integrated circuit is a serial device, and operates in a very similar
manner to the serial ADC, using the same three data, clock and chip select signals.
However in this case the data signal is bi-directional, as it is necessary to write to, and
read from, the EEPROM memory.
The 512 byte memory is divided into two pages, each page containing 256 bytes.
Therefore to correctly locate a memory cell you must specify both its page number (0
or 1) and its address (0 to 255).
Like the ADC, the EEPROM makes use of two 'standard' sub-procedures to carry out
the serial communication. These sub-procedures can be copied directly from the
datasheets. Sub-procedure 'eewrite' is used to write data to the EEPROM, and
'eeread' is used to read data back from the EEPROM.
Therefore to write the value '85' to EEPROM address '23' on page '1' the program
would be
let data = 85
let address = 23
let page = 1
gosub eewrite
'Set the data.
'Set the address.
'Set the page.
'Write the data to the EEPROM.
To retrieve the data and show it on the computer screen (via the debug command) the
program would be
let address = 23
let page = 1
gosub eeread
debug data
'Set the address.
'Set the page.
'Read the data from the EEPROM.
'Send data to the computer screen.
Technological Studies: Systems and Control Students’ Notes (H) Outcome 4
5
Analysing Data with a Spread-sheet
HOST COMPUTER
SERIAL LINK
ANALOGUE
SENSORS
MULTIPLEXER
ADC
MICRO-CONTROLLER
EEPROM
After a data-logging experiment it is usual to 'upload' the data to a host computer so
that the readings can be analysed via a spread-sheet application. This enables
mathematical calculations to be made, and also allows the generation of graphs.
The 'upload' procedure requires serial communication between the Stamp Controller
and the host computer. This is achieved via a serial cable connected to the Datalogger
Module
Technological Studies: Systems and Control Students’ Notes (H) Outcome 4
6
Technological Studies: Systems and Control Students’ Notes (H) Outcome 4
1