Designing a simple alarm circuit using microcontroller

Thread Starter

nestbulala

Joined Dec 12, 2015
111
I am designing a simple alarm circuit using PIC12F629 and I need advise from this forum of experts on how I could accomplish and fine tune the circuits. The alarm input set the GP0 High and flashes an LED through Mosfet. When the GP1 set high, GP0 should remain high steadily. There is also a lamp test but it is outside of the microcontroller.
Please see the attached circuit for your reference.Alarm Signalling Circuit using PIC12F629 MCU.jpg
 

Attachments

spinnaker

Joined Oct 29, 2009
7,830
Schematic is horribly drawn and overly complex.

Why do you need a 48V supply?

You better have REALLY good heat sink on that what appears to be a regulator. Your regulator is going to drop 43V all in heat. Why not just use a 7805 (you would still have heat issues)? Far better a switching regulator if you have to use 48v.

What's with reset shutting off ground?

Why a 100uf cap across supply? Isn't your supply already filtered? A .1ufd decoupling cap from the VDD to VSS is all that is needed.
 
Last edited:

Wingsy

Joined Dec 18, 2016
86
I take it that you're stuck with the pushbuttons connected to the 48v supply, otherwise I would move them to the PIC side of the regulator and connect them directly to the PIC with a pullup resistor.

And those optocouplers ... I don't see the need for those since you're not using them for isolation. The pushbuttons and the PIC already share the same ground so they aren't really needed. You can do away with the optocoupler and replace it with, say, a 7.5k resistor (to ground), and connect the junction of the 7.5k and the 68k (that goes to the switch) directly to the PIC.

Edit: Just saw your "Disregard" post as I posted my reply. Too late.
 

John P

Joined Oct 14, 2008
2,025
I don't see any "disregard" posting!

What I do see is that the lamp test button puts 48V on the gate of Q2. The data sheet maximum there is 20V. And R6 rated 4W? You're planning to burn some serious power.
 

ErnieM

Joined Apr 24, 2011
8,377
The lamp test should test the way the lamps are actually lit, not some other alternate way, unless you want to call it the "kinda sorta lamp test."

Thus drive both the alarm input and some other input. When the micro sees both it drives the lamps but does not latch or whatever the alarm input does.
 

Thread Starter

nestbulala

Joined Dec 12, 2015
111
I have modified the circuit to reflect your advise but I keep the kinda sorta lamp test because there was no issues I faced.
Alarm Signalling Circuit using PIC12F629 MCU V1.jpg
 

spinnaker

Joined Oct 29, 2009
7,830
That 7805 is still going to generate a serious amount of heat. You would be better with a buck regulator. TI has the LM2675. Very easy to use. The only thing you need to be concerned is PCB layout. Major concern is the location of the coil. If you don't want to build one, they can be purchased as a breakout board.


You really should draw your supply separate from your schematic. That way you can change it out as needed and makes for a cleaner looking main schematic.

I am not seeing a decoupling cap for your mcu.

IMHO The switches should be supplied by the 5vdc.

This is how I do switches with a pull up.

upload_2017-2-5_20-5-37.png

Oops typo on the pullup values. Now corrected above.
 

Attachments

Last edited:

eetech00

Joined Jun 8, 2013
3,856
I am designing a simple alarm circuit using PIC12F629 and I need advise from this forum of experts on how I could accomplish and fine tune the circuits. The alarm input set the GP0 High and flashes an LED through Mosfet. When the GP1 set high, GP0 should remain high steadily. There is also a lamp test but it is outside of the microcontroller.
Please see the attached circuit for your reference.View attachment 120002
Hi

Heh.....I guess this is a new version?

Suggestion.....feed all the pushbuttons off reg 5v (like spinnaker suggested) and connect them to the inputs of the microcontroller. Put all the logic in the pic and let the pic control the mosfet. Maybe use a wall wart instead of 7805, the 7805 will probably burn up anyway.

I forgot what the relay is supposed to do....
 

John P

Joined Oct 14, 2008
2,025
I don't think the voltage regulator will heat up much, as it passes very little current, only about 1mA to run the processor, another 1.5mA through R8 and R10, but 8mA max (5mA typical) to run itself (lost to Gnd via pin 2). I can't see how it can lose as much as half a watt. Similarly, R1 won't heat up much, and could be a half watt resistor.

