Sunday, June 5, 2016

The Disalarmer! (Part 1)

Occasionally you get an idea that is way too much work and complication to justify going thru with it. This is one such idea, but a good learning experience. It should also lead to another, hopefully more worthwhile project.

I have an old Sony alarm clock from maybe junior high that I still use to this day as it has a nice loud and obnoxious alarm that is guaranteed to wake you up. But it has a drawback... it's loud and obnoxious. Due to it having a combo CD-player it actually has a decent pair of speakers and a some amplification. So, what is there to fix?

Well truly, not that often. Again, this idea is not worth the effort. I'm typically the person who hits the snooze a few times in the morning. On occasion, I'll get up with the intent to start my day, but ultimately end up on the couch.... And then the alarm goes off from the bedroom. What to do?

Let's Bluetooth the alarm clock.

The Plan

First we should define our main objectives:
  • Emulate the "snooze" button
  • Emulate the "off" button
  • The circuit should sleep while the alarm is not going off
  • The Bluetooth module should be easily removable, so that I can use it for other projects if I need it.
Like most things we'll probably need a microcontroller (I've chosen the PIC12F1572). Nothing fancy, just a few I/O. We're gonna want to tie into the physical buttons, and mimic a button press.We're also gonna want to listen to some signal indicating that the alarm is currently sounding.

Connection to the Clock

So where to start? Well, fortunately, there is a service manual, complete with schematics and drawings. Shown below is how the circuitry for the buttons on the alarm clock.

The button inputs to the processor for the alarm clock are pulled low thru 100K resistors to the ground. Pushing the button puts 5V across the 10K and 100K voltage divider (essentially 5V goes to the clock input).
$V_{IN} = V_{cc}\frac{R445}{R445+R456}=5V\frac{100K}{100K+10K}=4.55V$
The capacitor is just there for debouncing, it smooths out the transition from low to high and back down as the mechanical button is pushed. We can more or less ignore it for our intuitive analysis.
Controlling the input ourselves is as simple as emulating the button. Just make one of our microcontroller lines drive high.
A 1K resistor is added just to protect the output driver of the MCU. I actually should have done something different... but we'll get into that a little later.

The buzzer signal is also going to be an easy tie-in (although tough to solder to such a small area). I hooked it up to the scope to get a look at it, a series of 5V pulses at the frequency of the alarm. Perfect for triggering an interrupt on change pin. Instead of a 1K resistor like the buttons, I threw in a 10K. Shown below is the buzzer portion of the clock schematic, where I soldered in after R428. And that is all our signal connetions. 5V was picked up near the buttons above, and ground was everywhere.
Buzzer 5V square pulses

Buzzer has five quick beeps followed by a long pause.

Other bits

We still need to incorporate a Bluetooth serial module. The particular module I have is some kind of BC04 variant (same pinouts). All it really needs is power and serial connections. That's it. And in our case we only need to receive data from the Bluetooth module. On power up it goes right into pairing, and defaults to 9600 baud. You can literally just connect with your phone and start sending serial data. However, it does run off of 3.3V, and is the most power hungry part of the Disalarmer. We'll need a voltage regulator, and some way of switching power to it.

Before I show the finished circuit, I just wanted to bring up a minor hiccup. The microcontroller I had turns out to be a PIC12LF1572; that 'L' indicating low voltage. Not a huge deal as we already need a 3.3V regulator. But the 5V clock signals present a little bit of a challenge. But first, the schematic.
Switching the Bluetooth module on and off is as simple as a PNP transistor. Pull the base to ground and you've got power. Outputs to the buttons are just thru series resistors R4 & R7. Drive high to "push" the snooze or off buttons, and tri-state them otherwise.

You may also have noticed D1 and R2. These are my mediocre solution to the 5V input problem. But this is enough for now. We'll look at interfacing the 3.3V and 5V circuits in the next post.