Notifications
Clear all

[Solved] Need pointers on how to create a latching relay with arduino including reset

52 Posts
7 Users
11 Likes
4,556 Views
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7010
Topic starter  

@will I think I forgot to mention one thing. I want to turn on a 12V circuit using a 3v3 or 5V Arduino. The power for the load does not come from the Arduino, after I latch the relay the Arduino can sleep. The load may be on for hours. I know I will have to use a Buck converter to step down the 12V to the 5V or 3V3 for the latch. Looking at the information I have available the MOSFET approach has the current flowing through the Arduino all the time the load is on since I don't see any latching mechanism. Is this making any sense?

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2535
 
Posted by: @ronalex4203

@will Thank you! One question though, the LED's in my application are not dimmable and don't need to be so should I use other pins than the PWM? For simple ON/OFF would I use the digital pins? Also the example MOSFET is still way more power than I need. I have probably less than 1A at 12V, maybe a lot less. The example is for a 16 A MOSFET. I know DigiKey has an online calculator thing but I haven't found it yet.

Yes, if all you need is on/off then just use a non-PWM pin.

You don't need to use the MOSFET from the example, it was merely intended to show you the principles. You just need a MOSFET which will be fully turned on at 5V (logic level) so that the minimum energy will be lost and have enough capacity for the voltage and current you'll need.

Of course its always safer to choose one which exceeds your needs to avoid over stressing it.

As Mark says, the MOSFET is just acting like a switch. While the Arduino feeds 5v into the gate, it stays turned on and the LEDs are lit. When the Arduino stops the 5V, the MOSFET turns off and the LEDs do too.

There's no need to power the Arduino and the LEDs from the same power source, but you'll need to power the Arduino somehow.

Anything seems possible when you don't know what you're talking about.


   
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7010
Topic starter  

@will The diagrams I have seen are ambiguous for my old brain. The load is a couple of 12V LED lights. Is it true that the Arduino is NOT providing any of the power the LED's are using? In other words it is acting like a tube triode.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2043
 

@ronalex4203 

When I open a basement door I want to sense that and turn on the lights.

What is lacking in your requirements that a motion sensor light switch, that are used for security purposes, can't do?

 

 


   
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7010
Topic starter  

@robotbuilder Too big, faces the wrong way, I want to do a bunch of other things, be connected by BT and WiFi and I want to build it myself. Also the biggest reason is this is not a house, it's an RV so 12V lighting.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2535
 
Posted by: @ronalex4203

@will The diagrams I have seen are ambiguous for my old brain. The load is a couple of 12V LED lights. Is it true that the Arduino is NOT providing any of the power the LED's are using? In other words it is acting like a tube triode.

The 12V power flows through the MOSFET, the Arduino is separately powered and just controls whether it flows or not.

MOSFET stands for metal oxide silicon field effect transistor and works using voltage to control the gate. As with bipolar transistors there are NPN and PNP (called N-channel and P channel MOSFETS) There seem to be a lot more N-channel circuits than P-channel circuit.

They operate in a similar fashion to transistors but use voltage rather than current to open or block the  circuit.

A triode amplifies, the MOSFET is usually used to close or open a circuit. Again, it's a switch, when fully turned on it has a very low power consumption.

Google will give you a far better understanding than I can do here 🙂

Anything seems possible when you don't know what you're talking about.


   
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2535
 
Posted by: @ronalex4203

@robotbuilder Too big, faces the wrong way, I want to do a bunch of other things, be connected by BT and WiFi and I want to build it myself. Also the biggest reason is this is not a house, it's an RV so 12V lighting.

Unless you live alone, I don't think you'll want the light to turn on and off automatically as the door opens. Otherwise you'll get trapped in the dark when the wife opens the door to tell you that the pizza has arrived 🙂

It'd be better to have two sensors, one near the top and the other near the bottom. That way, your system would be able to tell if you were going down (top triggers before bottom) and turn the lights ON; or coming back up (bottom triggers before top) and turn the lights off. If one sensor gets triggered but the other one doesn't (within 3 seconds, say) then the lights aren't changed. That'll allow your wife to open the door, step down a step and pass on a message or for you to come part way up the steps to pass a message.

That assumes that only one person will be in the basement at a time. After that it gets more complicated to count, but still totally feasible.

Anything seems possible when you don't know what you're talking about.


   
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7010
Topic starter  

