20160307
otil de
ArduinoConso1VOk
banc de fatigue pour chronométrer durée de vie d'une machine, était
ArduinoConso1V
la durée estincrémentée dans la memoire EEPROM de l'Arduino et peut donc être relue après remise de l'alimentation
le compteur peut être remis à zero
ArduinoHardrebootALaFreebox
expérimentation avec alim par accu
NiMh 2500 mAh
banc de fatigue:
C:\Users\adminpo\Desktop\ARDUINO\arduino-1.6.7\examples\po\
HeuresDeVol?
exemple d'usage:
CHRONO chrono;
long epromused=0;
void setup() {
Serial.begin(115200);
Serial.println("\ndemo CHRONO et COLDSTART V0.03.");
epromused=chrono.begin (MSDIV,epromused,true);
if (coldstart.now()) {
Serial.println("now a repondu true");
chrono.raz();
}
}
void loop(){
chrono.update();
coldstart.running();
delay(100); ////delays are just for serial print, without serial they can be removed
Serial.print("loop, 5 flash at 1 Hz ");
// 10 blink
for (int ipof=0;ipof<10;ipof++) {
digitalWrite(led, !digitalRead(led) ); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a second
Serial.print(".");
}
Serial.println(millis());
delay(10000);
}
et
// ------------------------------------
#define DEBUG
#undef DEBUG
class CHRONO {
// heures de vol
public:
long begin(long ms,long adcount){
msdiv=ms;
adcompteur=adcount;
startstep=r4(adcompteur);
#ifdef DEBUG
Serial.print("Chrono started , step (ms): ");
Serial.println(ms );
Serial.print("chrono: ");
Serial.println(startstep);
#endif
return adcompteur+length();
}
long length(){
return 4;
}
long step(){
return msdiv;
}
long start(){
return startstep;
}
void update(){
long ms=millis();
long dif=ms-msprev;
if ( dif> msdiv) {
long inc=dif / msdiv;
msprev=ms-inc*msdiv;
w4(adcompteur,r4(adcompteur)+inc);
msprev=ms;
#ifdef DEBUG
Serial.print("chrono: ");
Serial.println(r4(adcompteur));
#endif
}
}
void raz(){
w4(adcompteur,0);
#ifdef DEBUG
Serial.println("RAZ Chrono");
#endif
};
long elapsed(){
return r4(adcompteur);
}
private:
long msprev=0;
long msdiv=-1;
long adcompteur =-1;
long startstep;
};
#undef DEBUG
// fin de heures de vol
// -------------------------------------------