Newsgroups: comp.robotics
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!news.sprintlink.net!news.indirect.com!seeker
From: seeker@indirect.com (Stan Eker)
Subject: RSTM printer and TEST modes info
Message-ID: <D8nxAz.F2v@indirect.com>
Sender: usenet@indirect.com (Internet Direct Admin)
Organization: Internet Direct, indirect.com
Date: Tue, 16 May 1995 08:37:46 GMT
X-Newsreader: TIN [version 1.2 PL2]
Lines: 119

 Here's the run down on the "printer" port of the Radio Shack Electronic
Tape Measure (RSTM).  In short, it's useless for robotics.  Not to say the
unit *itself* is useless, but it's "printer" port sure is.  It's TEST
mode (detailed at the end) looks like a viable way to use it, though.

 If you don't know what it is, the RSTM is a small (1.5"H x 2.5"W x 5"L)
ultrasonic distance measurement device, powered by 4 AAA batteries.  It
has a small keypad and an LCD display, and will measure distances between
2' and 40' (0.6m to 12.2m).  It'll also do additive distance, area and
volume measurements, but I'd never use it for anything needing accuracy.
In US mode, it's resolution is 0.1 feet, in metric it's 1 cm.  It's a toy.

 Disemboweled from the case, the transducer is 1.2" dia. and .4" thick, and
the PCB is 2.3" by 3.1", not too ungainly for small robotics use.  Since
it only costs $24 + tax, it's cheaper than the Polaroid unit.  The "printer"
option was obviously never implemented, and probably never will be.  The
designer must have had some cheap serial printer in mind as an add-on.

 To use the "printer" at all, you have to wire a pin to the START switch,
and additional port pins for the DATA, CLK and /CTS lines, or 4 port pins
total.  Further, using the on-board Toshiba micro to run it wastes time.
From the time you hit the START line until it's output the value, about
3 seconds have passed (bare minimum).  If the robot is _moving_, it may
take significantly longer as it'll keep pinging until it gets 2 readings
in a row of the same value.  Really useless for us.

 In normal operation, the display will flicker for about a second after you
hit the START switch, then it'll ping, display the distance, wait for another
second and ping again.  If the two readings match, it'll stop and beep.
Total time for one measurement cycle if all goes well is 3 seconds.  If the
second reading doesn't match, it'll keep pinging.

 If you're insatiably curious, here's how the "printer" option works.  There
are 4 pads on the lower-left of the board surrounded by a white box, with
the legend "PRINTER" next to 'em.  They're all open-drain, and I used 10K
pullup resistors (any value from 5-50K would probably work) to the VDD line.
The top one is the CLOCK output (active on rising edge), the next is the
serial DATA output (may be inverted; I didn't finish checking), the next
down is the /CTS input, and the bottom is the /RTS output.

 If you short the R33 pad with the thin run going up to an adjacent pad just
below it, it enables the "printer" option.  Nothing happens until AFTER the
RSTM has gotten a valid measurement.  Hit the START switch and wait (ho, hum).
Now you're ready to read the data out.

 A brief low input on /CTS causes /RTS to go low, and ~20uS later it starts
sending the byte.  Data should be latched externally on the rising edge of
the CLOCK output line, and the clock will be low for 15uS, high for 15uS until
all 8 bits of the byte are sent.  The /CTS output line then goes high and it
waits for another low transition on the /RTS input.  That's one byte.
All told, it sends 8 bytes out.  I couldn't determine the entire data stream
(ancient logic analyzer), but the RSTM only needs to send out 4/5 bytes for
the distance (XX.X(X) feet/meters), so the rest must be a space character,
an M or FT characters and a carriage-return or LF (as a good guess).

 When it's in "printer" mode, it WILL NOT accept further commands until you
have read all 8 bytes out, and the bytes aren't available until the measure
cycle has completed fully.  If you can afford to wait 3 or MORE seconds for
a reading, you might want to experiment further with the "printer" mode, but
the possibility of never getting a stable reading means you can wait up to
18 pings (and seconds) before finding out you (or the target) are moving.

                           ----------------

 Of more interest is it's TEST mode.  There's a solderable jumper pad on the
bottom of the board below R33/R34 (split circle).  If you bridge it, the unit
will continually send out pings, about once each second.  Also, when it's in
test mode, it WON'T turn itself off after 60 seconds.  If you monitor when
it sends out a pulse and when the return signal is received with a couple of
port pins, you can determine the distance in code quite easily.  More on this
in a future message.  Alternately, you can gut the microcontroller and run
the unit with port pins, but it looks like you'd need 4 or 5 of them.  I'd
rather let it run continuously and save the pin(s) needed to start up the
measurement cycle, reducing the design load from 3-4 pins to just two.

 When it's in TEST mode, it won't halt and display ERROR if the echo comes
from a source less than 2' or more than 40', it just keeps on pinging.  If
you're monitoring the main transmit and the receive pins, you should be able
to work below the 2' minimum, and the resolution is only limited by your
code, not the LCD displayable characters.  That 0.1 foot resolution offends
me, somehow.

 Undoubtedly, part of the 2' minimum distance is the length of the 50KHz ping,
and some more is because there is either minimal or no damping of the 
transducer AFTER the transmit ping.  Mine would display down to 1.7 feet in
TEST mode (no other modifications).  2 feet works out to ~1.82mS, and 50KHz
is 20uS/cycle, so there's room for improvement.  As I said, I'll post the
final results sometime later.  I'll undoubtedly be using it's TEST mode.

 Warning to newbie hardware hackers: the transducer uses a HIGH VOLTAGE pulse
to ping the transducer. I didn't measure it, but would guess somewhere around
300-400V on average.  It's fairly low current, but watch your fingers!

                           ----------------

 I was slightly wrong in an earlier post - the cost (in the US) to have
Radio Shack mail you the service manual for the RSTM (catalog #63-645)
is only $4.12, a real steal if you're gonna hack one up.  Be warned that
it's wrong.  The picture of the PCB layers matches mine, but the pinout
shown for the micro is a 66 pin rectangular QFP, while the board actually
has the die bonded directly to a 64 pin square footprint, covered with
potting compound.  There's a couple of parts tacked onto the back of the
board that likely don't show on the schematic.  Same as usual.

 Because of the incorrect pinout, you have to follow traces and whatnot to
find the actual pins or parts coming from the micro.  It's shown as 47C420
in the schematic, which is one of the Toshiba 4-bit microcontrollers in a
64 QFP package (no data sheet handy, just an old IC Master).  It runs from
internal ROM, so there's no chance of being able to hack it's code to `fix'
the obvious deficiencies.  The rest of the manual (20 pages total) appears
OK, but it's sloppy.  They list caps as `Not used', yet they're not shown
either on the schematic or the PCB, so why bother?  At least they sold it,
unlike nearly every other manufacturer's line when you ask for schematics.
I may bitch and moan about Radio Shack, but they're nice in that regard.

  __________________________________________________________________________
 |  Stan Eker            |                                                  |
 |  seeker@indirect.com  |      (this mind intentionally left blank)        |
 +-----------------------+                                                  |
