Offline
Newbie
Karma: 0
Posts: 13
|
 |
« on: February 13, 2013, 05:04:27 pm » |
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. 5 4.98 5 5 4.95 4.62 4.27 4.26 5 4.93 4.7 4.58 5 4.79 5 5 4.35 4.53 5 5 5 4.91 4.84 4.52 5 5 4.67 4.54 5 4.69 5 5 4.43 4.32 5 4.92 5 5 I have tried changing the board I'm using aswell as the input pin. Has anyone experienced anything similar ?
|
|
|
|
« Last Edit: February 14, 2013, 02:41:35 am by gmbroh »
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19018
I don't think you connected the grounds, Dave.
|
 |
« Reply #1 on: February 13, 2013, 05:10:41 pm » |
Have a look at this thread http://arduino.cc/forum/index.php/topic,144195.msg1084872.html#msg1084872Please use code tags when posting code. for (int thisReading = 0; thisReading < numReadings; thisReading ++) ac_input[thisReading] = 0; they're already zero; this is pointless.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 218
Posts: 13896
Lua rocks!
|
 |
« Reply #2 on: February 13, 2013, 06:30:18 pm » |
What are you expecting exactly? A 65 Hz signal would have a period of 15 mS, and you have a 2 mS delay between readings. What is your circuit?
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Tesla Member
Karma: 89
Posts: 6335
-
|
 |
« Reply #3 on: February 13, 2013, 07:01:46 pm » |
I am trying to measure the voltage of an 5volt AC rectified voltage at 65Hz
How have you connected the Arduino to the source? Where does the rectified signal come from - is it possible that it includes some smoothing?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
God Member
Karma: 9
Posts: 836
|
 |
« Reply #4 on: February 13, 2013, 07:14:36 pm » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Tesla Member
Karma: 89
Posts: 6335
-
|
 |
« Reply #5 on: February 13, 2013, 09:23:12 pm » |
The phrase "5 volt rectified AC voltage" is gibberish.
To me that seems like a reasonable way to describe a DC signal which has been obtained by rectifying an AC signal. Your DC voltage has a peak of 5 volts and a minimum of about 4.5 volts.
Do you mean that this is what would be expected from a rectified sin wave? If so, how did you predict the minimum value?
|
|
|
|
« Last Edit: February 13, 2013, 09:25:41 pm by PeterH »
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 218
Posts: 13896
Lua rocks!
|
 |
« Reply #6 on: February 13, 2013, 09:39:51 pm » |
I am trying to measure the voltage of an 5volt AC rectified voltage at 65Hz. Using the UNO R3 Below is the current code.
Is that full-wave or half-wave rectification?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 218
Posts: 13896
Lua rocks!
|
 |
« Reply #7 on: February 13, 2013, 10:12:49 pm » |
Read this before posting a programming questionPlease edit your post, select the code, and put it between [code] ... [/code] tags. You can do that by hitting the # button above the posting area.
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15314
Measurement changes behavior
|
 |
« Reply #8 on: February 14, 2013, 01:00:00 am » |
I am trying to measure the voltage of an 5volt AC rectified voltage at 65Hz. Using the UNO R3 Below is the current code.
Is that full-wave or half-wave rectification? And with or without a filter capacitor? Lefty
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 218
Posts: 13896
Lua rocks!
|
 |
« Reply #9 on: February 14, 2013, 01:36:19 am » |
See reply #2: What is your circuit?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 13
|
 |
« Reply #10 on: February 14, 2013, 02:32:17 am » |
What are you expecting exactly? A 65 Hz signal would have a period of 15 mS, and you have a 2 mS delay between readings. What is your circuit?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 13
|
 |
« Reply #11 on: February 14, 2013, 02:38:48 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 13
|
 |
« Reply #12 on: February 14, 2013, 02:40:36 am » |
I am trying to measure the voltage of an 5volt AC rectified voltage at 65Hz. Using the UNO R3 Below is the current code.
Is that full-wave or half-wave rectification? And with or without a filter capacitor? Lefty It is full wave rectification without a filter capacitor.
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Online
Brattain Member
Karma: 274
Posts: 25480
Solder is electric glue
|
 |
« Reply #13 on: February 14, 2013, 02:59:11 am » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19018
I don't think you connected the grounds, Dave.
|
 |
« Reply #14 on: February 14, 2013, 03:04:51 am » |
The input to the arduino is 0 to 5volts ac I dont understand why you think its dc. Because your scope trace clearly shows everything above 0V. Alternating current implies a current reversal.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
|