@will LOL, I forget normal folks don't know what an RV basement is. I was worried about how to signal turn off, but in another YT video comparing a bunch of radar based sensors plus other's like PIR I noted the PIR is blocked by the door, so I will use that signal as the OFF. The only catch is PIR is temperature sensitive, so I will need to add a temperature sensor to bias the PIR. Lucky for me that is all done with code and I have tons of experience writing code. I might also consider turning the lights off after a certain amount of time perhaps based on the PIR or whatever radar sensor I use. They are LED's so I am not worried about burning them out and I have several spares in any case, they use a trivial amount of current that my 600AH LiFePO4 battery bank and 1,080 solar array will never notice. Now I am off to order some IRF520's that are a closer match to my requirements.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2043
 
Posted by: @ronalex4203

@will LOL, I forget normal folks don't know what an RV basement is. 

That explains  a lot!!  I imagined you stored your RV in the basement somehow.

So I read that an RV basement is usually no more than a couple of feet high and is generally just an extra compartment that is located under the floor of an RV.

 

   
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7010
Topic starter  

@robotbuilder More or less, I can sit inside mine and lie down as well. It is about 8 ft x 4 ft sortof, there are some bumps. and 3ish ft tall.

This project in total will have 11 or 12 modules plus maybe some power modules (12V to 5V) where the principal modules are close enough to share a power module. I haven't decided if I should just build power conversion into each device or make a specialized box. The power box could be as small as 55mm x 35mm x 15mm (2 1/8 x 1 3/8 x 1/2)

I am a big fan of the divide and conquer school for design and troubleshooting.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2535
 
Posted by: @ronalex4203

When I open a basement door I want to sense that and turn on the lights. I currently use mag reed switches but they don't work that well and I want to do more off the open event.

Can you please explain why reed switches fail in this case, it seems to be an ideal situation for using them ?

Anything seems possible when you don't know what you're talking about.


   
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2043
 

@ronalex4203 

Looking at the information I have available the MOSFET approach has the current flowing through the Arduino all the time the load is on since I don't see any latching mechanism. Is this making any sense?

The "latch" is in the Arduino. Unlike a MOSFET a relay would be consuming power in its coil all the time it was on. Does it matter if the Arduino is on all the time? The power is there all the time for the LEDs and probably other devices so does the little amount of extra power consumed by the Arduino matter? It can be doing other neat stuff with turning the LED lights on or off being only one of its tasks.

The electricity flowing through the LEDs is not flowing through the Arduino only through the MOSFET (switch) which when fully on (no resistance between source and drain)  essentially consumes no power.  In the case of a MOSFET the Arduino only consumes a minute amount of power to turn it on. The MOSFET is a static device that stays on while the gate holds a static charge. You can remove the power source from the MOSFET gate and it will stay on until the base is earthed to discharge the gate. Thus they are used to store data in a memory chip even when it is not connected to a power source.

 

 


   
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7010
Topic starter  

@will Agree. The area around the hatch is poorly designed for fastening anything and because the door is a slam door, the switches get easily damaged. I will post a picture that may be helpful but keep in mind I do want to experiment with other ways of detecting human presence. If I can find a way to mount the switches reliably, I may use them as a secondary means of determining opening the door and closing the door. Looking at the switches, I might have mounted the fixed side wrong. Too bad, I am still going ahead with the Radar and PIR.

IMG 6478
IMG 6480
IMG 6479

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7010
Topic starter  

@robotbuilder THANK YOU! That is very educational. I am new to a lot of this so question everything. Just telling me the answer will not always be what I want, I NEED to understand the why, that way then I know what/how/why it works. Like I mentioned early on, I was schooled in the tube era and have no training in solid state so my base knowledge is lacking. I have ordered a few MOSFETS and not ordered any relays so now I can move on to the next problem. Again, thanks to all of you who tried to pound the info into my thick skull. I think I am going to really like this group. Given the opportunity I will repay it forward.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2535
 

@ronalex4203

Thanks for the explanation, I understand it now.

There are a lot of potential sensors you could use to sense the door opening and closing, but it seems that they'd have to be mounted on the inside of the opening to prevent accidental triggering by activity outside the vehicle.

PIR devices usually operate by triggering when they detect a moving IR difference between the lobes of the plastic dome. It may not be a problem if the sensor is indeed a cavity that's heated uniformly.

Similarly, they may be triggered by anything causing a temperature change between areas of the "ceiling", such as a stove or heater creating a temperature differential in the floor.

Anything seems possible when you don't know what you're talking about.


   
Page 2 / 4