Design of Digital Voltmeter By using Micro-controller Part 2

 Microcontroller based Digital AC Meter Part 2 Code And Circuit

First Part available here



Circuit Diagram 

#include"lcd.h"
#include "adc.h"
#include "delay.h"
double volt_read_disply();
int main(void)
  
{   
     int adc_value1=0;  
  LCD_SetUp(PB_0,PB_1,PB_2,P_NC,P_NC,P_NC,P_NC,PB_4,PB_5,PB_6,PB_7);
  LCD_Init(2,16);     
     adc_init();
    
     LCD_Clear();
  LCD_GoToXY(0,0);  
  
  LCD_DisplayString("  g-Electron"); 
  _delay_ms(1000); 
  
 while(1) 
 {  
       adc_value1 =  volt_read_disply();
    LCD_GoToLine(1);  
    LCD_DisplayString(" Volt : ");    
    LCD_DisplayNumber(10,adc_value1,3);   
    LCD_DisplayString("V");  
    _delay_ms(1300);
 } 
}

double volt_read_disply()
{   int i,adc_value[40]={0}; int temp =0;
 
 adc_init();

  for(i=0; i<40;i++)                        // samples taking from 41 times 9.4milli second taken about on complte half cycle
   { 
   adc_value[i] = read_adc(0);  // reading voltage           
  }
   
  temp = adc_value[0];  
 for(i=0; i<40; i++)
 {
  if(temp<adc_value[i])
  temp=adc_value[i];
 }  
 
      return ((double)temp*0.224828935); // int to double casting
   
}

Post a Comment

This comment has been removed by a blog administrator. -

https://www.ramakkalmedutourism.com

[blogger]

MKRdezign

Test

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget