Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67c7e25a4a | ||
|
|
e97b6fd98b | ||
|
|
f19124b6df | ||
|
|
72eb1efda4 | ||
|
|
e5bb8fcc4c | ||
|
|
f6b4d8edd2 | ||
|
|
9a0c4ca74c | ||
|
|
e63fe005d5 | ||
|
|
84524e04fe | ||
|
|
cdb747dd5e |
@@ -1,34 +0,0 @@
|
|||||||
#ifndef REGULATIONINTENSITE_H
|
|
||||||
#define REGULATIONINTENSITE_H
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
float rapportR;
|
|
||||||
int pinU;
|
|
||||||
|
|
||||||
float uMesure;
|
|
||||||
float uReel;
|
|
||||||
} PontDiviseur;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
float r;
|
|
||||||
int pinU1;
|
|
||||||
int pinU2;
|
|
||||||
|
|
||||||
float u1;
|
|
||||||
float u2;
|
|
||||||
float i;
|
|
||||||
} CurentFromR;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
float targetI;
|
|
||||||
int pinPWM;
|
|
||||||
|
|
||||||
float *curI;
|
|
||||||
} Reg;
|
|
||||||
|
|
||||||
float readCurentFromR(CurentFromR *);
|
|
||||||
float readUFromPontDiviseur(PontDiviseur *);
|
|
||||||
void regulationI(Reg *);
|
|
||||||
void regulationVCE(Reg *);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
#include "mesure.h"
|
#include "mesure.h"
|
||||||
|
|
||||||
#define __PIN_PWM__ 3
|
#define __PIN_PWM__ 3
|
||||||
#define DEBUG
|
//#define DEBUG
|
||||||
float target_curent = 0.05;//ma
|
float target_curent = 0.05;//ma
|
||||||
courant collecteur(A0,A1,100,1,1,0.248,0.248); // R1 10K, R2 3K3
|
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]);
|
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
|
par ex
|
||||||
@@ -25,7 +25,7 @@ void setup()
|
|||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
static int PWMCourent = 122;
|
static int PWMCourent = 122;
|
||||||
float iBase = base.lireCourant();
|
double iBase = base.lireCourant();
|
||||||
if(iBase < target_curent*0.9)
|
if(iBase < target_curent*0.9)
|
||||||
PWMCourent++;
|
PWMCourent++;
|
||||||
else if(iBase > target_curent)
|
else if(iBase > target_curent)
|
||||||
@@ -43,6 +43,7 @@ void loop()
|
|||||||
analogWrite(__PIN_PWM__, PWMCourent);
|
analogWrite(__PIN_PWM__, PWMCourent);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.print("PWM:");Serial.print(PWMCourent);
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
16
mesure.cpp
16
mesure.cpp
@@ -1,5 +1,5 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "arduino.h"
|
#include <Arduino.h>
|
||||||
#include "mesure.h"
|
#include "mesure.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ courant::courant(uint8_t pinU1, uint8_t pinU2, int r, uint8_t bridgeU1Enable, ui
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->bridgeU1Enable = 0;
|
this->bridgeU1Enable = 1;
|
||||||
this->bridgeU2Enable = bridgeU2Enable;
|
this->bridgeU2Enable = bridgeU2Enable;
|
||||||
bridgeU1RapportR = 1;
|
bridgeU1RapportR = 1;
|
||||||
if(bridgeU2Enable)
|
if(bridgeU2Enable)
|
||||||
@@ -86,7 +86,7 @@ void courant::config(uint8_t pinU1, uint8_t pinU2, int r, uint8_t bridgeU1Enable
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->bridgeU1Enable = 0;
|
this->bridgeU1Enable = 1;
|
||||||
this->bridgeU2Enable = bridgeU2Enable;
|
this->bridgeU2Enable = bridgeU2Enable;
|
||||||
bridgeU1RapportR = 1;
|
bridgeU1RapportR = 1;
|
||||||
if(bridgeU2Enable)
|
if(bridgeU2Enable)
|
||||||
@@ -101,22 +101,24 @@ void courant::lireTension()
|
|||||||
u1RAW = analogRead(pinU1);
|
u1RAW = analogRead(pinU1);
|
||||||
u2RAW = analogRead(pinU2);
|
u2RAW = analogRead(pinU2);
|
||||||
|
|
||||||
u1 = (u1RAW*(5.0/1024.0))*(bridgeU1RapportR+1);
|
u1 = (u1RAW*(5.0/1024.0))*(1/bridgeU1RapportR);
|
||||||
u2 = (u2RAW*(5.0/1024.0))*(bridgeU2RapportR+1);
|
u2 = (u2RAW*(5.0/1024.0))*(1/bridgeU2RapportR);
|
||||||
|
|
||||||
}
|
}
|
||||||
double courant::lireCourant()
|
double courant::lireCourant()
|
||||||
{
|
{
|
||||||
lireTension();
|
lireTension();
|
||||||
double i = ((u1-u2)/820.0)*1000;
|
double i = ((u1-u2)/(double)r)*1000;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
double courant::lireTensionU1()
|
double courant::lireTensionU1()
|
||||||
{
|
{
|
||||||
|
lireTension();
|
||||||
return u1;
|
return u1;
|
||||||
}
|
}
|
||||||
double courant::lireTensionU2()
|
double courant::lireTensionU2()
|
||||||
{
|
{
|
||||||
|
lireTension();
|
||||||
return u2;
|
return u2;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user