Camille Annequin
/
trprepre
mesuring curent
Revision 3:45185bc91e89, committed 2019-06-03
- Comitter:
- Annequin
- Date:
- Mon Jun 03 09:33:47 2019 +0000
- Parent:
- 2:ad0b044d0a10
- Commit message:
- mesuring curent
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r ad0b044d0a10 -r 45185bc91e89 main.cpp --- a/main.cpp Sat Dec 04 11:31:07 2010 +0000 +++ b/main.cpp Mon Jun 03 09:33:47 2019 +0000 @@ -2,9 +2,179 @@ #include "mbed.h" #include "TextLCD.h" +#include <math.h> +//#include <cmath> +Ticker toggle_ueff_ticker; +//Ticker toggle_ieff_ticker; +TextLCD lcd(p25, p26, p21, p22, p23, p24); // rs, e, d4-d7 +InterruptIn mybutton(p12); +InterruptIn mybutton2(p13); +DigitalOut myled(LED1); -TextLCD lcd(p15, p16, p17, p18, p19, p20); // rs, e, d4-d7 +AnalogIn inputu(p15); +int vn; +int inu; +float v2n, v2ninter, anu, anmoy, ueff; +//float v2ninter = 0; +//float anu = 0; +//float anmoy = 0; +//float ueff; + +AnalogIn enteri(p17); +int in; +int ini; +float i2n, i2ninter, ani, animoy, ieff; +//float i2ninter = 0; +//float ani = 0; +//float animoy = 0; +//float ieff; + +float pactive; + +//AnalogIn A0(p17); +//AnalogIn A1(p18); +//AnalogIn A2(p19); +//AnalogIn A3(p20); +int a=0; +int n; +int n2; +int cpt; +float nrj = 0; +float nrjh; +int nrjhint; +int nrjhint_1; +void toggle_ueff() { + + + vn = (inputu.read_u16() - 32768); + v2ninter = v2n; + v2n = (vn * vn); + anu = (anu + ((v2ninter + v2n)/2)); + + + + in = ((enteri.read_u16()*1) - 32768); + i2ninter = i2n; + i2n = (in * in); + ani = (ani + ((i2ninter + i2n)/2)); + + n++; + if (n >= 5000) + { + anmoy = (anu/5000.0); + ueff = 0.873961*((sqrt((double)anmoy)*353.5533)/32768.0); + + anu = 0; + + animoy = (ani/5000.0); + ieff = ((sqrt((double)animoy)*5)/32768.0); + ani = 0; + -int main() { - lcd.printf("Hello World!\n"); + pactive = ueff*ieff; + n = 0; + cpt++; + if(cpt == 2){ + myled = 0; + cpt = 0; + nrj = (nrj + pactive); + nrjh = nrj / 3600; + nrjhint_1 = nrjhint; + nrjhint = nrjh; + + if(nrjhint >= (nrjhint_1 + 1)) + { + myled=1; + } + } + } + +} + + + + + +void pressed() +{ + a++; + if(a>=5){ + a = 0; + } +} + + +void pressed2() +{ + a--; + if(a<=0){ + a = 4; + } } +void clear() +{lcd.cls();} + +int main() +{ + toggle_ueff_ticker.attach(&toggle_ueff, 0.0002); + //toggle_ieff_ticker.attach(&toggle_ieff, 0.0001); + mybutton.fall(&pressed); + //mybutton.rise(&clear); + mybutton2.fall(&pressed2); + //mybutton2.rise(&clear); + while(1) + { + pactive = ueff*ieff; + clear(); + lcd.locate(9,1); + lcd.printf("page %d",a); + + if(a == 0){ + //clear(); + lcd.locate(0,0); + //lcd.putc(a); + lcd.printf("Ueff = %f",ueff ); + + lcd.locate(0,1); + //lcd.putc(a); + lcd.printf("Ieff = %f",ieff ); + // wait(0.2); + + } + + + + if(a == 1){ + // clear(); + lcd.locate(0,0); + //lcd.putc(a); + lcd.printf("nrjh = %d",nrjhint ); + // wait(0.2); + + } + if(a == 2){ + //clear(); + lcd.locate(0,0); + //lcd.putc(a); + lcd.printf("Pactive = %f",pactive ); + //wait(0.2); + + } + if(a == 3){ + // clear(); + lcd.locate(0,0); + //lcd.putc(a); + lcd.printf("anu = %f",anu ); + //wait(0.2); + + } + if(a == 4){ + // lcd.locate(0,0); + //lcd.putc(a); + //lcd.printf("ueff = %lf",ueff ); + // wait(0.2); + // clear(); + } + wait(1.0); + } +}