Closing two circuits with a single switch

Thread Starter

Zurn

Joined Mar 4, 2019
117
Well, the community here has been so helpful that I'm back for more...

This one seems pretty simple. I'm trying to use a single reed switch to (almost) simultaneously put a uC to sleep and cut power to the entire system. Before I explain here's the jist:

IBPS-Orca.png

uC1 is the battery controller. When SW1 is held for 3 seconds it changes the TTL level connected to the gate of MOSFET Q1, which in turn connects and disconnects power to the rest of the system.

uC2 is a microcontroller that logs data onto an SSD. It's powered by the battery controlled by uC1. Here's the catch: before the power from uC1 is disconnected to uC2, the switch on uC2 (SW2) must be closed in order for uC2 to save its data and go to sleep. Once it's in sleep mode the power can then be disconnected. Remember: SW1 has to be held for 3 seconds before changing states, whereas SW2 only changes immediately.

I have theoretical solution for the risk of losing power to uC2 before it goes to sleep - either a UPS or large capacitor (probably a UPS because the data logged by uC2 is critical). My question is simple: how do I close the switch at SW2 with just SW1?

Again, I'm playing with solutions, but I'd love to hear from some more experienced perspectives.
 

LesJones

Joined Jan 8, 2017
4,189
Use a 2 pole push button. (Or drive a two pole relay from SW1) If one contact on each push button is at the same potential (Ground for example.) then a single diode would do what you want.

Les.
 

Thread Starter

Zurn

Joined Mar 4, 2019
117
If one contact on each push button is at the same potential (Ground for example.) then a single diode would do what you want.
You mean a diode would allow me to use the same switch to close both connections while keeping their current flow separate? Unfortunately I lack proper schematics for both uCs, so I'm uncertain what the potential is for any of the contacts. There is certainly some current flow from somewhere (I learned this by temporarily frying one of them after trying to multiplex a single reed switch).

I'm leaning towards the DPST relay right now... seems like the safest/most reliable option.
 

LesJones

Joined Jan 8, 2017
4,189
Using two opto isolators MAY solve your problem but you would need to know the schematic of the input circuits of the uCs.

Les.
 

MrChips

Joined Oct 2, 2009
30,802
This is a relatively straight forward problem. We can illustrate this with the use of a timing diagram.
Are switches SW1 and SW2 currently mechanical push-buttons?
Will SW2 be replaced with an electronic signal while SW1 remains as a manually operated switch?

Here is an example of a timing diagram, albeit a rather complex one. I shows the sequence of events as one event triggers another event.

1576074023958.png

Once you draw the timing diagram of what needs to happen then we can look at some possible implementations with actual electronic components.
 

Thread Starter

Zurn

Joined Mar 4, 2019
117
Are switches SW1 and SW2 currently mechanical push-buttons?
They're both SPST-NO reed switches. Apologies for indicating them as such on the schematic (still have yet to zero in on a reliable/free way to digitally sketch circuit diagrams).

Will SW2 be replaced with an electronic signal while SW1 remains as a manually operated switch?
That depends on whatever the simplest design is.

I'm not so certain how to sketch out a timing diagram for this, namely because I'm still unsure of the relation between SW1 and SW2. I guess it would look something like this, with each dashed line representing 1 second:

IBPS-Orca-timing-diagram.png

I hope that clarifies more than it confuses!
 

MrChips

Joined Oct 2, 2009
30,802
Here is my interpretation of what you want to happen.

SW1 is closed for 3 seconds. If closed for less than 3 seconds nothing happens.
After 3-second closure of SW1 detected, close SW2 for x-milliseconds.
Wait for n-seconds for uC2 to go into sleep mode.
Shut down system power.

Correct me if I am wrong.
 

AnalogKid

Joined Aug 1, 2013
11,038
MrChips raises two followup questions.

1. Does pressing SW1 for fewer than 3 seconds have some other function, or is sytem shutdown its only function and the 3-second timer is a way of preventing accidental activation's.

2. Is there any problem with forcing uC2 to write to the SSD without the sytem shutting down? For example with a DPST switch, if the switch is presssed for only 1 second, uC2 will go into its shutdown protocol but uC1 will not remove power. Is it OK for accidental, short SW1 presses to cause SSD writes while the system keeps running, or does the SW2 handler cause uC2 to halt after the SSD write?

ak
 

Thread Starter

Zurn

Joined Mar 4, 2019
117
Use a 2 pole push button.
I also agree this would be the perfect solution, however, I'm having a lot of difficulty finding a double pole reed switch. (Has to be activated through a 1" thick piece of glass so it's gotta be a reed switch!)

Verify that holding SW2 closed for three seconds does not cause a problem in the uC2 programs. If not, the switch is the most simple solution.
Holding SW2 has no problems for uC2... in fact it was designed to be held (with an inserted magnet) to keep the device in sleep mode indefinitely.

Here is my interpretation of what you want to happen.

SW1 is closed for 3 seconds. If closed for less than 3 seconds nothing happens.
After 3-second closure of SW1 detected, close SW2 for x-milliseconds.
Wait for n-seconds for uC2 to go into sleep mode.
Shut down system power.

