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.

[PIC] AC Voltage measurement by using ADC

Status
Not open for further replies.

ud23

Advanced Member level 3
Advanced Member level 3
Joined
Apr 20, 2011
Messages
926
Helped
185
Reputation
370
Reaction score
180
Trophy points
1,323
Visit site
Activity points
6,138
same ADC is used to measure DC Voltage sensing i got the fine result

What is the maximum accuracy i can get in between these voltage levels(170- 280).

Are you trying to read a AC voltage directly from ADC?
 

Hi,

I am using

Pic30f5011 Controller,
12 bit ADC,
EXT OSC with Pll 4x,


I need to sense AC Voltage 170 to 280 Volt for Single phase and 3 Phase applications.
ADC sensing the voltages and calibration also done but the problem is i am not getting the accurate result, output voltage linearly varying .

Getting the results like.....

Fluke reading(V) ADC output reading(V) Difference(V)

270 - 273 = -3
262 - 266 = -4
250 - 251 = -1

230 - 230 = 0
220 - 220 = 0 (Calibrated here)

200 - 198 = +2
190 - 187 = +3
172 - 168 = +4
140 - 135 = +5
100 - 96 = +4
80 - 77 = +3
60 - 55 = +5
40 - 35 = +5
30 - 26 = +4
10 - 10 = 0
8 - 10 =-2

same ADC is used to measure DC Voltage sensing i got the fine result.

What is the maximum accuracy i can get in between these voltage levels(170- 280).

- - - Updated - - -

Schematic for ADC channel...

AN0,AN1,AN2 analog pins to interface pic


ADC schematic.PNG

- - - Updated - - -
 

Are you trying to read a AC voltage directly from ADC?


No i used Op-amp, i attached schematic above...

in program calculated RMS for ac current

- - - Updated - - -

Code:
#define DC_Offset1 2042 	
#define DC_Offset2 2042		//for Analog Pin 
#define DC_Offset3 2042		//For analog pin 

#define OPV 5.035 			//operating controller voltage 
#define Gain 244.442		//gain = (OPV)* Fluke Voltage measurement at the end of OPAMP (Converted DC vlotage)

#define Mul_fact_B 0.325	//Multifiaon Factor =  (gain*OPV)/4096 //here 4096 is for 12 bit adc 2^12 (Offset max expected)
#define Mul_fact_Y 0.300
#define Mul_fact_R 0.330




void Adc_Init(void)
{
	ADPCFG	=	0xFFFF;		//configuring channels
	ADPCFGbits.PCFG13 =0;  		//Blue	
	ADPCFGbits.PCFG14 =0;		//Yellow
	ADPCFGbits.PCFG15 =0;		// Red 
	ADCHS             = 0;
	ADCON3bits.ADCS   = 31;		//A/D Conversion Clock Select bits.
	ADCON3bits.SAMC   = 1; 		//sample for 1 Tad cycles 
	ADCON3bits.ADRC   = 0; 		//Clock derived from system clock
	ADCSSL	=	0x0000;		 
	ADCSSLbits.CSSL13 =1;	
	ADCSSLbits.CSSL14 =1;
	ADCSSLbits.CSSL15 =1;	
	ADCON2bits.ALTS=0;			  //0 = Always use MUX A input multiplexer settings, (bit 0)
	ADCON2bits.BUFM=0;		//0 means Buffer configured as one 16-word buffer (bit 1)
	ADCON2bits.SMPI=2;			//Sample/Convert Sequences Per Interrupt Selection bits (bit 5-2)
	ADCON2bits.CSCNA=1;		//1= scan i/p, 0= dont scan (bit 10)
	ADCON2bits.VCFG=0;			//Voltage ref Config (bit 15-13)
	ADCON2bits.BUFS=0;			//0 means BUF select any one of set 8-16 resgisters,0r 0-7 (bit 7)
	ADCON1bits.ADON=0;		//on or off A/D (BIT 15)	
	ADCON1bits.ADSIDL=0;		//IDEAL MODE RUN BIT(BIT 13)
	ADCON1bits.FORM=0;		//OUTPUT FORM 00 (16 BIT UNSIGNED INT)
	ADCON1bits.SSRC=7;			//111 = Internal counter ends sampling and starts conversion (auto convert).       
ADCON1bits.ASAM=1;			//1 is for auto sample,0 Sampling begins when SAMP bit set (BIT 2)
	ADCON1bits.SAMP=0;			//ASAM = 0, writing ‘1’ to this bit will start sampling	(BIT 1)
								
	ADCON1bits.DONE=0;			//Done Coversion (BIT 0)
	ADCON1bits.ADON=1;			
}

void Display(unsigned long int root1,unsigned long int root2,unsigned long int root3)
{
		Mean_sqrt1 = sqrt(root1/Samples);	//applying mean and square root to the result of value1
		Mean_sqrt2 = sqrt(root2/Samples);	//applying mean and square root to the result of value2
		Mean_sqrt3 = sqrt(root3/Samples);	//applying mean and square root to the result of value3
		
		digi_result1 = ((float)Mean_sqrt1*Mul_fact_B);
		digi_result2 = ((float)Mean_sqrt2*Mul_fact_Y);	
		digi_result3 = ((float)Mean_sqrt3*Mul_fact_R);

	
		printf("\nBLUE = %.2f V      \t", (digi_result1));
		printf("\tYELLOW = %.2f V    \t", (digi_result2));
		printf("\tRED = %.2f V", (digi_result3));
		digi_result1=0;	digi_result2=0; 	digi_result3=0;


int main()
{
	Adc_Init();

	while(1)
	{
		while(!ADCON1bits.DONE);

		buf_read1 = ((signed int)ADCBUF0 - DC_Offset1);	//To get the exact DC 
		buf_read2 = ((signed int)ADCBUF1 - DC_Offset2);	//To get the exact DC 
		buf_read3 = ((signed int)ADCBUF2 - DC_Offset3);	//To get the exact DC 


		////////To get RMS (ROOT MEAN SQUARE)//////////////////////

		root1 += pow(abs(buf_read1),2);		//applying root to the buf0 value
		root2 += pow(abs(buf_read2),2);		//applying root to the buf1 value
		root3 += pow(abs(buf_read3),2);		//applying root to the buf2 value
		
		j++;
		if(j >(Samples-1))
		{
			Display(root1,root2,root3);
			root1 =0,root2=0,root3=0;
			j=0;
		}
	}
}
 

sorry for late reply

I assume that you are using LM324 and as mentioned in your schematic image that your VCC1 is 5v. And we don't know what is your set gain value.But I guess you are get full scale output(5v) from the op-amp circuit.can you share what is the maximum output you get with your circuit.
 

sorry for late reply

I assume that you are using LM324 and as mentioned in your schematic image that your VCC1 is 5v. And we don't know what is your set gain value.But I guess you are get full scale output(5v) from the op-amp circuit.can you share what is the maximum output you get with your circuit.


I am utilizing two channels of ADC in PIC30F5011, one for reading what Input Voltage that is going to Servo Motor, and the other channel
for reading Output Voltage from the same Servo Motor.
I have used two of same differential amplifier circuit built with MCP6294 as shown in this thread posting in between my PIC and input(AC) voltage for
reading AC Voltages.

I have utilized RMS calculations mentioned as shown in this thread.
I have calibrated the reading of my ADC at 230 Volts, but I get a variation of +/- 5 volts while testing with voltages between 20 and 280.
I made comparision with fluke true RMS multimeter and varied voltages with a variac.

i am trying to measure voltage so the input voltage to my pic will be in around from 2 volts to 5 volts max as i am using 12 bit adc where division factor will be 4096.

gain = (OPV)* Fluke Voltage measurement at the end of OPAMP
the calculation of my Mul_fact_B = (gain*Opearating voltage)/4096
so i made tehse calculation at 230 volts and defined as value in my code
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top