Probleme au niveau du calcul du pont

This commit is contained in:
Adrien Van 2017-02-15 21:41:51 +01:00
parent cdb747dd5e
commit 84524e04fe
2 changed files with 15 additions and 14 deletions

View File

@ -1,10 +1,10 @@
#include "mesure.h"
#define __PIN_PWM__ 3
//#define DEBUG
#define DEBUG
float target_curent = 0.05;//ma
courant collecteur(A0,A1,100,1,1,0.248,0.248); // R1 10K, R2 3K3
courant base(A2,A3,10000);
courant base(A2,A3,820);
/*
courant collecteur(Potentien Haut U1,Potentiel Bas U2,Resistance[,Pon résistif sur U1,Pon résistif sur U2, Raport Résistance U1, Raport Résistance U2]);
par ex
@ -43,6 +43,7 @@ void loop()
analogWrite(__PIN_PWM__, PWMCourent);
#ifdef DEBUG
Serial.print("PWM:");Serial.print(PWMCourent);
Serial.print("\tIBase:");Serial.println(base.lireCourant());
Serial.print("\tIBase:");Serial.print(base.lireCourant());Serial.print("\tU1:");Serial.print(base.lireTensionU1());
Serial.print("U2");Serial.println(base.lireTensionU2());
#endif
}

View File

@ -12,8 +12,8 @@ courant::courant(uint8_t pinU1, uint8_t pinU2, int r)
pinMode(pinU2, 0);
bridgeU1Enable = 0;
bridgeU2Enable = 0;
bridgeU1RapportR = 1;
bridgeU2RapportR = 1;
bridgeU1RapportR = 0;
bridgeU2RapportR = 0;
}
courant::courant(uint8_t pinU1, uint8_t pinU2, int r, uint8_t bridgeU1Enable, uint8_t bridgeU2Enable,...)
{
@ -36,17 +36,17 @@ courant::courant(uint8_t pinU1, uint8_t pinU2, int r, uint8_t bridgeU1Enable, ui
if(bridgeU2Enable)
bridgeU2RapportR = va_arg(ap, double);
else
bridgeU2RapportR = 1;
bridgeU2RapportR = 0;
}
else
{
this->bridgeU1Enable = 0;
this->bridgeU2Enable = bridgeU2Enable;
bridgeU1RapportR = 1;
bridgeU1RapportR = 0;
if(bridgeU2Enable)
bridgeU2RapportR = va_arg(ap, double);
else
bridgeU2RapportR = 1;
bridgeU2RapportR = 0;
}
va_end(ap);
}
@ -59,8 +59,8 @@ void courant::config(uint8_t pinU1, uint8_t pinU2, int r)
pinMode(pinU2, 0);
bridgeU1Enable = 0;
bridgeU2Enable = 0;
bridgeU1RapportR = 1;
bridgeU2RapportR = 1;
bridgeU1RapportR = 0;
bridgeU2RapportR = 0;
}
void courant::config(uint8_t pinU1, uint8_t pinU2, int r, uint8_t bridgeU1Enable, uint8_t bridgeU2Enable, ...)
{
@ -82,17 +82,17 @@ void courant::config(uint8_t pinU1, uint8_t pinU2, int r, uint8_t bridgeU1Enable
if(bridgeU2Enable)
bridgeU2RapportR = va_arg(ap, double);
else
bridgeU2RapportR = 1;
bridgeU2RapportR = 0;
}
else
{
this->bridgeU1Enable = 0;
this->bridgeU2Enable = bridgeU2Enable;
bridgeU1RapportR = 1;
bridgeU1RapportR = 0;
if(bridgeU2Enable)
bridgeU2RapportR = va_arg(ap, double);
else
bridgeU2RapportR = 1;
bridgeU2RapportR = 0;
}
va_end(ap);
}
@ -108,7 +108,7 @@ void courant::lireTension()
double courant::lireCourant()
{
lireTension();
double i = ((u1-u2)/820.0)*1000;
double i = ((u1-u2)/(double)r)*1000;
return i;
}