Correct me if I am wrong.
The idea is to only have one reed switch. Close and hold the switch shut with a magnet: uC2 goes into sleep mode right away and after 3 seconds of the switch being closed uC1 changes its TTL level to cut system power.

1. Does pressing SW1 for fewer than 3 seconds have some other function, or is sytem shutdown its only function and the 3-second timer is a way of preventing accidental activation's.
As its wired now (i.e. in the schematic in my first post), SW1 only cuts system power and that only happens after its closed for 3 seconds. And ya, the 3 second hold is to prevent accidentally changing uC1's TTL level and shutting off the system power (uC1 was originally a battery controller for a computer system, though that's not what I'm using it for).

2. Is there any problem with forcing uC2 to write to the SSD without the sytem shutting down? For example with a DPST switch, if the switch is presssed for only 1 second, uC2 will go into its shutdown protocol but uC1 will not remove power. Is it OK for accidental, short SW1 presses to cause SSD writes while the system keeps running, or does the SW2 handler cause uC2 to halt after the SSD write?
uC2 actually has a nice little feature that if its sleep mode procedure is activated (i.e. via SW2 for now) but not kept activated (i.e. SW2 isn't held closed), it wakes up again after 20 seconds or so and continues it's operations as normal (creates a new log file, begins logging, etc).

*********

Thanks for the responses... If anyone knows of any double poled reed switches that don't cost $300, please let me know!!!
 

MrChips

Joined Oct 2, 2009
30,802
Ok. You can do this with two 555-timer circuits.
Closing SW1 triggers both 555-timers, one for x-milliseconds and the other for 3 seconds.
The output of the short timer is used as the input replacing SW2.
The timeout of the 3-second timer is used to shut down system power.
 

Thread Starter

Zurn

Joined Mar 4, 2019
117
Ok. You can do this with two 555-timer circuits.
Closing SW1 triggers both 555-timers, one for x-milliseconds and the other for 3 seconds.
The output of the short timer is used as the input replacing SW2.
The timeout of the 3-second timer is used to shut down system power.
That's good advice. I'll look into it, however, I do know the guys I'm working on this project with are not gonna like a solution as complex (they're basically luddites) as an IC!
 

AnalogKid

Joined Aug 1, 2013
11,038
1. What is the open-circuit voltage across SW2?

2. What is the closed-circuit voltage between SW2 and GND when SW2 is closed?

3. Can you inspect the pc board and determine if either end of SW2 is connected to Vcc, GND, or a resistor going to either one?

ak
 

Thread Starter

Zurn

Joined Mar 4, 2019
117
1. What is the open-circuit voltage across SW2?

2. What is the closed-circuit voltage between SW2 and GND when SW2 is closed?

3. Can you inspect the pc board and determine if either end of SW2 is connected to Vcc, GND, or a resistor going to either one?

ak
1. 3.0V
2. 3.3V whether open or closed
3. Not at the moment. I'll have a clone of the same board soon which I can take apart, hopefully before the end of the month.

What? But you are already using uC1 and uC2!
"That's a great idea!" was the response.
 

AnalogKid

Joined Aug 1, 2013
11,038
1. 3.0V
2. 3.3V whether open or closed
Let's try again. When the switch is open, the voltages at the two terminals must be different, or else closing the switch would do nothing. Let's arbitrarily label the two switch terminals a and b.

1. What are the *open-circuit* (unpressed) voltages with respect to GND at switch terminals a and b?

2. When the switch is pressed (closed), the voltages at a and b should be identical. What is that voltage with respect to GND?

ak
 

Thread Starter

Zurn

Joined Mar 4, 2019
117
My mistake...

1. When open terminal a has 3.32V and terminal b has -0.03V
2. When closed both have 3.32V

...but that's basically what I said in the last post so maybe I'm still confused.

I have another question: how does one use a 555 timer to simply close a switch that has a separate voltage source. I have the output activating a BJT, which works fine when, for example, I power an LED from the same voltage source as the IC. But in the case of my application I want to use it activate current from one terminal on my uC to another. I suppose I could use those terminals to power my IC, but I'm worried the extra current draw, regardless of how small it is, may mess with the greater circuitry of the uCs... I imagine there's a simple solution for this that I'm missing...
 

MrChips

Joined Oct 2, 2009
30,802
Here is a typical application where the output of a 555-timer circuit is used to switch on an NPN transistor.
+VLOAD can be different from +VCC. The load can be an LED, opto-coupler, relay, etc.
555-timer transistor output.jpg
 

AnalogKid

Joined Aug 1, 2013
11,038
1. When open terminal a has 3.32V and terminal b has -0.03V
2. When closed both have 3.32V
Your results tell me that the switch input to uC2 rests low (probably held low by a resistor), and the switch pulls it up to Vcc (3.3 V). This can be done electronically with a PNP transistor, the output of an opto-coupler, or - maybe - a direct connection to the output of a CMOS 555, such as the LMC555, running on 3.3 V. If we get very lucky, this whole thing might reduce down to a single diode.

Next up is determining what is happening at SW1, so we know which end is being switched in which direction. Same two questions as in #17 for SW1.

Also, what power is available to run the timer circuit?

Where are you located?

ak
 
Last edited:
Top