How Cristal Oscillator Works

Print   

02 Nov 2017

Disclaimer:
This essay has been written and submitted by students and is not an example of our work. Please click this link to view samples of our professional work witten by our professional essay writers. Any opinions, findings, conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of EssayCompany.

D.D.C. Wickramarathna

S10646

2010/s/12296

Report on last week's work (12.02.2013)

Exercises

How Cristal Oscillator works

A crystal oscillator is an electronic component, which uses to the mechanical resonance of a vibrating crystal of piezoelectric material to create an electrical signal with a very precise frequency. This frequency is commonly used to keep track of time, to provide a stable clock signal for digital integrated circuits and to stabilize frequencies for radio transmitters.

The crystal oscillator circuit sustains oscillation by taking a voltage signal from the quartz resonator, amplifying it, and feeding it back to the resonator. The rate of expansion and contraction of the quartz is the resonant frequency, and is determined by the cut and size of the crystal.

How to find Input/output Impedance of Non- Inverting Op-Amp

Input Impedance of Non- Inverting Op-Amp

D:\uoc\ph 3032\ip impedence.jpg

Find Ri : Ii = i+ (ideal i- = i+ = 0)

Ri = = ∞

Input impedance (Ri) = ∞

Output Impedance of Non- Inverting Op-Amp

D:\uoc\ph 3032\op impedence.jpg

Output impedance (R0)

Find VL : 0 = i1 + i2 + i- (ideal i- = i+ = 0)

0 = i1 + i2 + 0

0 = + (ideal V- = V+ = 0)

0 = + (ideal V- = V+ = 0)

0 =

0 = VL

Output impedance (R0) = RL =

Substitute VL (R0) = RL = = 0

Output impedance (R0) = 0

Nyquist Theorem

Nyquist's theorem developed by H. Nyquist, which states that an analog signal waveform may be uniquely reconstructed, without error, from samples taken at equal time intervals. The sampling frequency should be at least twice the highest frequency contained in the signal.

Program Codes of Practical session

Light a LED Bulb Using Switch

#include <avr/io.h>

#include <util/delay.h>

#define F_CPU 1000000ul // 1MHz

#define LED PORTD0 // define PORTD0 as LED

#define SW PORTD1 // define PORTD1 as SW

