Shop OBEX P1 Docs P2 Docs Learn Events
Help Getting The BS2SX To Sense That A Circuit Is On. — Parallax Forums

Help Getting The BS2SX To Sense That A Circuit Is On.

beazleybubbeazleybub Posts: 102
edited 2008-04-30 07:00 in General Discussion
I understand pull-up and pull-down resistors used with switches to detect input but I·want to go a step further.

Can someone point me in the right direction getting the BS2SX to detect when an external·circuit is on?

I would like to be able to program my BS2SX to see when an electromagnet has been energized from a separate circuit and then execute my program.

Thanks electroheads!

Cheers

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
What if there was nothing? Nothing is something!

Comments

  • Sens-a-DatSens-a-Dat Posts: 44
    edited 2008-04-29 09:52
    The use of a Hall-Effect sensor would work well with your design. There are different types available and these links may help you to review some of them:
    www.allegromicro.com/en/Products/Categories/Sensors/index.asp
    www.allegromicro.com/en/Products/Design/Tech_Pubs.asp#B

    I am enclosing a PDF file which Allegro MicroSystems published and is freely available on the internet. These sensors cost around $1.50 or less and can be found on sites like www.Mouser.com and www.Digikey.com.

    The link for the attached PDF is: www.allegromicro.com/en/Products/Design/an/an27701.pdf
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-04-29 14:26
    If you want to detect the actual electrical energy you can connect an opto-coupler to the target circuit. Depending on the voltage the circuit uses and the current for the LED in the opto you will choose an appropriate resistor. The transistor side will usually need a pull-up resistor on the BASIC Stamp side. This circuit offer optical isolation from the circuit being monitored. I hope this helps. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • beazleybubbeazleybub Posts: 102
    edited 2008-04-29 16:18
    Those are some great suggestions. Thank you very much [noparse]:)[/noparse]

    Yes, All I am looking to do is to detect when the circuit is on.
    The electromagnet uses 12V and I was trying to find a way to tell BS2SX that it was on.

    Do I really need an opto-coupler for 12V? Could I just use a resistor to pull the voltage down to a level the BS2SX could handle? Though the use of an opto-coupler makes more sense because I would be using the opto-coupler as a switch essentially right.

    Thank you again for you suggestions everyone here is always very helpful. smilewinkgrin.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    What if there was nothing? Nothing is something!

    Post Edited (beazleybub) : 4/29/2008 4:31:22 PM GMT
  • beazleybubbeazleybub Posts: 102
    edited 2008-04-29 16:58
    I have a thought,

    Would it be possible to use a transistor with a pull-down resistor to act as a switch to detect when 12V is present?



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    What if there was nothing? Nothing is something!

    Post Edited (beazleybub) : 4/30/2008 5:38:01 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2008-04-29 18:48
    You could use a transistor, but not the circuit you posted. I'd recommend instead using an optocoupler with the LED triggered by the 12V circuit and the output phototransistor connected between the I/O pin and ground with a 10K resistor connected from the I/O pin to +5V. The input is low if the LED is on and high if the LED is off.
  • beazleybubbeazleybub Posts: 102
    edited 2008-04-29 18:59
    The circuit I provided was just an example. I am sure I have the B C E in the wrong places! shocked.gif
    Is the reason for·using an opto-coupler instead of a transistor just for BS2SX protection from voltage spikes?
    And is it hard to determine which opto-coupler to use?

    Would this one work ok?

    http://www.mouser.com/Search/ProductDetail.aspx?qs=4ATM%2ftDn4NqEnv6KYbMn5Q%3d%3d

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    What if there was nothing? Nothing is something!

    Post Edited (beazleybub) : 4/29/2008 7:21:41 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2008-04-29 20:18
    There are so many optocouplers on the market that differ only slightly in their specifications and pretty much any would work. The one you mentioned should work. You'll need a series resistor for the LED to limit the current to 10-15mA and you'll need a pullup resistor on the phototransistor's collector.

    The reason for suggesting an optocoupler is that you have +12V running around. It's easier to make a mistake in wiring with an input transistor switch and destroy the Stamp than it is to make a mistake in wiring an optocoupler. Optocouplers are cheap. Stamps are expensive.
  • beazleybubbeazleybub Posts: 102
    edited 2008-04-30 07:00
    Yeah, it's like the guy who went to RadioShack and asked the sales person if they had canned smoke.
    When the salesperson asked, "What in the world do you need canned smoke for?" the man replied, I was working on a electronics kit you sold me earlier and when I powered it up the smoke escaped.

    I used·NPN transistors as a switch to supply power for some relays in a previous project and hoped that I could use them again for my current application because I have a wide variety of NPN and PNP on hand.

    I do however appreciate the fact that an opto-coupler is pretty much fail safe when it comes to using voltages capable of euthanizing my stamp.

    Thank you everyone for the suggestions!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    What if there was nothing? Nothing is something!
Sign In or Register to comment.