Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] phase lock loop using microcontroller initial step using ADC

Status
Not open for further replies.

patelvivekv1993

Newbie level 6
Newbie level 6
Joined
Feb 21, 2014
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
81
i want to design a Phase lock loop using microcontroller with memory block method(i.e not using hardwired XORing)....i know its somewhat hard and complicated so i wanted to start by starting with small small steps........
i am using PIC18F4550 right now i have configured its ADC with TAD as 64Tosc and acquiring time as 2Tad and i am using 48Mhz crystal so calculating with that values i think my sampling freqeuncy is 250KHz ??????
i am using mikro c Pro for PIC and proteus for simulation.......
Now i wanna know that 250KHz samling frequency means that if i provide a 250KHz sine wave to the analog channel my all output must be 0????(or nearer to 0) as at that time the sampling would be done...
i know that it will be also the case for double and half frequency....but thats not my concern right now....

what i wanna do right now as initial step towards PLL is find out whether the signal supplied to the controller is of a certain frequency or not....so is my logic correct???

becuase i have simulated the above with mikro c and proteus and i m gettting the wrong results i.e instead of getting 0 at 250KHz i am getting it at 250Hz

i am attaching my mikro c project as well as proteus file and writing the code below

Code:
//Memory Card Chip Select Connection
sfr sbit Mmc_Chip_Select at RB2_bit;
sfr sbit Mmc_Chip_Select_Direction at TRISB2_bit;


unsigned char filename[] = "vivek.txt";
unsigned char error;
unsigned int temp;
double adc_value,voltage;
unsigned char tagline[] = " hello i am vivek using mikro c ";
unsigned char voltage_Log[7];
void main()
{
 unsigned char ones,point_ones,point_hundreds,newline='\r\n';
 TRISD =0x00;
 ADCON0 = 0b00000001;    //A/D Converter Power Up
 ADCON1 = 0x00;          //All Analog Channels
 ADCON2 = 0b10111110;    //Right Justfied and Slowest Clock for better accuracy
 ADC_Init();

 SPI1_Init();
 SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);

 error = MMC_Init();
 while(error == 1)
 {
  LATD=0xff;
  error = MMC_Init();
 }
  LATD =0x00;
 MMC_Fat_Init();
 SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);

 Mmc_Fat_Assign(&filename,0x80);
 while(1)
 {
  adc_value = ADC_Read(0);      //Read Temperature from ADC
  voltage=adc_value*5/1023;
  ones = voltage/1;
  ones = ones | 0x30;
  temp=voltage*10;
  point_ones = temp%10;
  point_ones = point_ones | 0x30;
  temp=voltage*100;
  point_hundreds = temp%10;
  point_hundreds = point_hundreds | 0x30;
  voltage_Log[0] = ones;
  voltage_Log[1] = '.';
  voltage_Log[2] = point_ones;
  voltage_Log[3] = point_hundreds;
  voltage_Log[4] = 'V';
  voltage_Log[5] = '\r';
  voltage_Log[6] = '\n';
  Mmc_Fat_Append();
  //Mmc_Fat_Write(tagline,sizeof(tagline));
  Mmc_Fat_Write(voltage_Log,sizeof(voltage_Log));
}
}


and if someone knows or has done PLL can u please give me some deep insight on actually how it is done using controller????

please help me here.....
thnx in advance.....
 

Attachments

  • PIC18project.zip
    220.4 KB · Views: 82

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top