Angelo Fraietta, Toby Gifford, and Ashley Kelso
Originally published in Chroma (34):6-10
When making a sensor using a variable resistor, it is important to note that you are using a voltage divider network. The goal is to have the sensor generate the maximum possible voltage swing that can be input to you CV to MIDI converter. This in turn means that your CV to MIDI converter will be able to generate the maximum possible number of MIDI messages. For example, if the output swing is 0 to +5V, the converter will generate controller messages whose values are 0 to 127. If the voltage swing is from +2.5VDC to +5VDC, the converter will only generate controller message values from 63 to 127. This has effectively halved your resolution. (Although many CV to MIDI converters, including new ones purchased from me have a 10 bit scaling capability that would reduce the effect of this problem, the point is that you need to maximize the swing without increasing the rail voltages).
Let's say that we are building a sensor based upon a light dependant resistor (LDR) that you get from Jaycar. You measure the LDR with your multi-meter and it exhibits a resistance of approximately 10kΩ when under the maximum light, and a resistance of approximately 200kΩ when there is minimal light. We need to select a value for the fixed resistor R1 in the voltage divider circuit, which we will say has a value of X, as we have not calculated its value yet.

If we select a value for R1 of 10kΩ, let us calculate the range of voltage that we would read at the sensor point.

When the LDR has the maximum amount of light, its resistance is 10kΩ, resulting in the following effective circuit.

The value at the sensor, which is the voltage dropped by R2, is determined by the voltage divider
![]()
![]()
![]()
![]()
VR2 = 2.5V
Let us examine the LDR with minimum amount of light, causing R2 to be 200kΩ.

The value at the sensor, which is the voltage dropped by R2, is determined by the voltage divider
![]()
![]()
![]()
![]()
VR2 = 4.76V
The voltage swing is therefore the voltage difference between the minimum light and the voltage at maximum light
Min = 2.5V, Max = 4.76V. The voltage swing is 2.26V -- this is less than half.
Let us now calculate the voltage swing if we used a fixed resistor value of 200 kΩ.

At the maximum light, R2 = 10kΩ.
![]()
![]()
![]()
![]()
VR2 = 0.238V
At the minimum light, R2 = 200kΩ.
![]()
![]()
![]()
![]()
VR2 = 2.5V
The voltage swing is from 2.5V to 0.238V, which is approximately 2.26V -- about the same as using a 10kΩ fixed resistor for R1.
The amount of voltage swing is effectively
![]()
or
![]()
What happens if we pick a resistor value for R1 halfway in between 10kΩ and 200kΩ -- say 105kΩ?
At the maximum light, R2 = 10kΩ, at minimum light, R2 = 200kΩ.
![]()
![]()
This gives a swing of 2.84V, which is an improvement. Try one more value for R1: say 50kΩ.
![]()
This gives a voltage swing of 3.16, which is much better than the original swing of 2.26V for R1 values of 10kΩ and 200k, and better than the value of 2.84V using a value of 105kΩ for R1. So how do we calculate what the optimum value would be for R1? There are at least two ways of looking at it. We can look in terms of the ratios between the R1, R2Max and R2Min, or we can calculate the value using differentiation.
When we originally looked at the problem, we chose an alternate value of 105k, half-way between the 10kΩ to 200kΩ variable resistor range. We often think of this as the average value, being the sum of the values divided by the number of values. This is known as the arithmetic mean.
![]()
For example,
![]()
This value equalled 105kΩ; it was found, however, that a value of 50kΩ produced a greater swing; and therefore, the arithmetic mean is not the optimal value. This is because the swing either side of the central point is based upon the ratios between R1: R2Max and R1:R2Min. Leon Battista Alberti (1407-1472) states "We shall therefore borrow all our Rules for the Finishing our Proportions, from the Musicians, who are the greatest Masters of this Sort of Numbers, and from those Things wherein Nature shows herself most excellent and compleat[sic]"; therefore, perhaps a musical analogy would be efficacious.
Imagine we have two musical notes,
and
. Suppose
that
is
a middle C at 256 Hertz and
is two octaves up at 1024
Hertz. What would you say is the note halfway between these? Would you take
the arithmetic mean of 640 Hertz? More likely you would take the C at 512
Hertz which is one octave above
and one octave below
. This is
because we tend to think of pitch on a logarithmic scale, which in turn is
because our perception of pitch intervals relies on the ratios of the
frequencies.
The situation with our voltage divider network
is similar in that what determines the voltage at the sensor point is the ratio
of
and
, so in
choosing the resistance 'halfway' between
and
we should take the halfway point
on a logarithmic scale. This point is called the geometric mean. The geometric
mean is like the arithmetic mean except that instead of adding the two values
and multiplying by ˝, the values are multiplied and the put to the power of ˝.
![]()
or
![]()
Relating this back to our musical analogy, 512 Hertz is the geometric mean of 256 Hertz and 1024 Hertz; the ratio of 256 : 512 is the same as the ratio of 512 : 1024 Hertz (they are both equal to 2).
So how do we prove that the geometric mean is the sweet
spot? The standard approach to solving an optimisation problem
such as this is to use differential calculus. Given a function y(x) the
derivative
(x)
of this function is the slope of the graph of y at the point x. If we are
looking for a maximum value for y, then we need to look for a point where the
slope of the graph of y is zero.
In our case we are seeking the maximum value of the Voltage Swing
![]()
We will use the standard result that for a
function of the form
we have the derivative
. This
formula is valid for all values of
, even when
is negative.
Considering the voltage swing as a function of
we obtain

At our optimal point this derivative must be zero. Hence
![]()
or

Cross multiplying and expanding yields
![]()
Then collecting terms and solving for
gives
![]()

Therefore.
![]()
In the case of our LDR with a range of 10kΩ to 200kΩ, we get the following:
![]()
![]()
R1 = 44.72 kΩ
Any resistance value for R1 greater or less than this value will give you a smaller voltage swing. The further away from the optimal value, the less your voltage swing.
Also when building your voltage divider sensors using variable resistors, don't forget to factor in any known input impedance into your calculations.
If you don't want to go through the drama of calculating it yourself, you can use this cool Resistor Calculator Utility .