Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Need to detect momentary switch and switch 12V, simply

Status
Not open for further replies.

iso9001

New Member
Hi,

I have a circut that has a momentary switch and a lamp.

I need to detect when the switch is pressed (either using a PIC or just a hardware circut) and then switch 12V to the lamp.

I know I could do it using a pic to watch for an falling edge on the switch line, and then use a push pull transistor setup to drive 12V to the lamp.

But I would like to keep the complexity and parts cound to a minimum.

Does anyone make a pushpull in a single package ?

Or is there a better idea to do this ?
 
You could either use a latching relay or a flip flop.

The switch would be connected to the set input of the flip flop with a pull down resistor (assuming the set is active high). The CD4027 would do.

The Q output would drive a transistor to turn the lamp on.

You could also have another switch connected to the reset (or clear) input to reset the FF to turn the lamp off.

Len
 
Yea, I was looking at flip flops just as I was reading your post.

I cant find one with a low enough pin count (<= eight), I dont mind the money, but space is kind of an issue.
 
An 8-pin dual opamp can do it like this one:
 

Attachments

  • alternate-action_again.gif
    alternate-action_again.gif
    3.6 KB · Views: 395
iso9001 said:
Yea, I was looking at flip flops just as I was reading your post. I cant find one with a low enough pin count (<= eight), I dont mind the money, but space is kind of an issue.
Earlier you mentioned it would be acceptable to use a PIC. How about a 12F509 or 12F629, those are both 8 pin PICs.
 
bonxer said:
iso9001 said:
Yea, I was looking at flip flops just as I was reading your post. I cant find one with a low enough pin count (<= eight), I dont mind the money, but space is kind of an issue.
Earlier you mentioned it would be acceptable to use a PIC. How about a 12F509 or 12F629, those are both 8 pin PICs.

You can also get the 10F series in six pin SM - really small!.
 
Oh no no, I already am using a pic. I just didn't know if I should 'waste' my interupt pin on a feature that is far less important then the rest of the pic is doing.

I just didn't know if there was a trick way to do this. Like some sort of momentary switch lamp driver ic thing.

The push pull just doesnt appeal to me because i need to add two new part numbers that look identical. I really would have thought someone would have a need for a specialized pushpull single package transistor
 
iso9001 said:
Oh no no, I already am using a pic. I just didn't know if I should 'waste' my interupt pin on a feature that is far less important then the rest of the pic is doing.

All you need is the switch and a pullup resistor (or not even the resistor, if you use the pullups on portb feature). There's no requirement to 'waste' an interrupt on the switch, simply poll it occasionally - this also helps with the debouncing required - PIC's are so fast (compared to button presses) polling is usally plenty fast enough. Even if you use interrupts, the interrupt routine usually just sets a flag, and the main program polls the flag - so why not just poll the switch?.
 
Ah, I forgot to complicate things,

Its a 12V signal that goes to the switch. The one I need to poll.

Think its O.K. to use a large (>500k) resistor and pass the 12V signal to directly to the pic ? Or is that going to screw stuff up ?
 
iso9001 said:
Ah, I forgot to complicate things,

Its a 12V signal that goes to the switch. The one I need to poll.

Think its O.K. to use a large (>500k) resistor and pass the 12V signal to directly to the pic ? Or is that going to screw stuff up ?

You can feed a 12V signal into a PIC pin with a simple series resistor, the protection diodes in the PIC clip it to 5V - the resistor stops the diodes passing too much current, the spec for the diodes is in the datasheet. You don't need as high a resistor as 500K - a 68K would only pass 100uA through the diode.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top