Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

ON-OFF 89S52 microcontroller

Status
Not open for further replies.

gauravkothari23

Advanced Member level 2
Joined
Mar 21, 2015
Messages
640
Helped
5
Reputation
10
Reaction score
4
Trophy points
1,298
Activity points
6,921
Hi all...
i have a small issue, have attached a circuit diagram.
in my circuit diagram, i have attached an MOSFET to turn on and off the 89S52 controller.
as per the circuit, when i press the button the MOSFET gets on and supplies the current to the controller and as the controller gets on, on the very first line of the my code, i have pulled the pin P1.0 high, which will keep the MOSFET on.
i have also tried using the hardware, but what happen is, untill and unless and i keep the button pressed the controller stays ON, and as soon as i release the button the controller gets OFF...
i have attached a LED to one of my pin to check the status of my controller.
can anybody please explain, can this of circuit be used to on and off the controller.
i cant use any rocker or a toggle switch to make the controller ON and OFF....
i want the controller to get auto OFF, so when i want my controller to get OFF, i just pull down the pin.
can anybody please help me to make this thing possible, if possible.
 

Attachments

  • CIRCUIT TEST.JPG
    CIRCUIT TEST.JPG
    84.6 KB · Views: 54

Hi,

We need voltages, exact fet type, resistors, capacitors...

when i press the button the MOSFET gets on
The button is between source and gate....so when you press the button, then V_gs is forced to zero.
But this makes a mosfet high ohmic...it surely is not "ON" in this case, it is "OFF".

What happens when you press the button is:
* the FET is OFF
* VCC is connected from battery --> pushbutton --> P1.0 --> uC internal protection diode --> uC_Vcc
* uC is running
* (accidentally programming P1.0 to LOW will cause a short circuit via not_released_button. Damage.)
* programming a HIGH causes V_gs to become near zero --> fet = OFF
* release button stops power supply

********
As far as i can see your mosfet never is ON.

Klaus
 

Hi,

We need voltages, exact fet type, resistors, capacitors...


The button is between source and gate....so when you press the button, then V_gs is forced to zero.
But this makes a mosfet high ohmic...it surely is not "ON" in this case, it is "OFF".

What happens when you press the button is:
* the FET is OFF
* VCC is connected from battery --> pushbutton --> P1.0 --> uC internal protection diode --> uC_Vcc
* uC is running
* (accidentally programming P1.0 to LOW will cause a short circuit via not_released_button. Damage.)
* programming a HIGH causes V_gs to become near zero --> fet = OFF
* release button stops power supply

********
As far as i can see your mosfet never is ON.

Klaus

Thanks Klausst...
I am sorry to say, but i forgot to say that i have added 1K resistor in between P1.0 and Mosfet Gate Pin.
but as per the diagram i have attached....
i have connected NPN MOSFET. so when gate gets high the MOSFET gets on. and thats what i am doing....
 

Hi,

i have connected NPN MOSFET. so when gate gets high the MOSFET gets on

You need positive V_GS to turn ON a N-CH mosfet.

Let´s say you need V_GS of 3V
and you have 5V at source, then you need at least 8V at the gate to turn the FET ON.....

Klaus
 

thanks klausst.... got your point....
so i hope, you exactly got what my requirement is....
so can you please let me know how can i make this of circuit using any other IC or circuit.
The thing is i just have to supply positive (+) signal just for a 10ms or more to any IC or circuit. if i do so then then circuit get on and stays till i decide to make it off.....
 

can we use optotransistor IC instead of MOSFET....
will it work
 

Hi,

you may use pushbutton circuits like:LTC2950

You may use a P-Ch MOSFET on the high side (source = battery, drain = load). Logic level threshold. It is ON when Gate = GND. need a 1M resistor or so between S & G.
Use a NPN digital transistor for uC control. E = GND, B = port , C= Mosfet_gate

***
Additionally I often use a diode form pulled_up uC_RESET_n (A) to pushbutton (K). Then the pushbutton acts as RESET as well as power_on


Klaus
 
Hi,

you may use pushbutton circuits like:LTC2950

You may use a P-Ch MOSFET on the high side (source = battery, drain = load). Logic level threshold. It is ON when Gate = GND. need a 1M resistor or so between S & G.
Use a NPN digital transistor for uC control. E = GND, B = port , C= Mosfet_gate

***
Additionally I often use a diode form pulled_up uC_RESET_n (A) to pushbutton (K). Then the pushbutton acts as RESET as well as power_on


Klaus

