Author Topic: Relay auto reset problem  (Read 524 times)

0 Members and 2 Guests are viewing this topic.

Offline AnalogologistTopic starter

  • Contributor
  • Posts: 21
  • Country: us
Relay auto reset problem
« on: September 25, 2026, 06:33:38 pm »
I was continuing to work on a previously designed circuit and then realized there was a design shortcoming in the relay circuit. Everything works as it should and there is no function issues. I have posted a way over simplified diagram of whats going on in this portion of the circuit. The MCU is controlling the relay with 2 output pins in order to switch the between two circuits. I have omitted all resistors, transistors, diodes, etc. as it is clutter to the actual question.

I am using a 2 coil latching relay for ease of hookup.

Problem:
Is there a way to cause the relay to reset itself if supply power is lost preventing circuit 2 from being latched active on re-power.
I thought possibly with a capacitor?  The operating time on the relay is only 2ms.

Any ideas would be appreciated.
« Last Edit: September 25, 2026, 06:37:02 pm by Analogologist »
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 7175
  • Country: de
Re: Relay auto reset problem
« Reply #1 on: September 25, 2026, 07:27:08 pm »
The normal way is to keep power to the MCU for long enough for it to do "last ditch" operations. Normally done with a reasonably sized capacitor on the 5 V line and a voltage sense circuit to trigger the NMI input.
 

Offline Uunoctium

  • Frequent Contributor
  • **
  • Posts: 517
  • Country: de
Re: Relay auto reset problem
« Reply #2 on: September 25, 2026, 07:46:58 pm »
Quick & dirty. Don't know, if it works in real. :-//
 

Offline AnalogologistTopic starter

  • Contributor
  • Posts: 21
  • Country: us
Re: Relay auto reset problem
« Reply #3 on: September 26, 2026, 03:07:09 am »
Was hoping for a simpler way to accomplish this without adding yet another sub-circuit or sub-routine to a rather complicated setup already. I might just have to live with the flaw.
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 4160
  • Country: us
Re: Relay auto reset problem
« Reply #4 on: September 26, 2026, 03:39:46 am »
Can you elaborate on the power failure scenario a bit? Are we talking about just the 5V power failing or both 5V and 12V rails collapsing?

What about having the MCU always reset the relay into a known state when it powers up?

Edit: You might consider adding a way for the MCU to determine the state of the relays. Probably just requires a few resistors per relay.

Edit 2: If only the 5V supply fails you could add a push button to reset the relay using power from the 12V rail. It's not automatic but it gives you a reset capability.
« Last Edit: September 26, 2026, 03:53:39 am by ledtester »
 

Offline Renate

  • Super Contributor
  • ***
  • Posts: 1732
  • Country: de
    • Renate's Android Page
Re: Relay auto reset problem
« Reply #5 on: September 26, 2026, 04:16:02 am »
If you always want your device to come up with the relay open, why did you even go down the path of a latching relay?
Why not a normal relay? Too much current? Use a solid state relay.
 

Offline AnalogologistTopic starter

  • Contributor
  • Posts: 21
  • Country: us
Re: Relay auto reset problem
« Reply #6 on: September 26, 2026, 07:18:35 pm »
@Renate
Yes, wanted to reduce the current load. Also having a constantly active relay is never a good idea especially for longer periods of time.

@ledtester
Now that's a thought. Why it never dawned on me I'll chalk up to old age.
I could add a delay and relay check to the power up sequence but I would have to add a transistor to another output pin to prevent the 12v on condition downstream before the relay is checked and set.

And yes both power sources are the same. 5v is regulated off the main 12v supply.
 

Offline SteveThackery

  • Super Contributor
  • ***
  • Posts: 3351
  • Country: gb
  • 50 year novice
Re: Relay auto reset problem
« Reply #7 on: September 26, 2026, 10:29:54 pm »
@Renate
Yes, wanted to reduce the current load. Also having a constantly active relay is never a good idea especially for longer periods of time.

@ledtester
Now that's a thought. Why it never dawned on me I'll chalk up to old age.
I could add a delay and relay check to the power up sequence but I would have to add a transistor to another output pin to prevent the 12v on condition downstream before the relay is checked and set.

And that gets messy. If you have a way of blocking the 12V feed until after you've set the relay, then you don't need the relay.

If you are going to set the relay at power-on then no matter how quickly you do it, there will be a 12V pulse fed down the line until the relay has been set, whether that is done in software or by some kind of pulse generated by a capacitor.

@Renate has given you the obvious answer: don't use a latching relay. Use a pair of ordinary relays. That way both current paths will be open circuit until one relay or the other is operated under the control of the microcontroller. From an engineering point of view, that is the correct solution.

