Post comments on this article and find any associated files and/or downloads at
www.nutsvolts.com/index.php?/magazine/article/march2015_PICAXEPrimer.
■ FIGURE 3. Pinout of the
PL2303HX cable.
■ FIGURE 4.
Prolific adapter
schematic.
unconnected end of the jumper wire
into either the +5V rail or the ground
rail.) The jumper wire provides an
opportunity to observe an interesting
aspect of the circuit, as we’ll soon see.
After you type this code into the
PICAXE Editor, download it to your
breadboard setup. Whenever you
insert the loose end of the long
jumper wire into the +5V rail, the
When you’ve completed your
breadboard setup for the experiment,
we can turn our attention to the
program we’ll use to test the inverter.
It’s so short that I’m including it here;
just type it into the PICAXE Editor. The
program simply displays the real time
state of the input to pin C. 3 on the
LED. If the input is high, the LED is
on; if the input is low, the LED is off.
LED should be off; whenever the
loose end of the jumper wire is
inserted into the ground rail, the LED
should be on.
because it’s known to work reliably
with PICAXE processors (as long as
the two data signals are inverted —
which we’re about to do); it’s readily
available; and it sells for less than half
the price of the FTDI cable.
Also, note what happens
whenever you disconnect the jumper
wire from the +5V rail — the LED
immediately lights. In other words,
Figure 3 presents the pinout of
the cable that we’ll be using in this
experiment. A cable with the same
color-coding is available on my
website ( www.JRHackett.net) and
elsewhere. (If you use a different
PL2303HX cable, the color coding of
the four wires may differ.)
The schematic for Experiment 2
(and 3) is presented in Figure 4.
‘‘=== InverterTest.bas ========
‘‘Program tests the 2N3904
‘‘inverter.
+5V is the only input level that results
in a low input to pin C. 3. If the input
to the transistor switch is at ground
level or if it is entirely disconnected,
the input to pin C. 3 is high.
‘‘=== Directives ========
#com 6
#picaxe 08M2
#terminal off
#no_data
When you’re finished testing
your breadboard setup, we can move
on to applying what we’ve learned in
Essentially, it consists of two NPN
transistor inverter circuits: one for
each of the two data signals. Both
inverter circuits function identically to
the single inverter circuit of
Experiment 1, and all six current-limiting resistors are again 10K.
‘‘=== Constants =========
symbol LED = C.2
‘
‘‘=== Variables =========
symbol data_In = pinC.3
Experiment 1. We’re going to invert
the Tx and Rx data signals on a USB-to-serial cable, so that it can be used
to power and program our PICAXE
projects.
In this experiment, we can ignore
the two headers in the schematic and
just focus on the required
connections. (When we get to
‘‘=== Begin Main Program ======
do
if data_In = 1 then
high LED
else
low LED
endif
loop
Experiment 2: Inverting
the Data Signals on a
USB-to-Serial Cable
Experiment 3, we’ll discuss the two
headers.) As you can see in Figure 4,
the output signal from the Prolific
I chose to use the Prolific
PL2303HX cable for Experiment 2
TxD line is connected to the base of
the lower inverter, and the inverted
output of the lower transistor is fed
to the Serin input on a PICAXE
12 March 2015