Mathis Vernay / Mbed 2 deprecated calibratio_jauge

Dependencies:   mbed HX711 BME280

Committer:
mathis_v
Date:
Wed Apr 15 08:05:40 2020 +0000
Revision:
1:dc5547452d12
Parent:
0:b513811affc9
a

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mathis_v 1:dc5547452d12 1 /*programme permettant de transmetre les valeur des jauges a un terminal par conection usb*/
mathis_v 1:dc5547452d12 2 /*Recupération : putty -> Serial -> COM"X" -> Speed = 115200*/
mathis_v 1:dc5547452d12 3
mathis_v 0:b513811affc9 4 #include "mbed.h"
mathis_v 0:b513811affc9 5 #include "HX711.h"
mathis_v 0:b513811affc9 6
mathis_v 0:b513811affc9 7 /* définition des constantes pour les jauges*/
mathis_v 1:dc5547452d12 8 #define PINSCK A5 /*Le pin A5 est l'horologe pour la transmision de données*/
mathis_v 1:dc5547452d12 9 #define CAL_FACT -125.794139 /*valeur permettant de convertir la valeur des jauges en gramme*/
mathis_v 0:b513811affc9 10
mathis_v 0:b513811affc9 11 Serial pc(USBTX, USBRX); /*Liaison série avec le pc*/
mathis_v 0:b513811affc9 12
mathis_v 1:dc5547452d12 13 HX711 s1(A1,PINSCK),s2(A2,PINSCK),s3(A3,PINSCK),s4(A4,PINSCK); /*déclaration des 4 jauges, 1er argument l'emplacement de la jauge, 2ème signale d'horloge*/
mathis_v 0:b513811affc9 14
mathis_v 0:b513811affc9 15 void print_4jauges();
mathis_v 0:b513811affc9 16
mathis_v 0:b513811affc9 17 int main() {
mathis_v 0:b513811affc9 18 /*ajustement des facteur de calibrations*/
mathis_v 1:dc5547452d12 19 s1.setScale(CAL_FACT);
mathis_v 1:dc5547452d12 20 s2.setScale(CAL_FACT);
mathis_v 1:dc5547452d12 21 s3.setScale(CAL_FACT);
mathis_v 1:dc5547452d12 22 s4.setScale(CAL_FACT);
mathis_v 1:dc5547452d12 23
mathis_v 1:dc5547452d12 24 /*
mathis_v 0:b513811affc9 25 s1.tare();
mathis_v 0:b513811affc9 26 s2.tare();
mathis_v 0:b513811affc9 27 s3.tare();
mathis_v 0:b513811affc9 28 s4.tare();
mathis_v 1:dc5547452d12 29 *//*Fonction à déclancher via une interation extérieur */
mathis_v 0:b513811affc9 30 while(1) {
mathis_v 0:b513811affc9 31 print_4jauges();
mathis_v 0:b513811affc9 32 }
mathis_v 0:b513811affc9 33 }
mathis_v 0:b513811affc9 34
mathis_v 0:b513811affc9 35 void print_4jauges(){
mathis_v 0:b513811affc9 36
mathis_v 1:dc5547452d12 37 double weight1, weight2, weight3, weight4, total;
mathis_v 0:b513811affc9 38
mathis_v 0:b513811affc9 39 weight1 = s1.getGram();
mathis_v 0:b513811affc9 40 weight2 = s2.getGram();
mathis_v 0:b513811affc9 41 weight3 = s3.getGram();
mathis_v 0:b513811affc9 42 weight4 = s4.getGram();
mathis_v 0:b513811affc9 43
mathis_v 0:b513811affc9 44 total=weight1+weight2+weight3+weight4;
mathis_v 0:b513811affc9 45
mathis_v 1:dc5547452d12 46 pc.printf("j1= %.0f j2= %.0f j3= %.0f j4= %.0f tt= %.0f\n \r", weight1,weight2,weight3,weight4,total);
mathis_v 0:b513811affc9 47 }