In: Electrical Engineering
HOW CAN I WRITE A PROGRAMING CODE IN ARDUINO DIE ABOUT THE ROOT MEAN SQUARE VALUE OF A SIGNAL
RMS value is nothing but the A C value of the signal.
Generally, As Arduino can read maximum 5 Volts, so it’s not possible to read directly 230V and for this reason we can use a step down transformer from 220V to 12V.
where max=the maximum value read by Arduino
Code:
const int readvoltage = A0; // Analog input pin that reads the voltage
int x = 0; // value associated with voltage
float v=0; //voltage after voltage divider
float i=0; //comparison variable
float maxim=0; // maximum variable which is used for rms
value
boolean OK=false;
float V=0; // voltage before voltage divider
float Vin=0;// voltage before bridge rectifier
float Vgrid=0; //grid voltage(rms value)
const float y=17.89; //transformer ratio
void setup() {
// initialize serial communications at 250000 bps:
Serial.begin(250000);
}
void loop() {
// read the analog in value:
x = analogRead(readvoltage);
Serial.println(Vgrid);
v=x*5.0/1023.0;// voltage on analog input
if(v<i && OK==false){
maxim=i;// 3.88 represent 230V in the grid
OK=true;
}
else if (v<=0.1){// because not every time voltage drop to zero
according to serial monitor
OK=false; //reset for next half duty cycle
}
i=v;
V=maxim/0.230;//0.230 come from the voltage divider resistors
R1=3288.4 and R2=983.6
Vin=V+1.4; //adding the bridge rectifier voltage drop
Vgrid=Vin*y*0.707;//voltage grid-RMS value-obtain 230V-229V for a
maxim=3.88
} //230V-231V measured with multimeter