Mathis Vernay / Mbed 2 deprecated calibratio_jauge

Dependencies:   mbed HX711 BME280

Committer:
mathis_v
Date:
Thu Mar 05 09:59:18 2020 +0000
Revision:
0:b513811affc9
Child:
1:dc5547452d12
affichage des jauges 1 a 4 + le total

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mathis_v 0:b513811affc9 1 #include "mbed.h"
mathis_v 0:b513811affc9 2 #include "HX711.h"
mathis_v 0:b513811affc9 3
mathis_v 0:b513811affc9 4 /* définition des constantes pour les jauges*/
mathis_v 0:b513811affc9 5 #define PINSCK A5
mathis_v 0:b513811affc9 6 #define CAL_FACT1 -57.8
mathis_v 0:b513811affc9 7 #define CAL_FACT2 -57.8
mathis_v 0:b513811affc9 8 #define CAL_FACT3 -57.8
mathis_v 0:b513811affc9 9 #define CAL_FACT4 -57.8
mathis_v 0:b513811affc9 10 #define AVG_SAMPLE 100
mathis_v 0:b513811affc9 11
mathis_v 0:b513811affc9 12 Serial pc(USBTX, USBRX); /*Liaison série avec le pc*/
mathis_v 0:b513811affc9 13
mathis_v 0:b513811affc9 14 HX711 s1(A1,PINSCK),s2(A2,PINSCK),s3(A3,PINSCK),s4(A4,PINSCK); /*déclaration des 4 jauges*/
mathis_v 0:b513811affc9 15
mathis_v 0:b513811affc9 16 void print_4jauges();
mathis_v 0:b513811affc9 17
mathis_v 0:b513811affc9 18 //------------------------------------------------
mathis_v 0:b513811affc9 19 DigitalOut myled(LED1);
mathis_v 0:b513811affc9 20 //------------------------------------------------
mathis_v 0:b513811affc9 21
mathis_v 0:b513811affc9 22
mathis_v 0:b513811affc9 23 int main() {
mathis_v 0:b513811affc9 24 /*ajustement des facteur de calibrations*/
mathis_v 0:b513811affc9 25 s1.setScale(CAL_FACT1); //Adjust to this calibration factor
mathis_v 0:b513811affc9 26 s2.setScale(CAL_FACT2); //Adjust to this calibration factor
mathis_v 0:b513811affc9 27 s3.setScale(CAL_FACT3); //Adjust to this calibration factor
mathis_v 0:b513811affc9 28 s4.setScale(CAL_FACT4); //Adjust to this calibration factor
mathis_v 0:b513811affc9 29 s1.tare();
mathis_v 0:b513811affc9 30 s2.tare();
mathis_v 0:b513811affc9 31 s3.tare();
mathis_v 0:b513811affc9 32 s4.tare();
mathis_v 0:b513811affc9 33 while(1) {
mathis_v 0:b513811affc9 34 print_4jauges();
mathis_v 0:b513811affc9 35 }
mathis_v 0:b513811affc9 36 }
mathis_v 0:b513811affc9 37
mathis_v 0:b513811affc9 38
mathis_v 0:b513811affc9 39 void print_4jauges(){
mathis_v 0:b513811affc9 40
mathis_v 0:b513811affc9 41 double weight1=0;
mathis_v 0:b513811affc9 42 double weight2=0;
mathis_v 0:b513811affc9 43 double weight3=0;
mathis_v 0:b513811affc9 44 double weight4=0;
mathis_v 0:b513811affc9 45
mathis_v 0:b513811affc9 46 double total;
mathis_v 0:b513811affc9 47
mathis_v 0:b513811affc9 48 weight1 = s1.getGram();
mathis_v 0:b513811affc9 49 //pc.printf("j1= %.0f ",weight1);
mathis_v 0:b513811affc9 50
mathis_v 0:b513811affc9 51 weight2 = s2.getGram();
mathis_v 0:b513811affc9 52 //pc.printf("j2= %.0f\r\n ",weight2);
mathis_v 0:b513811affc9 53
mathis_v 0:b513811affc9 54 weight3 = s3.getGram();
mathis_v 0:b513811affc9 55 //pc.printf("j3= %.0f ",weight3);
mathis_v 0:b513811affc9 56
mathis_v 0:b513811affc9 57 weight4 = s4.getGram();
mathis_v 0:b513811affc9 58 //pc.printf("j4= %.0f ",weight4);
mathis_v 0:b513811affc9 59
mathis_v 0:b513811affc9 60 total=weight1+weight2+weight3+weight4;
mathis_v 0:b513811affc9 61 //pc.printf("tt= %.0f \r\n",total);
mathis_v 0:b513811affc9 62
mathis_v 0:b513811affc9 63 pc.printf("j1= %.0f j2= %.0f j3= %.0f j4= %.0f tt= %.0f \n \r", weight1,weight2,weight3,weight4,total);
mathis_v 0:b513811affc9 64
mathis_v 0:b513811affc9 65
mathis_v 0:b513811affc9 66 }