DEBUGGING A REV. D
STAMP BOARD
ver: 31-oct-01
Basic debugging
|
"Help, my &$#!!@$ Stamp board
doesn't work!!"
"Help, I'm getting 'Hardware not found' errors!!"
"Help, I'm getting 'EEPROM verify failed'errors!!"
"What do I do?!!"
|
The key to debugging is to follow a logical procedure and to isolate the problem
which could be with your circuit, with your program or with your Stamp board.
Here are some things to try. Read through this entire document. Also, see the
pictures at the end of this document to help understand some of the procedures.
- Disconnect everything including cable and battery and anything you have connected
to the pins. This way you can determine if the fault lies with the Stamp board
or with your circuit.
- Measure battery voltage with your DVM. If less than 7V, get a new battery.
- Connect battery to Stamp. Within 4 seconds, measure the battery voltage.
If 0V, you have a short circuit somewhere. Disconnect the battery immediately
and see if you can find the short.
- Connect the battery. Measure the voltage between the +5V pin and GND pin.
It should be at +5V. If not, check your battery voltage (and that you have plugged
in your battery). If the battery is OK and if you have nothing plugged into the
Stamp and the +5V pin does not read +5V, you have a dead voltage regulator on
your Stamp board. Bring the board in for a swap.
- Plug in the programming cable to the Stamp and to the PC. On the PC side,
the cable goes into the parallel (printer) port. Check the +5V pin on the Stamp
for voltage again.
- Fire up stamp.exe on your PC.
- Write a one-line program. (The single command "END" is fine. Actually,
a blank program is also fine for checking Stamp-PC communication.) Download to
the Stamp. If you get a "Hardware not found", check (1) battery plugged in, (2)
stamp cable plugged in securely at both ends, (3) battery voltage is good, (4)
+5V pin on Stamp is good. If still getting a download error, try the following:
- Try it on another computer to confirm the problem is not with your cable
or Stamp board.
- Try one of the fixes listed in the "Running stamp.exe under Win95/98"
section of this document.
- Some laptops have trouble communicating with Stamps. After trying all the
Win95/98 fixes described here, see the Running stamp.exe from a laptop technote.
- If you can't get the Stamp to turn on an LED, try holding your LED and resistor
against the +5 and GND of your Stamp board. The LED and 330 ohm resistor should
be in series. Try the LED in both orientations.
- If you can't get the Stamp to drive outputs (LED's, motors), unhook your
circuit from the Stamp pins. Write the following program:
loop:
toggle 0
pause 2000
goto loop
Measure the voltage at pin 0 (red DVM lead on pin 0, black lead on GND) after
downloading. Pin should alternate between +5V and 0V every two seconds. If not,
try it with a different pin and implement your LED flasher with any pin that works.
- If you can't get your Stamp to recognize inputs, see the "Understanding
the Stamp DEBUG command" section of this document.
- If your program doesn't start cleanly when you connect your battery, try
connecting the battery in a single, firm motion. If the battery rattles around
in the contacts, it can cause your Stamp to start someplace other than at the
beginning. Also, try putting a "PAUSE 1000" as the first line in your
program if you are getting erratic startup behavior.
- If you get "Expected a direction, address symbol, or instruction...." or
similar message, it means you have an error in your program. Find and correct.
- If you get "Error: eeprom verify failed", it may mean there is still a parallel
port communication problem, or it may be a bad Stamp chip. Try your Stamp on a
computer you know can communicate with Stamps to determine if it is the Stamp
or the computer. If you need a new board, see the next section of this document.
- Ask a friend.
- Ask one of the course staff.
- Bring your Stamp to office hours for a debug session.
Swapping your Stamp board
If you are still getting "Hardware not found" or "EEPROM failed
to verify" errors, you may have a bad Stamp board. To confirm, try loading
a program using the ME2011 (ancient) DOS computers located outside room 380 MechE.
If you still are getting an error, it's the Stamp board. Bring your board to a
section instructor for a swap. Enclose a note explaining the error msg you are
getting.
Boards with a pin or two broken off are generally fine. Most robots don't need
all the pins.
Understanding the Stamp DEBUG command
The DEBUG command is a great way to see what is going on in your program while
it runs. Inserting a few strategically placed DEBUG statements in your program
during the testing phase does wonders in helping track down bugs. Read about DEBUG
in the stamp manual. With the programming cable attached to the PC and the PC
running stamp.exe, DEBUG will print the value of its argument on the PC screen.
Try out the following program while your switch is connected to pin 4. Watch what
happens to the printed value of pin4 when you press and release the switch. If
you are not detecting switch changes on the PC screen, disconnect your switch
from the Stamp pin and try connecting the pin directly to +5 and then to GND as
shown in the picture below. If state changes on pin4 are not being recognized,
try with another pin. If the changes are being recognized, then it's your switch
circuit. Try measuring the voltage at the pin with your DVM. It should go from
+5V to 0V when you press the switch.
'---------------------------------------------------
' Debug demo program (wkd 22-mar-00)
'---------------------------------------------------
initialize:
OUTPUT 0 ' LED
INPUT 4 ' switch
start:
debug pin4 ' print status of switch
pause 1000 ' so the text doesn't fly by too fast
goto start
Remember DEBUG when you are deep into developing and testing code for your robot.
It can be a lifesaver for figuring out if the problem is with your circuit or
with your program.
Running stamp.exe under Win95/98/Me
The downloading process requires a tight, bidirectional coupling between the Stamp
and the PC. Because Windows 95/98 is a pseudo multi-tasking system, sometimes
the download process is erratic. You might get "Hardware not found" or "EEPROM
verify failed" errors. If you try it two or three or six times, you might get
a download to work once. It might work on Tuesday, but not on Saturday. This behavior
is computer dependent. Your friend's computer may do a download perfectly.
Here are some things to try if you can't communicate with your stamp. You may
need one or more of these fixes:
- Try running stamp.exe from Windows by clicking on its icon. This will create
a DOS window under Windows. On some computers this will allow stamp.exe to access
the printer port, on others it won't.
- Run Stamp.exe in full DOS mode, not from a DOS window running under Windows.
For this hit Start then Shut Down then Restart in MS-DOS mode. If you want to
do the same thing directly by clicking on the stamp.exe icon, you must set it's
properties. To do this, right-click on the Stamp application icon, select Properties
then the Program tab then the Advanced... button. In the Advanced Program Settings
dialog box, select MS-DOS mode then OK. When you next start stamp.exe by clicking,
it will change your machine into pure DOS mode. Note that when you exit stamp.exe,
your computer will have to boot up Windows again.
- (This tip is thanks to Matt Haga, a former ME 2011 student.) Sometimes restartarting
to DOS out of Windows will leave certain device drivers loaded that can cause
conflicts with the Stamp running off the parallel port. To solve this problem,
you need to powerup your computer directly into DOS without letting the computer
load Windows first. For Windows 98, do the following: (1) Start, then Shut down.
(2) Select Restart, then OK, then press and hold the CTRL key until the Windows98
Startup Menu appears. (3) Enter the number 5 to select the Command prompt only
option, then press Enter. You will now be running in pure DOS mode. (Notes: 1.
You may have to disable some virus checkers for this option to work. 2. This is
the recommended method if you are having stamp.exe problems with your WindowsNT
or Win2000 machine.)
- The "Hardware not found" error can occur because stamp.exe has
difficulty communicating directly with the printer port. You can try to "uncapture"
the printer from the parallel port. To do this, click on the Start button, then
Settings, then Printers. Right-click on your printer, select Properties then the
Details tab. Click on the End Capture button.
- Take a look at the hardware configuration of your parallel port if your computer
allows it. Generally, you can access hardware setting by pressing ESC or a particular
function key during powerup (see the manual for your comptuer). This configuration
screen comes up before you boot Windows and is not the same as the Properties
screen for the parallel port driver under Windows. Navigate to the place where
you can set parallel port settings. Try setting the printer port for something
other than it is now. Choices may be something like "Standard bi-directional
port", "EPP", and so on. This is a trial and error process; no
ordinary mortals are able to figure out what all those settings mean.
- If you have a laptop and are having difficulties communicating with your Stamp,
even after trying all of the fixes above, see the "Running stamp.exe from
a laptop" technote elsewhere on this web site. This describes how to build
a custom cable interface that works for some laptops.
- If you have Windows ME, you can't run in full DOS mode. Instead you must make
a startup disk and boot your computer into DOS. See next hint.
- Make a DOS boot disk. See How to Make
a Boot Disk for details.
Some pictures
Here are some pictures which might help you understand the debugging process.
 |
 |
| Figure 1: Using the voltmeter to check if the battery is good. |
Figure 2: Checking if the +5V supply on the Stamp board is good. Note
that the black lead of the voltmeter is on the battery (-) terminal which
is easier to find. |
 |
 |
| Figure 3: Using the voltmeter to see if pin1 is putting out 0 and 5
volts in response to a Stamp program which toggles pin 1. |
Figure 4: Using a jumper wire to set Pin4 high and low by jumpering
Pin4 to GND (shown here) then to +5. Be careful not to touch two pins at
once with one side of the wire. . |