Note to new Propeller users:
When the same code (file) is used
for multiple objects, only one copy
of the object code is loaded into hub
RAM — this maximizes available
space. If two or more objects are
declared using the same code, each
object will get its own set of
variables, but code and data will be
■ FIGURE 2. RFID harness.
Here's where I landed: I created an RFID object that —
when called frequently as we did in the LED examples —
takes care of activating/deactivating the reader as desired,
and provides tag data when a tag has been presented.
Note that the normal servo extender cables are about
a foot long; EFX-TEK carries a version that is nearly six feet
long should you want to move the reader away from the
Let's have a look.
Getting connected to the RFID reader is very simple:
It requires a 5V supply, an enable output, and a serial
input. The enable pin on the reader is active low and has
a pull-up. To activate, we pull this line low; to deactivate,
we release the pin to the pull-up.
The RFID object uses three standard objects to get
everything done: jm_io is used for pin control; jm_time
takes care of timing; and jm_fullduplexserial (my
derivative of FullDuplexSerial) is for the serial connection
to the reader.
I confirmed with designer Joe Grand that the serial
output is driven. This means we must insert a 3.3K or
higher resistor into the serial line as shown in Figure 1. My
favorite little development tool is the Propeller Activity
board (PAB) which includes this resistor on each of its
servo headers. To simplify connections to the PAB, I
hacked a couple servo extenders as in Figure 2.
Jumping into the start() method, we find that it
expects two pins — one for enable, the other for serial
pub start(en, rx)
enpin := en
cog := sin.start(rx, rx, %1100, 2400)
cogstop(cog - 1)
cog := 0
bytefill(@tagbuf, 0, 11)
Remember that good object design dictates that
restarting an object ensures any cogs that had previously
been launched are shut down; this is handled with the
stop() method, which also puts the object into disabled
state and clears the RFID tag buffer.
The pins used for the reader are cleared in the master
cog and the enable pin number is saved for use in other
methods. The last big step is to start the serial interface.
■ FIGURE 1. RFID
Again, we're using a full-duplex serial object, but setting it
to half-duplex/open-drain mode (safest when using a
driven device like the RFID reader) at 2400 baud. If the
serial cog loads, the reader is enabled.
The real work is done in the check() method:
16 June 2015