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
    I moved the crystal a lot closer to the PIC and removed the wires connecting it. Although this did not change anything. The PIC still will not work if I don't put some sort of load on any of the pins and hold it high. I still cannot put capacitors in the circuit or it stops working. I checked for any short circuits with my multimeter and it is ok. I changed the LEDs and resistors to lower the current drawn from them. Nothing is helping :(

    I do have normal insulated wire, but I don't use it on breadboards. It is messy, tinned wire does the job perfectly. The circuit works as it is, but without capacitors and I need to hold a pin high.
     
  2. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi daniel,
    Unless I am going cross eyed, looking at your circuit and project board you have the wrong pins for power and the crystal.:confused:

    It is a 16F877A.?
    xtal should be 13 and 14

    Power is 12 and 11.?
     

    Attached Files:

    Last edited: Dec 12, 2008
  3. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    yeah even the schematic has it wrong and how about a 22k resistor to MCLR?

    ericgibbs: to help your claim:

    [​IMG]
     

    Attached Files:

    Last edited: Dec 12, 2008
  4. dave

    Dave New Member

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


     
  5. danielsmusic

    danielsmusic New Member

    Joined:
    Jul 24, 2005
    Messages:
    458
    Likes:
    0
    Location:
    cheshire

    Yes! You guys are right! Thanks for spotting that, I feel quite stupid now. Now it works with caps. Although, it is still unstable. For some reason it speeds up and slows down, I think this is to do with the current drawn.

    Does there have to be a resistor to MCLR? Can't I just connect it directly to VDD?
     
  6. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    You need to pay attention to the datasheets.

    The 20K (or so) resistor is used to tie mclr to VDD is a pull up resistor. If you tie VCLR direct to +5 your programmer will not be able to lower it to gnd or raise it to VPP. Use the resistor.

    Why do you have a zif socket. Are you not using ICSP?

    I do not think the PIC speed changes in relation to current draw. Triple check the wiring.
     
    Last edited: Dec 12, 2008
  7. danielsmusic

    danielsmusic New Member

    Joined:
    Jul 24, 2005
    Messages:
    458
    Likes:
    0
    Location:
    cheshire
    At the moment, I don't need to use MCLR. I never got round to wiring ICSP at the moment, I want to have a working PIC before I start doing stuff like that.

    YouTube - PIC Acting strange

    Code used:
    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 think it was AtomSoft
    {
       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, 3);  
          clear_bit(portb, 3);
       }
       set_bit(portb, 7);        
        clear_bit(portb, 7);
    }

    void main()
    {
        trisa = 0;
        trisb = 0;
        trisc = 0;
        trisd = 0;
        trise = 0;

        portb = 0;
        unsigned char f = 0;
        int i = 0;
        while(1)
        {
            for(i = 0; i < 8; i++)
            {
                toggle_bit(f, i);
                test(f);
                delay_s(1);
            }
            delay_s(1);
            for(i = 7; i >= 0; i--)
            {
                toggle_bit(f, i);
                test(f);
                delay_s(1);
            }  
            delay_s(1);
        }
    }
     
    EDIT: I'm not sure why delay_s doesn't work properly, it may even be the cause of the problem. I wouldn't expect it to change, even if it doesn't time it right.
     
    Last edited: Dec 12, 2008
  8. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    If your having problems and think its on current drawn it may be those wires. Use the coated ones. Im not sure who i learned it from i think it was either Pommie, 3v0 or Futz. They have a really clean look to there stuff and i though or learned a clean breadboard is easy to do. Just takes longer on big projects
     
  9. danielsmusic

    danielsmusic New Member

    Joined:
    Jul 24, 2005
    Messages:
    458
    Likes:
    0
    Location:
    cheshire
    If a smaller current on the PIC doesn't slow it down, then I guess it's not current drawn but another problem. It seems to be after a few seconds running that it goes unstable. Nothing gets hot any more, not even the regulator.
     
  10. danielsmusic

    danielsmusic New Member

    Joined:
    Jul 24, 2005
    Messages:
    458
    Likes:
    0
    Location:
    cheshire
    It looks like it wasn't working because of a bad connection on the crystal, it seems to be stable now.

    Thanks for all your patience and help everyone :)
     
  11. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    evon tho i didnt help really ... your welcome :D
     
  12. danielsmusic

    danielsmusic New Member

    Joined:
    Jul 24, 2005
    Messages:
    458
    Likes:
    0
    Location:
    cheshire
    Oh dear, I'm having problems again :(

    It seems the crystal oscillator isn't oscillating at all and leaving the CLKIN and CLKOUT pins floating. This can be proved by completely removing the crystal, nothing changes. Is there any common causes to this? I will create and post a schematic/picture if needed.


    EDIT: I'm wondering if it's worthwhile soldering it all to strip board? I think the problem may lie with the resistance of the breadboard.
     
    Last edited: Dec 13, 2008
  13. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    If you have working with the code you may have changed the line
    #pragma DATA _CONFIG, _CP_OFF & _LVP_OFF & _BODEN_OFF & _PWRTE_OFF & _WDT_OFF & _XT_OSC

    Such that the _XT_OSC is missing ?

    What where you doing when it quit. Or what did you do to make it not work?
     
  14. danielsmusic

    danielsmusic New Member

    Joined:
    Jul 24, 2005
    Messages:
    458
    Likes:
    0
    Location:
    cheshire
    I think it's bad connections on the breadboard, or maybe the crystal. I jammed the crystal in the ZIF socket and it worked for a moment, but not for long.
    I have checked and rechecked as much as I could, I have checked the code, pins etc.

    EDIT: I have cascaded the 74HC595 to drive a LED matrix. It does draw the intended output, be the scanning is clearly visible and sometimes even very slow.
     
    Last edited: Dec 13, 2008
  15. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    The first thing I would do is to get rid of the ZIF socket and add an ICSP connector so you can do ICSP programming. I think you will find that the socket is just one more place for bad connections.

    What are you using for a programmer ? What does the ICSP connector look like.
     
    Last edited: Dec 13, 2008
  16. futz

    futz Active Member

    Joined:
    Sep 15, 2007
    Messages:
    2,043
    Likes:
    24
    Location:
    Vancouver, B.C.
    What resistance? The breadboard capacitance myth is crapola too. Unless your breadboard is old worn out junk (or new junk :p), it's not that. Good quality breadboards work fine.

    If I were you I would definitely stop using bare wires immediately. And get rid of the alligator clips too. They're flaky as hell. You're just asking for problems doing that. Use either commercial breadboard wires or make your own from 22AWG phone wire or similar. Probably half the wires on the breadboard below are phone wire. I get mine from construction sites. Electricians throw enough scraps away to keep me and everyone else in breadboard wires forever. :D
    [​IMG]
     
    Last edited: Dec 13, 2008
  17. futz

    futz Active Member

    Joined:
    Sep 15, 2007
    Messages:
    2,043
    Likes:
    24
    Location:
    Vancouver, B.C.
    One more HUGE vote for getting rid of the silly ZIF and going with ICSP. It's the only way to get anything done.

    ZIFs are for when you need to quickly program a batch of chips with the same program, for very small production runs. They're not suited for learning and experimentation, as moving the chip back and forth is too slow and tedious.

    ICSP is quick and easy. None of that constantly moving the chip back and forth from socket to socket nonsense. Just hit a few keys or click a few mouse clicks and the chip is reprogrammed. AND you can debug it in-circuit properly when you do ICSP. You can't debug a circuit when its chip is in the programmer's ZIF socket.

    EDIT: In the photo above, my ICSP connector is at the upper left of the breadboard. I use 2x5 IDC because they're very solid. 1x5 is too wobbly.

    Here's a photo of a nice solid ICSP programming/debugging setup in action:
    [​IMG]
     
    Last edited: Dec 13, 2008
  18. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    nice and neat Futz! Can you send me a link to where you get those beautiful buttons. Please. I made so many things better for prototyping. Like buttons , oscillators and many others like pots etc... by adding or modding the pins and making them headers ... they stick off the board slightly but 100% sturdy and safe and easy to plug in play :D
     
    Last edited: Dec 13, 2008
  19. futz

    futz Active Member

    Joined:
    Sep 15, 2007
    Messages:
    2,043
    Likes:
    24
    Location:
    Vancouver, B.C.
    I'm not sure where I got them. I think it was BG Micro, but they have standard tact switches under that part number now. The ones I have have kind of strange rubbery tops and have thinner legs that fit the breadboard perfectly.
     
  20. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi,
    The problem I have found with most ZIF sockets is the shortish pin length, they are not designed to be plugged into project boards.

    As 3v0 has said, for starters get rid of the ZIF socket from the project board and plug the PIC directly into the board.

    To remove the PIC, use a small [5 inch] screwdriver and carefully lift/lever one end partly out, then the other end of the PIC.
     
  21. danielsmusic

    danielsmusic New Member

    Joined:
    Jul 24, 2005
    Messages:
    458
    Likes:
    0
    Location:
    cheshire
    After more testing, I think the problem lies with the other circuitry my PIC is driving, not the PIC itself. I have (neatly) soldered the PIC onto strip board with crystal and decoupling caps.

    I am doing the same with matrix driver, I'll post back later on when it's finished.
     

Share This Page