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.

Power detector using 8051 microcontroller

Status
Not open for further replies.
Can you give us a more detailed description of what you mean by detecting power?
 
Crystal ball says, Your trying to detect the presence of AC. My crystal ball has a crack in it, so I'm not really sure. It also can't seem to figure out what the mains voltage is either for some reason.
 
A pinch of ochre dust, bone powder from a blind rat, some ancient amber grindings and verdigris for potency then using a flame from magnesium shavings......we have:

Connect the output of the optocoupler transistor, emitter to 8051 ground, collector to a 10K pull up to the 8051 VCC. Then collector to 8051 digital input pin to read hi/lo logic.

Supply the LED of the optocoupler with a resistor of sufficient value to limit the current thru the LED to about 10mA based on your supply voltage. Include a diode rectifier and a subsequent 100uF capacitor (of sufficient voltage rating) if you're dealing with A.C.

Now when power is on...8051 in sees a logic low, when power is off 8051 sees a logic high.
Be aware of the risks of line power (A.C.) if you're dealing with it.
 
If you are talking about a power meter, then you need an ADC and a transformer... The transformer connects to the AC and will give you an accurate voltage representation... Then you need a current transformer... Loads of these around the net.... One here?? For instance..

If you are making a power cable detector then Read this!!!
 
Actually I am making a real time project and I want to know how to detect power in microcontroller.
So you want to know how much power the micro controller is using??
 
Is not the ans.
I think u cant understand my ques...
suppose u have a frequency 50Hz, after 20ms there is no power at diode input then my optocoupler detect that their is power cut but actually power is not cut... How can I detect actually power is cut.
 
Did you understand my question
Not really!

I don't know what the "power" is doing!! I don't know what the "diode" input is!! I don't know if the same "power" is supplying the micro....

I think a basic sketch of what is required may help!
 
Is not the ans.
I think u cant understand my ques...
suppose u have a frequency 50Hz, after 20ms there is no power at diode input then my optocoupler detect that their is power cut but actually power is not cut... How can I detect actually power is cut.
These words can be interpreted in dozens of ways. A micro, an octocoupler and a diode, that's all I understood. And you said something about power and AC. Mains power monitor via microcontroller, no?

Draw a hand sketch of you circuit, take a photo, put it in attachment and the confusion will disappear!
 
Is not the ans.
I think u cant understand my ques...
suppose u have a frequency 50Hz, after 20ms there is no power at diode input then my optocoupler detect that their is power cut but actually power is not cut... How can I detect actually power is cut.

Hi,

It sounds like all you want to do is detect the "voltage" not the power. The voltage to the uC chip.

If so, then your description sounds strange because normally you would have a filtered and regulated power source to power the uC chip with, and that would not go to zero just because the line frequency happens to go through zero every 1/2 cycle.
If you do it that way however, then you need to use another rectifier and filter cap to filter the power to the chip and then measure that with the opto coupler. That will tell you for sure if the power is lost to the chip. To filter it digitally, set a timer to time the amount of time it is seeing an 'off' condition. If it stays 'off' for more than say 50ms without coming back 'on' then it is off for good. If it comes back on within that time frame, then start the timer counter over again.
 
However, this input is for a circuit with separate power source. I don't know if she wants a circuit with it's own power supply, or something which is powered by mains. It could be done one thing: it can be connected to the mains a battery charger circuit that charges a battery, which is the power supply of the circuit. When the mains drops, the circuit will operate for a long period of time until the mains recovers.


I ''researched'' a bit the 8051 microcontroller and, seriously, such a B.I.G microcontroller for such a simple thing?? Or this circuit has additonnal features?
 
Last edited:
...suppose u have a frequency 50Hz, after 20ms there is no power at diode input then my optocoupler detect that their is power cut but actually power is not cut... How can I detect actually power is cut.

If you are sampling the voltage on the output side of the opto-coupler using the ADC, you time-average the voltage over an interval longer than 20ms. {Software: V(ave) < trip point}

If the output of the opto-coupler is interpreted as a logic signal, then you start timing on any rising edge. If another edge doesn't happen within ~25ms, you conclude that the AC went off. (Software retriggerable one-shot multivibrator).
 
Hi,

It sounds like all you want to do is detect the "voltage" not the power. The voltage to the uC chip.

If so, then your description sounds strange because normally you would have a filtered and regulated power source to power the uC chip with, and that would not go to zero just because the line frequency happens to go through zero every 1/2 cycle.
If you do it that way however, then you need to use another rectifier and filter cap to filter the power to the chip and then measure that with the opto coupler. That will tell you for sure if the power is lost to the chip. To filter it digitally, set a timer to time the amount of time it is seeing an 'off' condition. If it stays 'off' for more than say 50ms without coming back 'on' then it is off for good. If it comes back on within that time frame, then start the timer counter over again.
can u please send me ur circuit
 
Hi,

So you need a circuit not a piece of software then?
It isnt perfectly clear what you are tying to do here because your short descriptions are not good enough to describe what you want to do. Try explaining this in detail, not just one or two short sentences. I am sure that will help clear this up quick. If your English isnt good enough try to get someone to help you write it out.

If you want to do it with a circuit then you have to have an alternate means to detect voltage levels. Probably a comparator and voltage reference. If the voltage falls lower than a certain level then an LED comes on or something.
 
Status
Not open for further replies.

Latest threads

Back
Top