Home Automation System

Wednesday, February 10, 2016

Phase shift of the AC current signal with Arduino

time taken to collect two samples

116 us

shiftvalue = V2 -V1/116us

for (int i ;i=172;i++){
TimeA =micros();
data[i]=anlogReading(A0);
TimeB[i]=micros()-TimeA;
}


for (int i ;i=172;i++){

Phase[i] = data[i]-data[i-1]/TimeB[i];

# Need to find phase shift of each values 
# to keep constant value to phase we need to add some corrective value to the main  value 
# How to get phase value  
# Normally to cover 360 deg it take 20 ms 
if  add each value of Phase  to complete 360 deg , time taken , are equivalent to 20 ms then same in the correct track . to adjust need to add some corrective values to each phase to get close to main value . 

}

Simple way of getting sample value 
# This can be in Setup() 
for (int i ;i=10;i++){
TimeA =micros();
data=anlogReading(A0);
TimeB[i]=micros()-TimeA;
}

for (int i ;i=0.02*1000/(Average Of TimeB[]);i++){
TimeA =micros();
data[i]=anlogReading(A0);
TimeB[i]=micros()-TimeA;
}


50Hz AC Current Arduino calibration

Sampling the 50 Hz wave in arduino Uno board analog reading;


50 Hz means , 50 cycles in a second,
to complete one circle it takes 20 ms

if you sample the wave in normal arduino Anlogreading
then it take 116us to take a sample ,
time that take to reading between two value is 116us ;
so 20 ms it takes only 172 samples ..(approx)

That is  20/116 ;

so ,,,, we need to identify the phase before process the sampling ,,,

for(i = 0; i<172;i++){
data[i]=analogRead(A0);
} 
and get the average of the sample,

or you can but may be zero for AC signal , because AC wave have negative value too,

so to avoid that, takes max value of the average signal and multiply with root square , to get RMS value.