View previous topic :: View next topic |
Author |
Message |
Guest
|
Best way to prototype hardware with PIC |
Posted: Thu Jun 22, 2006 6:37 am |
|
|
HI Everyone,
I have a PICDEM 2+ demo board, and using that, I have finished most of the software for a project, but now I want to really focus on creating the hardware.
I started using a breadboard, and i got it to work, but for some reason, I think the connections with the crystal (32K) or decoupling caps (~20 pF) arent working well. I think its because the breadboard isnt great for this application because of the 32K crystal. For the compiler I have the clock set up as XT. Should I be using the HS option?
Also, should I be using different capacitors with that crystal (how can I calculate what capacitor I should use versus the clock speed?). Also, have people used breadboards to prototype with clock speeds in the MHZ range? If so, what should I be aware of?
If using a breadboard to do hardware prototyping isnt feasible, what should I use? I'm hesitant go get a PCB made and then find out it doesnt work. What's the best way to do hardware prototyping for microcontrollers?
Thanks! |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Thu Jun 22, 2006 6:53 am |
|
|
What kind of breadboard are you using? If it is one of the white plastic kind where you push in little wires, then your crystal circuit may never quite work right.
There are application notes (from Microchip and from crystal manufacturers) detailing the proper selection of components as well as how to construct the circuit. Guard rings and short ground runs are important.
Having circuit boards made is relatively inexpensive compaired to the headaches and what your time is worth when dealing with dodgy breadboards. At the very least, consider getting the perforated board with solid copper on the top and bottom. You use a little tool to isolate the holes. Gives you something close to solid power and ground planes for a prototype. Or learn how to etch your own circuit boards. _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Thu Jun 22, 2006 7:07 am |
|
|
Quote: |
I started using a breadboard, and i got it to work, but for some reason, I think the connections with the crystal (32K) or decoupling caps (~20 pF) arent working well. I think its because the breadboard isnt great for this application because of the 32K crystal.
|
A breadboard is not the best hardware to work when you are dealing with low signals
and high frequencies, but for single test it will be usefull. I never use it, instead I
have 3 models of home-made multi purposes boards that cover all the PICs size/packages
that I use and I made all my prototypes on there.
Quote: |
For the compiler I have the clock set up as XT. Should I be using the HS option?
|
You didn�t mention what microcontroller are you using but as general rule the compiler
crystals options for the midd-range family are:
LP: 32Khz - 200Khz
XT: 200Khz - 4Mhz
HS: 4Mhz - 20Mhz
Quote: |
Also, should I be using different capacitors with that crystal (how can I calculate what capacitor I should use versus the clock speed?).
|
Read the datasheet. It is not necesary any calculation, find the chapter
"Oscillator Configuration" of the PIC you are using and you will find all the required info.
Humberto |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Thu Jun 22, 2006 8:02 am |
|
|
I don't want to complicate things... but to solve the breadboard/crystal problem you could chose a PIC with an internal OSC. Then the beadboard
may work great for a prototype. I always look for the easy way out. |
|
|
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Thu Jun 22, 2006 8:31 am |
|
|
I, usually, build my proto-types on a breadboard first so I can make changes as needed. Once I get things running there I'll etch a PCBoard and put things together to ensure that the hardware is solid. If you go to www.pulsar.gs they have items there that will help you make a fairly inexpensive board and it doesn't take much time. Simply download a schematic/PCB program (there are several threads on this board about them) and you'll be in the PCB business in no time.
Ronald |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1907
|
|
Posted: Thu Jun 22, 2006 8:53 am |
|
|
I have a Micro Engineering Labs Lab-X1 board (http://www.melabs.com). It has a variable clock oscillator on board, settable with jumpers. It also comes with spaces for you to install pin headers/sockets for making easy direct connections from the PIC to external hardware.
What I do is prototype external circuitry on one of those white solderless breadboards, and make connections from that to my PIC. |
|
|
iso9001
Joined: 02 Dec 2003 Posts: 262
|
|
Posted: Thu Jun 22, 2006 11:58 am |
|
|
I've used that white breadboard type for some of my projects and have never had a problem yet. Thats usually with 10Mhz resonators with built in caps, however....
I have found that through some magical bread board properties I can take a 20Mhz fox can-type xtal, plug it into the breadboard with no caps and it works fine. I know its by sheer luck that it works. I don't even want to look at that setup on the scope. It would give me bad dreams.
I'd agree with the internal clock for now. Then when you make the pcb, give yourself some options. Like for the first couple pcb's I made since I didn't know what was going to work and what wouldn't, I made two spots for different xtals, different cap options, spots for pull ups/downs etc etc. I still do that with new circuits now and then. |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1907
|
|
Posted: Thu Jun 22, 2006 12:38 pm |
|
|
iso9001 wrote: | I have found that through some magical bread board properties I can take a 20Mhz fox can-type xtal, plug it into the breadboard with no caps and it works fine. I know its by sheer luck that it works. I don't even want to look at that setup on the scope. It would give me bad dreams. |
It's probably all the stray capacitance inherent with those boards. On one project I worked on, I filled all unused portions of the PCB with ground plane once I had routed all the signal and power lines, including in & around the lines that ran from the micro to the crystal and the crystal caps. The clearance between the ground plane and other lines/etc was set to something like 0.012" or something like that. This is my standard practice.
Once I had soldered everything on, I had a helluva problem getting the pic to run. Sometimes it would run, sometimes not, sometimes it wouldn't even start, sometimes it would start & then freeze up..... I found that if I "twacked" the crystal with my finger that it would run for a while.
Turns out that the problem was that the close spacing between the ground plane and the crystal lines added enough stray capacitance to just put the oscillator on the brink of working/not working. I took out the crystal caps altogether and it worked perfectly.
I learned my lesson from that - now I don't fill the board underneath/around the crystal cctry with a ground plane. I haven't had a problem with crystals since. |
|
|
jbmiller Guest
|
breadboards |
Posted: Fri Jun 23, 2006 5:15 am |
|
|
I've used the white breadboards since the 16C84 came out(ugh,that's been a while!) and on the 20MHz 16F877s.Never had a problem and I use 20GA soild copper wire(Bell tell 6 pair) for jumpers.Then I 'solderstitch' the circuit onto Ratshack perfboards(4 by 6" size),again no problems. Either I'm lucky or my neat and tidy approach is good.
Jay |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jun 23, 2006 11:39 am |
|
|
Quote: | now I don't fill the board underneath/around the crystal circuitry
with a ground plane. I haven't had a problem with crystals since. |
Your problem was likely the ground-fill on the top layer. Most of the
boards we make are 4-layers or more, and we always make layer 2
be the ground plane. It's under the crystal as well. We've never had
a problem with that. Though, all crystals are running in XT or HS mode.
We don't normally do ground-fill on the top layer. |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1907
|
|
Posted: Sat Jun 24, 2006 8:50 am |
|
|
PCM programmer wrote: | Quote: | now I don't fill the board underneath/around the crystal circuitry
with a ground plane. I haven't had a problem with crystals since. |
Your problem was likely the ground-fill on the top layer. Most of the
boards we make are 4-layers or more, and we always make layer 2
be the ground plane. It's under the crystal as well. We've never had
a problem with that. Though, all crystals are running in XT or HS mode.
We don't normally do ground-fill on the top layer. |
You're right - this was only a 2 layer board.
If you've ever done the math (or been forced to do the math), running a ground conductor close to a line (on the same layer) has a much bigger effect on stray capacitance than running the signal and ground conductors on different layers. |
|
|
Stu_H Guest
|
|
Posted: Sat Jun 24, 2006 5:44 pm |
|
|
I always use the white plastic breadboards to get a project started. I've not had any major problems so far, and I've been doing it this way for over 10 years. PIC12/16/18 series, all work fine. I usually use a crystal oscillator for projects with a single PIC, and with the 18F series I've found that even the HSPLL at 32MHz works fine on the breadboard.
Of course, I'm lazy. I omit the 22(ish)pf capacitors that should be on each leg of the crystal to ground when using a breadboard - just stuff the crystal across the appropriate pins. (I do it properly on the PCB!)
Stray capacitance on the board making things OK? I don't know, all I know is that it works - even with the 18F PICs at 4x PLL!
(I *have* been using the same plastic breadboard over that time - perhaps others might not be so tolerant). |
|
|
sd211
Joined: 15 Nov 2005 Posts: 4 Location: NC, USA
|
Re: Best way to prototype hardware with PIC |
Posted: Sat Jun 24, 2006 6:33 pm |
|
|
Anonymous wrote: |
If using a breadboard to do hardware prototyping isnt feasible, what should I use? I'm hesitant go get a PCB made and then find out it doesnt work. What's the best way to do hardware prototyping for microcontrollers?
Thanks! |
I had similar problem with breadboard (PIC not stable) and have designed a PCB for PIC that I can plug into a breadboard. I liked this approach and have made number of other standard "modules" that make it easier and faster to prototype new hardware. These modules are available at beaglerobotics.com.
Sergey Dryga |
|
|
|