My Pic16f877a has problems with power supplies

Discussion in 'General Electronics Chat' started by yuanshikai, Nov 14, 2011.

  1. yuanshikai

    Thread Starter Member

    Sep 17, 2011
    49
    0
    I made a simple voltmeter using my pic16f877a but the result was very unstable. Later, I found out that the power supply used as the source for the reference voltage of the pic was the one that was unstable. I changed my power supply but it still became very unstable. Is it possible that my pic affected the operation of power supplies connected to its Vdd?
     
  2. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Do you have a 0.1uF/100nF bypass cap between Vdd and Vss? This helps stabilize fast transients. If the power supply has larger transients, add a 47uF cap in parallel as well (reason for both is electrolytic capacitors do not respond as fast as ceramic capacitors, which are often the type 0.1uF caps are found in).

    PIC uCs don't draw much current at all, 2mA for the 16F877 at 5V and 4Mhz. Add any outputs, such as LEDs to that current draw, however. So the power supply shouldn't have been damaged, nor the PIC, unless the voltage went over 5.5V by a large margin.

    Try running the PIC from 6V (4 AA batteries) with 2 diodes in series to reduce the voltage to around 5V to see if you still have problems with the PIC.

    Make sure you are giving the PIC enough time to complete the conversion, see the intro Here .

    If unable to fully stabilize your power supply, use a precision voltage reference, there are many around, something like the Microchip MCP1541 4.096V Precision Reference would be sufficient.

    The external reference is easy to hook up, one pin to power, one to ground, third pin is 4.096V reference out, add a 0.1uF between supply and ground on the reference, and a 10uF cap between reference out and ground. The reference only provides 2mA max, but the ADC doesn't require much current.

    Use the external Vref on RA3, see page 111 of the 16F877 Datasheet for config setting details.

    The extra stuff associated with external Vref:
    1) You need to configure at least 2 ADC input pins, though you do not need to use/measure both, it will take away RA3 if you are using it as a digital output. The Vref configuration using the fewest pins is 2 ADC inputs with 1 Vref. RA0 and RA1 would be the ADC inputs, and RA3 would be the input for the 4.096V Vref output from the voltage reference, Vss is the ground reference. You can choose more analog in channels from the table on page 112 of the datasheet for config settings.

    2) You need to scale your ADC input voltage to 0-4V using a voltage divider, I'd suggest 1% resistors for the divider.
     
  3. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    You really should post a schematic of exactly how you have things wired up at the present.

    Omitting bypass capacitors will be very troublesome.

    You should have a 10nF capacitor from your ADC input pin to GND to provide a low impedance input. If you are using a voltage divider to derive your input signal, consider using an opamp as a buffer/voltage follower connected between the voltage divider and the 10nF cap on the ADC input pin. A small cap (say, 100pF) from the divider junction to GND will help to keep the junction quiet (resistors create noise; think of water hissing through a mostly closed nozzle on a garden hose). Metal film resistors are quieter and more accurate than carbon film or carbon resistors.
     
  4. yuanshikai

    Thread Starter Member

    Sep 17, 2011
    49
    0
    thanks for the replies..
     
  5. yuanshikai

    Thread Starter Member

    Sep 17, 2011
    49
    0
    btw, follow-up question, so the output of a variable regulated dc power supply can be affected by the circuit it is attached to? even though it's just supposed to perform like a dc cell in your circuit and it's value isn't supposed to change?
     
  6. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    If the load exceeds the capabilities of the regulator, certainly.

    A DC cell (like a battery) is not a regulated supply. Its voltage will change depending on the load and charge remaining.
     
  7. yuanshikai

    Thread Starter Member

    Sep 17, 2011
    49
    0
    what would be the parameters/characteristics of the load that would make it exceed the capabilities of the typical power supply?
     
  8. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    If the load is going to draw more than about 80% of the supply rating, you need a more capable supply. It is never a good thing to operate electronics at 100% of their capacity/rating.
     
  9. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Usually drawing more current than it is rated for. If you are using a 7805 without a heatsink, and drawing more than 750mA, it may overheat and fail if there isn't a lot of airflow over it. The 7805 is rated for 1.5A draw if it has a good heatsink on it.

    Shorting outputs for a small period of time can destroy a regulator, powering inductors without a protective diode to stop inductive kickback when power is removed can also cause harm.

    Can't really say unless we know what you have for a complete circuit, input voltage/current, output voltage/current of rated regulator, and voltage/current of all devices connected to the regulator output. In other words, a complete schematic diagram of what is connected to what.
     
  10. yuanshikai

    Thread Starter Member

    Sep 17, 2011
    49
    0
    sorry, i don't really know the circuit of the power supply I used. I just connected the positive of the power supply to the Vdd and MCLR of my pic and the negative to the Vss.
     
  11. yuanshikai

    Thread Starter Member

    Sep 17, 2011
    49
    0
    sorry, i don't really know the circuit of the power supply I used. I just connected the positive of the power supply to the Vdd and MCLR of my pic and the negative to the Vss. And I think the what connections i connected to the I/O pins of my pic doesn't affect it.
     
  12. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    What is the rated output voltage of your power supply, and the current rating of the power supply?

    What voltage are you measuring out of the power supply?

    To the most basic question, what is not working? Can you program the PIC? Does the ADC return a number? Does it display? Does anything overheat, etc.
     
  13. yuanshikai

    Thread Starter Member

    Sep 17, 2011
    49
    0
    the most basic question is, my power supply that's supposed to provide a steady voltage of 5V, fluctuates from like 4V to 6V. Disconnect the power supply and it works just fine.

    The power supply is rated 0-24V and 300mA.
     
  14. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    The power supply isn't regulated well, or is built to be load regulated, e.g. the output will be x volts as long as the current draw is 300mA.

    Get a switching 5V regulator, they come with phones for free and are laying everywhere in the US, though I'm not sure where you are from. Please fill in your location in your profile.

    For the 4-6V swing, the 4V reference will work if you put a big enough cap on it's supply pin, like 470uF, the PIC's ADC will be using that 4.1V Vref and you'll get stable results. Add a diode to the Vdd of the PIC so you don't go over it's voltage, or, seriously, get a good power supply. With essentially no regulation, you are likely to damage more parts cost than a small power supply will cost.

    Or, get a good power supply, 5V@500mA is all you need for most projects that don't involve motors or light bulbs (LEDs are OK, relays are at the limit).
     
  15. yuanshikai

    Thread Starter Member

    Sep 17, 2011
    49
    0
    thanks for the help..
     
Loading...