Go Down

Topic: Please check where did i go wrong..help me (Read 245 times) previous topic - next topic

bsk_goud

Jan 17, 2013, 07:57 am Last Edit: Jan 17, 2013, 09:05 am by AWOL Reason: 1
Code: [Select]
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}}

lloyddean

What is this supposed to do?

Code: [Select]

   for (i=0; i >=0; i++)

LarryD

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: [Select]
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);
}
The way you have it in your schematic isn't the same as how you have it wired up!

michinyon

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.

AWOL

Where did you go wrong?
You posted the same incomplete code twice, without [font=Verdana][[/font]code] [font=Verdana][[/font]/code] tags.
I've deleted one of the posts, and put code tags in the other.
"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.

Go Up