Thursday, August 21, 2014

Simple MHz Oscillator using an ATtiny15

Most engineers will recognise the problem: Your schema needs a stable 1 or 2 MHz clock generator (in the author’s case it was for a Pong game using an old AY3-8500). A suitable crystal is not to hand so you cobble together an RC oscillator (there are plenty of diagram for such a design). Now it turns out that you don’t have exactly the right capacitor so a preset pot is add e d to allow some adjustment . Before you know it the clock schema is taking up more space on the board than you had hoped. 

Providing the application does not demand a precise clock source a tiny 8-pin microcontroller may offer a better solution to the problem. It needs no additional external components and an old ATtiny15 can be found quite cheaply. Another advantage of the solution is that clock frequency adjustment does not involve changing external components and is not subject to component tolerances. 

The microcontroller’s internal RC oscillator is already accurately calibrated to 1.6 MHz. With its inbuilt PLL, internal Timer 1 can achieve up to 25.6 MHz [2]. By configuring internal dividers the timer can output a frequency in range of roughly 50 kHz up to 12 MHz from an output pin. The difference between calculated and the actual output frequency increases at higher frequencies. A meaningful upper limit of about 2 MHz is a practical value and even at this frequency the deviation from the calculated value is about 15 %.

MHz Oscillator using an ATtiny15 Schematic

MHz

The schema diagram could hardly be simpler, aside from the power supply connections the output signal on pin 6 (PB1) is the only other connection necessary.The example program, written in Assembler is just 15 lines long! With a program this short comments are almost super fluous but are included for clarity. The code can be downloaded from the Elektor website [1]. 

The program only needs to initialise the timer which then runs independently of processor control to output the clock sign al . The processor can then be put into sleep mode to memory used up the remaining 99 % is free for use for other tasks if required. 

The OSCCAL register contains a calibration byte which allows some adjustment of the CPU clock. This gives a certain degree of fine tuning of the output frequency. A recommendation in the Atmel data sheet indicates that the CPU clock frequency should not be greater than 1.75 MHz otherwise timer operation cannot be guaranteed. 

The more recent ATtiny45 can be substituted for the ATtiny15. In this case the CK SEL fuses should be set to put the chip’s Timer 1 into ATtiny15- compatible mode [3]. After adjustment to the program it will now be possible to obtain a higher (or more exact) frequency from the timer, the ATtiny45’s PLL can operate up to 64 MHz.

Related Posts:

  • Build a Car Voltage Regulator Circuit Using LM317The car cigarette lighter socket does not only light cigarettes, but can be utilized as an electrical channel for powering tools to work on the car such as laptops and other electronic devices. The following schema diagram sh… Read More
  • Magic Lights Circuit using Bi Colour LEDThis is the magic lights schema which use bi-colour LED as the output to provide the light. The schema uses 14 bi-colour (red and green) LEDs having 3 terminals each. Various dancing colour patterns are generated utilizing th… Read More
  • Power Pulse Using by LM350 and NE555This is a Simple Power Pulse Using by LM350 and NE555 Circuit Diagram. This schema can use to drive lamp,power LED,DC motor etc. Adjust R5 for output amplitude.Adjust R1 for output power .Power Pulse Circuit DiagramThe LM350 … Read More
  • 6W amplifier using TA7222APThis is a good news for the car owners because this amp works with 12v.TDA7222AP is an excellent integrated audio amplifier which can deliver 5.8W to a 4 Ohms loadNotes. * The schema can be assembled on a Vero board. * Use 12… Read More
  • Melody Generator using IC UM66Here is the simplest melody generator schema you can make using an IC.The UM66 series are CMOS IC’s designed for using in calling bell, phone and toys. It has a built in ROM programmed for playing music. The device has very l… Read More

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.