int main(void){

DDRD=1; // set portd0 as output

while(1){

PORTD=0;

if((PIND & (1<<SW)==0){//comparison of register D and PORTD1 with ‘&’ operator

PORTD = 1<< LED; // assign 1 to portD0

//PORTD =(PORTD | 1<<LED1);

}

}

}

When we running above program, saw that when we press the switch, the LED is on. In here LED and Switch are controlled using Port D.

Binary Counter

#include <avr/io.h>

#include <util/delay.h>

#define F_CPU 1000000ul // 1MHz

#define LED PORTD // define PORTD as LED

#define LED_D DDRD // define DDRD as LED_D

#define SW PORTB // define PORTB as SW

#define SW_D DDRB // define DDRB as SW_D

#define SW1 PORTB0 // define PORTB0 as SW1

#define SW1_IO PINB // define PINB as SW1_IO

int main(void){

unsigned char count=0;

LED_D = 255; //set the data direction of PortD as output

SW_D =0; //set the data direction of PortB as Input

SW = 0<<SW1 ; // assign zero to portB0

while(1){

if((SW1_IO & (1<<SW1)) ==0){ /* comparison of register B and PORTB with ‘&’ operator*/

count++; //increase the current value of ‘count’ by one

LED =count; //set LED value as count value

_delay_ms(50);

}

LED =count;

}

}

When we press the switch, 8 LED shows the binary value of the counts of switch pressed (only 0-9 counts). In here LEDs are controlled using Port D and Switch is controlled using Port B.

0 to 9 Counter using a Switch

#include <avr/io.h>

#include <util/delay.h>

#define F_CPU 1000000UL

#define SSD_DATA PORTD // define PORTD as SSD_DATA

#define SSD_DATA_D DDRD // define DDRD as SSD_DATA_D

#define SW PORTB // define PORTB as SW

#define SW_D DDRB // define DDRB as SW_D

#define SW1 PORTB0 // define PORTB0 as SW1

#define SW1_IO PINB // define PINB as SW1_IO

int main(void){

DDRC = 255; //set the data direction of PortC as output

PORTC= 1;

unsigned char SSD[]={0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f};

unsigned char count=0;

SSD_DATA_D =255; //set the data direction of PortD as output

SW_D =0; //set the data direction of PortB as Input

SW = 0<<SW1; // assign zero to portB0

while(1){

if((SW1_IO & (1 << SW1))==0){

count++;

_delay_ms(50);

}

SSD_DATA =SSD[count];/*select the array element relevant to value of ‘count’ and assign that array value to SSD_DATA*/

}

}

When we press the switch, SSD shows the value of the counts of switch pressed (only 0-9 counts). In here SSDs are controlled using Port D and Switch is controlled using Port B.

0 to 9999 Counter

#include <avr/io.h>

#include <util/delay.h>

#define F_CPU 1000000

#define SW PORTB // define PORTB as SW

#define SW_D DDRB // define DDRB as SW_D

#define SW1 PORTB0 // define PORTB0 as SW1

#define SW1_IO PINB // define PINB as SW1_IO

#define SSD_DATA_D DDRD // define DDRD as SSD_DATA_D

#define SSD_DATA PORTD // define PORTD as SSD_DATA

#define SSD_DIG PORTC // define PORTC as SSD_DIG

#define SSD_DIG_D DDRC // define DDRC as SSD_DIG_D

unsigned char SSD[]= {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f, 0x6f};

unsigned char dig[]={0,0,0,0};

void decode(unsigned int num){

dig[0]=num/1000;

dig[1]=(num%1000)/100;

dig[2]=(num%100)/10;

dig[3]=(num%10);

}

void display(unsigned int rounds){

unsigned int i=0,j=0;

for(j=0;j!=rounds;j++){

for(i=0;i!=4;i++){

SSD_DATA = SSD[dig[i]]; /*select the ‘dig’ array element relevant to value of ‘i’ and also assign that array element value as ‘SSD’ array element and assign that array value to SSD_DATA*/

SSD_DIG=1<<i; //

_delay_us(10);

SSD_DIG=0; //remove ghost effect

}

}

}

int main(void){

SSD_DATA_D =255; //set the data direction of PortD as output

SW_D=0; //set the data direction of PortB as output

SW=0<<SW1; // assign zero to portB0

unsigned int count=0;

SSD_DATA_D=0xff; /*set the data direction of PortD as output*/

SSD_DIG_D=15; /*set the data direction of PortC(0-3) pins as output*/

while(1){

if((SW1_IO & (1<<SW1))==0){

count++;

decode(count); //Decode the count value

display(1000); //use instead of delay function.

}

display(100);

}

}

When we press the switch once, the MCU begin to count from 0 and seven segment displays shows the counts. That means the counts are reach to 10, it shows as 0010 on the display. We can change delay time between 2 numbers when changing the value of "display (1000)". If we press the switch without release, the counter set as pause condition and temporary pause the counting.

0 to 9999 Bidirectional Counter

When we running above code, saw that the seven segment display shows zero before the values. That means if we want to show 10 on the display, it shows as 0010. Therefore we modified above program to avoid that and to show only 10 on the SSD.

Also we modified above code to count forward and reverse when pressing a switch. When we press the switch once, counter begin to count forward. If we press the switch again, counter count reverse form current counter value. If we press the switch again, the counter counts forward beginnings with current counter value. Below code has been written including above modifications.

#include <avr/io.h>

#include <util/delay.h>

#define F_CPU 1000000

#define SW PORTB

#define SW_D DDRB

#define SW1 PORTB0

#define SW1_IO PINB

#define SSD_DATA_D DDRD

#define SSD_DATA PORTD

#define SSD_DIG PORTC

#define SSD_DIG_D DDRC

unsigned char SSD[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0};

unsigned char dig[]={10,10,10,0};

void decode(unsigned int num){

dig[0]=num/1000;

if(dig[0]==0){ //check the value of num/1000

dig[0]=10; /*insert 10 as 0th element of "dig" array. 10th element of "SSD" array is 0. Therefore there is nothing display on the 4th segment of SSD*/

dig[1]=(num%1000)/100;

if(dig[1]==0){ // check the value of (num%1000)/100

dig[1]=10; /*insert 10 as 1st element of "dig" array. 10th element of "SSD" array is 0. Therefore there is no displaying anything on the 3rd segment of SSD*/

dig[2]=(num%100)/10;

if(dig[2]==0){ // check the value of (num%1000)/10

dig[2]=10; /*insert 10 as 2nd element of "dig" array. 10th element of "SSD" array is 0. Therefore there is no displaying anything on the 2nd segment of SSD*/

}

dig[3]=(num%10);

}else{

dig[2]=(num%100)/10;

dig[3]=(num%10);

}

}else{

dig[1]=(num%1000)/100;

dig[2]=(num%100)/10;

dig[3]=(num%10);

}

}

void display(unsigned int rounds){

unsigned int i=0,j=0,k=0;

for(j=0;j!=rounds;j++){

for(i=0;i!=4;i++){

SSD_DATA = SSD[dig[i]];

SSD_DIG=1<<i;

_delay_us(10);

SSD_DIG=0;

}

}

}

int main(void){

SSD_DATA_D =255;

SW_D=0;

SW=0<<SW1;

unsigned int k=0;

unsigned int count=0;

SSD_DATA_D=0xff;

SSD_DIG_D=15;

while(1){

if((SW1_IO & (1<<SW1))==0){

count++;

decode(count); //Decode the count value

display(1000);

//_delay_ms(50);

}

else {

if((SW1_IO & (1<<SW1))==1){

for(k=count;k!=0;k--) {

count--; //reduce the current value of ‘count’ by one

decode(count); //Decode the count value

display(1000);

if((SW1_IO & (1<<SW1))==1){

break;

}

}

}

} display(100);

}

}



rev

Our Service Portfolio

jb

Want To Place An Order Quickly?

Then shoot us a message on Whatsapp, WeChat or Gmail. We are available 24/7 to assist you.

whatsapp

Do not panic, you are at the right place

jb

Visit Our essay writting help page to get all the details and guidence on availing our assiatance service.

Get 20% Discount, Now
£19 £14/ Per Page
14 days delivery time

Our writting assistance service is undoubtedly one of the most affordable writting assistance services and we have highly qualified professionls to help you with your work. So what are you waiting for, click below to order now.

Get An Instant Quote

ORDER TODAY!

Our experts are ready to assist you, call us to get a free quote or order now to get succeed in your academics writing.

Get a Free Quote Order Now