ON/OFF button for PIC16f877a (ambiguity)


Closed Thread
Results 1 to 12 of 12
  1. #1
    Join Date
    Aug 2012
    Posts
    6

    Default ON/OFF button for PIC16f877a (ambiguity)

    Hi, I'm very new to microcontrollers and i need an ON/OFF button for my sphygmomanometer project to turn it off and on and i don't know if i did the wiring of the pic the right way or not ?
    Name:  Sans titre.JPG
Views: 2602
Size:  15.6 KB

    if it's correct, does turning ON & OFF the pic (the way i wired it) could make any firmware glitches or some other problems ? , i'm using pic16f877a ..
    i'm new at this so please bear with me (and excuse my poor english,it's not my native language).. any help at all would be much appreciated, thanks in advance

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: ON/OFF button for PIC16f877a (ambiguity)

    EDIT: Double post, sorry.
    Last edited by HenrikOlsson; - 22nd August 2012 at 07:50. Reason: Double post.

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: ON/OFF button for PIC16f877a (ambiguity)

    Hi,
    If all you want is a simple on/off, like a toggle switch or something, then you should wire it in series with Vdd. Always remember to put a decoupling capacitor from Vdd to Vss/GND on each of the Vdd pins, 100nF or something (it's not critical). The MCLR pin is the reset pin, when pulled low it will reset the PIC but it does not turn it off. If you want a "restart button" then pull MCLR high thru a resistor and put the switch between MCLR and Vss/GND.

    EDIT: Ooops, apparently I'm not awake yet, you have it wired properly, just remember the decoupling caps.

    /Henrik.

  4. #4
    Join Date
    Aug 2012
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: ON/OFF button for PIC16f877a (ambiguity)

    thank you very much for your reply, i posted the same question in an other forum and a member replied :
    You may have corrected your diagram. What I see with a 1:26pm time on it looks like a correct on/off switch. When the switch is closed and stays closed, the microcontroller turns on and goes through a reset cycle. When the switch is opened, the microcontroller immediately turns off no matter what it's doing. Like most switches, your on/off switch probably bounces a bit. Usually the reset cycle takes a little time, often more than the bounces, so this bouncing may not affect the microcontroller. When the switch is turned off, the switch will also be bouncing, but the microcontroller will be trying to complete a reset cycle and will not likely complete that before the switch stops bouncing.

    If you have sensors attached to your microcontroller and these are not running off the microcontroller Vdd / Vss lines, you can damage the microcontroller if the sensors are powered when the microcontroller is not powered.

    This sort of thing applies to any microcontroller including the Stamps and the Propeller. The Stamp module has a filter capacitor across the Vdd / Vss power lines which would avoid the bouncing issue.
    i do have an MPX2050 piezoresistive pressure sensor (supplied 10V) attached to the MCU through some AOPs (supplied 5V each) the AD620 and OPA2277.. could that make a problem ? considering the way i wired the ON/OFF switch ?

    and also a 6v electro-valve ?! should i make any changes ?.. thank you so much in advance
    Name:  Sans titre2.JPG
Views: 2732
Size:  29.8 KB
    Name:  Sans titre1.JPG
Views: 3333
Size:  41.4 KB

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: ON/OFF button for PIC16f877a (ambiguity)

    Hi,
    When there's no power applied to the Vdd rail of the uC driving its pins may result in the protective diode between the input and Vdd to conduct and start "feeding" the uC internally so to speak. You have 64k in series with that possible "feed" so it's unlikely it will actually work but it might try to start up and that can perhaps make it do some weird things. I'd proably turn off power to any circuitry that's interfaces TO the uC as well as the uC itself.

    EDIT: On a second look I see that you have the output the AD620 directly connected to a pin on the uC, if it can supply enough current then you could be in trouble.

    /Henrik.
    Last edited by HenrikOlsson; - 22nd August 2012 at 18:36.

  6. #6
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: ON/OFF button for PIC16f877a (ambiguity)

    To expand on what Henrik said, you could be in trouble at any time, not just during power up. The ADCO signal needs examination, and could possibly need some resistance and protection diodes.

    Is there still more to the circuit you are not showing? Where does the power come from and what are those circuits?

  7. #7
    Join Date
    Aug 2012
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: ON/OFF button for PIC16f877a (ambiguity)

    Thank you gentlemen for your replies, much appreciated ..
    That's the whole thing that i've attached ( Conditioning Circuit "Amplification + filtering .." and the Command Circuit "Motor + electrovalve .." )
    besides the LCD and MMC interfacing circuits ..

    Name:  Sans titre3.JPG
Views: 8609
Size:  54.5 KB

    i'm still working on the LCD interface with the mcu .. mainly i'm going to wire :

    - the "Enable" LCD pin to the pic pin 30 (RD7/PSP7)
    - the "Register Select" LCD pin to pic pin 29 (RD6/PSP6)
    - the LCD's Data pins (DB0,DB1,DB2, ... DB7) to the pic's (pin 33,pin34,pin35,...pin40) in order (which represent RB0 to RB7)
    - and of course Read/Write to the GND & Contrast Adjustment to a Potentiometer

    - do you think i should do some changes in any of the circuits ??
    - should i add a current limiting resistors or some protection diodes to the ADC0 & ADC1 ?? if so what's the right way to wire the protection diodes into the existing circuit ?

    Thank you again for your help ..
    Last edited by irilias; - 23rd August 2012 at 17:44.

  8. #8
    Join Date
    Aug 2012
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: ON/OFF button for PIC16f877a (ambiguity)

    Thank you gentlemen for your replies, much appreciated ..

    That's the whole thing that i've attached ( Conditioning Circuit "Amplification + Filtration ..." plus the Command Circuit "Motor + electrovalve" .. )
    besides the LCD & MMC interfacing circuits ....
    Name:  Sans titre3.JPG
Views: 2823
Size:  54.5 KB
    i'm still working on the LCD interface with the MCU but mainly i'm going to wire :

    - the "Enable" LCD pin to the pic pin 30 (RD7/PSP7)
    - the "Register Select" LCD pin to pic pin 29 (RD6/PSP6)
    - the LCD's Data pins (DB0,DB1,DB2, ... DB7) to the pic's (pin 33,pin34,pin35,...pin40) in order (which represent RB0 to RB7)
    - and of course the Write/Read pin to the GND & the Contrast Adjustment to a Potentiometer .. .

    - do you think i should do any changes to any of the circuits ?
    - should i add some current limiting resistors and/or protection diodes to ADC0 & ADC1 ? if so, how can i wire the protection diodes the right way into the existing circuit ?

    Thank You again for your help ..

  9. #9
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: ON/OFF button for PIC16f877a (ambiguity)

    Hi,
    Is the analog input circuitry, ie the sensor and filter etc powered by an external source or does your circuit supply power to it as well? I ask because it would be much easier for you to just simply switch the power to the whole circuit instead of just the microcontroller but I suspect there must be a reason for not doing that?

    If you do need to have the analog circuitry powered and just power down the uC (can't think of a good reason for that if the analog circuitry isn't connected to something else as well) then I don't see an easy way to prevent current going into the input and possibly forward bias the the protective diode on the input thus basically supplying the Vdd rail of the uC - except electrically disconnecting (think relay etc) the output of the analog circuitry from the input on the uC. Instead of powering the uC down completetly you could perhaps just pull the MCLR low or put it to sleep.

    Again, I'm not saying you WILL have a problem doing it the way you have it but you MIGHT.

    The LCD connections sounds allright, just DEFINE them properly in PBP if you're going to use LCDOUT. You could ofcourse use 4-bit mode instead of 8-bit if you're running short on pins.

    /Henrik.

  10. #10
    Join Date
    Aug 2012
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: ON/OFF button for PIC16f877a (ambiguity)

    sorry i couldn't edit my previous post .. i just forgot to mention that i'm thinking of using an ATX power supply to power the whole project .. and turn it ON/OFF as needed from the back (switch behind the power supply)

  11. #11
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: ON/OFF button for PIC16f877a (ambiguity)

    Last time I checked, ATX supplies do not have 10V.
    If you don't have any need for the pressure sensor to be on without the microcontroller being on as well, then derive the 5V for the microcontroller from the 10V supply in the same way you've derived the 3V from the 5V.

  12. #12
    Join Date
    Aug 2012
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: ON/OFF button for PIC16f877a (ambiguity)

    i was thinking of tweaking the ATX a little bit ... anyway you're idea sounds way better.
    my project needs at least 27 Watts to function properly that's why i thought of using the ATX at first because it already delivers more than enough power for my project ..
    ( and besides it has over-current protection, under-voltage protection, and short circuit protection ... )
    Last edited by irilias; - 24th August 2012 at 15:06.

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts