1

I'm using a PIC 18F4550 to blink an LED in a breadboard through a resistor. I think the circuit is correct because a simulation with Proteus works fine.

The physical circuit doesn't work unless I hold the LED with my hand. When I release my hand it stops.

I used a typical 0.1uF ceramic decoupling capacitor between Vcc and Vdd.

now I connected the two pairs of (vcc ,ground)

What could be the cause of my problem?

enter image description here

bouqbouq
  • 583
  • 8
  • 27
  • 1
    And what makes you think that connecting both pairs of power pins is optional? – Matt Young Aug 19 '14 at 17:12
  • 1
    All power pins should be connected, also the wires from C1, C2 to Vss should be quite short. It should work when you do that, though 20MHz in a breadboard is usually not recommended. – Spehro Pefhany Aug 19 '14 at 17:13
  • @MattYoung why why I hold my hand it works??? I connected just one pair – bouqbouq Aug 19 '14 at 17:15
  • Connect both pairs. Does it work now? If not update your question. Your diagram shows a 16F877 and you mention PIC18. Which is right? – David Aug 19 '14 at 17:18
  • 1
    Related: http://electronics.stackexchange.com/questions/22662/if-a-pic-mcu-provides-multiple-vdd-vss-should-you-provide-power-to-them-all – David Aug 19 '14 at 17:22
  • @David ok sorry it's PIC18F4550, now I connectd the both pair, but still not working, I should hold by hand – bouqbouq Aug 19 '14 at 17:23
  • @MattYoung now I connected both but still not working, do you think 0.1uF capacitor is insufficient?? – bouqbouq Aug 19 '14 at 17:31
  • 1
    Makouda, I see you took away the image of your schematic because you had the wrong uC shown. Please re-post a corrected circuit, as otherwise it's nearly impossible to diagnose the problem you're having. – Dan Laks Aug 19 '14 at 17:42
  • 3
    It's a very sad day when we close questions about key basic topics as "unclear" *after* an answer has already solved - and implicitly clarified - the issues! – Chris Stratton Aug 19 '14 at 18:01
  • 2
    @ChrisStratton Check the revision history. The O.P. has removed the schematic from the post. Are we supposed to provide answers when the O.P. is pulling the rug from under our feet? That's not sad; that's irritating. – Nick Alexeev Aug 19 '14 at 18:09
  • 1
    @NickAlexeev now I explained the max, and the answer clarified everythinkg, I don't know why it's on hold – bouqbouq Aug 19 '14 at 18:18
  • 3
    @NickAlexeev - if you don't have enough information to answer, then don't. **But don't presume to tell others who may have more relevant expertise that they do not have the information they need**. Doing so merely cements the poor reputation of this site's dominant clique. – Chris Stratton Aug 19 '14 at 18:36
  • @ChrisStratton At the risk of repeating myself. My point is that you don't change the question after it has already been answered. That is inconsiderate. I'm not going to discuss this with you right here any further. If you desire to continue this discussion, we can do it in meta or in chat. – Nick Alexeev Aug 19 '14 at 18:42

1 Answers1

7

Connecting BOTH pairs of VDD/VSS is absolutely required. Connecting only one pair is not optional and may produce unpredictable results. And it's wise to put decoupling capacitors on each pair separately.

The behavior associated with the proximity to your hand may be because you left the PGM pin unconnected. If you have LVP enabled (one of the configuration bits in your code), the PIC will go into programming mode if the PGM pin is driven high. The PGM pin should be tied to ground for normal operation. But if that pin is left floating, it acts like an antenna and any nearby electrostatic force (your hand) may cause it to swing high or low. However, if you do not have LVP enabled, that is unlikely the problem.

On another note, Microchip recommends a resistor between MCLR and VDD. A 10k resistor is common.

Dan Laks
  • 8,504
  • 4
  • 27
  • 43
  • it works fine but by putting PGM down (to ground), are you sure PGM should be high (vcc) – bouqbouq Aug 19 '14 at 17:44
  • 1
    As I said in my answer, it will go into programming mode if it's driven high. So forcing it to ground, as you have now done, allows the PIC to run normally. Just remember to remove that wire when you program it or your programmer may not work. – Dan Laks Aug 19 '14 at 17:49
  • I've edited my answer to clarify the PGM should be tied to ground for normal operation. – Dan Laks Aug 19 '14 at 17:52
  • 1
    +1 Spot on! I had the same problem with the PGM pin left floating and I've been scratching my head for days over it. – m.Alin Aug 19 '14 at 19:58