daisyChain
New Member
I want a way to automatically switch the power source of my sound system (amplifier) between the vehicle battery and the house battery. When the vehicle (alternator) is running, I want to use the vehicle battery(alternator) as the source of power. When the vehicle is not running, I want to use my house battery as the source of power.
More details: I don't mind if the sound system needs to shut off for some duration of time during this automatic switching mechanism. The main reason I am going through the trouble of the 'complicated' relay switching logic is to make sure that the high (unsteady) voltage from the alternator does not get connected to the output from the DC/DC converter because there are many other devices using the steady (precise) 12v output from the DC converter and I want to make sure these devices don't receive the alternator's unsteady 14+ V.
I believe I have captured all cases that I need to consider as far as the microcontroller's sensors are concerned (including taking into account precautions for failed relays whose outputs are stuck connected). If the microcontroller turns ON at any point in time, it will correctly detect the current state and correctly set triggers as necessary. Similarly, if the microcontroller turns OFF at any point in time, the result (assuming the relays don't fail) will be that the amplifier loses power and the sound system stops outputting sound (which I am ok with) (if a relay's output was connected at the point in which the microcontroller turned OFF AND the relay failed - causing its output to stay stuck connected, then the amplifier would still be powered and outputting sound).
I have the ability to program a microcontroller with this logic, but I am fairly new to electrical systems and relays, so I want to make sure this is a sound (and safe) approach and perhaps if I am missing something (let me know), or if there is an alternative/easier way to achieve what I am trying to do?
The logic I will employ is as follows:
- IF A senses 12V AND B senses high voltage (~14 V) it will indicate that the vehicle (alternator) is running, relay 2 is disconnected, relay 1 is connected, and the amplifier is using the house battery.
+ THEN the microcontroller will then disengage relay 1 (via T1).
- IF A senses ground (0 V) AND B senses high voltage (~14 V) it will indicate that both relays outputs are disconnected, the vehicle (alternator) is running, and the amplifier is NOT powered.
+ THEN The microcontroller will then engage Relay 2 (via T2).
- IF A senses (Non high) voltage (~12 V) AND B senses (Non high) voltage (~12 V) it will indicate that the vehicle (alternator) is NOT running and the amplifier is powered by EITHER the vehicle battery OR house battery.
+ THEN The microcontroller will then disengage relay 2 (via T2).
- IF A senses ground (0 V) AND B senses (Non high) voltage (~12 V) it will indicate that the vehicle (alternator) is NOT running, both relays outputs are disconnected, and the amplifier is NOT powered.
+THE The microcontroller will then engage Relay 1 (via T1).
In short hand pseudo code the gist of this is:
More details: I don't mind if the sound system needs to shut off for some duration of time during this automatic switching mechanism. The main reason I am going through the trouble of the 'complicated' relay switching logic is to make sure that the high (unsteady) voltage from the alternator does not get connected to the output from the DC/DC converter because there are many other devices using the steady (precise) 12v output from the DC converter and I want to make sure these devices don't receive the alternator's unsteady 14+ V.
I believe I have captured all cases that I need to consider as far as the microcontroller's sensors are concerned (including taking into account precautions for failed relays whose outputs are stuck connected). If the microcontroller turns ON at any point in time, it will correctly detect the current state and correctly set triggers as necessary. Similarly, if the microcontroller turns OFF at any point in time, the result (assuming the relays don't fail) will be that the amplifier loses power and the sound system stops outputting sound (which I am ok with) (if a relay's output was connected at the point in which the microcontroller turned OFF AND the relay failed - causing its output to stay stuck connected, then the amplifier would still be powered and outputting sound).
I have the ability to program a microcontroller with this logic, but I am fairly new to electrical systems and relays, so I want to make sure this is a sound (and safe) approach and perhaps if I am missing something (let me know), or if there is an alternative/easier way to achieve what I am trying to do?
The logic I will employ is as follows:
- IF A senses 12V AND B senses high voltage (~14 V) it will indicate that the vehicle (alternator) is running, relay 2 is disconnected, relay 1 is connected, and the amplifier is using the house battery.
+ THEN the microcontroller will then disengage relay 1 (via T1).
- IF A senses ground (0 V) AND B senses high voltage (~14 V) it will indicate that both relays outputs are disconnected, the vehicle (alternator) is running, and the amplifier is NOT powered.
+ THEN The microcontroller will then engage Relay 2 (via T2).
- IF A senses (Non high) voltage (~12 V) AND B senses (Non high) voltage (~12 V) it will indicate that the vehicle (alternator) is NOT running and the amplifier is powered by EITHER the vehicle battery OR house battery.
+ THEN The microcontroller will then disengage relay 2 (via T2).
- IF A senses ground (0 V) AND B senses (Non high) voltage (~12 V) it will indicate that the vehicle (alternator) is NOT running, both relays outputs are disconnected, and the amplifier is NOT powered.
+THE The microcontroller will then engage Relay 1 (via T1).
In short hand pseudo code the gist of this is:
Code:
if A == 12 and B >= 14:
T1.set(OFF)
if A == 0 and B >= 14:
T2.set(ON)
if A == 12 and B == 12:
T2.set(OFF)
if A == 0 and B == 12:
T1.set(ON)