Shop OBEX P1 Docs P2 Docs Learn Events
PIR Sensor — Parallax Forums

PIR Sensor

Robert MartinezRobert Martinez Posts: 13
edited 2006-11-03 00:25 in General Discussion
Hello, I am a new member and very new to electronics. In the last ten years I have spent a lot of money trying to figure out how to learn about electronics. As a machinist I have always wanted to combine electronics and mechanical components. I have purchased how to software, Programming kits, servos and boards from e-bay. I've bought it all. As a business owner I have never been able to·find the time to learn in a traditional fashion.··A college student that I employ mentioned the parallax website. I purchased the BoeBot kit and I am light years ahead of the last ten years combined. My wife is a Halloween fanatic. She has been building props and dummies for years. It is now my desire to wake them up.
·
So now my question. I have purchased some PIR sensors in order to activate the voices and lights that are normally activated by a photosensor, or button. Using the PIR senor and the bs2 stamp I have learned how to light an LED or make sound with a Piezo speaker. I have a gruesome doll sitting on my porch that lets out a blood curdling scream when a button is pushed in her belly. I cut the button off and tried to make the basic stamp and PIR sensor activate. It seems that using an I/O and ground add electricity to the circuit.·What I need to do is use the breadboard and 2 ports as a switch. Can anyone lead me to a circuit that will accomplish this? I figured out how to do it with a photosensor and a flashlight but that is too obvious.

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-10-31 16:48
    Robert,
    ·
    ·· Without knowing what the switch does or how much voltage or current it switched, connecting the ground and I/O pins could damage the BASIC Stamp.· What you should do to be on the safe side is have the BASIC Stamp activate a Relay, which would have the same effect as pushing the switch, assuming it was a 2-pin connection (NO or NC).· Attached is a simple schematic for controlling a Relay with a BASIC Stamp I/O pin.· I hope this helps.· Take care.

    NOTE: V+ is the Relay voltage and R1 should be chosen to provide minimal current to switch on the Relay.·


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    320 x 240 - 6K
  • Robert MartinezRobert Martinez Posts: 13
    edited 2006-10-31 17:06
    Thanks, that should do it.
  • Robert MartinezRobert Martinez Posts: 13
    edited 2006-10-31 20:37
    Hello again. I tried checking the voltage. With my meter set on .400m I get nothing. The circuit has 3 watch batteries if that means anything. The voltage is not written on the batteries. The board has a clearly marked GND. I tried touching that and both ends of the cutoff wire and I get no voltage. I get a OL. reading with the multimeter beeping but I don't know what that means. I was able to purchase the 1n4001 part but the store could not help me on the NPN part. They also need to know the voltage and the value of the resister that I need. I am not sure if this helps or not. By the way I think that the switch is NO. When I touch the two bare wires together the circuit runs.
  • Robert MartinezRobert Martinez Posts: 13
    edited 2006-11-01 00:08
    Ok, so you all know that I know almost nothing. Here is another attempt. I touched the two wires together and got 3.7 volts while the circuit ran. Is the relay a seperate part than the 1N4001? or do I connect one leg of the diode to + and the other to whatever transistor I end up with?
  • BenoitBenoit Posts: 47
    edited 2006-11-01 15:06
    Robert,
    For the NPN transistor, 2N3904 or any equivalent should do the trick.
  • Robert MartinezRobert Martinez Posts: 13
    edited 2006-11-01 15:47
    Thanks, I wasn't able to get the prop connected using the PIR sensor but it worked pretty good with the light sensor and a flashlight.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-02 02:35
    Robert,
    ·
    ·· Was it just a coding issue?· Your earlier post indicated the PIR was responding normally when lighting and LED, so I assume it wasn’t a functional issue, but you should be able to use it as you wanted.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Robert MartinezRobert Martinez Posts: 13
    edited 2006-11-02 17:12
    The PIR works fine. I ran out of time trying to get answers. I left the prop setup with the photosensor and it worked fine. My goal at this point is to understand the circuit that you sent. I have been reading about the components that you chose so that I can design better circuits myself. I do have a couple of questions. Keep in mind I am not questining your circuit. I just want to know why.

    1) Why an NPN transistor and not a PNP? They seem to do the same thing to me.

    2) The voltage of the Halloween prop is 3.7 volts. Why can't I just use a transistor as a switch alone? Some transistors can handle huge voltage.

    3) Why couldn't the I/O pin control the relay by itself?

    4) What is the purpose for the Diode? My understanding is that it is a one way valve. aren't the electrons going to flow one way anyway?



    I am going to buy the 2N3904 transistor as recomended by couch-pilot. I still need to know what resistor I would need. I would like an explanation of how to figure this out myself. Here is the information that I have on this transistor.

    Type SW. (I read about FET's) What does SW Mean?

    P/N = NPN

    PD 350 mW (Is this the current input to the base in order to make it work?)

    V CEO 40V (I assume that this means that the transistor can control a 40 volt circuit)

    IC 200mA (I thought IC was Integrated Circuit. What is 100mA telling me?)

    hFE 100 (? Huh)

    TO-92 ( I know this one is the type of transistors because of the picture)

    10/$1.00 I love this one. This is the cheapest hobby I have. I already have hundreds of components and my wife doesn't even notice checkbook dropping. hop.gif



    If all these questions are too much. Please make some reading recomendations. I would prefer books that assume I know nothing to begin with. Thanks.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-02 17:27
    Robert,
    ·
    ·· NPN and PNP transistors work differently.· I would recommend Googling for a tutorial that focuses on transistor theory.· Suffice it to say in this context you could break it down into the NPN being an active-high transistor and the PNP being active-low.· This is fine if we’re working on controlling say 5V from a 5V control signal.· But in the end the control and supply voltages will make this more complex as the supply voltage the transistor is switching become greater than the control voltage (5V).·
    ·
    ·· I suppose you could just use a transistor alone…I am not familiar at all with the circuit from this prop, so I don’t know if it provides the pulse you need and for the correct amount of time.· But if you merely needed to drive a larger load from an already existing circuit it is quite possible a transistor could’ve solved that for you by itself.
    ·
    ·· You never want to control a Relay with an I/O pin for a couple of reasons.· The first is current.· Even 5V Relays with 20mA coils are already drawing maximum current from the pin.· Using a transistor will seriously reduce the amount of required current.· In some cases the required current and/or voltage to activate the relay would already be too much for the I/O pin.· But the second problem is that a Relay is an inductive Device.· It generates back EMF when it de-energizes which can damaged the I/O pin.
    ·
    ·· The clamping diode shown in the schematic helps protect against that, but I always prefer to play it safe and use a 20 cent transistor so if something fails it doesn’t take out the I/O pin.· I won’t go into the details as they’ve been hashed out on different threads even recently.· But suffice it to say you should have one when driving any inductive load, such as a Relay, Solenoid or even a Motor.
    ·
    ·· On the transistor specs…My guess is the SW means “switching” which that transistor is (Small Signal Switching).· PD is Power Dissapation…VCEO is the Collector-Emitter Voltage, which is essentially how much voltage the transistor can switch.· IC is the collector current, which is essentially how much current the transistor can handle.· hFE is the gain.· It tells you how much current the base needs in relation to how much current you’re driving across the collector.· In this case whatever the collector current is, the base current will be 1/100 of that.· I hope this helps.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Beau SchwabeBeau Schwabe Posts: 6,563
    edited 2006-11-02 17:53
    Chris,

    you beat me to a reply....[noparse]:o[/noparse])

    Robert,

    1) Why an NPN transistor and not a PNP? They seem to do the same thing to me.
    ·· If the supply voltages are the same, then it is ok to use a PNP, however when the supply voltages are different, an NPN is a better choice,
    ·· since usually both supplies will have a common ground connection.

    2) The voltage of the Halloween prop is 3.7 volts. Why can't I just use a transistor as a switch alone? Some transistors can handle huge voltage.
    ·· You might be able to if your transistor can handle the correct amount of current.

    3) Why couldn't the I/O pin control the relay by itself?
    ·· It could if the required current was within the specs of what the I/O pin could handle.

    4) What is the purpose for the Diode? My understanding is that it is a one way valve. aren't the electrons going to flow one way anyway?
    ·· You are correct, they are like a one way valve, and that's exactly why you need one with an inductive load.· An inductive load works like a
    ·· big "U" tube full of water on one side.· When you release the 'valve' the water oscillates back-n-forth until an equilibrium is reached.
    ·· When you apply energy to an inductor it creates a magnetic field around the inductor.· When you remove the energy from the inductor, the
    ·· magnetic field collapses and induces an electrical charge in the reverse direction back into the circuit.· The DIODE is there to protect the
    ·· other electronic components from experiencing a reverse polarity which could destroy them.


    I am going to buy the 2N3904 transistor as recommended by couch-pilot. I still need to know what resistor I would need. I would like an explanation
    of how to figure this out myself. Here is the information that I have on this transistor.
    See the link below...
    http://forums.parallax.com/attachment.php?attachmentid=37701

    Type SW. (I read about FET's) What does SW Mean?
    I think this is just a general purpose SWitch type transistor.

    PD 350 mW (Is this the current input to the base in order to make it work?)
    This is the total amount of Power that the transistor can dissipate in the form of heat without a heat sink.

    P = I * V· ; P = Power in Watts ; I = Current in Amps ; V = Volts

    V CEO 40V (I assume that this means that the transistor can control a 40 volt circuit)
    This is the maximum voltage allowed across the Collector-Emitter transistor junction.


    IC 200mA (I thought IC was Integrated Circuit. What is 100mA telling me?)
    IC or ICE is the maximum current allowed through the Collector-Emitter junction.· I = Current


    hFE 100 (? Huh)
    This is the amplification value of the transistor.· A transistor is a current device.· The hFE applies to the relationship between the
    B-E(Base Emitter Junction) and the C-E(Collector Emitter Junction).· If you apply 2mA of current to the B-E junction, then with an hFE of 100 the
    C-E junction should be able to drive a 200mA load.·· 2mA x 100 = 200mA·· <-- This assumes you don't go beyond the IC ratting of the transistor.

    TO-92 ( I know this one is the type of transistors because of the picture)
    This simply is the package style of the transistor.




    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Robert MartinezRobert Martinez Posts: 13
    edited 2006-11-02 20:12
    Thanks. That helps quite a bit. I is difficult being this ignorante of the terminoligy and parts. I think spending time here will do me some good.
  • Robert MartinezRobert Martinez Posts: 13
    edited 2006-11-02 22:45
    I hate reading my posts after I submit them. I are college educated. blush.gif
  • metron9metron9 Posts: 1,100
    edited 2006-11-03 00:25
    This link will open a java applet with a simulator you can watch electrons flow. Make your own circuits or look at the circuits you can load. Most major components are in it so testing ans seeing what happens is very enlightening when you are new to the subject.

    I'm on the other side of the coin, hardware was my problem, software was a breeze. I am finally over the last year or so understanding how hardware components work outside the confines of the software domain.

    http://www.falstad.com/circuit/

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think outside the BOX!
Sign In or Register to comment.