proyecto Smart Meter

Dependencies:   mbed TextLCD

Committer:
jvicente
Date:
Mon Dec 17 23:09:04 2018 +0000
Revision:
2:f50bb191b326
Parent:
1:fa4a5417c176
plantilla cambios

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 2:f50bb191b326 15 InterruptIn boton(USER_BUTTON);
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 2:f50bb191b326 31 //sacar el dato selecionado por la pantalla
jvicente 0:776a559bda2f 32 }
jvicente 0:776a559bda2f 33
jvicente 2:f50bb191b326 34 void cambiar()
jvicente 2:f50bb191b326 35 {
jvicente 2:f50bb191b326 36 //incrementar el contador de dato a mostrar
jvicente 2:f50bb191b326 37 }
jvicente 0:776a559bda2f 38
jvicente 0:776a559bda2f 39 int eBoton=0;
jvicente 0:776a559bda2f 40
jvicente 0:776a559bda2f 41 void captura()
jvicente 0:776a559bda2f 42 {
jvicente 1:fa4a5417c176 43 //leer las senales analogicas y meterlas en el buffer adecuado
jvicente 2:f50bb191b326 44 float datoTension=tension.read();
jvicente 2:f50bb191b326 45
jvicente 0:776a559bda2f 46 if(bufferActivo) {
jvicente 0:776a559bda2f 47
jvicente 0:776a559bda2f 48 } else {
jvicente 0:776a559bda2f 49
jvicente 0:776a559bda2f 50 }
jvicente 0:776a559bda2f 51
jvicente 0:776a559bda2f 52 if(contador==muestras) {
jvicente 1:fa4a5417c176 53 //Si se ha completado de llenar un buffer indicar el flag
jvicente 0:776a559bda2f 54 }
jvicente 0:776a559bda2f 55 }
jvicente 0:776a559bda2f 56
jvicente 0:776a559bda2f 57 int main()
jvicente 0:776a559bda2f 58 {
jvicente 0:776a559bda2f 59 Ticker timerCaptura;
jvicente 0:776a559bda2f 60 Ticker timerVisualizacion;
jvicente 0:776a559bda2f 61 timerCaptura.attach_us(&captura,200);
jvicente 0:776a559bda2f 62 timerVisualizacion.attach(&visualizacion,1.0);
jvicente 2:f50bb191b326 63 boton.rise(&cambiar);
jvicente 0:776a559bda2f 64 while(1) {
jvicente 0:776a559bda2f 65 if(flag) {
jvicente 1:fa4a5417c176 66 //Pocesar buffer
jvicente 0:776a559bda2f 67 }
jvicente 0:776a559bda2f 68 }
jvicente 0:776a559bda2f 69 }