Best Practices for driving a relay with an I/O pin.
Oldbitcollector (Jeff)
Posts: 8,091
I'm currently working on a project which incorporates the Propeller controlling a "real world" item.
I'm using a 5v relay (which seems to be perfectly happy at the 3v output of the Propeller) with a
diode between the pin and the relay. Can someone confirm that this is "best practice" in this situation?
Also, as I plan to use PWM at some point in this project, does someone know correct part# for a
solid state equivalent of the top of their head?
Thanks!
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Visit the: The Propeller Pages @ Warranty Void.
I'm using a 5v relay (which seems to be perfectly happy at the 3v output of the Propeller) with a
diode between the pin and the relay. Can someone confirm that this is "best practice" in this situation?
Also, as I plan to use PWM at some point in this project, does someone know correct part# for a
solid state equivalent of the top of their head?
Thanks!
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Visit the: The Propeller Pages @ Warranty Void.
Comments
I assume you mean the diode is across the coil connections (reverse biased) ?
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
·
Actually, I wasn't really worried about the VSS side of the relay. My diode is between the I/O pin
and the relay itself. Reverse against the I/O pin to keep current from coming back to the Propeller.
No?
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Visit the: The Propeller Pages @ Warranty Void.
Graham
edit: some reed relays contain a diode for protection.
Post Edited (Graham Stabler) : 3/4/2010 3:53:54 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Leon Heller
Amateur radio callsign: G1HSM
The way you have the diode, it blocks the current. There is nowhere for the current to go. This generates very high voltages across the coil.
With the diode across the coil, the diode absorbes the current caused when the coil is turned off. Keeping the voltage at 0.7V max.
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
·
I've had no issues running this circuit in an on/off loop for well over an hour.
(That might be another testament to how robust the Propeller is.)
I get the idea that Figure 2 is the direction I need to go in? Do I need the transistor?
Edit: This is the relay I'm using.
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Visit the: The Propeller Pages @ Warranty Void.
Post Edited (Oldbitcollector) : 3/4/2010 4:34:26 PM GMT
So something like this?
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Visit the: The Propeller Pages @ Warranty Void.
When the diode is turned off the magnetic field collapses, this field contains energy. A back emf is then produced, this means that the potential of the point connected to the propeller pin will rise however now the diode will become forward biased and the energy will return to the supply.
Graham
I tend to be a visual learner and the text descriptions just weren't completely sinking in.
It looks like a single relay or two should be fine in my situation.
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Visit the: The Propeller Pages @ Warranty Void.
· If you use the transistor, don't forget a resistor between the Propeller pin and the base of the transistor. The value will depend on how much current the relay needs, and the gain of the transistor.
· I'd start with a 1K and lower it if that doesn't work. Don't go below about 180 Ohms though.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
·
Re: Also, as I plan to use PWM at some point in this project, does someone know correct part# for a solid state equivalent of the top of their head?
Sorry, not aware of any solid state equivalent for the top of my head or any one else's head, however if you are looking for a solid state relay to replace the one you are using I may be able to help if you post the current rating and voltage it is to be used for
Basically I'm switching 4.5-9v DC with a Propeller pin.
Thanks
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Visit the: The Propeller Pages @ Warranty Void.
I have some ULN2803 driver chips left over from the Christmas Give-a-Way. I gave away about 40, and I have about 20 left. I'll sent you a couple.
Drive directly from the Prop, and the protection diode is built in. I have never tried to run it at 3.3 volts though. But what the heck, they are free and might come in handy for another project.
Jim
I'll give them a look see. [noparse]:)[/noparse]
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Visit the: The Propeller Pages @ Warranty Void.
For PWM what about using a mosfet, some have amazingly low on resistances, convenient packages and can be switched directly by the propeller. If you are just switching power they are a great solution.
Cheers,
Graham
relay drivers.· You will need to use an ohm meter to measure the relay coil
resistance to get an idea of required current unless you have a data sheet
which gives the relay holding current. The diode is important.
The assumption in the discussion so far is that the relay is small and the
current is low enough for the prop to drive it directly. However I like having
some kind of drive interface, single transistor or an open drain or open collector
IC . I prefer to wipe out the driver rather than the micro is something bad happens.
Tom