You are quite wrong to say "a constantly active relay is never a good idea especially for longer periods of time". This is absolute nonsense. Relays are designed to be held "active" indefinitely, and there are numerous applications where a relay may be held in the operated position for hours, days, months. You say you want to reduce the current load arising from having the relay coil permanently energised. Why? Is current in short supply? Are you running this kit off a battery? No, you aren't. In any case you can get solid state relays where the energising current is minute. Your objections are misplaced - it is a complete non-issue.

If you don't want to re-engineer the relays, then you need to use the "last gasp" method described by @Benta. Basically, set the relay on power-down, not on power-up.

You have your answer: @Renate's solution, to replace the latching relay with two normal relays; or @Benta's solution, to set the relay on power-down using a capacitor for sustenance and an interrupt triggered by the power line dropping.
 

Online negativ3

  • Frequent Contributor
  • **
  • Posts: 558
  • Country: th
Re: Relay auto reset problem
« Reply #8 on: September 26, 2026, 11:52:29 pm »
A comparator and a cap sufficient to operate the coil.
Normal operation by mcu pin would need to be OR'd.

Simplify by using non-latching relay and design/accept extra energy draw while activated, forget the mcu pin and code for relay deactivation.
 

Offline AnalogologistTopic starter

  • Contributor
  • Posts: 21
  • Country: us
Re: Relay auto reset problem
« Reply #9 on: September 27, 2026, 05:59:06 pm »
yeah, upon closer study I have completely failed to realize that the I/O pins have a 20mA limit and the MCU itself has a max total current of 250mA (not sure could be 500mA) have to recheck that.

So instead of using a standard relay with a 40mA coil added to the fact it will be a constant load while the dual coil has 26mA coils 6ms load but still slightly above the 20mA I/O max (thought I could sneak by with it). I see the issues will begin to multiply and I'll need to redesign the whole thing.

Sorry to wasted your time on a foolish error on my part.
 

Offline Renate

  • Super Contributor
  • ***
  • Posts: 1732
  • Country: de
    • Renate's Android Page
Re: Relay auto reset problem
« Reply #10 on: September 28, 2026, 04:01:12 am »
Sorry to wasted your time on a foolish error on my part.
Eh, you got us all thinking, so that's not a bad thing. :)
 

Offline PGPG

  • Super Contributor
  • ***
  • Posts: 1323
  • Country: pl
Re: Relay auto reset problem
« Reply #11 on: September 28, 2026, 10:12:50 am »
to realize that the I/O pins have a 20mA limit and the MCU itself has a max total current of 250mA

In your first post you said:

I have omitted all resistors, transistors, diodes, etc. as it is clutter to the actual question.

What for me means that you have resistors, transistors, diodes in your real circuit but you only don't show them as they are not related to actual question.
If you have them then it is incomprehensible why you care about I/O pins current limit?

I think no one is expected to use uC I/O pins to directly drive relay coils. Why it is easy to protect small transistor against overvoltages when switching coil current off (even small BC847 isn't afraid of 50V) it is almost impossible to limit such overvoltages to absolute maximum ratings of uC that are probably 0.3V over supply voltage or 0.3V below gnd level.
 

Offline AnalogologistTopic starter

  • Contributor
  • Posts: 21
  • Country: us
Re: Relay auto reset problem
« Reply #12 on: September 29, 2026, 05:03:23 pm »
Quote
What for me means that you have resistors, transistors, diodes in your real circuit but you only don't show them as they are not related to actual question.
If you have them then it is incomprehensible why you care about I/O pins current limit?

The intent was that I omitted all the surrounding components also attached to the MCU to highlight the problem area only.

Yes, the intent was to drive the relay directly. With that said. The specs on the MCU tell me that I have a total of 80mA limit through the chip and 25mA ( I would say 20Ma to be safe) per I/O pin at 5v. Which is why I went latching instead of constant.

I have located some Panasonic relays (non-latching) with a  4.5v 11mA coil rating that I assume would operate perfectly fine with a proper flyback diode in place without the need for more external circuitry?
« Last Edit: September 29, 2026, 05:55:43 pm by Analogologist »
 

Online PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 3351
  • Country: au
Re: Relay auto reset problem
« Reply #13 on: September 30, 2026, 09:09:40 am »
I have located some Panasonic relays (non-latching) with a  4.5v 11mA coil rating that I assume would operate perfectly fine with a proper flyback diode in place without the need for more external circuitry?
You need to check the VOL of the port pin at 11 mA which needs to be comfortably under 500mV, or under ~45 ohms.
A max pin spec of 25mA fails to say how much voltage is dropped doing that.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->