Pages: [1]   Go Down
Author Topic: Please check where did i go wrong..help me  (Read 228 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
void setup()
{
  Serial.begin(9600);
}

void loop() {
    for (i=0; i >=0; i++)
    {
 VdcSensed[i] = analogRead(A0);
 IdcSensed[i] = analogRead(A1);
 VdcActual[i] = VdcSensed[i] * (5.0 / 1023.0);
 IdcActual[i] = IdcSensed[i] * (5.0 / 1023.0);
 Vdc[i] = 200 * VdcActual[i];
 Idc[i] = IdcActual[i] * (2000.0 / 411.2);  
 P[i] = Vdc[i] * Idc[i];
 deltaP[i] = (P[i] - P[i-1]);
  
  Serial.println(VdcSensed[i]);
  Serial.println(IdcSensed[i]);
  Serial.println(VdcActual[i]);
  Serial.println(IdcActual[i]);
  Serial.println(Vdc[i]);
  Serial.println(Idc[i]);
  Serial.println(P[i]);
  delay(5000);
    }
}

Moderator edit: CODE TAGS {{sob}}
« Last Edit: January 17, 2013, 03:05:49 am by AWOL » Logged

Des Moines, WA - USA
Offline Offline
God Member
*****
Karma: 25
Posts: 779
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is this supposed to do?

Code:
   for (i=0; i >=0; i++)
Logged

Offline Offline
Faraday Member
**
Karma: 68
Posts: 2806
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This may help get you started.
You really have to explain what you are trying to do.
What kind of errors you are getting.

In fact, read:
http://arduino.cc/forum/index.php/topic,97455.0.html

Code:
void setup()
{
  Serial.begin(9600);
}
float P;
float lastP=0.0;
void loop() {
 float VdcSensed = analogRead(A0);
 float IdcSensed = analogRead(A1);
 float VdcActual = VdcSensed * (5.0 / 1023.0);
 float IdcActual = IdcSensed * (5.0 / 1023.0);
 float Vdc = 200 * VdcActual;
 float Idc = IdcActual * (2000.0 / 411.2); 
 float P = Vdc * Idc;
 float deltaP = (P - lastP);
       lastP=P;
  Serial.println(VdcSensed);
  Serial.println(IdcSensed);
  Serial.println(VdcActual);
  Serial.println(IdcActual);
  Serial.println(Vdc);
  Serial.println(Idc);
  Serial.println(P);
  Serial.println(deltaP);
  Serial.println("");
  delay(5000);
}
Logged

The way you have it in your schematic isn't the same as how you have it wired up! That goes for me too.

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

Your loop will run indefinitely,  or until it runs out of numbers.   
You probably don't want to do this.

It is unnecessary,   because the loop() function will operate over and over again anyway.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26514
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Where did you go wrong?
You posted the same incomplete code twice, without [code] [/code] tags.
I've deleted one of the posts, and put code tags in the other.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Pages: [1]   Go Up
Jump to: