Jump to content

Built first circuit using PIC.  Had problem but...


Guest sstandfast
 Share

Recommended Posts

Guest sstandfast

Hey, I don't really have a problem anymore I was just wondering why doing what I did solved the problem that I had.

I am new to PIC's and circuits in general but have recently taken an interest in both.  I am starting out slowly, working my way up until I feel confident enough to build the project that got me interested in PIC's; a remote control for my PC so I can remotely sort through all my .MP3's on my computer.  But I am rambling.

Anyway, when building my first test circuit, the "Hello World" for PIC's, I designed a circuit that would flash an LED on RB7 of my 16F877.  It seamed simple enough, a couple of resistors, capacitors, an LED and my PIC and I was on my way.  Here is a link to the schematic that I have drawn up of my simple test circuit.  http://www.angelfire.com/my/shawnspage/flash.sch

The circuit itself was simple enough to layout on my breadboard, and after finding an old power supply for a Commodore 64 I was ready to rock-and-roll.

I plugged in the 5V supply and sat back and waited for that glorious moment where my sense of accomplishment would glow along with the LED.  Well I waited and I waited and I waited and nothing happened.  Needless to say I was disappointed.  So I grabbed my trusty DIMM and Logic Probe and went to work trying to trace down my problem.  I could find no hardware glitches right away.  I had 5.21V on both MCLR and Vdd.  I was registering 2.5V on pin OSC2/CLKOUT and 2.15V on OSC1/ClKIN.  But RB7 was not changing like it was supposed to.  It was remaining a constant low; I was reading 0V on that pin w/respect to ground.  So it seamed to me that the chip was not executing the program that was programmed onto it.  But to make a long story short, I had tried to reprogram the chip several times to no avail and was about to rebuild the circuit on the breadboard when I solved the problem.

Like I said, I was about to rebuild the circuit again, just to make sure that it was wired correctly when I discovered my problem.  What happened was, having forgotten that I still had power applied to the circuit, I simply grabbed hold of both of the capacitors that were on the crystal and yanked them out.  I then jumped back in surprise.  THE LED CAME ON! It went right back out again, but it came back on a half-second later.  The LED was flashing!  What this means, I think I know but I am unsure of and that is why I wanted to ask you guys to make sure.  I think what was happening is that the capacitors that I was using were keeping the crystal from oscillating like it is supposed to.  Normally I would attribute this to the caps. being to large for their purpose but they are only 0.022uF (0.022 microfarad) which is 22.0 picofarad if I’m not mistaken.  The crystal is connected across the two OSC/CLK pins on the chip while the two caps are connected in series with each pin to ground.

If anyone has any idea as to why the oscillator is working without the caps in place any information you can give will be greatly appreciated.  Until then, I will just continue to watch as my pride turns on and off with the flash of an LED.

Thanks,

Shawn

Link to comment
Share on other sites

Hey Shawn, Well done. ::)

The first step is the biggest !!!!

OK. What I think is happening is that the capacitance of the stripboard between adjacent tracks is probably in the order of 30pF and can be much more on longer tracks. When you fit the capacitors 0.022uF which is actually 22000pF or 22nF there is far too high a value of capacitance. Removing the caps is giving enough from adjacent tracks for the xtal to oscilate (bad spellin !)

Be very careful with capacitor values as there are 1000pF to a nF and 1000nF to a uF. Also the value of capacitors in parralell is the opposite to resistors, with caps in paralell C = C1+C2 where resistors would be

1/R = 1/R1+1/R2.

Good luck and well done.

Dave

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...