Interfacing Arduino to 12V Alarm CLock

Hi everyone,

I am trying to give my arduino the ability to "press" buttons on my alarm clock. The problem is that I don't really know how to make it happen. I know it should be possible with transistors, but I'm not sure how to implement them. I need to pull the pins high(12V) on the IC in the alarm clock for for a "button press". I assumed that a PNP transistor would work, but I almost killed my arduino using those. The only way I managed to get it to work was using NPN transistors to ground the base pins on the PNP transistors. I am wondering if there is a way that would minimize the number of components to accomplish this.

There are four signals that i need to control. I have a good selection of components kicking around so I should be able to humor most suggestions. Here is the link to the data sheet for the clocks IC http://pdf1.alldatasheet.com/datasheet-pdf/view/41213/SANYO/LM8560N.html (no idea why all of the voltage ratings are negative)

1) Little reed relays. 2) Opto-isolators

Thanks for trying, but reed relays will not suffice. I should have clarified that a relatively high switching speed is needed (roughly 60Hz).. And that solution would not reduce the parts count, which would be nice.

What didn't work using an NPN transistor?

Looking at the datasheet, I see 6 switch inputs. You can use a ULN2003 for your NPN transistors, and a couple of DIP resistor packs for the pull-up and base resistors you need for the PNPs.

Another approach that might work for you is a display driver chip like the UCN5812, but it's an old design, and I don't know how available it is now.

What didn’t work using an NPN transistor?

How would one go about using an NPN transistor to pull a pin up to +12V? From what I understand, NPN transistors can only sink current. I believe that my application requires sourcing current (into the pin on the IC). If you could post a schematic, maybe I could understand your question.

Also, if you could help me choose a good value for RB, that would be great.

This is the only configuration that worked for me…

This is very sloppy and annoying on my breadboard(there are four of these).

@Ran Talbott
Thank you for that suggestion. That would certainly reduce the part count. I’ll look into it.

BTW, I am only using four of the six inputs.

A long time ago I made a button push setup (below) using an NPN transistor to jumper the channel up button on a tv remote control.

A long time ago I made a button push setup (below) using an NPN transistor to jumper the channel up button on a tv remote control.

I don't think that your IR-remote application is the same as mine. It looks like you are using 12V(I think that's what serial is) to switch a lower voltage level (probably 3V). And it looks like your IC needed a "low" signal to switch--opposite my situation.

Which one is valid?

Both. I am using an arduino to press the buttons very rapidly in order to set the alarm quickly. The fastest the clock will take inputs from the buttons is 60Hz. Or maybe that is 30Hz(I just had a moment of clarity). Regardless, 30Hz is still faster than I would try to switch with a relay. The eventual goal is to have an alarm clock set with a keypad interface. So far I have used Processing in place of a keypad as mine has not come in yet. I type in the desired time and the arduino sets it correctly in the blink of an eye.

If not, then you are playing with fire.

Clarify your statement.

Huh? If you are using an Arduino you can generate a high or low whenever you wish. Clarify your statement.

An arduino can generate a high or low whenever one wishes, but only at TTL levels. To clarify--when you wish to control a different(non-TTL) level switch with a TTL device, pulling something high or low requires different components. For example: NPN vs. PNP transistors.

I know my project is silly, but it gives me something to do between semesters. I am in the stage of optimization. Once I get this situated I will make a nice enclosure for it.

I don't think that your IR-remote application is the same as mine. It looks like you are using 12V(I think that's what serial is) to switch a lower voltage level (probably 3V). And it looks like your IC needed a "low" signal to switch--opposite my situation.

Not really the way things work. Modify your schematic so thet the NPN transistor collector is connected to the + side of the clock button (or to the +12v if you are sure the + side of the clock button is a direct connection to the +12v supply). Connect the transistor emitter to the other side of the clock button (chip side?), and to the arduino ground. Assuming you have a 1k-5k resistor connected to the transistor base, take a wire connected to the arduino +5v point and start touching the end of the resistor that is not connected to the transistor base. Check to see if the alarm setpoint changes. Also make sure the alarm set enable button is pushed if the clock has one. ;)

Man, you people are very harsh. I know for a fact that the button can be switched at 30Hz. I have both tested by: a) changing the timing in the program until I saw failures and b) reading the clock inputs on an oscilloscope(17mS on then 17mS was the shortest switching time that registered completely). I thought that the switch-debouncing measures taken by the manufacturer would have been the limiting factor, but it appears--because of the convenient number of 30Hz--that it is the clock frequency of the IC. http://www.youtube.com/v/r9b17pz0228&hl=en&fs=1

Modify your schematic...

That would make it impossible for the pin to ever go HIGH... As soon as there is current on the base, the +12V would be shorted to ground through the transistor(poof & magical smoke)... And if my Arduino is connected through USB to my computer, that could be damaged too.

and to the arduino ground.

To humor your suggestion, I have modified my schematic to the setup you have described: Explain to me how the clock pin can ever reach +12V in this configuration..

The [working] configuration in my previously posted schematic can be seen in this photo. I know my resistor values are random, but they work. I had no idea what amount of current was needed to switch the buttons for the calculations. I tried this and it worked:

Furthermore you can't see the display changing that fast, so it seems of no practical purpose.

I don't need to see it changing to know it works. I tell it to set the clock to XX:XX, the display flashes through the numbers quickly, and then the clock is set to exactly the time I requested. The point is to set the clock quickly. There is no practical purpose of this exercise other than the learning experience. Also, I have checked to make sure that the transformer is isolated since you mentioned it--it is. I always treat appliances that are plugged into mains with extreme caution (not worth my life to be lazy, but thank you for the advice. I didn't consider the significance of an 'isolated' transformer).

To humor your suggestion, I have modified my schematic to the setup you have described: Explain to me how the clock pin can ever reach +12V in this configuration..

Kind of simple, when a current is passed across the transistor junction between the base and emitter, the junction between the collector and emitter becomes electrically conductive. ~12v (less junction voltage drop) is then supplied to the clock input from the +12v source. Have you ever looked at schematics showing how to control a 12v relay using a 5v arduino output pin and a transistor?

The [working] configuration in my previously posted schematic can be seen in this photo.

well, if it is working, what is your problem?

Man, you people are very harsh.

I try not to be harsh, but I will have fun with those the that continue to bang themselves in the head with a rock, then whine about how it hurts. :)

Have you ever looked at schematics showing how to control a 12v relay using a 5v arduino output pin and a transistor?

That is a completely different objective than mine. In your suggestion you are essentially shorting 12V to GND and connecting that short to the input of the clock Ic. When we have a transistor in saturation between +12V and 0V, it is shorted.. The voltage at any point along a wire shorted to GND will be zero.

well, if it is working, what is your problem?

You have not read the objective of this thread.. I would like to minimize the parts count. So far I have had only one suggestion that would accomplish that.

...but I will have fun with those the that continue to bang themselves in the head...

I came to the forum seeking advice from experts(or at least someone who has done this before).

That is a completely different objective than mine. In your suggestion you are essentially shorting 12V to GND and connecting that short to the input of the clock Ic. When we have a transistor in saturation between +12V and 0V, it is shorted.. The voltage at any point along a wire shorted to GND will be zero.

How is your head feeling? There is no dead short in your modified schematic unless you also connect the arduino ground to the clock ground (which was not suggested and is not shown in the schematic).

unless you also connect the arduino ground to the clock ground

You need common ground...

You need common ground...

Why? Have you actually tried it without one?

Why? Have you actually tried it without one?

Sorry.. I'm not going to short 12V into the ground of my Arduino therefor my USB port on my computer...

Sorry.. I'm not going to short 12V into the ground of my Arduino therefor my USB port on my computer...

Well, just to save the rock from being chipped into gravel, try this: Instead of using your arduino to supply the base voltage/current to the NPN transistor, use any 3-12v DC power source, a battery being ideal. Connect the - to the arduino ground shown on the schematic, and repeatedly touch the + to the resistor connected to the transistor base. See if the if the alarm setpoint changes. Careful as this could be an al-Qaeda trick to blow you up!

I think there might be another way, but I'm not sure if the Arduino is capable of it. Since it can be a three-state device (LOW, HIGH, and INPUT), you could take a PNP transistor, connect the emitter to +12V, the collector to the clock button, and the base to an Arduino pin through a resistor (~1K should work). When the digital pin is set to INPUT, it should turn the button off, with 0V appearing at the collector. When the pin is set to LOW, there should be +12V at the collector, turning the button on. However, I'm not sure if the Arduino can handle the current-limited +12V that might appear on the base. Also, I'm not sure how easy it is to change from INPUT to OUTPUT, but I think that's what Charlieplexing is all about, right?

I'd actually be very curious to know if that might work. It'd definitely save some transistors in the future for the cost of some extra code (I think).

Kyle

When the digital pin is set to INPUT..

I'm pretty sure when you change a pin to INPUT mode it floats, which isn't exactly 0V. However, I do like that idea. I don't even know where to look to see if the Arduino can take the +12V to GND.. I think it would be more likely to cause damage when the pin is set to LOW because that would really be the only time any current would flow into the Arduino. I will try to find what the current is for an INPUT HIGH. Perhaps from there I can figure this out.

According to page 316 of the ATmega's data sheet (http://www.atmel.com/dyn/resources/prod_documents/doc8271.pdf), the input leakage current is 1 uA.. If that's the case, I'd expect a much lower voltage on the input.. I have no idea if my logic is correct here..

The only pin on an ATmega168 or 328 (and likely many others) that can handle 12V is the RESET pin. Other pins are limited to Vcc+0.5V as an absolute limit without risking damage to the part.

I'd suggest using a single NPN (or N-channel FET) with a pullup resistor between it's collector and 12V, emitter tied to ground (common with Arduino), and the base tied to your Arduino output through a second resistor. Then connect the clock chip input to the transistor collector. Now, while you keep the Arduino output high, the transistor will be on, keeping the clock chip input low. Pulsing the Arduino output low will briefly turn off the transistor, allowing the pullup resistor to raise the clock chip input to 12V. The value of the pullup resistor depends on the required clock chip input current. You would repeat this combination (transistor plus two resistors) for each clock chip input you want to control.