I am trying to measure the voltage of an 5volt AC rectified voltage at 65Hz. Using the UNO R3 Below is the current code.
const int numReadings = 25;
int ac_input[numReadings];
const int analogInPin = A0;//Pin for input for AC voltage
float ac_output = 0;
int index = 0;
void setup()
{
Serial.begin(9600);
pinMode(A0, INPUT);
for (int thisReading = 0; thisReading < numReadings; thisReading ++)
ac_input[thisReading] = 0;
}
void loop()
{
ac_input[index]= analogRead(analogInPin);
ac_output = ((ac_input[index]/1023.0)*5.0);
Serial.println(ac_output);
delay(2);
index = index + 1;
if (index >=numReadings)
index =0;
}
The problem is that the output on the serial monitor only shows the peak values of the voltage. That is from 4-5v instead of zero.
The phrase "5 volt rectified AC voltage" is gibberish.
If you have rectified it, it isn't an AC voltage. The electron flow is no longer alternating in direction.
You will expect to see a DC voltage with a voltage ripple. Which is exactly what you are getting.
Depending on the type of rectifier, you will see 65 Hz or 130 Hz ripple. I can't tell from your
sampling rate, exactly which you are getting.
Your DC voltage has a peak of 5 volts and a minimum of about 4.5 volts. That is exactly what you
are getting.
michinyon:
The phrase "5 volt rectified AC voltage" is gibberish.
If you have rectified it, it isn't an AC voltage. The electron flow is no longer alternating in direction.
You will expect to see a DC voltage with a voltage ripple. Which is exactly what you are getting.
Depending on the type of rectifier, you will see 65 Hz or 130 Hz ripple. I can't tell from your
sampling rate, exactly which you are getting.
Your DC voltage has a peak of 5 volts and a minimum of about 4.5 volts. That is exactly what you
are getting.
The input to the arduino is 0 to 5volts ac I dont understand why you think its dc. I have attached a print screen of the input to the arduino
It is full wave rectification without a filter capacitor.
Without any load resistor the sample and hold capacitor on the arduino input will act as a smoothing capacitor.
Put a 10K load ( resistor) between the analogue input and ground.
You are supposed to sample at twice the frequency, in this case: 7.65 mS, although because of the full-wave rectification I suspect half that, namely 3.825 mS.
In your other thread on this subject, which I referred to in reply #1, I suggested buffering readings and then printing them out.
Why didn't you do this?