DEBUGGING A STAMP BOARD

ver: nov-05

Debugging your Stamp board

"Help, my &$#!!@$ Stamp board doesn't work!!"
"Help, I'm getting 'Check power supply' errors"
"Help, I'm getting erratic results!!"
"Help, my computer can't talk to the Stamp board!!!"
"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 to help understand some of the procedures. A different document describes how to debug the older Stamp Rev. D board.

  1. 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.

  2. Measure battery voltage with your DVM. If less than 7V, get a new battery.

  3. 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.

  4. Connect the battery. Measure the voltage between +5V (Vdd) and GND (Vss). It should be between 4.95 and 5.05 volts. 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, but you will have to pay for the new board (see price on the contract).

  5. Plug in the programming cable to the Stamp and to the PC. Check that the Stamp is still at +5V.

  6. Fire up stampw.exe on your PC.

  7. Write a one-line program. (The single command "END" is fine. Download to the Stamp. If you get a "Check power supply", or a COM port error, 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 using another cable to see if that is the problem. If not, try using another computer (if you are at the UofM, use the computers outside of MechE 380) to confirm the problem is not with your computer.

  8. 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.

  9. 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 P0 (red DVM lead on P0, black lead on Vss) 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.

  10. If you can't get your Stamp to recognize inputs, see the "Understanding the Stamp DEBUG command" section of this document.

  11. 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.

  12. 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.

  13. If you can't get your computer to talk to the stamp board and if your board and cable work on other computers, then the problem is probably with your computer talking to the serial port. The message you may get is something like "BASIC Stamp II not found on any COM port", or the message may be some variant of "Check power supply." Try this:
    1. Check that your Com ) port is working properly. ("Com port" means the same as "serial port".) In Windows, Start menu > Right click on My Computer > Properties > Hardware > Device Manger. (This is how it works under WindowsXP; other versions of Windows may have a slightly different way of getting to the Device Manager.) In the Device Manager window, double click on Ports (COM&LPT). There should be at least one Com port listed and this this is the Com port number your stamp is plugged into. Right click on the Com port > Properties. Confirm that there is a "This device is working properly" message in the Device status window. If not, there is something wrong with your Com port.
    2. If you are using a USB-to-serial adapter cable and it is installed properly, you should get a COM port listed in the device manager with a note that the port is associated with the UCB adapter. That is the COM port to use. If no COM port is listed, there is something wrong with the way the adapter is installed.
    3. In the Stamp editor, select Edit > Preferences > Editor Operation tab. Pull down the menu in the Default Com Port box and select the Com port number for your computer. If your Com port does not show up in this box, click on the box with the three dots to the right of the Default Com Port pulldown menu and add your Com port to the Com # box.
    4. Also, look at document on setting up a Stamp serial port (PDF)

  14. If your computer has no serial port (true for some newer laptops), then you need to purchase a USB-to-serial converter converter.

  15. You can also go to the Parallax web site and download the latest version of the Stamp editor.

  16. You can try booting up the computer in SAFE mode (see your Windows help file, or type "Windows SAFE mode" into Google) then running the Stamp editor. This will let you see if other drivers are locking up the port.

  17. You can try running your board with the computers in ME 308. This will tell you if the problem is with your board or with your computer. See the note on running the stamp editor on the ME308 computers for details.

  18. The *only* way to confirm that you have a bad Stamp board: Strip board of *all* wires and components Dead stamps have one of 2 behaviors. First behavior is the +5 supply is blown. Confirm (did you clean the board of all components?) by measuring voltage between Vss and Vdd with a good battery. If the battery voltage while plugged in is good and there is not +5 at Vdd, the power supply is gone. Second behavior is no download. The only way to confirm this is to have the suspected dead board and a known good board side by side. Confirm download with the good board. Then using the cable and battery from the good board, confirm the dead board has a valid +5 and cannot download. After you have confirmed the board is bad is when you can contact a staff member about doing a swap.

  19. It is highly unlikely that you have a bad Stamp board. They pretty much never break even though it may be the first thing you suspect. Moral? When debugging, what's wrong is generally not the obvious.

  20. Ask a friend.

  21. Ask one of the course staff.

  22. Bring your Stamp to office hours for a debug session.

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 Guide.

With the programming cable attached to the PC and the PC running stampw.exe, DEBUG will print the value of its argument on the PC screen. Try out the following program while your switch is connected to P4. Watch what happens to the printed value of P4 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 (Vdd) and then to GND (Vss) as shown in the picture below. If state changes on P4 are not being recognized, try with another pin.

If the changes are still not being recognized, then it's your switch circuit. Measure the voltage at the pin with your DVM. It should go from +5V to 0V when you press the switch. If not, perhaps the wires are not connected to your switch terminals. Try directly touching the wires to each other. Or, perhaps your switch is faulty or needs a wiggle. Disconnect the wires from the switch and use the beeper function of your DVM to check for switch continuity.

If the debug screen is giving erratic results, randomly changing between 0 and 1, it's because you have an open circuit somewhere. Pins with nothing connected will randomly change their state

'---------------------------------------------------
' Debug demo program (wkd 07-nov-02)
'---------------------------------------------------


initialize:
  OUTPUT 0                  ' LED
  INPUT 4                   ' switch
start:
  debug dec in4             ' print status of switch
  pause 250                 ' 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.

 


Some pictures

Here are some pictures which might help you understand the debugging process. The pictures show the older Stamp Rev. D board, but you get the idea.

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. .