Discuss this article in the Nuts & Volts forums at http://forum.nutsvolts.com.
■ FIGURE 3. Pin diodes.
■ FIGURE 2. Card reader with Prop-BoE.
Prop-BoE as in Figure 2. Note that the reader is powered
by 5V and that all of the open-collector lines from the
reader to the Propeller are pulled up through 10K (I used
a SIP with five 10K resistors).
If you’re new to the Propeller, you might be worried
about connecting a 5V circuit to the I/O pins. It is quite
safe to do — so long as we use a proper current-limiting
Have a look at Figure 3. Each Propeller I/O pin is
protected by over-voltage diodes that — as we can find in
the datasheet — have a forward voltage of 0.3V and a
current limit of 500 µA. Knowing this, we can do a little
work with Ohm’s Law to determine the proper size for a
R = (5.0 – (3.3 + 0.3)) / 0.0005
Doing the math, R works out to 2.8K. That said, it’s
not a common value. For 5V interfacing, then, I use 3.3K
( 4.7K and 10K are fine, too, for low speed circuits like the
While working on the card reader code, I got a text
message from my pal, Rick (another one of those amazing
special effects wizards that I hang out with). He was
wondering about the correct size of the current limiter for
interfacing a 5V circuit to the Propeller.
I reminded him to remember 3.3: Use a 3.3K resistor
to protect the 3.3V Propeller from a 5V circuit.
CARD, PLEASE ...
The device we’re using reads track 2 from ISO cards
— like a credit card. This track is low density, and contains
mostly numeric data and a few control characters. In my
experiments with credit cards, I find that the credit card
number is followed by the field separator character and
additional data (usually the expiration date of the card).
Before we get to the code, let’s look at the purpose of
the reader’s outputs:
/RDT Inverted data
/RCL Active-low clock
/CLD Low while card is in motion
/CLD1 Low when card is inserted into reader
/CLD2 Goes low when card hits end stop
Understanding the purpose of each signal — and how
data is written to the track — makes it fairly easy to design
an algorithm for reading from the card. Data on track 2 is
framed by special characters; there’s the Start Sentinel at
the beginning, then it is terminated by the End Sentinel:
1. Wait for card insertion.
2. Wait for card motion.
3. Look for Start Sentinel character.
4. Read characters into buffer, then quit when End
Sentinel or End Stop is detected.
March 2013 15