This is only a preview of the October 2024 issue of Silicon Chip. You can view 45 of the 112 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Items relevant to "3D Printer Filament Dryer, Part 1":
Items relevant to "8Ch Learning Remote Receiver":
Articles in this series:
Items relevant to "JMP012 - WiFi Relay Remote Control":
Videos relevant to "JMP015 - Analog Servo Gauge":
Articles in this series:
Items relevant to "Dual-Rail Load Protector":
Items relevant to "Micromite Explore-40":
Purchase a printed copy of this issue for $13.00. |
Mini Projects #015 – by Tim Blythman
SILICON CHIP
Analog Servo
Gauge
A gauge with a needle is often the
simplest way of communicating a
reading. This project lets you convert
an analog voltage to a gauge readout. Because
it uses a servo motor, you can make it really big!
› Only needs a 5V DC supply
› Span and offset adjustment trimpots
› Converts a 0-5V signal into a PWM signal to drive a servo motor
› Uses just one comparator IC and a voltage regulator, plus some passives.
T
his project displays a voltage
from 0-5V using a moving needle.
While simple analog voltmeter movements can do this, they are delicate,
somewhat expensive, and limited in
size due to the movement’s strength.
Our servo motor allows a much
larger pointer to be used. That means
some extra circuitry is needed, but
our circuit uses just a few inexpensive
parts and can be built on a prototyping board in under an hour.
The servo we are using (intended
for use in remote-controlled [RC] vehicles and such) comes with mounting
screws and plastic arms (‘horns’), so it
is easy to attach it to a dial to suit your
application. Making a suitable needle
that can be affixed to the horn is also
straightforward.
This sounds like the perfect application for a small microcontroller board
like an Arduino; it would need just a
single analog input and one digital output pin. However, servo motors similar
to those we are using were invented
before microcontrollers. So we can
drive the servo motor using some
old-fashioned analog electronics.
You can see a video of the Servo
Gauge working at siliconchip.au/
Videos/Analog+Servo+Gauge
How an RC servo works
The term ‘servo motor’ has a broader
scope than just the type we are using
in this project. In general, any motor
that uses a feedback system to attain
accurate positioning can be considered
a servo motor. Specifically, we use a
standard three-wire servo, as used for
radio control (RC) and robotics.
Apart from 5V power and ground,
this type of servo has a digital input
that accepts a pulse train. The pulses
are sent around 50 times per second;
the exact rate is unimportant but the
pulse width is. Pulses around 1-2ms
are commonly used.
These servos have a shaft connected
to a potentiometer. When the servo
receives a pulse, it generates its own
pulse, the length of which depends on
the potentiometer position.
By comparing the pulse lengths, the
Some components are packed quite
closely around IC1 (as can be seen in the
lead photo), but you should be able to
squeeze them all in with some care. Note
the blue wire and two bridged pads on
the back of the PCB (circled in white).
Australia's electronics magazine
siliconchip.com.au
servo knows whether it needs to turn
clockwise, anti-clockwise or stay still
(when it has reached the desired position). Bob Young’s article in the March
1991 issue explains this in more depth
(siliconchip.au/Article/7102).
Unsurprisingly, modern servos contain a microcontroller, but they are still
compatible with the same protocol that
dates back to the 1960s. So we can easily interface with modern servo motors
using electronics of a similar age.
Circuit details
Our circuit (shown in Fig.1) consists of several simple sections with
distinct purposes. The section around
REG1 at upper right generates a stable
3.3V for the rest of the circuit from the
5V DC input.
Since the servo can draw relatively high current pulses that might
affect the 5V rail, this is necessary to
ensure the rest of the circuit does not
change its behaviour. We are using an
LM2936-3.3 regulator with the two
capacitors it requires at its input and
output.
The other two parts of the circuit
each use half of an LM393 dual comparator IC. As the name suggests, this
IC compares the voltages of its two
input pins. If the + (non-inverting)
input (pin 3 or 5) is higher than the –
(inverting) input (pin 2 or 6), the corresponding output pin (pin 1 or 7) is
not driven.
If the inverting input is higher than
the non-inverting input, the output is
pulled to ground (0V). This is known
as an ‘open collector’ or ‘open drain’
since it is usually implemented with
a transistor where the collector (or
drain) is only connected to the output pin.
The circuit around IC1a is a sawtooth waveform generator. Initially,
the 2.2µF capacitor is discharged and
the V_SAW level (and thus pin 2) is
at 0V. Around 2.2V is on pin 3, so the
output at pin 1 is not driven and thus
pulled up by the 1kW resistor.
The 2.2µF capacitor charges up via
the 1kW and 4.7kW resistors until it
reaches 2.2V, at which point the comparator output goes low. This causes
the capacitor to start discharging via
the 4.7kW resistor, into the comparator’s low output pin.
At the same time, the voltage at pin
3 goes to around 1V. When the capacitor (V_SAW) reaches 1V, the comparator output changes again and the cycle
siliconchip.com.au
Fig.1: 3.3V regulator REG1 ensures variations in the supply voltage don’t
affect the pulse timing. One half of the comparator (IC1a) provides a sawtooth
waveform, while the other half (IC1b) uses that to generate pulses suitable for
driving the servo motor.
5.0
4.0
3.0
2.0
1.0
0.0
-1.0V
-20.0ms
0.0
20.0
40.0
60.0
80.0
100.0
Scope 1: the blue trace is V_SAW (pin 5 of IC1b), green is pin 6 of IC1b, yellow/
brown is the servo control signal from pin 7 of IC1b and red is output pin 1 of
oscillator IC1a.
5.0
4.0
3.0
2.0
1.0
0.0
-1.0V
-20.0ms
0.0
20.0
40.0
60.0
80.0
100.0
Scope 2: this is the same as Scope 1 except that the green trace voltage has
changed slightly due to varying the control signal voltage, resulting in a change
in the pulse width of the yellow/brown trace that goes to the servo motor.
Australia's electronics magazine
October 2024 69
We created this simple design, printed it out and glued it to some cardboard to
suit a 5V scale over about 90°. The needle is simply a piece of dark-coloured cardboard
glued to one of the servo horns. All the necessary screws should come bundled with the motor.
Watch the polarity of the electrolytic capacitors; their negative leads all connect to the ground rail.
continues around 40 times per second.
Scope 1 shows the V_SAW voltage (the
blue trace) and the pin 2 comparator
non-inverting input (red trace).
The arrangement of resistors and
potentiometers connected to the second comparator translates the input
voltage (from the Control input) to a
voltage suitable for feeding to comparator IC1b.
The modified voltage fed into IC1’s
pin 6 is the green trace in Scope 1,
while the output to drive the servo
(from pin 7) is the yellow trace. The
stack comprising the 4.7kW resistor,
1kW potentiometer and 10kW resistor
puts the green trace just below 2.2V,
near V_SAW’s peak, so we get the brief
pulses needed to drive the servo.
The 10kW potentiometer allows us
to set how much of the Control input
signal is passed on to the rest of the
circuitry, while the 100kW resistor
ensures that the Control input only has
a small effect on the green trace level.
The 2.2µF capacitor in this part of
the circuit ensures that the control
voltage doesn’t change too rapidly. If
the voltage here jumped around too
fast, it could cause glitches that would
make the motor behave erratically or
even damage it.
Scope 1 was captured with the control input at 0V, while Scope 2 has the
control input at 5V; otherwise, the circumstances are identical. You can see
that the green trace has lifted slightly,
causing the pulse width to nearly
halve. That gives the required 1-2ms
pulse range to control the servo over
a roughly 90° range of rotation.
Construction
The first step is to build the circuit,
which can be done on a small prototyping board with a similar layout to
a breadboard (except that the power
rails are down the middle). You don’t
have to follow our layout strictly, but
we know it works, so you might find
it easier to match it.
Check our photos and the layout
diagram, Fig.2, while you solder the
components to the board and add the
Fig.2: here is how
we have laid out
the components
on a prototyping
board. Note that
there is a single
wire link under the
IC, between pins
2 and 5, shown
in cyan. The
ground and 5V
supplies for the IC
are also connected
by bridging pins 4
and 8 to their power
rails with solder
blobs.
70
Silicon Chip
wires. While most features are visible from the top of the board, a wire
and a couple of solder links are on the
underside (see the photo on the opening spread).
Start by fitting the IC socket; this will
make it easier to run some tests with
the IC out of circuit. Note the direction of the notch (to the left). Install
the parts as shown, paying attention
to the orientation of the electrolytic
capacitors.
After fitting all the components
except IC1, add the wires shown.
Three are on the copper side of the
board, under the IC1 socket. In addition to those, there are two dark grey
ground wires, two orange 3.3V power
wires and one cyan/blue signal wire;
don’t forget to add any of them.
After that, connect a 5V DC power
supply and run some tests. We used
cut-off jumper wires so that we could
plug into an Arduino board for power
but you might have a different idea.
Apply 5V and check that you get
3.3V at pin 1 of the regulator (towards
Fig.3: use this guide to help cut a
hole to suit the servo motor. It can
be copied (or downloaded and
printed) for use as a template.
Australia's electronics magazine
siliconchip.com.au
the bottom in Fig.2); you should be
able to measure different voltages of
around 2-3V at pins 1, 2 and 3 of IC1’s
socket. Pin 6 of the IC socket should
be about 2.0-2.2V.
Disconnect the power and plug IC1
into its socket, being careful not to
fold up any of the pins under its body.
Power on the circuit and connect the
servo motor to the three-way header.
It will probably run to one of its end
stops and stall. Adjust the 1kW trimpot
so that it is near the middle of its travel.
It should work backwards; that is,
turning the trimpot clockwise will
cause the servo to turn anti-clockwise.
If it is not responding, disconnect the
power to avoid damaging the servo’s
mechanism and motor, then check
your wiring.
If all is well, connect a jumper wire
from the signal input (where the blue
wire is shown in Fig.2) to 5V. You
should then be able to move the servo
by adjusting the 10kW trimpot. Again,
be careful not to allow the servo to run
against its end stops excessively.
Parts List – Servo Gauge (JMP015)
1 micro servo motor [Jaycar YM2758]
1 25-row prototyping board [Jaycar HP9570]
1 8-pin IC socket [Jaycar PI6500]
1 3-way header, 2.54mm pitch [cut from Jaycar HM3212]
2 2-way headers, 2.54mm pitch [cut from Jaycar HM3212]
1 10kW side-adjust mini trimpot [Jaycar RT4016]
1 1kW side-adjust mini trimpot [Jaycar RT4010]
1 10cm length of insulated wire
1 5V power supply (see text)
1 gauge face and needle to suit (see photos)
Semiconductors
1 LM393 dual comparator, DIP-8 (IC1) [Jaycar ZL3393]
1 LM2936-3.3 3.3V LDO voltage regulator, TO-92 (REG1) [Jaycar ZV1650]
Capacitors
1 10μF 16V radial electrolytic [Jaycar RE6066]
2 2.2μF 63V radial electrolytic [Jaycar RE6042]
1 100nF 50V multi-layer ceramic or MKT [Jaycar RM7125]
Resistors (all ¼W or ½W 1% axial)
1 100kW [Jaycar RR0620]
1 10kW [Jaycar RR0596]
2 4.7kW [Jaycar RR0588]
2 2.2kW [Jaycar RR0580]
3 1kW [Jaycar RR0572]
Turning it into a gauge
You have a bit of flexibility in choosing your gauge face and pointer. The
servo should be supplied with screws
and plastic horns for mounting.
The photos show the basic gauge we
created, with a printed piece of paper
glued to some cardboard, to show
readings from 0V to 5V. The servo will
have a usable span of just over 180°,
but we’ve gone for a more traditional
analog gauge range of about 90°.
Fig.3 shows the dimensions of the
holes for the servo, which should
help you to cut out your gauge face
to suit. There is one rectangular cutout to make plus two small holes for
self-tapping screws to retain the servo
motor. The grey-shaded circle shows
the servo shaft, which serves as the
pivot point for the Gauge.
Fig.4 shows the image we printed
to make the gauge face; it is available
as a PDF download from siliconchip.
au/Shop/11/488
For the needle, we screwed one of
the horns to the servo shaft, then glued
a pointer to it so that it pointed at the
0V marker.
Using it
To calibrate the Gauge once the glue
has set, power the circuit and connect
the voltage input to 0V (eg, ground on
the protoboard). Then adjust the 1kW
siliconchip.com.au
Fig.4: the gauge panel artwork we created shown at 90% of actual size. You can
download it as a PDF from siliconchip.au/Shop/11/488
trimpot until it points at the 0V point
on the gauge.
Next, connect the input to 5V (or
whatever your maximum will be). The
3.3V rail is another well-defined and
accurate level. Adjust the 10kW trimpot so that it points accurately for the
higher input.
Australia's electronics magazine
The two inputs interact slightly, so
switch back and forth between them a
couple of times to make minor adjustments until the Gauge is operating
accurately.
Remember that the 10kW trimpot
will slightly load the source of the
control voltage.
SC
October 2024 71
|