where in this case should i attach the push button.
one more thing i would like to ask..
can i use this type of circuit to ON and OFF the controller.
because i might ON the controller every once in a 2 hour and keep it on for just 10 minutes, and make it OFF.
i hope pulling the controller ON and OFF again and again wont damage the controller.
 

Hi,

where in this case should i attach the push button.

-->
It is ON when Gate = GND.
so connect the pushbutton between GND and gate.

*********
can i use this type of circuit to ON and OFF the controller.
* press pushbutton --> MOSFET is ON --> uC is powered
* uC sets port pin high --> digital bjt is ON --> FET_gate is GND --> FET is ON, uC is powered

to power OFF:
* uC sets port pin low --> digital bjt is OFF --> FET_gate is V_Batt (pulled up) --> FET is OFF, uC power is OFF

*********
because i might ON the controller every once in a 2 hour and keep it on for just 10 minutes, and make it OFF.
HOW do you decide to ON the controller? with the pushbutton?

If the uC is powered OFF, then obviously the uC is dead .. it can not do anything... so you need a "powered" device to switch ON the supply for the uC. This can be the "INT_N" pin or the "ALERT_n" pin of an RTC. But - as usual for an RTC - it needs to be powered.

********
i hope pulling the controller ON and OFF again and again wont damage the controller.
I can´t remember that I´ve seen in any uC datasheet a limitation of ON/OFF cycles. --> Don´t worry about that. (for sure you need to keep on all datsheet specifications)

********
Other solution:
Nowadays there are uC with very low power_down_current. Often below 1uA. So it makes no sense to switch OFF power. The uC is continously powered.

Then you may use internal periferal like "watchdog" or internal "RTC" to wake up the uC from power down.
This is my preferred solution. It needs low power. It need less part count. Small, cheap. And the best benefit: you can adjust everything with software.

for example wakeup every two hours:
if you need to be active only once in two hours, then you may use the watchdog to wake up. But usually the watchdog can´t delay for 2 hours. Then simply wake up every 2s. then use a counter and after every wakeup increment it´s value. if it is below 3600 then immediatel go to power_down. But when 3600 (=3600 x 2s = 2h) then start your application (don´t forget to reset the counter) ....

Another example for fast wakeup:
Maybe you want to build a PC_mouse and need to detect if somebody moves it. Then maybe wake up every 10ms... check if the position has changed .. and - if not changed - goto sleep/power_down.

Klaus
 
Hi,



--> so connect the pushbutton between GND and gate.

*********

* press pushbutton --> MOSFET is ON --> uC is powered
* uC sets port pin high --> digital bjt is ON --> FET_gate is GND --> FET is ON, uC is powered

to power OFF:
* uC sets port pin low --> digital bjt is OFF --> FET_gate is V_Batt (pulled up) --> FET is OFF, uC power is OFF

*********

HOW do you decide to ON the controller? with the pushbutton?

If the uC is powered OFF, then obviously the uC is dead .. it can not do anything... so you need a "powered" device to switch ON the supply for the uC. This can be the "INT_N" pin or the "ALERT_n" pin of an RTC. But - as usual for an RTC - it needs to be powered.

********

I can´t remember that I´ve seen in any uC datasheet a limitation of ON/OFF cycles. --> Don´t worry about that. (for sure you need to keep on all datsheet specifications)

********
Other solution:
Nowadays there are uC with very low power_down_current. Often below 1uA. So it makes no sense to switch OFF power. The uC is continously powered.

Then you may use internal periferal like "watchdog" or internal "RTC" to wake up the uC from power down.
This is my preferred solution. It needs low power. It need less part count. Small, cheap. And the best benefit: you can adjust everything with software.

for example wakeup every two hours:
if you need to be active only once in two hours, then you may use the watchdog to wake up. But usually the watchdog can´t delay for 2 hours. Then simply wake up every 2s. then use a counter and after every wakeup increment it´s value. if it is below 3600 then immediatel go to power_down. But when 3600 (=3600 x 2s = 2h) then start your application (don´t forget to reset the counter) ....

Another example for fast wakeup:
Maybe you want to build a PC_mouse and need to detect if somebody moves it. Then maybe wake up every 10ms... check if the position has changed .. and - if not changed - goto sleep/power_down.

Klaus

Thanks Klausst....
got it...
i have made a circuit diagram.... just attaching it....
ONOFF CIRCUIT.jpg

- - - Updated - - -

please let me know if the things are correct
 

Hi,

seems to be correct.

If you use a 10nF capacitor in parallel with the pushbutton, then it will power the uC every time you connect the battery = automatic start after battery change.
Additionally it make that the uC is powered for some ms after releasing the pushbutton, so the uC has plenty of time to initialize and set P1.0 = high.

