1. 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.
    Dismiss Notice

Breadboard and my microcontroller.

Discussion in 'Microcontrollers' started by danielsmusic, Dec 10, 2008.

  1. danielsmusic

    danielsmusic New Member

    Joined:
    Jul 24, 2005
    Messages:
    458
    Likes:
    0
    Location:
    cheshire
    Is this a bad idea? I've noticed my PIC16F877A is pulling a lot of current, voltage regulator is struggling to say the least (It's a LM7805). The PIC is driving an 8 bit shift register which is connected to LEDs through a 100ohm resistor.

    The output pin is right next to a power pin (Can't remember which one). Assuming the rails are acting as 2nF capacitor and my PIC is driving the shift register at 4Mhz would this mean the "resistance" between the output pin and the power pin to be 0.02Ohms?
    Would this be why it is pulling so much current? I've checked for short circuits and found nothing.
    (Xc = 1/(2*PI*F*C))
    (0.02 = 1/(2*3.141*4000000*0.000002))
     
  2. blueroomelectronics

    blueroomelectronics Well-Known Member

    Joined:
    Jan 21, 2007
    Messages:
    12,536
    Likes:
    170
    Location:
    Toronto, Canada
    How much current is it drawing?
     
  3. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,331
    Likes:
    653
    Location:
    Derbyshire, UK
    If a PIC is pulling a lot of current, then you've wired it wrong - I don't like breadboards, but there's no such problems as you suggest.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA

    About building uC circuits.

    When I build a uC circuit I do it in stages. It makes debugging much easier.

    First I build the regulator section and check to see that it is working.

    Next I add the programming header (ICSP), processor, crystal, and caps. If all goes well the processor can be programmed and will run programs.

    Next I add whatever other hardware is on the PCB in groups based on function. Each group is tested.


    A smaller regulator will force less current through a badly wired circuit. I like to use a 100ma output regulator which is enough for many circuits. Some have reverse voltage and short circuit protection too.
     
  6. danielsmusic

    danielsmusic New Member

    Joined:
    Jul 24, 2005
    Messages:
    458
    Likes:
    0
    Location:
    cheshire
    I've checked the circuit and it's all wired correctly. Whenever I do anything high speed, it starts pulling a lot of current and fails. The regulator is 1A and it gets warm. It seems to be pulling >250mA.
     
  7. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,331
    Likes:
    653
    Location:
    Derbyshire, UK
    Are you measuring the current the PIC is taking, or the entire circuit?.

    Bear in mind your 8 LED's will be taking about 250mA.
     
  8. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    he never said how many LEDs he has. Just that they are connected to the shift register. Also what type of leds?

    Try to use instead of the 100 OHM resistors 220-330 ohm resistors.

    Now since you are using a LM7805 what is the input(supply) voltage to that? What is the wall adapter rated @?

    EDIT:
    @ 5v using 100 ohm resistors. If all is on then it would take about 400mA for all 8 LEDs. (if my math is right)
     
    Last edited: Dec 10, 2008
  9. theo92

    theo92 New Member

    Joined:
    Aug 1, 2008
    Messages:
    177
    Likes:
    0
    Location:
    WB, India
    I think, It's better to use 330 ohm for the LEDs.
    is the LEDs are quite different from standard? ie high lumens, ulrabright etc.
    are the all LEDs glow at a same time or one by one?
    try using 78L05 instead of 7805...
    I never saw such problem though, with breadboard. My first preference is breadboard for prototyping everything except VHF and high gain preamp projects.check for any faulty capacitors too
     
  10. kchriste

    kchriste New Member Forum Supporter

    Joined:
    Jul 23, 2006
    Messages:
    3,677
    Likes:
    47
    Location:
    Victoria BC, Canada
    What else gets warm? Does the PIC get warm?
    As already mentioned, the high current draw probably is coming from the LEDs and not the PIC.
    How would using a regulator rated for less current and power dissipation help?
     
  11. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,331
    Likes:
    653
    Location:
    Derbyshire, UK
    No it's not, because you forgot the voltage drop of the LED's :D
     
  12. danielsmusic

    danielsmusic New Member

    Joined:
    Jul 24, 2005
    Messages:
    458
    Likes:
    0
    Location:
    cheshire
    It seems to be the LEDs, yes. I definitely underestimated their current draw. There is some very strange behaviour from the PIC though. I can use my shift-register to flash 1 LED on and off, but after 4 flashes it just stops. If I put an LED straight from an output on the PIC, I can make it flash and it doesn't stop. Just when I use the shift register.

    EDIT: It is definitely not the code.
     
    Last edited: Dec 10, 2008
  13. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    i knew that lol... (i just forget things :D)

    So that a typical 1.2vdrop - 1.5vdrop / 100 Ohms * 8 = 304mA - 280mA.

    You have to factor in the Wall Adapter tho. What if its giving only 9v @ 200mA. Dont think it would work well. Also if its giving too much Voltage then it can be harming the 7805 also if the current coming in isnt enough then its stressing everything.
     
  14. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    care to show the shift code used to flash it?
     
  15. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,331
    Likes:
    653
    Location:
    Derbyshire, UK
    I wouldn't be that sure - I would suspect it almost certainly is the code - in that you're not feeding the shift register correctly.

    But, as always, post the circuit you're using (and the code) - so we can see how you've connected it up, and if you've included all the required components.
     
  16. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    Atomsoft has a point.
    How much output current is the wall adaptor rated for ?
    Does the regulator still provide 5V when it is too hot?
     
    Last edited: Dec 10, 2008
  17. danielsmusic

    danielsmusic New Member

    Joined:
    Jul 24, 2005
    Messages:
    458
    Likes:
    0
    Location:
    cheshire
    I'm not using a wall adapter, I'm using a battery (7AH sealed lead acid).

    Code (text):

    #include <system.h>
    #pragma DATA _CONFIG, _CP_OFF & _LVP_OFF & _BODEN_OFF & _PWRTE_OFF & _WDT_OFF & _XT_OSC


    void test(unsigned char data) //stolen from a website, I can't remember where now
    {
       unsigned char bits;
       for (bits=0x80; bits != 0; bits >>= 1)
       {
          if ((bits & data) == bits)  
          {    
              set_bit(portb,0);
          }
          else
          {
             clear_bit(portb, 0);
          }
          set_bit(portb, 1);  
          clear_bit(portb, 1);
       }
       set_bit(portb, 2);        
        clear_bit(portb, 2);
    }

    void main()
    {
        trisb = 0;
        portb = 0;
        unsigned char f = 0;
       
        while(1)
        {
            toggle_bit(f, 5);
            test(f);
            delay_s(1);
        }
    }

     
    [​IMG]
     
    Last edited: Dec 10, 2008
  18. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    try:
    Code (text):

    void test(unsigned char data) //stolen from a website, I can't remember where now
    {
       unsigned char x;
       for (x=0;x<8;x++)
       {
          if (data & 0x80) != 0)
              set_bit(portb,0);
          else
             clear_bit(portb, 0);

          set_bit(portb, 1);
          clear_bit(portb, 1);\

          data=data<<1;
       }
       set_bit(portb, 2);        
       clear_bit(portb, 2);
    }
     
     
    Last edited: Dec 10, 2008
  19. danielsmusic

    danielsmusic New Member

    Joined:
    Jul 24, 2005
    Messages:
    458
    Likes:
    0
    Location:
    cheshire
    That would not work because you're only testing the 8th bit. The function I have works fine, I have tested all the LEDs in different combinations.
     
  20. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    forgot the shift i see :D I fixed tho..

    So since it works fine whats the issue.
     
    Last edited: Dec 10, 2008
  21. kchriste

    kchriste New Member Forum Supporter

    Joined:
    Jul 23, 2006
    Messages:
    3,677
    Likes:
    47
    Location:
    Victoria BC, Canada
    danielsmusic,
    You need at least 0.33uF on the input and 0.1uF on the output of the 7805 or it may become unstable. Put them as close as possible to the 7805. You should also have a 0.1uF close to the PICs power pins.
     
    Last edited: Dec 10, 2008

Share This Page