Crystal Question

I'm currently working on a project involving dual-processing using two PIC18F2431 chips. The details can be found here: students.oc.edu/james.klein
My question is, will we be able to share a 10Mhz external crystal-oscillator signal between the two PICs, or does each processor need its own crystal? The processors will be communicating via SPI, if that matters at all. Thanks for any responses.
- Jim
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
On 26 Nov 2004 20:52:44 -0800, the renowned snipped-for-privacy@student.oc.edu (OC Systems Team) wrote:

It's fine to use an external oscillator module.
Best regards, Spehro Pefhany
--
"it's the network..." "The Journey is the reward"
snipped-for-privacy@interlog.com Info for manufacturers: http://www.trexon.com
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
OC Systems Team wrote:

In short - You are destined to fail! DO NOT DO THIS! The rock (crystal) is cannot be driven by two drivers AND that are in two different locations AND that have SMT pads that pick up more capacitance AND that have traces that pick up even more capacitance AND will have phase shift errors on each AND will cause cancellations from each driver AND will cause premature failure of the rock AND it might work if all the temperature conditions are in the right harmonic AND you are crazy to this in the first place AND no it will not work.
Like Spehro said, you CAN use an oscillator to drive both, but not a crystal. Be sure to route the oscillator into the INPUT of the OSC pins. In this case for the PIC18F2431 is the OSC1 pin. In fact for the cost of (2) crystals and the (4) dampening capacitors is about the same as (1) oscillator and (1) decoupling cap for the +Vin. I highly recommend oscillators over crystals unless you know what you are doing - which appears you do not.
If you do use crystals - notice i said crystal(S), then make sure that all ground and power planes are removed from under the: PIC OSC1 and OSC2 pads traces to the crystal Crystal SMT pads. traces to the dampening capacitors (e.g.:10-20 pF) Dampening Capacitors SMT pads.
This is necessary in order to properly 'tune' the crystal with the damping capacitors. The capacitors on each end of the rock need to be dampened in order to prevent FAILURES! If you over dampen the crystal with too large capacitors, then you will round off the waveform. If you add too much capacitance by not removing the grounds like i said, then the damn thing may never start-up. And good luck with the dremel tool!! :-)
Adding too little capacitance will leave over shoot on the waveform that is sure to cause failure. Usually not right away, but over time. Probably enuf time to get your grade! ;-)
BTW if you really screw up and ooppssed on the ground, then try taking off the caps and start from there by looking at the OSC1 inputs and OSC2 outputs with a 10 Mega Ohm or better high impedance probe. If you really screwed up and tried the duallie approach, then you are really screwed up. Pull out the soldering iron and remove the crystal (and it's caps too!) and add an oscillator to both OSC1 for both devices.
Digikey has loads of oscillators - cheap!

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Time to adjust the meds.

It's different on this planet.
A parallel resonant crystal is designed to operate with a certain value of shunt capacitance. That capacitance is provided by the micro's input pins, board parasitics, and the two caps to ground, which are seen as SERIES connected, and need to be roughly twice the value of the crystal's specified shunt C. For a 22 pF crystal, you would subtract about 5pF for chip and parasitics, then double the remainder of 17pF to 34pF, and use 33pF caps. This is a starting value, you can measure the operating frequency, and adjust the caps as needed to get dead-on frequency. A shortwave receiver with BFO is good for this, as it makes no connection to the oscillator. If you're careful with your math, you can load some code into the micro to toggle a pin at some much slower rate, and then measure that frequency with a counter or scope, as accurately as possible.
The caps are not about "dampening". They are there to overwhelm the small and somewhat difficult to control/predict capacitance of the layout and chip. If you designed the crystal for just the capacitance of the chip, you'd always be off since the parasitics would add to that. Deisgning for an extra capacitance 3-5 times higher than the parasitics, allows you to be that much more accurate, once you determine exactly the right C values to use.
In the pic, you do have a lot of crystal drive options, and you also need to check that the power level you are driving the crystal with isn't out of spec for the crystal. Most AT cut parallel crystals are pretty broadminded about this, and hard to damage, but fork types, like 32kHz watch crystals, are designed for microwatts of drive, and can easily be shattered.
Finally, there is an additional check you should make before releasing a design. Oscillator gain level margin. Microchip has an appnote on this, AN949. Look under "Negative resistance testing"
Have a look at the tech notes on Statek's web site, or any of the other major crystal makers.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Dave VanHorn wrote:

So take them and stop telling us. We don't care.

Whatever it is, it's not Earth! ;-)

Yes.
Forget all this garbage. Use an oscillator and save yourself alot of trouble. Don't listen to any of this crappy advice, or you will spend days on debugging.

More off-topic crap.

Like hell they are not!! They certainly are!! This statement alone tells me that you are an idiot!!!

"overwhelm" --- now there's an electronic term!!!! HA! HA! HA! HA! HA!

Of course you idiot!

HIGHER THAN THE PARASITICS??? The damn thing will never start-up!! HA! HA! HA! HA! HA!

Anything else more vague? :-/

Yes.
NO! Many 'normal' crystals are even smaller than the 32.768 kHz clock crystals and require just as much attention to the drive current. Especially over 30 MHz. Take no chances on assuming that any of them will - check the drive current specs -- or better yet forget about crystals and use an oscillator!!

More crap. Forget about this.
Avoid them and use a single oscillator and a single PIC.

Don't waste you time. Look at *any* oscillator at Digi-key and pick one that is in your price range and buy it. Follow the design notes on the manufacturer's website and be done with this issue already.
And make sure that you forget all of dave's advice!! At least you will have a chance then.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

I see, you know more about this than the people who design the PICs, and the ones who make the crystals.. Interesting.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Dave VanHorn wrote:

NO. I just know more than you, which is enough for most people with common sense. Your ideas probably have good intentions, but they lack good direction.
These students need quick and solid results, not mindless details that will lead them astray. If you looked at their design, then you would know that all of this is wrong, especially the fact that there are (2) micros to begin with.
That's interesting!
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Well, I'll let the OP decide what he needs, and what sources he should give credibility to. I provided links to back up my assertions, from credible sources.
My copies of Art of Electronics are out on loan so I can't quote chapter and page, but I believe this is also covered there.
I do take offense that you call me a liar. I've been doing this for more than 20 years, in volume production of commercial designs. When I say that it can be done properly, it's because I've seen it done (right and wrong) and I've done it succesfully, and it's NOT THAT BLOODY HARD!
But, since you are behaving like a mindless troll, so shall you be treated.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Dave VanHorn wrote:

Good! Certainly not yours, especially if he follows your bad advice.

No you did not. Where? What sources? Show me a crystal manufacturer that recommends sharing a crystal for (2) microcontrollers. Again you are a liar!!

You must quoting from the 'Bad Designs' section of the book as usual.

Your should since you are to liar blantly that you have made viable circuits by loading two drivers off of one crystal. Again i call you a liar!!

Volume productions of what? Bad designs. It's a wonder someone didn't fire your ass years ago.

And mostly wrong.

Sure after you screw up a lot. But let's try to get it right the first time.

This all started from your bad design advice. That's too bad if your feelings are hurt, especially if someone else has to suffer the consequences of your bad advice. If anything you should learn to 'think' before giving technical advice. Well, it's probably too late for you old man. Apparently, you didn't learn too much about good design techniques over the years. Please make damn sure about what you are talking about in the future and perhaps you won't have to suffer someone ridiculing you.

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Jim;
you have (or will have) major 'grounding' problems. You are not thinking in terms of current returns fro each device. You MUST think in terms of RETURN paths for each voltage AND for each DEVICE too!!!! That means that for the +5V that supplies the PIC you will have a +5V_Return.
WHY is this important you ask!!??!! Well let's look at it this way -- what kind of currents is the PIC using hummm? i'll tell you that they are very small and in milliAmps. AND what kind of currents are the motors using hummm? I suspect that it is the +12V battery. Well guess what; with the 'grounds' tied together you are going to experience current surges to the PIC that will really scramble it's brains! :-b
You will need to separate each 'ground' for each device and then slowly think about what you are doing with the return (ground) paths. IF they are low current and the same voltage, then by all means tie them together. IF there are high and low current devices sharing the same voltage then partition out the plane and connect them together AT ONE POINT ONLY and that connection should only be large enough to share the currents that each will need to share.
Let's say that you PIC is driving the h-bridge with a 20mA signal from one of it's ports. Then you will need a small return path for that signal. Otherwise what will form the connection to complete the circuit? huh? Also you really don't want to drive a motor driver with a +5V line if it is a +12V motor. It would be better to use an opto-isolator to separate the +5V digital and the +12V motor drive circuit. this way each 'ground' is totally isolated and sure to work. You will also have the benefit of isolating the digital from the power circuits in case of a catastrophic failure. ;-)
Go thru the RETURN paths for each voltage for each part with the amount of CURRENT flowing thru the return path.
-EM
OC Systems Team wrote:

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Jim;
Can i ask why you are using (2) PIC microcontrollers when you don't have all the ports on one device filled up? This design does not require more than (1) microcontroller. If you need more I/O then get a larger device. Don't use two devices. You should be able to control both motor drivers with (1) PIC easily. Make your life easy by taking out the other PIC and other reset circuit. You should add some other cool features like a FLASH based PIC instead of the one you picked. And how about wireless stuff - there's some good stuff from TI and Micrel too. Also your motor drivers are pretty old. Check out acroname's website for cool ideas. Also check out nubotics too for ideas. And check out other robotics websites.
EM
OC Systems Team wrote:

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

EM seems to think you intend to just connect both pic's osc pins in parallel, and that would be a very bad idea.
This can be made to work. You must take a few precautions to minimize EMI.
Pick one of them to be the master, and implement the oscillator on that chip. Return your crystal caps directly to the master's ground pin by discrete tracks. Take the output side of the oscillator on the master to the input of the slave, through a resistor. Locate this resistor as close as possible to the master pic. Provide a solid ground track directly between the two micro's ground pins. Set up the slave to run from external oscillator.
Adjust the resistor value so that you have good margin on the oscillator amplitude at the slave, but it is attenuated somewhat. (see data sheet for minimum voltages)
If this isn't a volume production product, and space isn't a large issue, then it might be simpler to use two crystals, or use a single canned (or discrete transistor) master oscillator, and feed each pic from it through resistors as above. You then would need solid ground returns from each pic back to the oscillator.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Dave VanHorn wrote:

Hey bozo read the post it says
"My question is, will we be able to share a 10Mhz external crystal-oscillator signal between the two PICs, or does each processor need its own crystal?"
and YES it is a very bad idea. -- Do not listen to this Dave VanHorn idiot! You are in a world of trouble if you try to do this and it is not worth any cost savings. Simply design in an oscillator and forget everything below. You are desiging a Microcontrolled Motor Driver, not a crystal resonance experiment!!

NO and NEVER and did i say NO!?

Forget his crappy advice. Simply eliminate one and find a device that supports all your pins in one device

NO!!! Wrong!!

NO!!! Wrong!!

NO!! BAD idea!! :-(

NO!! All of this advice belongs on what *not* to do!

Use a single oscillator with a single PIC and you're done! Forget Dave's BullSh*t!!

And finally NO!
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Emphasis added for clarification.
Actually, I did read that. Nowhere do I see him SAY that he intends to connect both pins of both pic's oscillator circuits together, although that may have been what he was thinking.. I'm sure that we have disabused him of that notion, and on this one point we are in complete agreement.
However, you are completely wrong on the rest. This is frequently done, and can be made to work just fine, provided you pay attention to a few EMI issues, as I described. It's been done in many commercial products, for many years.
It would appear that you've had some bad luck with this in the past, but all I can tell you is that this works just fine, if done right.
I've also seen it done wrong, which once cost me a trip to Taiwan on Christmas day, to solve that problem on a production line. Their protos all worked, but 50% of their production didn't.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Dave VanHorn wrote:

That's right you didn't!! If you would have looked at his design instead of a knee-jerk bone-headed response that you made then probably you *might* have got it right. Instead you fed them false and misleading advice that is sure to give them trouble in designing and debugging. And there is NO GOOD WAY TO SHARE A CRYSTAL, especially for undergrad students.

I don't believe that you ever do this and made it work. You are a LIAR!!! (or an idiot; or perhaps both) This BAD industry practice and anyone worth their salt in Engineering will tell you this.

NEVER. So don't mislead other with crappy advice. Ask any crystal manufacturer if sharing a crystal is correct and they will think you are nuts or an idiot. Both of which i find that you are.

Who really cares?
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
It's funny someone mentioned "JERK" - that's exactly the word I was thinking of as I read this post. That word just seems to pop into my mind when I see someone resort to insults and name calling because they disagree with someone else's opinion and lack the maturity to hold an adult conversation.
~WEC
-----

> Hey bozo read the post it says <snip>

of a

have got

give <snip>
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
This was an adult conversation. Excuse me little boy, but adults cuss and get angry and are opinionated. So grow up. If you don't like, hit the 'un-subscribe' button sonny.
"W.E.Cole" wrote:

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Electron Man wrote:

Sorry 'Electron Man,' this can and does work, is recommended by Microchip, and is in several of my designs. The whole purpose of the Oscillator Out pin on the PIC is to provide the driving power to provide a clock to another device - any device that needs a clock. Design the crystal circuit for one PIC, and daisy chain the output to the second PIC's clock input. Not rocket science.
To the OC Systems Team: Don't let ANYONE tell you things like "You are destined to fail!" and get away with it. You can do this. Do your research, test your theories, and prove them wrong.
Randy
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Mr VanHorn is correct. I had a case using 12F675 PIC and needed more I/O than I could have if I used a Xtal. If I drove the chip with an external osc I would have the correct number of I/O to use. I was going to use an external osc but didn't have one in stock. So I took another 12F675 and used it as an oscillator. IIRC I took OSC2 from the oscillator PIC and tied it directly to OSC1 on the other PIC and initialized it for external oscillator. This works fine and if you read the MicroChip literature I believe they indicate this is OK to do.
Dan T.

Dan Thompson (AMA 32873, EAA 60974, WB4GUK, GROL) remove POST in address for email
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.