proyecto Smart Meter

Dependencies:   mbed TextLCD

Committer:
jvicente
Date:
Mon Dec 17 23:06:03 2018 +0000
Revision:
1:fa4a5417c176
Parent:
0:776a559bda2f
Child:
2:f50bb191b326
plantilla;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jvicente 0:776a559bda2f 1 #include "mbed.h"
jvicente 0:776a559bda2f 2 #include "math.h"
jvicente 0:776a559bda2f 3 #include "TextLCD.h"
jvicente 0:776a559bda2f 4
jvicente 0:776a559bda2f 5 #define muestras 100
jvicente 0:776a559bda2f 6
jvicente 0:776a559bda2f 7 TextLCD lcd(D8, D9, D2, D3, D4, D5, TextLCD::LCD16x2); // rs, e, d4-d7
jvicente 0:776a559bda2f 8 Serial pc(USBTX, USBRX); // tx, rx
jvicente 0:776a559bda2f 9
jvicente 0:776a559bda2f 10 int contador=0;
jvicente 0:776a559bda2f 11 int bufferActivo=0;
jvicente 0:776a559bda2f 12 int flag=0;
jvicente 0:776a559bda2f 13 AnalogIn tension(A0);
jvicente 0:776a559bda2f 14 AnalogIn intensidad(A1);
jvicente 0:776a559bda2f 15
jvicente 0:776a559bda2f 16
jvicente 0:776a559bda2f 17 struct Vectores{
jvicente 0:776a559bda2f 18 float vTensionA[muestras];
jvicente 0:776a559bda2f 19 float vTensionB[muestras];
jvicente 0:776a559bda2f 20 float vIntensidadA[muestras];
jvicente 0:776a559bda2f 21 float vIntensidadB[muestras];
jvicente 0:776a559bda2f 22 }vectores;
jvicente 0:776a559bda2f 23
jvicente 0:776a559bda2f 24 struct Medidas{
jvicente 0:776a559bda2f 25 float Vrms;
jvicente 0:776a559bda2f 26 float Irms;
jvicente 0:776a559bda2f 27 }medidas;
jvicente 0:776a559bda2f 28
jvicente 0:776a559bda2f 29 void visualizacion()
jvicente 0:776a559bda2f 30 {
jvicente 0:776a559bda2f 31 float datoTension=tension.read();
jvicente 0:776a559bda2f 32 }
jvicente 0:776a559bda2f 33
jvicente 0:776a559bda2f 34
jvicente 0:776a559bda2f 35
jvicente 0:776a559bda2f 36 int eBoton=0;
jvicente 0:776a559bda2f 37
jvicente 0:776a559bda2f 38 void captura()
jvicente 0:776a559bda2f 39 {
jvicente 1:fa4a5417c176 40 //leer las senales analogicas y meterlas en el buffer adecuado
jvicente 0:776a559bda2f 41
jvicente 0:776a559bda2f 42 if(bufferActivo) {
jvicente 0:776a559bda2f 43
jvicente 0:776a559bda2f 44 } else {
jvicente 0:776a559bda2f 45
jvicente 0:776a559bda2f 46 }
jvicente 0:776a559bda2f 47
jvicente 0:776a559bda2f 48 if(contador==muestras) {
jvicente 1:fa4a5417c176 49 //Si se ha completado de llenar un buffer indicar el flag
jvicente 0:776a559bda2f 50 }
jvicente 0:776a559bda2f 51 }
jvicente 0:776a559bda2f 52
jvicente 0:776a559bda2f 53 int main()
jvicente 0:776a559bda2f 54 {
jvicente 0:776a559bda2f 55 Ticker timerCaptura;
jvicente 0:776a559bda2f 56 Ticker timerVisualizacion;
jvicente 0:776a559bda2f 57 timerCaptura.attach_us(&captura,200);
jvicente 0:776a559bda2f 58 timerVisualizacion.attach(&visualizacion,1.0);
jvicente 0:776a559bda2f 59 while(1) {
jvicente 0:776a559bda2f 60 if(flag) {
jvicente 1:fa4a5417c176 61 //Pocesar buffer
jvicente 0:776a559bda2f 62 }
jvicente 0:776a559bda2f 63 }
jvicente 0:776a559bda2f 64 }