But R1 is tricky: it has to drop the voltage to 35V max, or the regulator will get more voltage than it can handle, so you have to know in advance what the current will actually be. If U1 draws its maximum operating current, then there won't be enough voltage left to generate 5V on the output (8mA through 5.6K drops 45V). I think to be conservative, R1 should be less than 5.6K. That might mean it needs t be a 1W type, but certainly not 5W.
 

merlynski

Joined Jan 24, 2017
2
Isn't D3 backwards? It seems that when 48v is applied D3 will be forward biased, and R6 (150 ohms?) will dissipate about 15 watts and all the magic smoke will escape. :eek: Also the relay will never pull in . . .
What is the relay's purpose? If D3 is turned around the relay will be activated any time the 48v supply is on, except when reset is pressed. :confused:
(PS. First post for me here)
 

Wingsy

Joined Dec 18, 2016
86
I don't see any "disregard" posting!

What I do see is that the lamp test button puts 48V on the gate of Q2. The data sheet maximum there is 20V. And R6 rated 4W? You're planning to burn some serious power.
It was there for a while.
 

Thread Starter

nestbulala

Joined Dec 12, 2015
111
Suggestion.....feed all the pushbuttons off reg 5v (like spinnaker suggested) and connect them to the inputs of the microcontroller. Put all the logic in the pic and let the pic control the mosfet. Maybe use a wall wart instead of 7805, the 7805 will probably burn up anyway.

I forgot what the relay is supposed to do..
The push buttons, alarm, lamp test, acknowledge and reset will remain there from 48V because this module will work in conjunction with the existing module and plug-in to the main controller. All we need is the alarm should be processed by the Microcontroller that should flash one second and off for one second. If the acknowledge is high, the output GP5 should remain steady high until a reset from the negative rail is pressed cutting off the negative supply.

Isn't D3 backwards? It seems that when 48v is applied D3 will be forward biased, and R6 (150 ohms?) will dissipate about 15 watts and all the magic smoke will escape. :eek: Also the relay will never pull in . . .
What is the relay's purpose? If D3 is turned around the relay will be activated any time the 48v supply is on, except when reset is pressed. :confused:
(PS. First post for me here)
Thanks in bringing out the D3, I will modify it. The relay will trigger an audible alarm outside of the circuit.

But R1 is tricky: it has to drop the voltage to 35V max, or the regulator will get more voltage than it can handle, so you have to know in advance what the current will actually be. If U1 draws its maximum operating current, then there won't be enough voltage left to generate 5V on the output (8mA through 5.6K drops 45V). I think to be conservative, R1 should be less than 5.6K. That might mean it needs t be a 1W type, but certainly not 5W.
The total current load is about 11 ma and there was no issue of heat dissipated on all components selected.
 

Thread Starter

nestbulala

Joined Dec 12, 2015
111
eetech00, thanks for your circuit, I think this is the best way to go. The only thing is that the reset should be disconnecting the power on the negative rail. The rest should be manage by the microcontroller.
 

eetech00

Joined Jun 8, 2013
3,856
Here is version with relay reset control.

I've shown the relay now driven by the Pic via an additional opto and GPIO pin. All it needs is the appropriate logic to control it.
I don't recommend interrupting the negative rail to accomplish reset.
 

Attachments

Thread Starter

nestbulala

Joined Dec 12, 2015
111
Ok eetech00, we can use the circuit on post # 16, SimpleAlm8.png but need to modify the code. When acknowledge on GP1 is high, GP5 should remain on until reset GP3 is enabled, otherwise it flashes one second on and one second off.. When lamp test GP2 is high triggers GP5 but other GPI0 should be low. I have limited knowledge on programming and I will appreciate any help you can share with on this project.
 

ErnieM

Joined Apr 24, 2011
8,377
The code for this is rather simple and straightforward. It wouldn't be the worst thing to even do it in assembler, but I would use C anyway.

What compiler will you use? Do you have any existing code you can share we can poke for you?
 
Top