Go Down

Topic: How a crystal works and what could replace it? (Read 764 times) previous topic - next topic

eddiea6987

Can a crystal be replaced by anything that outputs  A frequency? does it have to be constant,  can it oscillate , like fade from 20 to 16mhz  and back?

Because i was just pondering away, and my understanding of crystals maybe be totally off, but i was thinking what if you had some of those brain wave sensors and then wire that to pins 9 and 10 where the crystal goes on the 328p and if you load the blink sketch for example it obviously will not blink once per second but more erratically , my question is would it even blink at all?

Is a frequency simply highs and lows if so can i use another arduino to make a frequency using PWM and wire it to where an atmegas crystal would go?
I could print the Arduino logo on a box of cereal and sell it as "Arduin-O's"

CrossRoads

Yes, you can drive the oscillator pins with something else. See Paragraph 8 of the data sheet. I believe you need a 0-5V signal, from 0-20MHz.
However:
"When applying an external clock, it is required to avoid sudden changes in the applied clock frequency
to ensure stable operation of the MCU. A variation in frequency of more than 2% from
one clock cycle to the next can lead to unpredictable behavior. If changes of more than 2% is
required, ensure that the MCU is kept in Reset during the changes."

I'm thinking maybe a  better bet is to get a voltage controlled oscillator and use whatever to alter the voltage seen at the VCO to adjust the frequency instead.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

retrolefty

Quote
Is a frequency simply highs and lows if so can i use another arduino to make a frequency using PWM and wire it to where an atmegas crystal would go?


Yes it has to be TTL logic levels, highs and lows. However a randomly variable clock signal would be possible, it that's really what you are after. If you really just want to simulate chaos in your program, just use the random() function, creatively.

eddiea6987

Ah thanks I have to give that data sheet a look even if i dont understand half of it , not really looking to create chaos just wanted to better understand what the pins accept as a clock.

crossroads i was looking at the Bobuino rev 17, that thing is a beast!!
I could print the Arduino logo on a box of cereal and sell it as "Arduin-O's"

CrossRoads

A beast in terms of capability & user flexibility!
Size wise, just a little bigger than an Uno.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

eddiea6987

Yeah i read through the PDf and what you get for that slight difference in size is a lot more of options. I thought the RTC and Jtag where a neat addition
I could print the Arduino logo on a box of cereal and sell it as "Arduin-O's"

CrossRoads

I don't have any tools that can take advantage of the JTAG interface  yet, but it will come on handy when I get around to writing a big sketch.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

oxyl

hi!

you can't just connect the PWM output to the clockinput! the resulting voltage of an PWM-signal is just the relation between on and off. the clock of an PWM-signal is fixed .

if you want to use an other arduino for a variable clock-source, it can only provide a variable voltage-output which can be used to control a voltage-controlled-oszillator.


the pwm-clock is about 500Hz

http://www.arduino.cc/en/Tutorial/PWM

lg oxyl

MarkT


Can a crystal be replaced by anything that outputs  A frequency? does it have to be constant,  can it oscillate , like fade from 20 to 16mhz  and back?


m = milli (0.001)
M = mega (1000000)

Hz is the correct symbol for Hertz.  16mHz is about 1 cycle per minute.

But you are not alone, I've seen many datasheets getting such things wrong!

With the standard fuse settings the 328 is configured as a crystal oscillator, but it is possible to feed a logic signal into the XTAL1 pin via a 1k resistor, leaving XTAL2 unconnected.  Seems to work fine (the oscillator circuit doesn't mind in my experience).
[ I won't respond to messages, use the forum please ]

Go Up