This commit is contained in:
Adrien VAN DAMME 2017-02-09 14:36:48 +01:00
parent 284f89dc62
commit 4120d69772
1 changed files with 5 additions and 5 deletions

View File

@ -21,8 +21,8 @@ void loop()
static float curent;
static int pwm_value = 0;
curent = get_curent();
Serial.println(pwm_value);
if(curent<target_curent*0.9)
Serial.println(curent);
if(curent<target_curent*0.95)
{
pwm_value++;
analogWrite(__PWM_OUT__, pwm_value);
@ -32,7 +32,7 @@ void loop()
pwm_value--;
analogWrite(__PWM_OUT__, pwm_value);
}
delay(50);
delay(10);
}
float get_curent()
@ -40,8 +40,8 @@ float get_curent()
int b = analogRead(__ANALOGIN_BR__);
int a = analogRead(__ANALOGIN_AR__);
float dv = (b-a)*(5.0/1023.0) ; //Tension réel
float curent = (dv/(float)__RESISTOR_VALUE__)*100;
float curent = (dv/(float)__RESISTOR_VALUE__)*1000;
Serial.print(a);Serial.print(";");Serial.print(b);Serial.print(";");Serial.print(dv);Serial.print(";");Serial.print(curent);Serial.print(";");
//Serial.print(a);Serial.print(";");Serial.print(b);Serial.print(";");Serial.print(dv);Serial.print(";");Serial.print(curent);Serial.print(";");
return curent;
}