Btw: You need bulk capacitor and fast decouple capacitors in any case at uC_VCC.

Klaus
 
Hi Klausst....
Thanks a Lot... You made my day....
Things are working Perfect.... Initially it was not working, but i added an pull up resistor at P1.0 it worked perfectly....
but i am not able to low the port pin to off the circuit.
so can i add a transistor BC547 to port pin to make the transistor 2N-3904 BASE pin high and low.....
BC-547 BASE = PORT 1.0
BC-547 EMITTER = 2N3904 BASE
BC-547 COLLECTOR = VCC
can i do this...????
 

Hi,

it depends on your Port1.0 output driving capabilities.

Please tell us the specifications for
* driving low (voltage and current)
* driving high (voltage and current)

A pullup at P1.0 makes the circuit to ON at default. At least many uC have high-Z outputs during reset.
I personally avoid this. But maybe you like this.

Klaus
 

Hi,

it depends on your Port1.0 output driving capabilities.

Please tell us the specifications for
* driving low (voltage and current)
* driving high (voltage and current)

A pullup at P1.0 makes the circuit to ON at default. At least many uC have high-Z outputs during reset.
I personally avoid this. But maybe you like this.

Klaus
sorry did'nt get your point....
i am driving the circuit at 5v
i added pullup to just check it out if the circuit is working perfect...
what i need now is i want to off the circuit using the software... for eg. making the port pin low will off the circuit..

- - - Updated - - -

sorry did'nt get your point....
i am driving the circuit at 5v
i added pullup to just check it out if the circuit is working perfect...
what i need now is i want to off the circuit using the software... for eg. making the port pin low will off the circuit..

how can i lower the pin using software.....
i have even tried using P3.7, 3.6, but non of them work
 

Hi,

to know what happens and to find a sloution ... either you or me has to read the microcontroller´s datasheet.

As I´m not working with the 89S52, I recommend you to read the datasheet. ;-)

Especially I/O specificatons:
I_OL (current output low)
I_OH
U_OL
U_OH
..and the given test conditions.

Klaus

added:
i am driving the circuit at 5v
I assume you mean VCC = 5V
...but this does not mean P1.0 high voltage is 5V, too. And it does not mean P1.0 output low voltage is 0.00V --> datasheet will tell you
 

Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output buffers can
sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the internal
pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low
will source current (IIL) because of the internal pull-ups.
In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count input
(P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX),

This is the only thing written for port1 in datasheet...
as it is written in datasheet....
"
When 1s are written to Port 1 pins, they are pulled high by the internal
pull-ups and can be used as inputs."
Then too its not getting high....
 

Hi,

"internal pullups" --> they will be specified

and you really say that nothing about "I_OL, I_OH, U_OL, U_OH" is given. I can´t believe.


So I opened your datasheet:
(and that´s what I expected !!!)
All specifications are given under "27. DC Characteristics"

We´re not here to read your datasheets!

I´m back tomorrow.

Klaus
 

The output signal polarity (default P1.0 high level is activating the power) might re-enable the power supply during switch-off. You should change the circuit to use active low level for power on. A NPN in common base circuit can be used as non-inverting level translator.
 

The output signal polarity (default P1.0 high level is activating the power) might re-enable the power supply during switch-off. You should change the circuit to use active low level for power on. A NPN in common base circuit can be used as non-inverting level translator.

Sorry FVM.... did not got what you meant to you....

- - - Updated - - -

Hi,

"internal pullups" --> they will be specified

and you really say that nothing about "I_OL, I_OH, U_OL, U_OH" is given. I can´t believe.


So I opened your datasheet:
(and that´s what I expected !!!)
All specifications are given under "27. DC Characteristics"

We´re not here to read your datasheets!

I´m back tomorrow.

Klaus

Sorry Klausst.....
i think it was a code error....
now i can ON the circuit using your ideas and can OFF it using the software...
i am extremely sorry klausst...
and thank you again klausst and FVM...
i pulled the port pin low inside a while loop... so now its working perfect...
 

hi ALL...
i again have a small problem...
the thing is this circuit works perfect with 89S52, but when i try using the same with other controller like SST89E516RD2, i am not able to swtich off the circuit... infact the circuit resets at the time when i give command to low the pin. i have checked that when the pin is low the voltage shown on the pin is still 2V becuase of pull up resistor 10K., but i remove the pull up resistor i am not able to on the circuit, the circuit stays on only till the button is pressed. if i release the button the circuit goes off i i dont attach pullup resistor to pin.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top