+ Post New Thread
Results 1 to 5 of 5
  1. #1
    Junior Member level 3
    Points: 571, Level: 5

    Join Date
    Feb 2011
    Posts
    28
    Helped
    0 / 0
    Points
    571
    Level
    5

    Controlling a relay with a switch and feedback to micro controller.

    Hello.

    i am trying control a relay directly with a switch. Click image for larger version. 

Name:	IMG_16861.jpg 
Views:	6 
Size:	1.14 MB 
ID:	92664
    there is also a connection to the pin of a micro controller. This is to detect if the relay is operating or not.
    when the common and N/C of the switch are connected, the micro controller can read the voltage as 5 volts and as a result detect that relay is OFF.
    however when the switch is operated, ie common and N/O of the switch are connected, the input of the micro controller is left floating.
    while it will probably work most of the time, there is a chance of detecting false positive or false negative.

    what can i do to improve this ?

    i cannot have the switch connected to a micro controller and have the micro controller turn the relay on, because the micro controller is other wise generally occupied and i need the relay to switch ON as soon as the switch is pressed.

    suggestions ?

    •   AltAdvertisement

        
       

  2. #2
    Super Moderator
    Points: 80,983, Level: 69
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    13,275
    Helped
    4433 / 4433
    Points
    80,983
    Level
    69

    Re: Controlling a relay with a switch and feedback to micro controller.

    Connect it to one of the supplies through a pull-up or pull-down resistor. One that is too high in value to draw excessive current but low enough to ensure the logic level when the micro input is floating. I suggest 10K to 22K as suitable values.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



    •   AltAdvertisement

        
       

  3. #3
    Junior Member level 3
    Points: 571, Level: 5

    Join Date
    Feb 2011
    Posts
    28
    Helped
    0 / 0
    Points
    571
    Level
    5

    Re: Controlling a relay with a switch and feedback to micro controller.

    do you mean like this ?Click image for larger version. 

Name:	ckt.jpg 
Views:	6 
Size:	180.0 KB 
ID:	92673



    •   AltAdvertisement

        
       

  4. #4
    Super Moderator
    Points: 80,983, Level: 69
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    13,275
    Helped
    4433 / 4433
    Points
    80,983
    Level
    69

    Re: Controlling a relay with a switch and feedback to micro controller.

    Correct!

    An open circuit pin will normally float at any voltage coupled to it by inductive or capacitive coupling. Because they draw such little current there is nowhere for the coupled charge to go so they could be at any voltage conducted to them although in most cases there will be some static protection mechanism inside the micro to prevent it going below ground or above supply voltage. These will not guarantee a logic level though. Adding a pull-down resistor will provide a path to discharge the pin to ground potential so it goes to (or extremely close to) zero volts and is seen as low logic level. The resistor can be a high value that discharges the weak conduction to the pin but doesn't cause problems when you intentionally connect a voltage across it.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



  5. #5
    Junior Member level 3
    Points: 571, Level: 5

    Join Date
    Feb 2011
    Posts
    28
    Helped
    0 / 0
    Points
    571
    Level
    5

    Re: Controlling a relay with a switch and feedback to micro controller.

    ok, thanks.
    will give it a try and report back



--[[ ]]--