Occasionally the analog signal provided by external sensors require an Analog to Digital
conversion with a resolution of greater than 8 bits. In order to extract the full information for
subsequent data processing within the microcontroller a higher resolution Analog to Digital
is thus required.
The solution described in this note enables this higher resolution with the on-chip 8-bit A/D
converter of the ST62, using only an additional Operational Amplifier (OpAmp) and a few
resistors
The technique implemented is that of the Algebraic Adder, a full discussion of the principle
of operation is included in this note.
A practical example of the external components used is shown in the following figure:
Figure 1.Example circuit
The resistances are selected by the ST62 I/O pins depending on the analog input voltage.
The selection programmed modifies the output voltage of the OpAmp in such a way that the
following A/D conversion is always made with the maximum input range of the converter.
This selection is made by software, therefore the total conversion time is increased versus a
normal 8-Bit conversion, however the precision is increased and the input voltage range can
be enlarged.
4/15Doc ID 2078 Rev 2
AN420Principle of operation of an algebraic adder
VNn
RNn
RrRN2
VN2
VN1
RN1
RN0
Vn
Vo
+
-
Vp
RP1
RP2
VP2
VP1
VPm
RPm
RP0
-36
V
0
K
i
i1=
m
∑
V
P
i
K
i
i1=
n
∑
V
N
j
×–×=
1
R
r
----- -
1
R
N
0
---------
1
R
N
j
--------
j1=
n
∑
++
1
R
P
0
---------
1
R
P
i
--------
i1=
m
∑
+
1
R
T
-------==
3 Principle of operation of an algebraic adder
Figure 2 represents the generic algebraic adder.
Figure 2.Generic algebraic adder
The circuit generates an output voltage equal to: i
To minimize the effects of the input polarizing currents, the total resistances seen from the
two inputs of the OpAmp should be the same. Therefore:
The two resistances RP0 and RN0 are needed to satisfy the above relation. In general, only
one of them will be needed.
(1)
(2)
Doc ID 2078 Rev 25/15
Principle of operation of an algebraic adderAN420
V
P
G
P
i
V
P
i
×
i1=
m
∑
G
P
0
G
P
i
i1=
m
∑
+
----------------------------------=
G
x
1
R
x
------=
V
n
V0G
R
G
N
j
j1=
n
∑
+×
G
N
0
--------------------------------------------- -=
G
N
0
G
R
G
N
j
j1=
n
∑
++G
P
0
G
P
j
j1=
m
∑
+G
T
==
V
0
V
N
j
j1=
n
∑
–
R
r
R
N
j
--------V
P
i
i1=
m
∑
R
r
R
P
i
--------
×+×=
K
i
R
r
R
P
i
--------=
K
j
R
r
R
N
j
--------=
To analyze the circuit, let us calculate the input voltages:
(3)
where
(4)
Relation (2) becomes:
(5)
From 3, 4 and 5 we get:
(6)
Relation (6) is the relevant formula to be used. It also explains the name given to this circuit,
since the output voltage is the 'algebraic sum' of the input voltages. To design the actual
circuit, you chose one value of Rr (arbitrarily). The other resistances are then determined by
the desired coefficients:
(7)
6/15Doc ID 2078 Rev 2
AN420Principle of operation of an algebraic adder
Finally, the values for RN0 and RP0 are chosen, based on (2).
Doc ID 2078 Rev 27/15
ExampleAN420
4 Example
Let us assume we have a voltage swing of 10 volts (0 to 10) that we want to convert with a
10-bit resolution. And let us assume we have a set of voltage sources VNj that we can
switch between 0 to 5 volts under software control, and each one independently from the
other.
Let us also assume we can 'cut' the 10 volt swing in 4 'pieces' of 2.5 volts each, and that
every 'piece' can be converted with 8-bit resolution. The overall resolution will therefore be:
8
2
(ST6 A/D resolution)
* 22
(# of 'pieces')
Let us call Vin the actual value of the source to be converted. For instance, if Vin ε [10, 7,5]
volts, we could supply the ST6 A/D with the voltage:
(V
-7.5volt)x2 => ε[0,5]volt
in
or, for (10,7.5) volts:
(V
-1.5xVN1)x2 = 2xVin-3xV
in
N1
where VN1 is one of the VNj sources, either 0 or 5 volts. In similar fashion, for the other
intervals, we could obtain:
(7.5, 5) volts
(V
)x2 = 2xVin-2xV
in-VN2
N2
(5, 2.5) volts
(V
-0.5xVN3)x2 = 2xVin-V
in
N3
(2.5, 0) volts
(V
-0xVN4)x2 = 2xV
in
in
So, relation (6) becomes:
V
= 2xVin-3xVN1-2xVN2-VN3 where Vin =V
0
The software driving the conversion will therefore verify if, given a certain status of the V
voltages, the conversion is far from being saturated. If so, another try will be performed with
a different status of the V
voltages. Figure 3 gives the flow chart of such software.
Nj
= 2
10
P1
Nj
8/15Doc ID 2078 Rev 2
AN420Example
VN1 = VN2 = VN3 = 0
CONVERT
SATURATED?
NO
DONE
Vin => [0, 2.5] V
CONVERT
VN3 = 1
YES
SATURATED?
NO
DONE
Vin => [2.5, 5] V
CONVERT
YES
SATURATED?
NO
DONE
VN3 = 0, VN2 = 1
Vin => [5, 7.5] V
YES
CONVERT
VN2 = 0, VN1 = 1
DONE
Vin => [7.5, 10] V
-36
R
r
R
P1
----------2R
P1
⇒5000Ω==
R
r
R
N1
----------3R
N1
⇒3333Ω==
R
r
R
N2
----------2R
N2
⇒5000Ω==
Figure 3.Conversion routine
The actual circuit values are calculated as follows. With arbitrarily chosen Rr equal to 10 KΩ,
the other resistor values are given by:
Doc ID 2078 Rev 29/15
ExampleAN420
R
r
R
N3
----------1R
N3
⇒10Ω==
1
R
r
----- -
1
R
N0
----------
1
R
N1
----------
1
R
N2
----------
1
R
N3
----------
1
R
N0
----------0.0007++++++
1
R
P0
----------
1
R
P1
----------+
1
R
P0
--------- -0.0002+=
1
R
N0
----------0.0007+
1
R
P0
----------0.0002+=
R
P0
-------∞R
N0
⇒2KΩ==
To satisfy relation (2), we obtain the following values, as indicated in Figure 4.
Assuming
10/15Doc ID 2078 Rev 2
AN420Application example
PC4
3.3K
5K
10K
10K
PC5
PC6
ST6215
PB0 (A/D Input)
2K
5K
Vin
OUTPUTS
-36
5 Application example
An example ST62 software program follows on the next pages. It executes the program flow
of Figure 3 in the application circuit of Figure 4.
Figure 4.Example circuit
The ST6215 pin allocation is arbitrary. The three outputs can drive other identical circuits,
when more the one 10-bit A/D channel is needed. Also, a different number of 'pieces' can be
used to achieve a different resolution.
Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the
right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any
time, without notice.
All ST products are sold pursuant to ST’s terms and conditions of sale.
Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no
liability whatsoever relating to the choice, selection or use of the ST products and services described herein.
No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this
document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products
or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such
third party products or services or any intellectual property contained therein.
UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED
WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS
OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.
UNLESS EXPRESSLY APPROVED IN WRITING BY TWO AUTHORIZED ST REPRESENTATIVES, ST PRODUCTS ARE NOT
RECOMMENDED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING
APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY,
DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. ST PRODUCTS WHICH ARE NOT SPECIFIED AS "AUTOMOTIVE
GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER’S OWN RISK.
Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void
any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any
liability of ST.
ST and the ST logo are trademarks or registered trademarks of ST in various countries.
Information in this document supersedes and replaces all information previously supplied.
The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners.