Generating a clock frequency

Go To Last Post
30 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

 

I follow the attached schematic to generate a 3.579545Mhz frequency, using the crystal 3.579545Mhz.  In the schematic, I choose C1 as 22pF.  The frequency output is no where near what I wanted.  Attached are what I see my scope.  Note that the scope shows around 110Mhz.  WHAT! Something is wrong, because my scope can go up to 100Mhz max!  That is one problem.  The other is that I can't get a square but a sine wave at the OUTPUT point shown in the schematic, even I choose square wave from my scope.

 

Appreciate any input any solution from other circuits.

 

Thanks!

Attachment(s): 

Last Edited: Sat. Jan 17, 2015 - 10:56 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'd suggest the crystal is not participating in the oscillation or the scope is lying to you. Note that your scope doesn't drop dead after 100MHz - my 300MHz tektronix goes way beyond its spec. Also understand the limitations of a digital scope - they can lie to you if you're not aware.

Last Edited: Sun. Jan 18, 2015 - 12:03 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'd bet that is an FM station signal. Been there, done that. I suspect that the probe and ground lead resonated around that frequency. Also note the amplitude - it IS a nice sine wave.

 

Any crystal oscillator will be a volt or more, close to Vcc in amplitude if you are using the high amplitude oscillator. 

 

I would check fuses. And, physical connections. A 3.5MHz crystal ought to go like a banshee!  IF you can access it it with a programmer, then it is running on the internal oscillator and nothing is even driving the crystal.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Look on the web for other crystal oscillator circuits using TTL inverters.  Try them, also, especially the one-gate Pierce oscillator.  They are all similar to the one that you are using.  The inverted output is being fed into the input through a small resistor.  This makes the IC unstable and the crystal makes it oscillate at the crystal frequency.  

If none of the other designs seem to work, try using a cheap 8-pin Tiny13 or other AVR as a crystal oscillator.   A Tiny13 is about the same price as a TTL chip from DigiKey, and you get a free microcontroller.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk wrote:

I'd bet that is an FM station signal. Been there, done that. I suspect that the probe and ground lead resonated around that frequency. Also note the amplitude - it IS a nice sine wave.

 

Any crystal oscillator will be a volt or more, close to Vcc in amplitude if you are using the high amplitude oscillator. 

 

I would check fuses. And, physical connections. A 3.5MHz crystal ought to go like a banshee!  IF you can access it it with a programmer, then it is running on the internal oscillator and nothing is even driving the crystal.

 

Jim

 

 

Wow! FM signal!  I don't have any microcontroller.  The complete circuit is attached to the OP with 5V DC supply.  That's it.   I don't understand what mean by ¨IF you can access it it with a programmer, then it is running on the internal oscillator and nothing is even driving the crystal.¨  What is ¨it¨?  Curious, how does one make sure the scope's probe is shielded from receiving the FM signal?

Last Edited: Sun. Jan 18, 2015 - 04:57 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

unebonnevie wrote:

I follow the attached schematic to generate a 3.579545Mhz frequency, using the crystal 3.579545Mhz. 

 

Ugh, I'd suggest to avoid those series LS04 circuits like the plague - they oscillate on crystal capacitance alone, and it is much better to use a Unbuffered CMOS Logic gate instead.

 

Look at parts like 74LVC1GX04 for a modern small Unbufferd Gate + Schmitt Buffer in a single package.

 

There is also the 74HC6323 which is a SO8 Osc + Divider, nice part but niche so expensive for what it is.

These days a small Micro with OscOUT feature can also be used as a Clock source, but you do need to pgm them first.

 

I wonder what is the cheapest/smallest Micro with Crystal + CLKOUT choices ?

(many of the smallest parts, lack  crystal Osc support )

 

Last Edited: Sun. Jan 18, 2015 - 04:04 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Who-me wrote:

 

unebonnevie wrote:

 

I follow the attached schematic to generate a 3.579545Mhz frequency, using the crystal 3.579545Mhz. 

 

 

 

Ugh, I'd suggest to avoid those series LS04 circuits like the plague - they oscillate on crystal capacitance alone, and it is much better to use a Unbuffered CMOS Logic gate instead.

 

Look at parts like 74LVC1GX04 for a modern small Unbufferd Gate + Schmitt Buffer in a single package.

 

There is also the 74HC6323 which is a SO8 Osc + Divider, nice part but niche so expensive for what it is.

These days a small Micro with OscOUT feature can also be used as a Clock source, but you do need to pgm them first.

 

I wonder what is the cheapest/smallest Micro with Crystal + CLKOUT choices ?

(many of the smallest parts, lack  crystal Osc support )

 

 

Yes, I could use an ATMEGA with CLKOUT for this, ATTINY84A, for example.  I thought I would like to try.  I am using a 74HCT04 NOT an LS04.

Last Edited: Sun. Jan 18, 2015 - 05:00 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

EUREKA!  I've got it.  Even though the original schematic (found on the web, by the way) does not include two 22pF to the crystals' leads, I thought I would put them in.  And boom! I've got the exact frequency!!!! I've noticed also that the scope would quickly display a square wave, then back to the sine wave.  Wondering why on that part.  But the frequency now is correct!

 

See attached image.

Attachment(s): 

Last Edited: Sun. Jan 18, 2015 - 05:19 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Simonetta wrote:

Look on the web for other crystal oscillator circuits using TTL inverters.  Try them, also, especially the one-gate Pierce oscillator.  They are all similar to the one that you are using.  The inverted output is being fed into the input through a small resistor.  This makes the IC unstable and the crystal makes it oscillate at the crystal frequency.  

If none of the other designs seem to work, try using a cheap 8-pin Tiny13 or other AVR as a crystal oscillator.   A Tiny13 is about the same price as a TTL chip from DigiKey, and you get a free microcontroller.

 

For reference on other circuits found: http://www.z80.info/uexosc.htm.

 

But I have gotten my original circuit working.  See my post above.  Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

unebonnevie wrote:

 I am using a 74HCT04 NOT an LS04.

 

To these bodgy circuits, that represents a large jump. No surprise it went strange.

 

unebonnevie wrote:

EUREKA!  I've got it.  Even though the original schematic (found on the web, by the way) does not include two 22pF to the crystals' leads, I thought I would put them in.  And boom! I've got the exact frequency!!!! I've noticed also that the scope would quickly display a square wave, then back to the sine wave.  Wondering why on that part.  But the frequency now is correct! 

 

Any time you see an unexplained change in a Oscillator, be concerned.

22pF pulls down the loop frequency, and then, if you are lucky, the Crystal will snap the oscillation that occurs.

However this is a lottery, and you need to test with slow Vcc changes, and add a resistor in series with the crystal to check margins.

 

All up, just use an unbuffered gate, (what the ATtiny's do too) - there  is no need in 2015, to use a circuit invented before CMOS, and hope it works with CMOS....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Who-me wrote:

there  is no need in 2015, to use a circuit invented before CMOS, and hope it works with CMOS....

 

but 2015 technologies own to the technologies of the past wink  Seriously, I like a challenge in this case, because I actually am providing the clock to the MC6847, a 30-year-old video display chip from the 8-bit computers.

 

Also, I would like to see an AVR circuit that uses the CLKOUT feature.  There has to be some sort of passive components (registor + caps) connected to the CLKOUT pin of AVRs that support such pin to ensure the clock output is exactly the AVR's system clock.

 

At the end of the day, I might just use an oscillator and be done with it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here's something i built earlier (like 30 years ago). This was wired using point to point magnet wire.
I had no trouble with the oscillator. I used 1k feedback resistors. 470R with a hct series is way too low, no wonder you had problems.

I'm not understanding what you're saying about clkout - you could use a 14.745MHz crystal on an avr and set a timer for ctc and output/4 to feed the 6847.

Attachment(s): 

Last Edited: Sun. Jan 18, 2015 - 07:28 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

Here's something i built earlier (like 30 years ago). This was wired using point to point magnet wire.
I had no trouble with the oscillator. I used 1k feedback resistors. 470R with a hct series is way too low, no wonder you had problems.

I'm not understanding what you're saying about clkout - you could use a 14.745MHz crystal on an avr and set a timer for ctc and output/4 to feed the 6847.

 

Thanks for the tip on using 1Kohm resistor.  MUCH better.  Youŕe geniussmiley  Please see the attached image.  It's passed midnight here, and I just had to try your suggestion and it's worth it!  It's not really square yet, but I have not tried to configure the probe attenuation to 10x or higher.  The image attached is at 1x attenuation.

 

Yeah, I could try using the 14.745Mhz (4x the 3.597Mhz) and do a timer for ctc and output/4.  That means I would set my timer to the period of 1/14.745Mhz and do two NOP instructions then toggle an output pin?  I can search the net for that, but any URL you know of, please point me to it.

 

I've learned a lot today!

 

 

Thanks!

Attachment(s): 

Last Edited: Sun. Jan 18, 2015 - 08:23 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You would set the timer to CTC mode and output toggle - no need for software intervention apart from setup. Your scope trace looks adequate. The ringing is probably due to a long gnd lead. Rarely would I use 1:1 on the probe.

Rather than HCT, use HCU or the old skool LS like I did (HCT was not available when I built my board, F series was the rage back then).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

You would set the timer to CTC mode and output toggle - no need for software intervention apart from setup. Your scope trace looks adequate. The ringing is probably due to a long gnd lead. Rarely would I use 1:1 on the probe.

Rather than HCT, use HCU or the old skool LS like I did (HCT was not available when I built my board, F series was the rage back then).

 

Reference: One good post at https://www.avrfreaks.net/forum/f....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

Here's something i built earlier (like 30 years ago). This was wired using point to point magnet wire.
I had no trouble with the oscillator. I used 1k feedback resistors. 470R with a hct series is way too low, no wonder you had problems.

I'm not understanding what you're saying about clkout - you could use a 14.745MHz crystal on an avr and set a timer for ctc and output/4 to feed the 6847.

 

Curious, now that the 3.579545Mhz circuit is working with 1Kohm for R1 and R2 in the original schematic of the OP, I tried to see if I could stabilize with a 14.745Mhz with R1 and R2 to 10 Kohm and I am not able to, although the 10K yields around 9.7Mhz.  Then I tried a bunch of other Kohms, e.g., 4K, 12K, 22Kohm, all of which are very unstable.  Is there a formula to calculate the R1 and R2 for 14.745Mhz?  Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you want a 0-5V square wave you can ditch C2

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

idealpcsolutions wrote:

If you want a 0-5V square wave you can ditch C2

 

Nope, does not help nor making it worse.  So, may be I just remove C2.  I ordered an unbuffered 74HCU04 and will see how that goes.  Ultimately, I will go with the oscillator to make life simple. :-)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why not just read Wikipedia for an explanation of the different crystal oscillator circuit?     And their characteristics.

 

