Ajout d'un nouveau programme de test de type multimètre
This commit is contained in:
parent
358490d27d
commit
cf28e8ae10
51
test/Measurement_ToolBox/Measurement_ToolBox.ino
Normal file
51
test/Measurement_ToolBox/Measurement_ToolBox.ino
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/**
|
||||||
|
* Auteur : Anatole SCHRAMM-HENRY
|
||||||
|
* Date : 11/11/2019
|
||||||
|
* Programme de test permettant de se familiariser avec les différentes formules U=R*I
|
||||||
|
*/
|
||||||
|
#include <math.h>
|
||||||
|
#define V_STEP 0.000805860 //Volt 3.3/(4096-1)
|
||||||
|
const double R_PREC(1471.0); //Ohm
|
||||||
|
|
||||||
|
unsigned int Raw(0.0);
|
||||||
|
double Vref(0.0);
|
||||||
|
double Iref(0.0);
|
||||||
|
double Rvar(0.0);
|
||||||
|
char buffer[300];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
// put your setup code here, to run once:
|
||||||
|
Serial.begin(115200);
|
||||||
|
pinMode(PA0, INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
Raw = analogRead(PA0);
|
||||||
|
Vref = rawToVref(Raw); //En Volt
|
||||||
|
Iref = Vref / R_PREC; //En Ampère
|
||||||
|
|
||||||
|
Rvar = (3.3-Vref)/Iref;
|
||||||
|
// put your main code here, to run repeatedly:
|
||||||
|
Serial.println("------------------------------------");
|
||||||
|
sprintf(buffer, "%d",Raw);
|
||||||
|
Serial.print("Raw : ");Serial.println(buffer);
|
||||||
|
|
||||||
|
sprintf(buffer, "%.6f Volts",Vref);
|
||||||
|
Serial.print("Voltage : ");Serial.println(buffer);
|
||||||
|
|
||||||
|
sprintf(buffer, "%.6f Amperes -> %.6f mA",Iref, Iref*1000.0);
|
||||||
|
Serial.print("Current : ");Serial.println(buffer);
|
||||||
|
|
||||||
|
sprintf(buffer, "%.6f Ohm",Rvar);
|
||||||
|
Serial.print("Resistance : ");Serial.println(buffer);
|
||||||
|
|
||||||
|
Serial.println("------------------------------------");
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
float rawToVref(float raw)
|
||||||
|
{
|
||||||
|
return V_STEP * (float)Raw;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user