AC voltage measurement using pic microcontroller

Status
Not open for further replies.
Sorry What 's circuit it can measure voltage without wait discharge time.
I'm want to measure voltage & frequency to MCU PIC18f8722.
thank for answer.
 

What is the formula ?? Please post in detail if Vx = 9V then R1? and R2?

- - - Updated - - -

measure the value of vx via digital volt meter
for eg if vx = 7v
then select
R1 = 1k , R2 = 2.5k

hameeds01
A.O.A Please write the formula, post in detail ..... thanx
 
Ihave a doubt with the response time vs accuracy........if you use it for application like stabilizer then

This ckt will be giving op voltage with ac component .if you try to remove the ripples using a big cap across it the signal changes slowly then.......

Can anybody suggest a method for measuring ac voltage peak with instantaneous response to change in voltage.......
 
hello,


I did some test to measure AC voltage
using a transfo 230V/9V Ac
in reality deliver 11,8V rms (because no load)
With a potentiometer of 10K 3 turns 1W
i reduce the voltage to 1,6V efficace (rms) and add a DC value of 2.5V (see excel image)
by a resitor divider +5V 1K (here) 1K 0V
And i take as quick as possible ADC measure (centered around the midle of range of ADC 2,5V) so AC 0V is centered.
and measure can evoluate between 0 and 1023 points.
With my PIC18F26K22 , quartz 10Mhz , i can get 172 measure within 20mS ( a timer1 flag ON after 20 mS)
No interrupt used.

so i store all meaure in a table and after i serach mini value and maxi value to
calculate Peak to peak value.
I get 928 point peak to pak value wich represente 1,6V efficace + 2,5V DC on Analog ADC input.
when i have 235V on primary of transfo..
So the rule is easy :
Voltage = pk2pk value *235/928 ( 928 is the calibration value)
You can see what i get on excel ,on my scope, and on my LCD.

Measures are coherents an d maybe enough accurate for you ?

here is the main part , i have LCD4x20 output and RS232 output..
but RS232 not needed at all , only for testing.
Maybe with a clock of 16Mhz it's possible to reach 200 meausre for 20mS...
don't forget ..it is for 50Hz (20mS)


Code:
//========= Main loop ==============
CRLF();
do
  { 
         
 j=0;n1=0;
  PIR1bits.TMR1IF=0;      // raz flag interrupt
  WriteTimer1(15537);    // 19,99mS
  T1CONbits.TMR1ON=1; 
      while(PIR1bits.TMR1IF==0)
      {
         ADCON0=1;   // ADON=1 et choix de canal 
         ADCON0bits.ADON=1; //GO
         n1++;
         Delay10TCYx(1); 
         ConvertADC(); // Start conversion
          while( BusyADC() );
         Table_sinusoide[j] = ReadADC(); 
       j++;
        }
       T1CONbits.TMR1ON=0; 
       PIR1bits.TMR1IF=0; 
      Put_RS('N');
     Put_RS('=');
       Write_Word_(n1,0);
       CRLF(); 
       mini=1024;
       maxi=0;
       for(j=0;j<n1;j++)
       {
        M=Table_sinusoide[j];
        if (M<mini) mini=M;
        if(M>maxi)maxi=M;
        Drapeaux.Fill=1;
        Write_Word_(M,0);
        Drapeaux.Fill=0;
        Put_RS(';'); // separateur de champs  
        k=1+ (j & 0x0003);
        LCD_Erase_Line(k);    
        k=sprintf(txt,"%04d ",M);
        LCD_puts(txt);
        Tempo(10000L);
       } 
       CRLF();
       LCD_Erase_Line(4); 
       ecart=maxi-mini;
       k=fprintf(_H_USART,"Maxi=%04d  Mini=%04d  Peak2Peak=%04d \n",maxi,mini,ecart);
       k=sprintf(txt, "Maxi=%04d  Mini=%04d",maxi,mini);
       LCD_Erase_Line(1);    
       LCD_puts(txt);
       k=sprintf(txt, "Ecart pk2pk =%04d",ecart);
       LCD_Erase_Line(2);    
       LCD_puts(txt);  
       // 928 is the nb of point between maxi-mini of sinusoide for
       // a voltage input of 1,6V efficae + 2,5V DC as offset
       Voltage=(float)ecart*235.0/928;
       print_flt(Voltage,1,0); // on RS232
       fltToa (Voltage, txt,2);
       LCD_Erase_Line(3);    
       LCD_puts(txt);
        
  Tempo(500000L);
 CRLF();
  }
while(1);  
 
}




https://obrazki.elektroda.pl/4397716400_1379348094.jpg
https://obrazki.elektroda.pl/9571937000_1379348194.jpg
https://obrazki.elektroda.pl/8104849100_1379348196.jpg


and the ascii file catched on my terminal (CSV file )

View attachment 50Hz_1_6V.csv.txt
 
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…