Shop OBEX P1 Docs P2 Docs Learn Events
PIR module Rev. B and relay — Parallax Forums

PIR module Rev. B and relay

Bondo2Bondo2 Posts: 6
edited 2013-10-09 15:14 in Accessories
Hi,

I have the PIR module rev. B and am trying to drive a 5v relay with it. I am using a 7.2v supply (old mobile phone adapter) and using 2N2222A transistor with a 2.2K resistor on the base. The problem is once I power up the circuit, the relay ticks but even if the red led under the lense goes off the relay stays energized. Any help ?
This is the relay am using http://www.aiks.hk/products-show.asp?classid1=318&classid0=295&classid2=375#

Comments

  • bomberbomber Posts: 297
    edited 2013-10-06 15:02
    Welcome to the forums Bondo! Are you using a 5V regulator/Switching supply? The PIR module is a 5V device and will probably be fried if power over 6V is applied; You may have fried your PIR. If this is the case, then you may need to get a replacement.
  • Bondo2Bondo2 Posts: 6
    edited 2013-10-07 00:32
    Thank you. I am using one of Nokia phones adapter which states that it is 5V but when I checked it with a multimeter it is actually giving out 7.2V. I replaced it with another one with an output of 5.12v. I don't think it is fried since it still activates when I pass by and then turns off after a while (the red LED indicator under the lens seems to be turning on and off). My problem is controlling the relay
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-10-08 09:43
    How do you have everything connected? Often times it is merely a matter of mis-wiring of the transistor, which can often happen because they like to list the pinouts in weird ways. Sometimes from the top view, sometimes the bottom. Can you provide a photo or diagram of your connections?
  • Bondo2Bondo2 Posts: 6
    edited 2013-10-08 10:33
    How do you have everything connected? Often times it is merely a matter of mis-wiring of the transistor, which can often happen because they like to list the pinouts in weird ways. Sometimes from the top view, sometimes the bottom. Can you provide a photo or diagram of your connections?

    I used this arrangement http://www.afiata.com/wp-content/uploads/2010/09/Relay-Controller-Circuit-using-D313.gif with a 2.2K resistor and 2N2222A transistor based on this pinouts http://www.galigear.com.au/image/cache/data/4e73_1-500x500.jpg

    If I change the resistor to 5k the relay never switches on and if I put the 2.2, it stays on even if the red led of the module is off.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-10-08 14:09
    Those are the wrong pinouts for the 2N2222A transistor. With the flat face toward you and the leads down the pins are Emitter, Base, Collector. It also helps to have the Base-Emitter voltage drop (I believe .7V on this transistor) and the HFE (gain) so you can correctly calculate the proper base resistor value to use. In order to do this you would also need to know how much current the load draws. That diagram also doesn't indicate which diode to use, but it will probably be a 1N400X.
  • Bondo2Bondo2 Posts: 6
    edited 2013-10-08 14:18
    Those are the wrong pinouts for the 2N2222A transistor. With the flat face toward you and the leads down the pins are Emitter, Base, Collector. It also helps to have the Base-Emitter voltage drop (I believe .7V on this transistor) and the HFE (gain) so you can correctly calculate the proper base resistor value to use. In order to do this you would also need to know how much current the load draws. That diagram also doesn't indicate which diode to use, but it will probably be a 1N400X.

    Thanks a lot. So according to this am connecting the emitter in place of the collector and vice versa, right ?. I don't have the data sheet for this transistor but I guess I will use the standard values for that model, which formula should I use to calculate the resistor ?. The load in this case is the relay, am I correct ?, the data sheet (in my previous post) shows nothing of the current.
    I will rewire in the morning since it is getting late here and report back
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-10-08 14:26
    The interesting thing is that I have an old printout of the pinouts for the 2N2222 I bought from Radio Shack back in the 80s and it lists the proper pinout, however when I look up the datasheey for the 2N2222A online I only find the metal can version, which is different.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-10-08 14:34
    Here is the datasheet for the equivalent TO-92 package. And the formula for the base current requires the Junction Forward Voltage, which for a Silicon Diode is 0.7V. The average HFE of your transistor is about 100, so depending on the load you're switching you would need 1/100th the current in the base-emitter junction. That can be calculated by taking your signal voltage, subtracting 0.7 from it and dividing by the needed current, which would give you the resistor value in ohms. For example, if you were switching 100mA then you would need 1mA on the base-emitter. So given a 5V drive signal the formula would be 5V - 0.7V / 0.001 = 4300 ohms. Of course drawing a little more current won't hurt so you could use a more common resistor value such as 3.3K. That would give you 5V - 0.7V / 3300 = 0.0013 or 1.3mA. Which should be sufficient to drive a 100mA load using that transistor.

    http://www.fairchildsemi.com/ds/PN/PN2222.pdf
  • Bondo2Bondo2 Posts: 6
    edited 2013-10-09 12:36
    Here is the datasheet for the equivalent TO-92 package. And the formula for the base current requires the Junction Forward Voltage, which for a Silicon Diode is 0.7V. The average HFE of your transistor is about 100, so depending on the load you're switching you would need 1/100th the current in the base-emitter junction. That can be calculated by taking your signal voltage, subtracting 0.7 from it and dividing by the needed current, which would give you the resistor value in ohms. For example, if you were switching 100mA then you would need 1mA on the base-emitter. So given a 5V drive signal the formula would be 5V - 0.7V / 0.001 = 4300 ohms. Of course drawing a little more current won't hurt so you could use a more common resistor value such as 3.3K. That would give you 5V - 0.7V / 3300 = 0.0013 or 1.3mA. Which should be sufficient to drive a 100mA load using that transistor.

    http://www.fairchildsemi.com/ds/PN/PN2222.pdf

    Unfortunately I broke my transistor as I was unsoldering and I don't have one and no stores nearby to buy. I used BC550 instead and based on this datasheet (http://www.futurlec.com/Transistors/BC550.shtml) but it didn't work and the same thing occurred with the relay latching and never releases even when the LED indicator of the PIR goes down.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-10-09 14:51
    Well, that transistor is rated at 100mA and does have a different pin-out than the 2N2222. Can you post a photo of your connections?
  • Bondo2Bondo2 Posts: 6
    edited 2013-10-09 15:14
    I used the same circuit as the previous one replacing the transistor. The pin out I used with the flat face toward me from left CBE (as per the data sheet I linked before). I am using a 2.2K resistor and 5v supply which should give a current of 1.95mA and with a gain of 100, I should be getting 195 mA which actually energizes the relay coil but even with the PIR inactive it stays so.
Sign In or Register to comment.