ExitAbound
Posts: 4
Joined: Fri Mar 16, 2018 1:21 am

Relay Concept Fact Check

Fri Mar 16, 2018 1:35 am

Hey everyone! I've got a project I'm undertaking for work, and I was running into a problem while trying to figure out if the goal I have in mind is a feasible way to go about doing this, or if its even possible at all. Any help or advice would be greatly appreciated to a beginner like me!

The main task I have to accomplish is the following: I need to control a normally closed maglock with my Raspberry Pi 3, using a relay (I haven't figured out what exact relay model I would need as of yet), and have the door disengage whenever the correct RFID tag is scanned. I know that this sort of thing is possible, I have a few projects I'm reading along with to try and emulate. Where the curveball lies is in the following detail:

I also need a secondary method of opening the Maglock to be worked into the system. So along with the RFID method, there has to be an overide switch which, when flipped, unlocks the door anyway.

From my understanding of relays, you have the inputs from the Pi that control a magnetic switch, which(in the normally closed case) will interrupt the flow of power, turning off the maglock and allowing it to open.

My question then becomes what is the best way to allow for two GPIO pins to control the same powered device? Would I want to have a relay with more than 1 output (or just two separate relays) and wire them in series so if one is broken, the loop is broken?

Follow-up to that question, does anyone have any advice in what sort of relay model would be best suited to this sort of project?

Thanks in advance!

klricks
Posts: 7172
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Relay Concept Fact Check

Fri Mar 16, 2018 2:34 am

There are relay boards with 1, 2, 4, 8, or 16 relays etc. If you want 2 relays search for 2 channel relay board.
You probably want relay with 5V coil so you can power it from the RPi.

What is the point of running 2 relays in series?
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

ExitAbound
Posts: 4
Joined: Fri Mar 16, 2018 1:21 am

Re: Relay Concept Fact Check

Fri Mar 16, 2018 2:41 am

klricks wrote:
Fri Mar 16, 2018 2:34 am
There are relay boards with 1, 2, 4, 8, or 16 relays etc. If you want 2 relays search for 2 channel relay board.
You probably want relay with 5V coil so you can power it from the RPi.

What is the point of running 2 relays in series?
Thanks for the reply! I just figured that if the relays, or I suppose the channels were in series, that only one of the triggers, button or RFID scan needs to activate to interrupt the power supply, and turn off the magnet.

Am I using 'in series' correctly here? I'm imagining running the wire from the output of one of the channels into the input of another channel, I'm not sure if that's how its done though, I'm just thinking about simple switches in series right now.

W. H. Heydt
Posts: 12785
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Relay Concept Fact Check

Fri Mar 16, 2018 3:02 am

Two relays in series is (functionally) an AND gate. Two relays in parallel is an OR gate. Just draw a diagram with switches for relays and it should be pretty quickly clear how that works.

For the actual project... If it were me, I would make the manual override a manual key-switch. The person with the key can just walk up and unlock the door with a key and it will stay unlocked until the key-switch is re-engaged.

(I once helped my son do a science fair project of building a one-bit adder using switches for inputs and relays for the logic.)

klricks
Posts: 7172
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Relay Concept Fact Check

Fri Mar 16, 2018 3:13 am

You can have multiple inputs into different GPIO's and then program the RPi to activate a single relay based on any one of the input triggers.

For example a typical magnetic door lock usually has a RFID or other type of cardreader on the outside and a motion detector on the inside.
Maybe a switch activated by a fire/smoke alarm. Plus an override button as you mentioned.

A program on the RPi will loop and continuously check for changes in any one (or more) of the 4 inputs and then activate the one relay for a period of time.

In your case the override button could just be a simple toggle switch in series with the relay. This would be simpler than a GPIO connected and programed switch.
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

ExitAbound
Posts: 4
Joined: Fri Mar 16, 2018 1:21 am

Re: Relay Concept Fact Check

Fri Mar 16, 2018 3:31 am

W. H. Heydt wrote:
Fri Mar 16, 2018 3:02 am
For the actual project... If it were me, I would make the manual override a manual key-switch. The person with the key can just walk up and unlock the door with a key and it will stay unlocked until the key-switch is re-engaged.
Oh I didn't know there were key-switch addons! Unfortunately I have to make the override with a pretty specific design in mind due to project constraints. Thanks for the advice though!
klricks wrote:
Fri Mar 16, 2018 3:13 am
You can have multiple inputs into different GPIO's and then program the RPi to activate a single relay based on any one of the input triggers.

For example a typical magnetic door lock usually has a RFID or other type of cardreader on the outside and a motion detector on the inside.
Maybe a switch activated by a fire/smoke alarm. Plus an override button as you mentioned.

A program on the RPi will loop and continuously check for changes in any one (or more) of the 4 inputs and then activate the one relay for a period of time.

In your case the override button could just be a simple toggle switch in series with the relay. This would be simpler than a GPIO connected and programed switch.
Ah! I didn't know that was a possibility. When I think about it, that is much simpler actually. So I would only need the one channel in the relay then. That simplifies things greatly. Luckily, the maglock isn't leading into a room with no exit, so I won't need to make any other special safety features like you outlined. Thank you so very much! I believe that answers my major concern :D

However, that does get me thinking... Do relays by default disengage for any length of time, or is it just however long the GPIO feeding into its control circuit reads high? So to keep the maglock from re-engaging accidentally, I should ensure that the output pin keeps sending the signal to the relay until some reset function is undertaken?

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: Relay Concept Fact Check

Fri Mar 16, 2018 3:38 am

ExitAbound wrote:
Fri Mar 16, 2018 3:31 am
Do relays by default disengage for any length of time, or is it just however long the GPIO feeding into its control circuit reads high?
there are actually 2 types of relays,
-1- the normal have one input that must be energized to operate the relay
-2- but there are relays with 2 inputs, where a puls on each input does a switch over.
that one would survive a powerfail, but your problem would be to find out what position its in.

W. H. Heydt
Posts: 12785
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Relay Concept Fact Check

Fri Mar 16, 2018 5:02 am

ExitAbound wrote:
Fri Mar 16, 2018 3:31 am
W. H. Heydt wrote:
Fri Mar 16, 2018 3:02 am
For the actual project... If it were me, I would make the manual override a manual key-switch. The person with the key can just walk up and unlock the door with a key and it will stay unlocked until the key-switch is re-engaged.
Oh I didn't know there were key-switch addons! Unfortunately I have to make the override with a pretty specific design in mind due to project constraints. Thanks for the advice though!
I wasn't thinking in terms of a Pi add-on, although a key switch could be wired to a Pi. I was thinking in terms a switch unit that takes a key to turn on or off. Think of a very simple version of the ignition swicth in a car. Put the key in and turn it and the switch is operated. In your case, you'd want it in series with the relay and one would open the switch to disengage the magnetic lock.

ExitAbound
Posts: 4
Joined: Fri Mar 16, 2018 1:21 am

Re: Relay Concept Fact Check

Sat Mar 17, 2018 5:15 am

KLL wrote:
Fri Mar 16, 2018 3:38 am
there are actually 2 types of relays,
-1- the normal have one input that must be energized to operate the relay
-2- but there are relays with 2 inputs, where a puls on each input does a switch over.
that one would survive a powerfail, but your problem would be to find out what position its in.
I see. I imagine the one with a single input is all the functionality I will need for this project.
I wasn't thinking in terms of a Pi add-on, although a key switch could be wired to a Pi. I was thinking in terms a switch unit that takes a key to turn on or off. Think of a very simple version of the ignition swicth in a car. Put the key in and turn it and the switch is operated. In your case, you'd want it in series with the relay and one would open the switch to disengage the magnetic lock.
Ah, okay, I get what you are saying. So a different style of switch for the same purpose. That would be a cooler way to have the override work!

Thanks everyone for your helpful replies and comments! I've got a better idea of how to go about this one now

Return to “Beginners”