Pages: [1]   Go Down
Author Topic: Problems measuring current from power source  (Read 2149 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm using a power source to measure the voltage and current at two of the analog inputs. The problem with this code is that its measuring the wrong current values. If one of the inputs is 5V then the current should be within the mili Amps. Instead its monitoring within 1-3Amps. I can't seem to see the problem with this code. This will be used to measure the current and voltage produced from a wind turbine to monitor the power. I'm using the Arduino Mega.

  int analogPin = A0;             //measure pin 0
  int analogPin1 = A1;             //measure pin 1
  int val0 = 0;                //variable to store the read value of Pin 0
  int val1 = 0;                //variable to store the read value of Pin 1
  double Vout0;
  double Current1; 
  double I;
  double P;
  double C = 204.6;             //constant value divider (5/1023) (ex 5V = 1023 serial monitor reading)

  void setup ()
  {
  }

  void loop()
  {
   val0 = analogRead(A0);       //read the value of Pin 0
   val1 = analogRead(A1);       //read the value of Pin 1
   Serial.begin(9600);       //initialize the input on analog pin 0 and 1;
                        //print out the value read:
   Vout0 = val0/C;
   Current1 = val1/C;
   
   I = Current1;                //current from pin A1
   P = Vout0 * I;
   Serial.print("Volts = ");
   Serial.println(Vout0);       //printout voltage in serial monitor
   Serial.print("Amps = ");
   Serial.println(I);          //printout amps in serial monitor
   Serial.print("Power = ");
   Serial.println(P);          //printout power in serial monitor
   Serial.println("===============================================");
   
   delay(2000);
  }
   
   
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 362
Posts: 17307
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Analog input pins don't measure current directly. There must be some external circuitry that is converting and scales some specific DC current range to the arduino 0-5vdc input range. Until you show us that circuitry and details it's hard to help you with your problem.

Lefty
Logged

Offline Offline
Edison Member
*
Karma: 50
Posts: 1702
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
   Vout0 = val0/C;
   Current1 = val1/C;
You are converting val1 by dividing it with the same constant as you use to convert val0 to volts.
It's very unlikely that they'll be the same. What is the full-scale current range on pin A1?

Pete
Logged

Offline Offline
Faraday Member
**
Karma: 62
Posts: 3080
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I'm using a power source to measure the voltage and current at two of the analog inputs

I can't even understand what you mean by this.....  "a power source"  is what,  exactly ?

To measure the voltage at the analog input,  you use ...   the analog input.  That's what it does.
The current should be negligible, because the analog input has quite a high impedance.
Logged

Tasmania - Australia
Offline Offline
Sr. Member
****
Karma: 16
Posts: 322
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

lvergara21, what is your status with this at the moment?

I notice you have in your main() the Serial.begin(9600).
Normally you do this only once, so the best place for that is in your Setup().

el_supremo is correct, you will most likely not be using the same scale factor value for both reading volts as current.

Also, where in the wind turbine circuit are you making the measurement, AC or DC side?

How are you measuring the current that you want to read from the wind turbine?
Typically, it is one of two methods, either a standard current shunt bar with an op-amp to bring up the mV to a higher value.
Or, secondly, a hall effect chip like the ACS712?
_____
Paul
Logged


Pages: [1]   Go Up
Jump to: