Alright, there isn't really a fast way of explaining the background to this project, so buckle up your patience belts and stay with me for a paragraph or two. I'm using my old 5.1 surround sound PC speaker set with my TV, hooked up through a PC I built for the purposes of playing media through my NAS. I believe the youths call this a Home Theatre PC, but what do they know. Everything was running fine, except for one major issue: when I turn on my TV, the speakers don't turn on with it. The speaker set gets pretty hot after a while, so I wasn't prepared to just always leave it on, and I certainly wasn't about to get up every time I turned the TV on or off. No sir. So I set to work to figure out another way.
At first I was thinking of building an elaborate setup with an Arduino and an IR receiver, to capture the TV remote's power signal and trigger a relay connected to the plug of the speaker set. But this wouldn't do because
- It was elaborate but too easy (setting up the Arduino would take an hour, and would be a waste of a good microcontroller
- The microcontroller in the speakers resets every time the power dies, resetting the volume to 0 and the bass to middle (which for my set, in an apartment, is a ridiculous amount of bass).
The second issue is resolved easily enough: route wires from the power switch inside the speaker controller dongle thingy and use a relay as a parallel switch. The first issue is resolved with a personal challenge: no microcontrollers.
With this in mind, my next idea was to find a way to attach flywires to the TV's power LED, which is only on when the TV is on... but that would involve taking apart my new flatscreen TV, which just wasn't going to happen. I thought about using a photoresistor placed in front of the LED, but that gets ugly (aesthetically).
Spotted the theme yet? I'm lazy and fussy. It's a winning combo.
Then it dawned on me: my TV has two USB ports, one for external storage, the other for ?? (wifi dongle I think, which I don't need). After a quick test to double-check I confirmed things:
TV On = USB Power On (5V),
TV Off = USB Power Off (0V).
So how does I gets TV make speakers go? Well, I tried making guttural noises while waving my hands from the TV to the speaker dongle, but that didn't seem to help. So I put on my braining hat and set to figuring out how to make it happen.
The challenges were:
- I don't want there to be any chance of wrecking my TV's electronics
- I don't want to use an external power source (ran out of plugs)
- When the TV first comes on, the USB voltage flip-flops for a few seconds meaning a simple rising edge detector will turn the speakers on and off a bunch which is no good
Since I've already been pretty long-winded in this post, I'll save everyone the chatter about how I slowly figured out how to make this work, and cut straight to the schematic:
If we go from left to right: the TV's USB power lines come in (through a stripped USB cable) and feed into an opto-isolator which, surprisingly, isolates the TV signal from the rest of the circuit. Now, the power signal gets fed into an XNOR gate which acts as an edge detector. How does it do this? Well, simply put, in this case the capacitor acts as a buffer, or a slowerer of things. So when the incoming signal goes from high-to-low or low-to-high there is a momentary difference in the inputs at the two terminals of the XNOR gate. This difference is big enough that momentarily the XNOR inputs see a logical 1 and 0, which triggers the gate.
When the XNOR gate turns on it pulls the output low which triggers a 555 timer configured in monostable mode. What that means is it will turn on for a set amount of time after being triggered by an input pulse (inverted, so normally high, pulled low - this is what the 555 timer needs, otherwise I'd use a regular XOR gate). While it's on, it essentially ignores the input signal, which is perfect for dealing with the unwanted signal changes.
I configured the timer to last about 7 seconds, enough to get past all the USB voltage flip-flopping as the TV turns on. The 555 timer output is fed to a relay which is connected in parallel to the speaker's power button. I also use the speaker's 5V supply to power the circuit, since it was easy enough to do once I cracked the unit open. I put some links to the websites and documents I used at the end of this post for reference.
Here's my speaker controller dongle thingy...
And if you pull the little rubber feet off the back you can easily take it apart.
The microcontroller is on the back of the circuit board, and I used a multimeter and the microcontroller's datasheet to figure out what pins were 5V, ground, and the power switch. I drilled a small hole next to where the cable comes out to run these 3 new wires out to my circuit.
After a bit of testing with a regular 5V supply I was ready to plug it all into the TV and speakers. It did the job perfectly!
About half a year later I finally decided to finish this project off by soldering it all up and putting it in an enclosure.
It took 6 hours of work to make it look this tidy. Again, fussiness for the win.
All closed up. Bigger than it needs to be, but still not going to get in the way.
All done, and never to be seen again!
I'm really happy with the way this project worked out, as it's proven to be a reliable circuit, and very convenient. Hopefully this post will inspire others to control stuff using their TV and at the very least remind us all that there's a complicated time consuming solution to every problem in life, so long as that problem uses electricity.
Edge Detector Circuits:
555 Timer on Sparkfun (good for datasheet):
555 Timer Modes (for Monostable operation):
Relay kit (I didn't use this kit, but it shows you what parts you need and I used most of the same parts):