Strangely enough,   most MCUs and assorted chips choose the most reliable configuration(s).

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:

Why not just read Wikipedia for an explanation of the different crystal oscillator circuit?

 

kartman@ is still a genius. smiley Great article / appnote from TI http://www.ti.com/lit/an/szza043....

Last Edited: Sun. Jan 18, 2015 - 08:17 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Unebonnevie - if you want old skool, think old skool. The apple2 had a 14.745MHz crystal, so dig up the schematics for it and a i think a vz-200/300 was the same. Note that using hct parts is way different to ls parts and hcu parts. As for the genius tag, i know enough about crystal oscillators that they are fiddly at the best of times - i've always used designs done by others. The vz-200/300 was interesting as they did some shenanigans to get european tv frequencies from the 6847.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

Unebonnevie - if you want old skool, think old skool. The apple2 had a 14.745MHz crystal, so dig up the schematics for it and a i think a vz-200/300 was the same. Note that using hct parts is way different to ls parts and hcu parts. As for the genius tag, i know enough about crystal oscillators that they are fiddly at the best of times - i've always used designs done by others. The vz-200/300 was interesting as they did some shenanigans to get european tv frequencies from the 6847.

 

I managed to find a 74LS04 part from my collection of logic ICs.  It yields the same results as the 74HCT04 I am using at the moment.  At the end of the day, I will just use an oscillator that I ordered one.  Simpler and less part.  I'll post a scope picture when that thing arrives.

 

I have seen tons of schematics, including the CoCo 2 and MC10, whose schematics are available, since they both use the MC6847.  Btw, I have the Apple IIes and extra 14.745Mhz crystals. I also have the VZ200/300 computers, which are clones of Radio Shack / Tandy computers, the Cocos and MC10.

 

It was good learning, and I am glad to have whipped up an oscillator circuit and got it working with your and people's help/input.  TI has an excellent appnote (http://www.ti.com/lit/an/szza043...) I mentioned in my previous note.  Very practical discussion on how things work.  Also, it features the sn74lvc1404, whose datasheet (http://www.ti.com/lit/ds/symlink...) shows some practical examples of generating clock frequencies with the chip, which is actually "chipper" than a typical oscillator.

 

Thanks!

Last Edited: Sun. Jan 18, 2015 - 08:43 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Posted are two scope snapshots when I use the unbuffered 74HCU04 in one case and using an oscillator in another case.  They are no better than the buffered 74HCT04 that I started with.  I thought the oscillator would give me an excellent square wave.

 

By the way, I power my breadboard from the USB port (5V DC) of my laptop.  I've noticed that when I plug in the charger for my laptop  I get a beautiful sine wave and very stable.  Unplugging the charger, I get the almost square wave shown in the attachments.

 

I believe the breadboard, etc., is very sensitive to power.  *Duplicate deleted. Ross*

Attachment(s): 

Last Edited: Thu. Jan 22, 2015 - 05:27 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

unebonnevie wrote:

Posted are two scope snapshots when I use the unbuffered 74HCU04 in one case and using an oscillator in another case.  They are no better than the buffered 74HCT04 that I started with.  I thought the oscillator would give me an excellent square wave.

 

74HCU04 needs a different circuit, usually in their Data sheets and the same as MCU oscillators.

If you want a square wave, you need a HCU04 plus HCT14 (schmitt), and that is what is in the 1GX04 I mentioned earlier.

 

 

unebonnevie wrote:

By the way, I power my breadboard from the USB port (5V DC) of my laptop.  I've noticed that when I plug in the charger for my laptop  I get a beautiful sine wave and very stable.  Unplugging the charger, I get the almost square wave shown in the attachments.

 

I believe the breadboard, etc., is very sensitive to power.  

That can also be other ground paths, but itis not a good sign to have Oscillators change significantly like that.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How have you connected the probe gnd lead?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

How have you connected the probe gnd lead?

 

Arggg..I attached the probe's alligator clip to the wrong GND!  It should be connected to the breadboard's GND.  Now it does.  Looks good!  The first photo show 1x attenuation of the probe.  The 2nd 5x of attenuation.  The 2nd photo shows a nice flat top of a square...Not perfect yet.  But good.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why are you so worried about having a perfect square wave? As you've seen, the ground lead has a large influence on what you see. If you want to measure it more precisely then ensure your probe is properly compensated and make the ground on your probe as short as possible - use a loop of wire from the 0V of the chip to contact the earth ring near the tip in your probe. See how the picture changes. Also, don't expect too much from cheapy probes and scopes. One probe on my tektronix scope is worth more than your scope. You pay for precision.

Your first pic has rounded edges probably due to probe and scope input capacitance - that's why you don't use 1X. Your second pic, the probe is overcompensated, thus the ringing on both edges. Use X10 and adjust the compensation on your probe. There's a little screwdriver slot either in the probe itself or in the little box on the bbc connector. Most scopes have a test point for this adjustment.

Last Edited: Fri. Jan 23, 2015 - 07:47 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

Why are you so worried about having a perfect square wave? As you've seen, the ground lead has a large influence on what you see. If you want to measure it more precisely then ensure your probe is properly compensated and make the ground on your probe as short as possible - use a loop of wire from the 0V of the chip to contact the earth ring near the tip in your probe. See how the picture changes. Also, don't expect too much from cheapy probes and scopes. One probe on my tektronix scope is worth more than your scope. You pay for precision.

Your first pic has rounded edges probably due to probe and scope input capacitance - it's why you don't use 1X. Your second pic, the probe is overcompensated, thus the ringing on both edges. Use X10 and adjust the compensation on your probe. There's a little screwdriver slot either in the probe itself or in the little box on the bbc connector. Most scopes have a test point for this adjustment.

 

Because I am learning so much from youlaugh, thus the finding out why not having a perfect square wave with the oscillator, at least.  All in all, it will be fine on a PCB.  Yes, my scope has a test point of 1Khz and it shows the most perfect square wave.  I didn't know about the screw thing on the probe.  I'll give it try if it's there.  See I learn that from your input by keep pursuing, as long as there time left for me on this project with the breadboard.  But, I am very happy with the results.  Thanks to you and others' input.

 

>One probe on my tektronix scope is worth more than your scope. You pay for precision.

 

Yes, very true.  I am only a hobbyist.  I should have married to a 1%er :-) :-)  No, seriously I have attended conferences where the probe costs 2x more than the scope itself.  I thought it was ridiculous, until now.  AS ANY DOCTOR WOULD SAY: ¨THE PROBING CAN BE SENSITIVE!¨  HAHA!

Last Edited: Fri. Jan 23, 2015 - 06:07 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

Why are you so worried about having a perfect square wave? As you've seen, the ground lead has a large influence on what you see. If you want to measure it more precisely then ensure your probe is properly compensated and make the ground on your probe as short as possible - use a loop of wire from the 0V of the chip to contact the earth ring near the tip in your probe. See how the picture changes. Also, don't expect too much from cheapy probes and scopes. One probe on my tektronix scope is worth more than your scope. You pay for precision.

Your first pic has rounded edges probably due to probe and scope input capacitance - that's why you don't use 1X. Your second pic, the probe is overcompensated, thus the ringing on both edges. Use X10 and adjust the compensation on your probe. There's a little screwdriver slot either in the probe itself or in the little box on the bbc connector. Most scopes have a test point for this adjustment.

 

 

Took me some time to find, but here is the best video of the explanation why there is some not perfect edges on the square wave.  It has to do with electromagnetic and impedance.

 

https://youtu.be/MJpDFnRQw8s

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That electromagnetism gets me every time! Maxwell has a lot to answer for.