MCP9700A vs. DS18B20
We’re using the 9700A primarily
because it provides the opportunity
to experiment with sending analog
values from the PICAXE to the Pi.
However, if your main interest is in
the temperature measurement itself,
there are these three good reasons to
choose the MCP9700A rather than
the DS18B20:
1. The DS18B20 is at least 10
times more expensive than the
9700A.
2. A PICAXE processor takes as
long as 750 mS to fetch the digital
temperature data from a DS18B20,
but it only takes about 1.25 mS to
read an analog input. In some
projects, this huge difference really
isn’t very significant, but we
ultimately want to program the Pi to
interrupt the PICAXE whenever it (Pi)
wants updated data.
As you may remember, the
PICAXE checks for an interrupt
condition after the completion of
every instruction (and frequently as
wait or pause commands are
executed).
Consequently, if the PICAXE
happens to be in the process of
reading data from a 18B20 sensor
when an interrupt occurs, it could
take as long as 750 mS for it to
respond, which would certainly
complicate the Pi programming.
3. Finally, since the DS18B20 is a
digital device, the Pi doesn’t need a
PICAXE to interface with it; it can do
so all by itself! If you’re interested in
that approach, you can search for
“Raspberry Pi DS18B20” (without the
quotes) — you will find many relevant
projects. (Also, you might want to
check out #11 in the Adafruit.com
Raspberry Pi Tutorials.)
We’re going to conduct three
different experiments this month, and
all of them can be carried out with
the same hardware setup, so let’s
begin with that. Figure 1 presents the
schematic of the circuit that we’ll use
for our experiments.
The first thing to note is that I
haven’t included the PICAXE
programming connections to the
08M2 pins C.0 (SerOut) and C. 5
(SerIn) but, of course, they are
required!
Also note that Vcc = 3.3V, which
is the supply voltage for all our
PICAXE-Pi projects. (In case you’re
wondering, the 9700A’s supply range
is 2.3V to 5.5V, so it will work fine in
our 3.3V circuit.)
Finally, we won’t be using the
connection between GPIO 14 (TxD)
on the Pi and pin C. 2 on the 08M2. I
only included it in case you (or I)
want to conduct additional
experiments with sending serial data
from the Pi to the PICAXE.
Figure 2 is a photo of my
breadboard setup for this month’s
experiments. As you can see, I’m
again using the stripboard interface
circuit that we constructed in our first
PICAXE-Pi article (August 2013).
Of course, you can use any
hardware setup you prefer — just
make sure that the 08M2 is powered
at 3.3V to match the levels on the
Pi’s GPIO pins, and that there is a
series resistor in the I/O connections
that we are using. (The stripboard
interface circuit includes 470 W
resistors in each GPIO line.)
If you are using the stripboard
circuit, you may want to refer to
Figure 3 which presents the pinout of
the GPIO header on the stripboard
circuit.
PICAXE-Pi Communications —
Part 2
In this month's Primer,
we're going to continue
our PICAXE-Pi serial
communication
experiments. As you
probably already know,
there aren't any ADC
(analog-to-digital
converter) inputs available
on the Pi, but PICAXE
processors have plenty of
them: three on the 08M2;
seven on the 14M2; 10 on
the 18M2; and 11 on the
20M2 and 20X2. To
demonstrate one way that
we can transfer an ADC
reading from a PICAXE
processor to the Pi, we're
going to interface an
MCP9700A (a.k.a., 9700A)
analog temperature sensor
with an 08M2 processor,
and serially send the
sensor's ADC reading on
to the Pi for display. Of
course, we can also do the
same thing with any
PICAXE processor, and
with a variety of analog
sensors. By the time we
complete this month's
experiments, we will have
covered the basic
techniques that can be
used to send a PICAXE
ADC reading to the Pi,
from any analog sensor
we choose. So, let's get
started!
; BY RON HACKETT PICAXE PRIMER
www.jrhackett.net
8 April 2014