thannara123
Advanced Member level 5
As my part of a project , An Atmega8 based AC 230 voltmeter made ,and works normally .
but some times it hangup or stuck {stuck the LCD display],especially
when toggles [rapidaly connect and disconnect] the input .
what may be the problem .
I am providing some information of the voltmeter
AVCC ---> VCC
Vref connected to capacitor 104 [.1uf]
230 volt ac stepdowned to 6 volt with bridge rectifre ,filtred with 1uf capacitor and finally given to a voltage divider
Some code
but some times it hangup or stuck {stuck the LCD display],especially
when toggles [rapidaly connect and disconnect] the input .
what may be the problem .
I am providing some information of the voltmeter
AVCC ---> VCC
Vref connected to capacitor 104 [.1uf]
230 volt ac stepdowned to 6 volt with bridge rectifre ,filtred with 1uf capacitor and finally given to a voltage divider
Some code
Code:
int main(void)
{
int adc_value1=0;
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_Printf("%d",adc_value1);
LCD_DisplayString("V");
_delay_ms(1300);
}
}
int volt_read_disply()
{ int i,adc_value[40]={0}; int temp =0, adc=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];
}
adc=temp;
return (adc*0.224828935);
}