Analogue to Digital Conversion
Analogue to Digital Conversion
Lecture 12
Uli Raich
UCC semester 2017/2017
COPYRIGHT © 2024 by the contributing authors
Slide 1 of 20
Analogue to Digital Conversion Printed Circuit Boards
In our sensor kit we have 2 different small printed circuit boards
with
Analogue to
Digital
Converters (ADCs) on board:
- The PCF8591 4 channel, 8 bit successive approximation ADC
- The ADS1115 4 channel 16b bit ΣΔ ADC
As you can already see here, different techniques
(successive approximation and ΣΔ) are used.
Both devices use the
I2C interface and are rather slow.
COPYRIGHT © 2024 by the contributing authors
Slide 2 of 20
In my treasure box I also have a few mcp3004 ADC chips,
which are 10 bit converters providing sampling rates of up to
200ksps (kilo samples per second)
These devices use the SPI interface which will not be explained in this course.
However, you are invited to read the data sheet and to try them.
If you want to play on higher frequency ADCs, then we have a
48 MHz ADC, which is employed in the Hantek 6022BE DSO
(
Digital
Storage
Oscilloscope)
Today we have 14 bit ADCs with sampling rate in the GHz range.
COPYRIGHT © 2024 by the contributing authors
Slide 3 of 20
Why do we use the PCF8591 ADC, which is the device with
the worst characteristics?
- Only 8 bit resolution
- Conversion rate determined by I2C bus frequency (100 kbps)
- Has four multiplexed input channels
- Has one 8 bit DAC channel
COPYRIGHT © 2024 by the contributing authors
Slide 4 of 20
Reasons to use the PCF8591
- We do not need a high precision or super fast AD conversion,
which gives us a resolution of better than 1/2 % full range
- We are only interested to understand the principle of A to D conversion
- Having analogue devices on the PCB allowing us
to test our setup is and important asset
COPYRIGHT © 2024 by the contributing authors
Slide 5 of 20
COPYRIGHT © 2024 by the contributing authors
Slide 6 of 20
Problems with the YL-40 board
There were 2 problems with the YL-40 board I bought from China:
- The connection of one end of the thermistor to ground was
missing and had to be added by soldering a short connection.
- The DAC output does not reach Vdd of full scale because
the LED connected to it draws too much current.
COPYRIGHT © 2024 by the contributing authors
Slide 7 of 20
COPYRIGHT © 2024 by the contributing authors
Slide 8 of 20
COPYRIGHT © 2024 by the contributing authors
Slide 9 of 20
As we can see from the photos and from the circuit diagrams,
the YL-40 has already 3 devices that can be connected
to the PCF8591 inputs through jumpers:
- a photo resistor (AIN0)
- a thermistor (AIN1)
- a potentiometer (AIN3)
AIN2 is unused and can be connected to the DAC output
The potentiometer is particularly useful as any change in resistivity
created when turning it, can immediately be observed on the
ADC values read back from the board.
COPYRIGHT © 2024 by the contributing authors
Slide 10 of 20
The PCF8591 block diagram
COPYRIGHT © 2024 by the contributing authors
Slide 11 of 20
Set the DAC value to Vcc/2 (½ of 0-Vcc interval)
and compare with analogue signal level
If signal level > DAC, set bit 7 to 1 and set DAC level to ¾ Vcc
else set bit 7 to 0 and set DAC level to ¼ Vcc
If signal level > DAC level set bit 6 to 1 and
set DAC level to ½ of the upper interval
else
set bit 6 to 0 and DAC leve to ½ of lower interval
After 8 approximations we have the converted 8 bit value
COPYRIGHT © 2024 by the contributing authors
Slide 12 of 20
COPYRIGHT © 2024 by the contributing authors
Slide 13 of 20
An include file to describe the ADC
COPYRIGHT © 2024 by the contributing authors
Slide 14 of 20
Once you have initialized the pigpio library with
and opened the
I2C bus with
you must set the control byte:
- controlByte =PCF8591_CHANNEL_C | PCF8591_4_SINGLE_ENDED;
i2c_write_byte(pi,handle,controlByte;
You can read the channel:
- adcValue=i2c_read_byte(pi,handle);
COPYRIGHT © 2024 by the contributing authors
Slide 15 of 20
Students typically have problems with
- Pointers
- Parameter passing
Therefore I tried to write a few demo programs
to show how to use these correctly
COPYRIGHT © 2024 by the contributing authors
Slide 16 of 20
COPYRIGHT © 2024 by the contributing authors
Slide 17 of 20
COPYRIGHT © 2024 by the contributing authors
Slide 18 of 20
Change in pointer value after the loop
What has happened to the pointer during the loop?
It has advanced and now points to the zero string terminator.
Subtracting the old value (hello) from the
new helloPtr value yields the string length
COPYRIGHT © 2024 by the contributing authors
Slide 19 of 20
Printing the remaining string
COPYRIGHT © 2024 by the contributing authors
Slide 20 of 20
--
Uli Raich - 2017-11-21
Comments
This topic: Embedded_Systems
> WebHome >
LectureSlides > Lecture12:AnalogueToDigitalConversion
Topic revision: r2 - 2017-11-23 - uli
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback