AVR overview =>
DCF77 receivers =>
32kHz Superhet => Xtal oscillator
Diese Seite in Deutsch:
AVR single chip controllers AT90S, ATtiny, ATmega and ATxmega
Crystal oscillator for the DCF77 superhet receiver
4 DCF77 superhet receiver with xtal filter
4.2 The superhet schematic
The following is rather experimental and only for hardcore
experimentalists that love extraordinary solutions. It replaces
the LC part of the oscillator and produces an exact crystal
controlled oscillation signal. Let's start with some warnings,
so that you can't argue you knew not what you're doing:
It seems that such an ATtiny25 is a strong RF generator,
contaminating anything in the area with strong stray signals.
So better do not go this road but use a commercial crystal
oscillator for 15 MHz.
- My first approach was to clock an ATtiny25 with a crystal
attached to the Xtal1 and Xtal2 pins, setting the CLKOUT
fuse and to switch to a high frequency external oscillator.
- I realized that this only works with xtals from 14 MHz
upwards. Xtals with lower frequencies do not work at all.
- With a 15MHz crystal the ATtiny25 works, but only at
operating voltages below 4 V.
- At 3.3 V the oscillator clock of the ATtiny25
contaminates the operating voltage by a strong RF signal.
It cannot be suppressed with 10 or 100nF ceramic capacitors.
The 15MHz signal also is on the generated sine waves and
is not reduced by the RC filters (which should be perfect
filters for that high frequency).
- The 15MHz signal also contaminates the DCF77 signal of
the cross antenna and cannot be filtered from there with
normal means. Mixed and amplified, this signal overshoots
any DCF77 RF, making it impossible to read the amplitude
changes of DCF77.
184.108.40.206 Concept using a crystal oscillator as basis
LC resonance circuits are slightly temperature sensitive, so
that its frequency has to be adjusted from time to time. Under
long term operation and with some aging of parts, this has some
disadvantages. An alternative to the LC would be to generate
the oscillator frequency from a xtal-controlled base frequency,
by dividing that with a fixed rate.
Of course, there are no 110.268 or 44.732 kHz on the
market. This solution here uses a xtal clocked AVR as a
An AVR, here an ATtiny25, is clocked by an external xtal
oscillator. Its timer/counter 0 works as a divider (in
CTC mode), divides the clock frequency by a fixed rate
and toggles the compare outputs A and B on compare match.
By starting outputs A and B with different start conditions,
it produces counter-phased rectangles. The rectangles are
filtered with an RC network, that yields sine waves that
can drive the TCA440's oscillator inputs with a symmetric
sine wave signal.
220.127.116.11 Selecting ´the crystal frequency
Digital dividers can only divide by integer values. Therefore
the xtal frequency, divided by the divider, has to fit nearest
to the desired TCA440 oscillator frequency. To find the nearest
fit I have listed all available xtals in a spreadsheet and
did some calculations with those.
In the table the higher (110.268 - 77.5 = 32.768 kHz as
well as the lower (77.5 - 44.732 = 32.768 kHz are considered.
The divider is calculated, the divider determined and the factually
generated frequency f is as well as its absolute deviation in
percent and in +/- Hz is listed. The table is available
here as OpenOffice file.
The table holds a second sheet, listing xtal oscillators only.
There are fewer, but also some frequencies that are not available
as discrete xtal. The output of the crystal oscillator is connected
to the ATtiny25's XTAL1 pin. The CLKOUT fuse can, but must not be
activated. The calculation sheet "xtal_oscillator" lists
that. In this mode the ATtiny25 can be operated with 5 V, the
reduction of the operating voltage is unnecessary.
Please note that the divider toggles the OC0 pins, so that two toggles
are necessary for one wave. The frequency therefore is half of the
compare value (+1).
|77.5 + 32.768 = 110.268 kHz||77.5 – 32.768 = 44.732 kHz|
When mixing the 77.5 kHz input signal with the higher frequency
(+32.768 = 110.268 kHz) the 15 MHz xtal has the
smallest deviation (0.02%, +26.1 Hz). The crystals 5.0688 and 6.4 MHz
deviate by 0.07% or 77 Hz and the xtal 4.194304 MHz by 0.1% or
108 Hz. When mixing with the lower frequency (77.5 - 32.768 =
44.732 kHz) the 9.216 MHz- crystal fits best, with 0.01% or
5.9 Hz deviation.
When mixing with 44.732 kHz the first harmonic (89.46 Hz) is
in the wider range of the input frequency. Therefore interferences
cannot be excluded, therefore the 15 MHz xtal was chosen. This
deviates by 26.1 Hz upwards.
18.104.22.168 Operating voltage dependancy of the frequency
When using a discrete xtal with 15 MHz plus two 18 pF
capacitors an operating voltage dependent frequency results, see
the graph. In principle, the xtal frequency should rather be
14.996.448 MHz to fit better to the input frequency. At
higher operating voltages the deviation even increases. But the
differences are more of an academic nature.
22.214.171.124 Rectangles to sine waves
Any ATtiny has an 8-bit counter/timer with OC0A and OC0B output.
The two pins can generate a symmetric output signal: OC0B generates
the opposite signal by starting with a high instead of a low
port-bit. So, the oscillator signal can be fed symmetrically to
the oscillator input of the TCA440.
On both outputs, OC0A and OC0B, rectangular signals are made.
Using those rectangles for mixing would have adverse consequences,
as rectangles consist of all uneven harmonics of the base frequency.
It is better if those harmonics are filtered off by use of a three
stage RC network.
The calculation spreadsheet OpenOffice file
here has a sheet
named "Oscillator_coupling", where I played with different
RC combinations. To have a large-enough signal the filter should
not damp the base frequency too much, but the third (and beyond)
To limit the number of components three RC filter stages have been
combined. Finally I selected a combination of 1kΩ and 2.2nF.
The loss of amplitude is limited and the harmonics are well
suppressed with that.
This displays the filter effect of the three stages, as calculated
with the spreadsheet.
The first stage (V(C1), blue curve) still is nearly fully reaching the
operating voltage limits. In the second stage (V(C2), the red curve)
the amplitude swing is smaller and the form is nearer to a sine
wave. In the third stage (V(C3), green curve) the amplitude loss
is lower and the wave is a nearly perfect sine.
Displayed here is only one signal, the second is reversed. With
that mixing can be made.
126.96.36.199 The schematic with a discrete crystal
The schematic is rather simple: the timer outputs OC0A and OC0B generate
the reversely clocked rectangle of 110.294 kHz, to be filtered in
three RC stages. The oscillator inputs on pin 4 and 5 of the TCA440
receive that signal.
The reset input of the ATtiny25 are, via a resistor of 10 kΩ,
tied to the operating voltage of 3.3 V. The xtal of 15 MHz is
connected to the XTAL inputs, each with a capacitor of 18 pF to
In practice, the xtal didn't swing above an operating voltage of
4 V. Even
did not resolve that problem. The operating voltage was therefore reduced
with a resistor, a Zener diode and an electrolytic capacitor to suppress
Zener random noise. In addition I realized that removing the standard
CMOS ceramic capacitor on the supply pin increased swinging of the xtal.
Mounting of this capacitor directly to VCC completely shut down swinging.
Starting swinging was increased by delaying reset with a small
electrolytic capacitor. With all that measures the oscillation is
reliable, but small signals on the supply line can still stop
- a variation of the two capacitors, or
- dividing the XTAL2/CLKO output pin's voltage with resistors, or
- adding a 1MΩ resistor parallel to the xtal to increase
back-coupling of the CLKI/CLKO inverter
I call this unbelievable behavior "reverse BOD level effect".
Reversed because applying more than 4V stops oscillation.
188.8.131.52 The schematic with an integrated xtal oscillator
This is the schematic using an integrated crystal oscillator. That
works at 5 V operating voltage and does not have any other
limitations like above described. Even though this type of xtal
oscillators produce a horrible rectangular signal (anything else
than a steap up and down), it works perfect with an ATtiny25.
These are the two sine waves of the two generated signals. Looks
184.108.40.206 Software for the ATtiny25
The software for the ATtiny25 consists of a few lines assembler:
The source code is listed here and can be downloaded in assembler
- The two output pins OC0A and OC0B are configured as outputs.
- The port register of OC0A is cleared, the one for OC0B is set
to one (reversed signal)./li>
- Both compare values are set to the divider factor (divider
- In the control port TCCR0A of timer TC0 the CTC mode is set
and both output pins are defined to toggle on compare match.
- In control port TCCR0B the timer is started with a prescaler
value of 1.
- The sleep mode of the controller is set to idle mode, the
SLEEP instruction is executed and the controller is not needed
; * Xtal oscillator for TCA440 *
; * 15 MHz ==> (77.5+32.768 kHz) *
; * (C)2019 by DG4FAC *
.include "tn25def.inc" ; Define device ATtiny25
; H A R D W A R E
; Device: ATtiny25, Package: 8-pin-PDIP_SOIC
; 1 / |8
; RESET o--|RESET VCC|--o +5 V
; XTAL1 o--|PB3 PB2|--o
; XTAL2 o--|PB4 PB1|--o Osc out -
; 0 V o--|GND PB0|--o Osc out +
; F I X E D C O N S T A N T S
.equ clock = 15000000 ; 15 MHz
.equ fosc = 77500+32768 ; Added
.equ divider = (clock+fosc)/(fosc*2)
.equ cCtc = divider - 1 ; CTC value
; R E G I S T E R S
.def rmp = R16 ; Multipurpose register
; M A I N P R O G R A M I N I T
sbi DDRB,DDB0 ; PB0 direction output
cbi PORTB,PORTB0 ; Clear OC0A output
sbi DDRB,DDB1 ; PB1 direction output
sbi PORTB,PORTB1 ; Set OC0B output
ldi rmp,cCtc ; Write CTC value
out OCR0A,rmp ; to compare register A
out OCR0B,rmp ; and B
ldi rmp,(1<<WGM01)|(1<<COM0A0)|(1<<COM0B0) ; CTC mode, toggle OC0A
out TCCR0A,rmp ; in TC0 control port A
ldi rmp,(1<<CS00) ; Prescaler = 1
out TCCR0B,rmp ; in TC0 control port B
ldi rmp,1<<SE ; Sleep enable, idle mode
sleep ; Go to sleep
; End of source code
220.127.116.11 Fuses of the ATtiny25
Prior to or after programming the flash the fuses of the ATtiny25
have to be set to work with the external xtal or xtal oscillator.
The following fuses have to be set with a discrete crystal:
The listed row has to be followed in any case, otherwise you risk
to end with a chip that cannot be programmed in ISP mode any more.
- CLKOUT has to be enabled.
- CLKDIV8 has to be disabled.
- The clock frequency has to be set to an external oscillator
of more than 8 MHz.
When using an external integrated xtal oscillator, setting the
CLKOUT fuse can be omitted, but the CLKDIV8 fuse and the oscillator
setting changes have to be made accordingly.
18.104.22.168 Mounting the xtal sine wave generator
This is the sine wave generator on a breadboard, here with a
discrete crystal. The six capacitors right to the ATtiny25 form
the three RC networks for sine wave filtering.
This is the version with the integrated xtal oscillator.
©2019 by http://www.avr-asm-tutorial.net