Shop OBEX P1 Docs P2 Docs Learn Events
Basic Stamp pins always high? — Parallax Forums

Basic Stamp pins always high?

MacadaciouseMacadaciouse Posts: 16
edited 2011-11-22 11:49 in BASIC Stamp
Hi all,
I'm trying to control a motor via relays. I'm using tip120 transistors to run 2 12v relays. When I connect vss to 12v+/the collector, the relays click. Connected to 12v-/emitter, nothing. I checked voltage on the pins and all are reading about 2v regardless of input. Did I fry something? The board comes on and responds normally otherwise. I have a fair amount riding on this relatively simple effect, I just don't know enough to troubleshoot.
Thanks for any advice,
Mac

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-11-18 10:06
    Post your code (use the [ code ] and [ /code ] brackets around your code ... without the spaces). Also post a diagram of your circuit for the transistors and relays.

    By default, the Stamp I/O pins are in input mode where they float in a high impedance state. You use LOW and HIGH statements to change them to specific output states (Vss or Vdd respectively).

    You will need a resistor between the I/O pin and the transistor's base. See Nuts and Volts Column #6 for a discussion of this.
  • ercoerco Posts: 20,256
    edited 2011-11-18 10:08
    Nice page on using relays with a microcontroller at
    http://www.kronosrobotics.com/Anotes/Relays.pdf

    Info also applies to Stamps.
  • MacadaciouseMacadaciouse Posts: 16
    edited 2011-11-18 11:02
    My code is as follows:
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    DO
    HIGH 1
    HIGH 0
    PAUSE 2000
    LOW 0
    LOW 1
    PAUSE 2000
    DEBUG "no?"
    LOOP
    

    The circuit was taken from here:
    http://www.arduino.cc/playground/uploads/Learning/relays.pdf
    but doubled up, so one relay controls power on/off through the other relay.

    What happens if a resistor is not used between the stamp and the transistor? Could I have damaged anything that way?
    Thanks for the links, I'm going through them now. It's all just a bit overwhelming, such a glut of information. Thanks for your help,
    Mac
  • ercoerco Posts: 20,256
    edited 2011-11-18 12:08
    Without the resistor, you could burn out a Stamp pin by allowing too much current to flow. Should be limited to 20 mA max.

    Your circuit diagram looks fine, should work OK if it's hooked up properly.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-11-18 12:08
    You need a resistor between the Stamp I/O pin (or Arduino I/O pin) and the transistor's base or you can damage the I/O pin or the transistor. If you have a multimeter, you can measure the voltage between the I/O pin and Vss when you run your program. It should go to somewhere near 5V when the program does its HIGH, then to around zero volts when the program does its LOW.
  • ercoerco Posts: 20,256
    edited 2011-11-18 12:13
    There is also the possibility that without the resistor, excessive current is flowing and your Stamp might be resetting if your supply voltage drops. So don't eliminate the resistor, but try lowering the value to 330 or 470 ohms from the 1K-2.2K resistor shown in your diagram and see if that works.
  • MacadaciouseMacadaciouse Posts: 16
    edited 2011-11-22 09:37
    I had it working like a champ, now the relays will only click for a second then release. The status light on the board goes dark and the red light on the serial adapter flashes before it returns to low. Anyone have a clue? Too high a load?
  • Mike GreenMike Green Posts: 23,101
    edited 2011-11-22 10:59
    Sounds like, when the relays close, your power supply is getting overloaded, the supply voltage drops, and the Stamp resets. If you're using batteries, they're probably dead or nearly dead.
  • MacadaciouseMacadaciouse Posts: 16
    edited 2011-11-22 11:37
    Do you mean power supply to the relay or to the stamp? I'm using wall adapters, however they're solid state and may be pushed beyond their limit. That would make sense considering the mechanism will go down, but not up; higher load.

    You've been so helpful, I hope you don't mind giving your opinion on another question; I'm using the parallax pir motion sensor and the output never seems to shift from high. I tried covering it to isolate it from movement and nothing happened, still high. Could I have inadvertently damaged it, or is this related to the jumper settings?

    EDIT: The relays are driving a 3hp motor which is on circuit with another animatronic figure, my computer and who knows what else. Could the whole circuit, or at least that one extension cord, be overloaded?
  • Mike GreenMike Green Posts: 23,101
    edited 2011-11-22 11:49
    There are all kinds of possibilities for what seems to be a power problem. Without a detailed schematic, it's hard to tell. You could be using wire too thin for the load on it. There could be noise / power surges, ground loops ... all sorts of things. Same thing for the PIR sensor. Without a schematic, I wouldn't venture a guess. The PIR sensor does respond slowly to changes in the field of view. How do you have the jumpers set?
Sign In or Register to comment.