OT- Interfacing Relay Contacts to AVR

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Afternoon and happy new year to all :)

Currently I am developing a new lighting controller that needs to be able to handle NC,NO (normally closed and Normally open) relay connections (eg from a PIR sensor/ momentary switch) - thing is I have no idea what is the best way to interface these to my microcontroller.

In the past I have just done some simple resistor biasing and basically used the relay as a switch that would pull the interrupt line on the microcontroller low. But to me this method seems a little hacky, especially when the distance between the controller and the Relay gets long.

Can anyone offer any assistance on this one?

Thanks in advance,
oddbudman

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For a long time I have successfully used opto isolators for this application. 5 V is a bit too low for reliable relay signalling, so I use 12 V with a dropping resistor to the opto LED. Then a 4k7 resistor from the collector to Vcc.

Also, I try to use changeover contacts to debounce the contacts. Two optos and r-s connected nand gates.

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are a number of ways to interface devices with non-logic level outputs to a microcontroller; you may not need a relay. Relay contacts will have contact "bounce" that may or may not need to be "debounced" depending on the application. I try to avoid relays if possible for a number of reasons.

The methods of connecting a device to a microcontroller really depend on the output of the device(s) itself. If you are connecting a momentary switch to a microcontroller, you will generally need a pull-up or pull-down resistor or activate the weak pull-ups in the microcontroller. A momentary PB switch will also have contact bounce. If the switch turns something on then you probably won't have to worry about debouncing the switch. If the switch increases a count, toggles something on or off, or selects a function, it will likely need to be debounced. It's really application dependent.

admin's test signature