In this article, we will discuss the oscillator of a microcontroller. Consider a PIC microtroller. It is a mid-range MCU family that uses an internal circuit for generating clock pulses for the microcontroller to work. This is an oscillator. An oscillator circuit helps in executing the instructions and peripherals of the function. For generating the one internal instruction, four clock (TCY) periods are used. The internal oscillator might have up to eight different modes. There are two modes, which allow the RC internal oscillator clock out (CLKOUT) to drive the I/O pins, or these modes allow the I/O pin to derive the general purpose instruction. The selection of these modes is based on device configuration bits. These bits are non-volatile memory locations. Their mode of operation is determined by the value written during the programming of the device.
Oscillator’s Mode of Operation
The oscillator has the following modes of operation:
- RC (External Resistor)
- HS (High-speed crystal or Resonator)
- LP (Low-frequency Power crystal)
- XT (CResonator)
- INTRC (Internal resistor at 4MHz frequency or capacitor with CLKOUT)
- INTRC (Internal resistor at 4MHz frequency or capacitor)
- EXTRC (Internal resistor or capacitor)
- EXTRC (Internal resistor or capacitor with CLKOUT)
The above modes or options of operation are present in a single device, and flexibility is available to fit the applications with different requirements of the oscillator. The RC option of the oscillator saves money, while the LP crystal option saves power. For selecting the different options, we use bit configuration.
Types of Oscillators
The MID-Range devices have up to eight different oscillator modes. The user uses only three bits of the configuration device (FOSC2, FOSC1, and FOSC0) to select one of these eight (LP, KT, HS, RC, EXTRC, EXTRC, INTRC, INTRC). The difference between modes KT, LP, and HS is to select the different frequency ranges of the internal oscillator. For example, the configuration bits 1 0 in HS mode are for high gain, and the configuration bit 0 1 in HT mode is for medium gain; similarly, the configuration bits 0 0 in LP mode are for low gain.
Crystal Oscillators or Ceramic Resonators
The crystal oscillators or ceramic resonators connect with the pins OSCI and OSC2 in LP, XT, or HS modes to establish the oscillation. A parallel-cut crystal is present in a PIC micro-oscillator for the design. If we use a series-cut crystal during manufacturing, then it may give a frequency that is out of range. We can see a crystal or ceramic resonator operation circuit in figure 1. It operates in HS, XT, and LP modes.
The circuit has an external clock source to drive the OSC1 pin; we may require series resistance Rs for an AT-cut crystal strip. RF is the feedback resistor, ranging between 2 and 10 MΩ. The buffer for the internal logic may be after or before the inverter oscillator, depending on the device.
Oscillator or Resonator Start Up
The oscillator or resonator will start up with its oscillations when the VCC voltage of the device increases. It’s time to start the oscillation, depending on factors such as the layout of the circuit oscillator, the quality of the crystal, the system temperature, the value of the capacitor, the value of the series resistor, the noise of the system, the VDD rise time of the device, the selection mode of the oscillator, and the resonant frequency. Figure 2 shows the oscillator start-up characteristics.
Component Selection for Oscillator
Figure 1 shows the oscillator circuitry, and according to this figure, the value of feedback Rs would be in the range of 2 to 10 MΩ. The value of this resistor varies with the deice voltages, variations in process, and temperature. During the selection of a resistor, we need to keep in mind the operating voltages of the device and its manufacturing process. For component selection, also see the component specification data sheet and typical values of capacitors C1 and C2. Each device data sheet gives the specific values, as we can see in Table 1.
The values of capacitors C1 and C2 would be according to the above table. The high value of the capacitor increases the stability of the oscillator but also increases the start-up time. The above table values are only useful for design purposes, but each oscillator or resonator has its own characteristics. All the resonators must have an external capacitor.
How to Select Internal Oscillator of PIC Microcontroller
Oscillator Circuit Tuning
The microchip devices have many purposes, such as frequency, voltage, and temperature measurements. These devices must have an external crystal or capacitor to meet the requirements of the applications. During the selection of these components, we need to keep the following factors in mind:
- The gain amplifier
- The resonant frequency
- Operational temperatures
- Oscillator start-up time
- Stability
- Life
- The power consumption
- The circuit simplification
- The use of standard components
- The combination of fewest components for desired result
- The range of supply voltages
- The desired frequency
We need to always keep the above factors in mind when tuning the oscillator or resonator.
Find the Best Values for Crystal
Here we will explain how to find the best values of crystal clock mode, C1, C2, and Rs. Mostly, for choosing the crystals, we use their parallel resonant frequency, but the design parameters are also important, like frequency or temperature tolerance. If you want to know more about the crystal operation and ordering information, then AN 588 is the best reference for you. The internal oscillator circuit in PIC micros is basically a parallel oscillator or resonator circuit, whose capacitance values are specific in the range between 20 PF and 32 PF.
At this range, the oscillator oscillates near the closest values of desirable frequency, but these values may juggle sometimes. The FOSC parameters are useful for choosing the clock mode. Clock modes are actually helpful for gain selection; lower gain is for lower frequencies, and higher gain is for higher frequencies. It is also possible to select a higher or lower gain depending on the need for the oscillator circuit. The selection of values for C1 and C2 is based on the load capacitance. But initially, the suggested values are used as suggested by the manufacturer and the table that is provided in the data sheet. Ideally, we choose the capacitor values in such a way that they must oscillate at the highest temperature and lowest VDD.
Applications of Oscillator
- It is actually an electronics circuit that produces the periodic oscillating signal that could be, at some point, a sine wave or a square wave.
- Its uses include signal generators for producing the oscillating signal. These signal generators then drive broadcasting devices such as radio, television, and transmitters.
- It is also useful in RF circuits for producing the RF oscillating signal.
- It is used in audio frequency devices for producing an audio frequency oscillating signal.
- The electronics amplifier is basically a linear oscillator, such as a transistor or op amp, that we can use as a feedback oscillator.
- The RC oscillator circuit, which consists of resistance and a capacitor, is helpful for producing lower frequencies.
- The LC oscillator circuit, which consists of an inductor and capacitor, is used for resonantly oscillating frequency signals.
Conclusion
In conclusion, this tutorial provides an in-depth overview of oscillators in microcontrollers. It also covers their types, workings, selection, tuning, and applications to help us better understand the concept. You can utilize these concepts for your complex microcontroller projects. Hopefully, this was helpful in expanding your knowledge.
You may also like to read:
- CCPM Servo Consistency Master/Servo Motor Tester
- Interface 28BYJ-48 Stepper Motor with ESP32 using MicroPython
- CCS811 Indoor Air Quality Gas Sensor
- Automatic dark detection circuit with Alarm
- LEAST LAXITY FIRST (LLF) SCHEDULING ALGORITHM
- IoT CCTV Camera using ESP32 CAM & Blynk App – Live Streaming
This concludes today’s article. If you face any issues or difficulties, let us know in the comment section below.
Hi,
Your courses for pic is very good .Do you have courses for atmega.
think you for this course is very good