5-segment square-root approximation - RV

advertisement
AVS-48 Picobridge® Project
Application
Note
Five-segment square root approximation
INTRODUCTION
DESIGN GOAL
It can be sufficient to approximate an analog square-root
function cheaply by a few linear segments in applications,
where the function needs not be very accurate. Linearisation of a temperature controller’s heating power vs. its
PID output [PH = RH * I2] is an example. In a closed-loop
control system, accuracy is mainly determined by circuits
other than the power output stage. Without such a linearisation, the closed-loop gain will change with the sample’s
heat load [PH = RH * (I + ILOAD)2]. This can make it more
difficult to optimise the PID settings in terms of speed and
stability. The following simple circuit approximates the
function
The operational amplifiers in our AVS-48 will be powered
with +/- 5 Volts and therefore all signal voltages must be
limited to +/- 3 Volts. The square-root circuit is placed
after the PID section, which delivers +3V at maximum,
and before the heater power stage, which requires +3V for
maximum output current.
Figure 1 shows sqrt(VIN) where 0.. VIN..+3V
(curve a). When sqrt() is approximated by linear segments, each segment line has a smaller slope than its
predecessor. We need an attenuator, whose attenuation
increases stepwise at each corner point for input voltages
that rise higher than the corner voltage. The first segment must naturally start from zero and it has the steepest
slope.
(1)VOUT = 3 * sqrt(VIN) / sqrt(3)
using one quad and one single low-cost operational amplifier plus 12 resistors.
The simplest solution would be to design an attenuator for
sqrt(VIN), and because sqrt(3)=1.73, amplify the result by
3/1.73. Then +3V input would yield +3V output, as de-
SQRT(Vin)
2
1.8
sqrt(Vin)*3/sqrt(3)
curve a
1.6
slope=1
Output (V)
1.4
1.2
1
0.8
sqrt(Vin)*0.5/sqrt(3)
curve b
0.6
0.4
0.2
the first segment has slope=1,
0
0
0.5
1
1.5
2
2.5
3
Vin (V)
Fig. 1. Square root of VIN and the same scaled down
RV-Elektroniikka Oy PICOWATT
Veromiehentie 14
FI-01510 VANTAA, Finland
phone +358 50 337 5192
e-mail: reijo.voutilainen@picowatt.fi
Internet: www.picowatt.fi
Revised: 2013-09-01
square_root_approximation.indd
RV-Elektroniikka Oy PICOWATT
Page 1
AVS-48 Picobridge® Project
Application
Note
Five-segment square root approximation
sired. But the steepest slope for an attenuator is 1 (= no attenuation). If a line with slope 1 is drawn from the origin,
it can be seen that the error to the real sqrt function is very
large, see Fig.1. This can be avoided by scaling down the
square root so, that the maximum output for 3V input is
much less than 1.73V. The scaling factor is a compromise
between accuracy of the first segment and offsets of the
5
4
op amp inputs.
We chose 0.5V maximum output
(Fig.1
curve b ). The attenuator output must then be amplified by
(a)
a factor of 6.5
4
Vout
(a)
D
P5V
D
R1
Vin
Vc
D1
P5V
R1
D2
R3
P5V
R3
N5V
Vout
D2
Vc2
N5V
R5
Vc2
R5
R2
G=R2/(R1+R2)
Vin
G=1
Vout
(a)
R6
G=R2/(R1+R2)
(b)
G=1
(a)
N5V
(b)
Vout
2
Vref
R1
Vin
Vc
Vc
C
Vref
3
Vout
R2
Vout
C
2
Vin
P5V
Vc
Vin
3
R6
D1
R2
R1
some reference voltage VREF so that VC1<VC2. Selection of
the corner points is a kind of matter of taste, where one
tries to keep the approximation error tolerable within the
range where VIN is likely to vary. It is important to notice,
that the corner points must be taken from the VOUT axis for
calculating the resistors for the VC divider, as shown by
Fig. 3b.
R2
Vin
D3
N5V
D3
Vc1
R4
Vc1
R4
Fig. 2. Simple case of two segments
B
B
A
A
Vc2
PRINCIPLE OF OPERATION
The idea is to generate zero-impedance nodes at selected
corner voltages. Each node should exhibit infinite impedance for input voltages less than the corner voltage, and
zero impedance for input voltages higher than the corner
point. These nodes are used for building an attenuator,
whose attenuation factor depends on the input voltage.
Figure 2a shows the simplest case of only one corner, or
two segments. As long as VIN is less than VC, the inverting
input is more negative than the non-inverting input. The
op amp output is near to the positive supply, diode D1
does not conduct and the right side of R2 sees a very high
impedance. VOUT equals VIN because there is no attenuation. But as soon as VIN exceeds the corner voltage VC,
the op amp output changes polarity. Diode D1 conducts
and the op amp tries to keep its inverting terminal at VC.
If the input voltage still increases, the slope of the new
growth will be R2/(R1+R2). See Fig. 2b.
Figure 3a shows the next step of having two corner points,
and it also shows the principle of the final circuit. The two
corner points are formed by a simple voltage divider from
Revised: 2013-09-01
(b)
Vout
(b)
segment2
Vc1 Vout
Vc2
segment1
Vc1
segment3
segment2
segment3
Vin
1: G=1
2: G=R1/(R1+R2)
segment1
3: G=R2R3/(R2R3+R1R3+R1R2) Vin
1: G=1
2: G=R1/(R1+R2)
Fig. 3. Three segment
approximation
3: G=R2R3/(R2R3+R1R3+R1R2)
Calculating resistor values for the attenuator is a little
tedious. A lot of help is provided by formula
(2)VOUT = (VIN /R1 + VC1/R2 + VC2/R3 +…)/
(1/R1 + 1/R2 + 1/R3 +…)
Using VIN values corresponding to the corner points, we
can solve first for R2, then for R3 and so on, if the circuit
has more than two corner points. A spreadsheet program
with goal seeking facility is good enough, unless one has
to do this calculation frequently.
square_root_approximation.indd
RV-Elektroniikka Oy PICOWATT
Page 2
AVS-48 Picobridge® Project
Application
Note
Five-segment square root approximation
Calculating resistor values for the VC divider needs trial
and error: one must seek for a combination where all resistors are near to easily available stock values, e.g. from
the E96 series (1% metal film). With our stock values, we
end up to R6..R10 values shown in Fig. 3.
THE FINAL CIRCUIT
The function to approximate is (Fig.1 curve b )
(3)VOUT = sqrt(VIN)*0.5/sqrt(3)
For calculating the attenuator resistances R1..R5 we use
eq. (2) successively, first for R1 and R2, then for R1,
R2 and R3 and so on. Each obtained value is replaced
by a suitable stock value before the next step in order
to prevent errors from cumulating. If no stock value is
found, one can try to change R1, but this requires a new
start from the beginning. We ended up with values R1..
R5 shown in Fig. 4.
The first corner voltage cannot be selected, it is determined by the fact that the first segment starts from zero
and its slope is one. The next three corners were chosen
visually:
for VIN = 0.0834
for VIN = 0.35
for VIN = 0.83
for VIN = 1.6
for VIN = 3
5
The non-inverting amplifier with gain 6 is trivial. Figure
5. shows how this approximation performs.
4
3
INPUT RANGE 0..+3V
P5V
R1
10K0
0..+0.5V
VIN
3
6
1
2
3VREF
corner voltages:
input
output
0.083
0.083
0.35
0.17
0.83
0.265
1.6
0.368
3
0.5
4
R10
100K
C
U2
TL051
7
D
2
P5V
R5
3K57
D4
R12 4K99
4
14
U1D
TL054
12
11
0.368V
VOUT
N5V
1N4148
13
0..+3V
5
VC1 = 0.0834
VC2 = 0.172
VC3 = 0.263
VC4 = 0.365
VC5 = 0.5
R11
1K00
N5V
R9
3K92
D3
1N4148
TL054
9
8
10
11
0.265V
U1C
4
R4
4K22
R8
3K57
7
5
11
0.172V
D2
1N4148
TL054
6
B
U1B
4
R3
4K75
R7
3K32
D1
1N4148
TL054
2
1
3
11
0.0834V
U1A
4
R2
4K99
A
R6
3K16
Title
SQUARE ROOT APPR. FI
Size
A4
Date:
Fig. 4. The final circuit
Revised: 2013-09-01
square_root_approximation.indd
RV-Elektroniikka Oy PICOWATT
Document Number
<Doc>
Friday, July 05, 2013
Page 3
AVS-48 Picobridge® Project
Application
Note
Five-segment square root approximation
5-SEGMENT APPROXIMATION
measured performance
3.5
0.25
3
0.2
sqrt(Vin)*3/sqrt(3)
Vout (v)
2.5
0.15
2
0.1
segment approximation
1.5
0.05
1
0
error
0.5
-0.05
0
-0.1
0
0.5
1
1.5
2
2.5
3
Vin (v)
Fig. 5. Calculated (yellow) and approximated (red) square root.
The blue curve and y-axis on the right show approximation error.
Picobridge® is a registered trademark of RV-Elektroniikka Oy Picowatt
Revised: 2013-09-01
square_root_approximation.indd
RV-Elektroniikka Oy PICOWATT
Page 4
Download