Featuring high gain and low noise. For low-frequency, small-amplitude signals.
This old-sock project was motivated by a desire to see a human heartbeat on the Newton screen.
With a simple amplifier + PIC-chip circuit to monitor the signal, and fleXYlog software on the Newton to display the result. The final prototype seen here shows the three main components - amplifier, battery pack and digital control box.
The results are very interesting, but the project is rather complicated and perhaps over-ambitious. The technical details are hard to explain and it's difficult to decide what to include, and what to leave out.
In this table of amplifier results, captured on
a Newton or PC during development of the project, there are 2 sensors in
operation. One provides direct electrical contact, the other is used as
a microphone.
|
|
|
|
| MP2k: heartbeat1 + beats-per-minute | MP2k: heartbeat1 | MP2k: model vs. real heartbeat |
| MP2k: wrist vs. fingers | MP2k: heartbeat2 | OMP: imitation
heartbeat
(used for serial speed adjustments) |
| PC: heartbeat from early prototype cct. | MP2k: ticking clock | PC: heartbeat detected using headphones as a sensor. |
| MP2k: sensors gripped by fists | OMP: ticking clock | MP2k: diode as sensor |
| MP2k: heartbeat from foot | PC: heartbeat2 | MP2k: calibration signal |
To date, there are few examples of heartbeats
using the smaller Newts. Maybe more will be added later in Part II.
Introduction
This project started before the Newton was born, even more than 20 years ago, when I bought an electronics text-book for my college studies. A Practical Introduction to Electronic Circuits (by Martin Hartley-Jones, Cambridge University Press, 1981, ISBN 0-521-29087-2, paperback, 2nd edition) has the basic amplifier circuit for showing a human heartbeat on page 104. The book is still in print as a 3rd edition, but the page numbering has changed - the circuit now may be nearer page 200. I was impressed with the design in 1981, and wanted to try it then, but it took 20 years before I got around to actually making the circuit. The main reason for the delay was knowing it needed a special oscilloscope, a digital storage-scope, to properly display the low-frequency signal, and no place I ever worked had such equipment.
Earlier this year I finally constructed the circuit,
and attached it to an ordinary oscilloscope.
Although a heartbeat signal detected on human
hands is much less than 1-milliVolt, the amplifier circuit produced a strong
signal - blip - blip - blip
- across the 'scope screen. But there was no useful detail
- just a quick vertical trace and no 2D image. And the blips shifted
around in space because stray voltages on the hands added noise.
There must be a better way to display the signal. This is where PIC chips and the Newton come to the rescue. The Newton becomes the digital storage-scope.
The design described here takes the basic Hartley-Jones circuit, adds a few components by trial-and-error to make a fabulous variable-gain amplifier, and adds some PIC chips to process the data. The results are fantastic.
There are 3 circuit-boards. In theory, the circuit
could all fit on one board, but the pcb design-process insists on using
fleXYcad
software on the Newton - and there are too many components for fleXYcad
to handle on just one board.
As it turns out, 3 boards work well, and add
some flexibility.
Board 1 Analog
The amplifier follows the Hartley-Jones example
and uses a standard 741 op-amp. Other more-serious designs use an instrumentation
amplifier, but these can be tricky to get working. I tried and failed.
Well, the instrumentation attempt did work (using a Burr-Brown INA101)
but after one heartbeat, it went into
orbit. So I use a single 741 op-amp and feed the output through an
opto-coupler.
A variable resistor allows for gain adjustment. The amplifier board uses
a 9-volt PP3 battery and draws 5-mAmps. Input sensors can be metal contacts
for electrical signals or a piezo-ceramic disc for acoustic signals.
Board 2 Analog
to Digital
The signal from the amplifier opto-coupler is
fed through a single transistor into a PIC chip (12F675). The PIC chip
uses its internal A/D facility and converts the analog signal to a 2-byte
digital value for each sample (see timing
diagram).
A variable resistor adds more gain, and also
helps adjust the vertical position of the final image.
The A/D PIC runs in a continous loop sending its 2-byte digital data at 19200 bps serial speed to Board 3 over a short cable connection. Both boards share the same enclosure and are fed by a single 9-volt PP3 battery. This combined circuit draws 25-40 mAmps, depending on components used.
Board 3 Digital
Storage
Board 3 uses two 16F628 PIC chips and a RAM chip.
One PIC chip processes the incoming data from the A/D PIC on Board 2. It
also processes a push-button, and it replays the data through an opto-coupler
to the serial output port at 1200 bps (see block
diagram). A second PIC chip simply increments the address-bus into
the 2k RAM chip (type 6116).
A push-button selects various functions. Default power-on state is to take the incoming digital data and immediately send it out of the serial port, at a speed that can be adjusted to match the Newton model being used. In this condition, the circuit is useful for general-purpose monitoring. It is not possible to see a complete heartbeat image in this state because there are too few samples per second. It is necessary to take a short SAMPLE of data and STORE it very quickly and then REPLAY it slowly to see a complete heartbeat image.
The next push-button state selects an internal imitation heartbeat shape, two beats in succession, and this is used as a check that the image can be seen entire on the Newton without data bytes being dropped. If the shape is distorted because of lost data, the serial speed can be slowed by using the push-button to add some pacing delays.
Another push-button state triggers the sample
of a real heartbeat. 1024 samples are taken from the A/D PIC over a 2 second
interval and stored in a 2k static RAM chip. During replay, two successive
data values from the RAM chip are averaged, to help eliminate noise and
produce a cleaner signal. These 2k RAM
chips were made by the millions a decade ago and can still be found
in scrap terminals, in old electronic workshops, and supplied by some specialist
component suppliers. The main reason for using this obsolete component
was its immediate availability to hand, and to see if a PIC chip could
connect to it easily, as an educational exercise.
Cautionary Note
Whilst this amplifier circuit is capable of displaying
a heartbeat, it is not designed for medical purposes. It is a simple general-purpose
small-signal amplifier e.g. it can also be used to measure the earth's
magnetic field, or monitor sounds.
Medical equipment is always covered by stringent
health and safety requirements. Electrical equipment attached the human
body must be free from hazardous voltages, and should fail into a safe
state. There are probably other requirements. The two opto-couplers used
in this general-purpose amplifier effectively isolate the human subject
and provide electrical safety (see diagram).
To reinforce this protection, the circuit should be powered by batteries
alone.
One important design decision will encourage the
use of batteries:
- There is no 50/60-Hz notch-filter. Because
of this, mains interference is easy to spot. When the user sees the characteristic
ac noise-signal, he knows he must either switch off the interference,
or move to an area free of mains equipment. In practice, the worst mains
interference is generated by a simple DC-power adaptor. These are easy
to switch off. Just moving more than 1-metre away from a mains power-cable
is often sufficient too.
2. The results are best seen on the faster Newtons,
or on a PC. To accommodate the slower performance of the OMP and MP100,
serial output-speed runs at a slow 1200 bps. Even with a minimum pacing
delay of 80 mSec for the MP2k running fleXYlog, it still takes 52
seconds to replay a screen-width of data in Landscape mode. The slower
OMP with a 300-mSec pacing delay and a narrower screen takes 79 seconds.
Some necessary calculations
Assuming 3 numeric text characters per data value
e.g. "362" + a CR/LF pair:
1. Time taken to scroll data across the screen-width:
MP2k: ((5 ASCII characters x 10 bits / 1200 bps)
+ 80mS delay per sample) x 427 pixels = ((50/1200) + 0.08) x 427 = 52 seconds,
in Landscape mode.
OMP/MP100: ((50/1200) + 300mS delay per sample)
x 233 pixels = 79 seconds.
2. To see the entire 1024 data samples stored
in the RAM chip scroll across the screen:
During replay the PIC chip takes 2 samples, makes
an average, and hence sends 1024/2 = 512 data samples.
MP2k: ((50/1200) + 0.08) x 512 = 62 secs.
OMP: ((50/1200) + 0.3) x 512
= 174 secs = 3 minutes !!
The idea behind the push-button is to speed up
the entire process. If the image being drawn on the Newton screen is clearly
not worth waiting for, and a new sample is needed, just hit the button.
This triggers a new sample.
For a slightly quicker display on OMP-size Newtons,
alternate bytes can be dropped within
fleXYlog to give a lower resolution
image in less time. But the difference is marginal, and performance on
the original OMP/MP100 is still too slow except for those with infinite
patience.
3. On a PC with a serial port, running Windows
or Linux (and using software to plot data in graphical form) there should
be no need for any pacing delay. Time to display the full data sample:
(50 / 1200) x 512 = 21 seconds. The serial speed
could also be boosted:
(50 / 4800) x 512 = 5.3 seconds.
Sewing-thimbles provide good electrical contact
if fingers are not too thin. Alternate sensors for thin hands are a pair
of small brass drawer-handles. The
curved shape provides good skin contact when held between the fingers.
The sensor wires are attached to a single mono
3.5-mm audio jack which plugs into the amplifier. The jack-socket on the
amplifier-pcb needs to be of sturdy quality. Some cheap sockets fail rapidly.
The brass handles needed to be dipped in acetone
to remove a protective lacquer layer that stopped electrical conductivity.
The very-first heartbeat image looked good, but it didn't match any known shape in books or www sites. Turned out the sensors were on the wrong hands, giving a back-to-front signal.
A wrist contact can also detect a heartbeat signal. This example shows a much lower-amplitude signal, probably due to the smaller surface-area of a square copper pad held with little contact-pressure.
To detect acoustic signals, a piezo-ceramic disc was suspended in the top-half of a small plastic drink-container, where it acts as a microphone. A 3.5-mm audio socket was mounted in the top. Twin-core cable with a 3.5-mm mono jack at each end connects the microphone to the amplifier.
The piezo-sensor is naturally very sensitive to all pressure changes, whether from air-movement or physical vibration. An unexpected discovery was its sensitivity to light from a torch.
Use of a single 3.5-mm mono-socket on the amplifier for the input-signal allows flexibility e.g. headphones can be used as an acoustic sensor when connected through a stereo/mono adaptor.
1-metre leads on the sensors have been used many
times. As long as the leads are kept more than 1-metre away from sources
of mains-power, the signal-to-noise ratio can be excellent. Running a Newton
MP2k on DC mains-power causes massive interference. This
picture shows what happens. The remedy is simple: use the Newton on
battery power.
Batteries
A single 9-volt PP3 is used internally for the
amplifier box. A pair of 9-volt PP3 batteries wired in parallel is used
as an external power-pack for the
larger digital control box. A single battery for the control box would
work, but some 6116 RAM chips draw twice as much current as others, and
a pair of batteries last longer.
Amplifier board:
- circuit schematic.
Drawn using fleXYcad on an MP2k, saved to unfiled Notes with the
SNAP button, then transferred to a PC and edited with ImageForge
to add labels and component values. The switch and power-LED are missing.
- component
layout, solder-side, pcb
tracks, pcb board.
- component layout
as fleXYcad text.
Description:
A dual-op-amp (LM358N) is used with one half
acting as a 2.5-volt reference supply.
The Hartley-Jones amplifier
uses a single 10-Meg feedback resistor. Two reference books show how this
high-value feedback resistor can be replaced with a T-shape
configuration of lower-value components, and this makes it easier to find
the components on scrap circuit boards. After some experimentation, I used
resistors with values 100k, 120k and 1k. Sending the amplifier's analog
output through an opto-coupler using battery power provides 3 benefits:
1. isolation (an important safety issue)
2. reduced noise (a battery is inherently
noise-free)
3. a novel method of providing variable
gain without adding distortion.
Normally, an opto-coupler chip would be used
in its digital mode, where a large current through the input transfers
maximum signal to the output. The output is either full on or full off.
But in this amplifier design, the opto-chip is running in analog
mode, where small variations in input need to generate small variations
in output.
The basic opto-arrangement
worked well until the opto-coupler chip was swapped with another, and a
problem cropped up. Manufacturing-spread among opto-chips seems to be worse
than transistors and it caused the DC output voltage to shift. This meant
having to adjust the value of the supply-resistor feeding the opto-chip.
A search of the www found an arrangement of resistors to give some feedback
and stability.
The opto-output from the amplifier is linked
to the A/D board by an external twin-core cable. Here it meets the rest
of the analog circuit - 3 resistors and a transistor - to interface
to the A/D PIC chip.
Alternatives to the LM358N dual-op-amp have also worked fine: LF353N, LM1458N.
During this development, little attention was paid to optimising the component layout with regard to noise reduction.
An important concept to get right is the RC time-constant
generated by the combination of input capacitor and resistors. It also
applies to the feedback resistors and capacitor around the opto-coupler
output. It's difficult to explain correctly, but if either component is
too
small, the signal-under-study is distorted by the behaviour of the
RC charge-time. The RC time-constant needs to be much greater than the
slowest change of input signal ( I think). A 100-uF cap + 10k resistor
makes a time-constant of 0.0001 x 10,000 = 1 second. An example of distortion
from a too-small input capacitor is shown here: the heartbeat pulse drops
negative, caused by the 10-uF input capacitor discharging too early
(RC time-constant: 0.00001 x 10,000 = 100-mSecs). This next image shows
distortion when 47-uF caps are used.
A similar effect is seen if the op-amp feedback
capacitor (2.2-nF preferred) in parallel with the feedback resistors
is too large: 3.3-nF creates distortion.
A/D board:
- circuit schematic
- component
layout, pcb tracks, pcb
board (clearly not enough time in the ferric-chloride!).
- component layout
as fleXYcad text
- photos to show variable-resistor mounting arrangement:
one,
two.
The A/D board is held in position by the rotary pot being fastened to the
lid.
- PIC code (Part II)
Description:
The board comprises a transistor, PIC chip, push-button
connection, DC power input, and 2 x LEDs. One LED (green) flashes when
serial data is being sent from the control box to the Newton. The other
LED (red) flashes when the button is pressed, and remains lit when the
A/D is collecting 1024 samples over 2 seconds.
PIC 12F675 has an internal 10-bit A/D converter.
Results are given in the range 0 - 1023. The rotary pot on the A/D board
varies a reference voltage between 5 and approx 2.5 volts. Using a 5-volt
reference signal, the PIC can detect changes down to: 5 volts / 1024 =
4.88
millivolts. With the minimum 2.5 volt reference signal, the smallest
resolution of analog input signal into the PIC becomes: 2.5 volt / 1024
= 2.44 millivolts.
To discover the smallest change of signal being
detected at the amplifier input, that corresponds to a change of 2.44 mV
at the PIC, this value needs to be divided by the overall gain of the circuit.
When the small variable-resistor on the amplifier is set to its
minimum, the gain is somewhere around 3000 (a fuller analysis is incomplete).
One unit-change of analog input signal at the amplifier is hence: 2.44
milliVolts / 3000 = 813 nanovolts.
The numbers sent from the control-box to the Newton are simply decimal equivalents of the A/D integers in the range 0 - 1023. (In reality, the maximum is around 800). It is left to the operator to convert these numbers into a voltage. For example, if the rotary pot is set midway (i.e. reference voltage = 3.75), and the Newton displays a signal varying from 320 to 380, this represents a voltage change: 3.75 / 1024 x (380 - 320) = 0.219 volts into the PIC. Divide by the amplifier gain (e.g. 3000) and this equates to a signal change of 73-microvolts.
The rotary pot serves 2 purposes. By design, it provides some extra gain to fine-tune the image. By sheer luck, it provides a way to shift the image up or down the Newton screen.
The transistor is a general-purpose type e.g.
2N3904, BC108. A common-emitter arrangement did work, but it also inverted
the signal. Rather than swap the input lines, it was decided to experiment
with a common-base arrangement that preserves signal polarity.
Digital Storage board:
- circuit
schematic
- component
layout(1), solder-side, component
layout(2), pcb tracks.
- component
layoutfleXYcad cct-text
- photo to show connection
of A/D board to control board.
- PIC code x 2 (Part II).
Description:
The control-box design went through 3 prototypes.
This version looked promising, worked
fine, but the daughter-board hits the lid of the container and the 2nd
rotary pot eventually became redundant.
For being experimental, the prototype circuits
have performed well. A short-circuit between two PIC data-lines did cause
a tricky problem. And connecting the PIC data and address-lines directly
to the 6116 RAM chip without any limiting resistors was a guess. It might
turn out that some other RAM chips will need resistors. For now, 2 of the
3 types tested have worked fine.
RAM chip ID markings: 'RCA Z CDM 6116 AE3', 'Toshiba
TC5517APL', 'Hitachi HM6116P-3'.
Using a PIC chip to increment address lines into the RAM chip is overkill, but I had no TTL clock/counter chips and didn't know what type was best.
The opto-coupler chip on the serial output requires plus/minus voltages to be supplied by the attached host device, on its DTR (+V) and TX (-V) pins. The present arrangement has been tested on several PCs and Newtons and seems to be both RS-232 compatible and RS-422 compliant. There is no need for a special cable - the regular Apple-brand 8-pin DIN/9-Way serial cable for PC is fine. A suitable adaptor to connect an 8-pin DIN cable may be found here: http://www.notwen.com/labo/mac2db9/
The circuit boards are designed to fit into readily
available plastic boxes (e.g. from http://www.maplin.co.uk. Small box for
amplifier: Pocket Clip Case, item KC95D. Large control box: Plain
HH2 Box, item ZB16S). Some plastic will need trimming in each. The
A/D board needs to be positioned so that the taller components fit between
the RAM chip and PIC chip when the lid is closed.
Testing:
Two artificial heartbeat signals were used for
testing the circuits.
1. An imitation heartbeat signal is created by
the software in PIC-A and is used to adjust the serial-speed pacing-delay
required by the older Newton models.
2. The second artificial signal was made in hardware,
to provide a reproducible shape to feed into the amplifier, to check that
the signal could travel through the complete circuit without getting distorted.
The original design for the hardware heartbeat test signal was found in
a magazine article, and heavily modified by using a PIC chip to replace
an oscillator and a dozen resistors. Essentially, the PIC chip sends a
sequence of 5-volt pulses of varying durations into a resistor-divider,
with a capacitor to smooth the rough edges, and a variable resistor to
alter the amplitude. This image shows a 50-microvolt
test signal. The signal seen here
is smaller, has been amplified more, and the peak is roughly 20-microvolt
high.
Operation
Download a pdf instruction manual (Part II).
Other uses
1. Spinning a few turns of copper wire will generate
an emf in proportion to the prevailing magnetic field (Part II).
2. The amplifier is very sensitive, and gives
useful results picking up radiation leakage (2.4-GHz) from a 650-W microwave-oven.
This signal was detected 13 feet away.
The sensor was a germanium diode with a capacitor across its 62-mm leads.
Gain set to maximum.
3. Shining a torch onto a piezo-ceramic disc
is perplexing (Part II).
Future experiments
Using a serial FRAM chip for storage, replacing
PIC-B and the 6116 RAM.
Making a 50/60Hz filter to fit inline between
the amplifier box and A/D board.
Rearranging the transistor circuit.
Some References
A Practical Introduction to Electronic Circuits
by Martin Hartley-Jones, Cambridge University Press, 1981.
ISBN 0-521-29087-2, paperback, 2nd edition. Basic
amplifier circuit on page 104.
Medical Physics and Physiological Measurement,
by Brown and Smallwood, Blackwell Scientific Publications, 1981.
ISBN 0-632-00704-4. Instrumentation heartbeat
circuit on page 283.
For the T-shape resistor feedback detail:
The Art of Electronics, by Horowitz &
Hill, Cambridge University Press, 1983.
ISBN 0-521-29837-7, paperback, page 122. No gain
equation provided.
Electronics: Circuits, Amplifiers and Gates,
D.V.Bugg, Institute of Physics Publishing, 1996
ISBN 0-7503-0110-4, paperback. Page 116 has a
formula for the gain calculation, but it doesn't seem to apply to my circuit.
For a hardware heartbeat circuit:
Circuit Ideas Pocket Book, Newnes (in
conjunction with Wireless World), 1995.
ISBN 0-7506-2336-5. Item called: Electrocardiograph
simulator.
Hobby magazines with heartbeat circuits, all
using instrumentation amplifier arrangements:
Elektor, July/August 1982
Everyday Electronics and Computer Projects,
January 1984
Electronics + Wireless World, July 1995
Elektor, October 2006. Contains two circuits.
Everyday Practical Electronics, November
2007
Updated: 20th December 2007