proyecto Smart Meter

Dependencies:   mbed TextLCD

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "math.h"
00003 #include "TextLCD.h"
00004 
00005 #define muestras 100
00006 
00007 TextLCD lcd(D8, D9, D2, D3, D4, D5, TextLCD::LCD16x2); // rs, e, d4-d7
00008 Serial pc(USBTX, USBRX); // tx, rx
00009 
00010 int contador=0;
00011 int bufferActivo=0;
00012 int flag=0;
00013 AnalogIn tension(A0);
00014 AnalogIn intensidad(A1);
00015 InterruptIn boton(USER_BUTTON);
00016 
00017 struct Vectores{
00018     float  vTensionA[muestras];
00019     float  vTensionB[muestras];
00020     float  vIntensidadA[muestras];
00021     float  vIntensidadB[muestras];
00022 }vectores;
00023 
00024 struct Medidas{
00025     float Vrms;
00026     float Irms;
00027 }medidas;
00028 
00029 void visualizacion()
00030 {
00031    //sacar el dato selecionado por la pantalla
00032 }
00033 
00034 void cambiar()
00035 {
00036     //incrementar el contador de dato a mostrar
00037 }
00038 
00039 int eBoton=0;
00040 
00041 void captura()
00042 {
00043     //leer las senales analogicas y meterlas en el buffer adecuado
00044      float datoTension=tension.read();
00045      
00046     if(bufferActivo) {
00047         
00048     } else {
00049         
00050     }
00051    
00052     if(contador==muestras) {
00053       //Si se ha completado de llenar un buffer indicar el flag
00054     }
00055 }
00056 
00057 int main()
00058 {
00059     Ticker timerCaptura;
00060     Ticker timerVisualizacion;
00061     timerCaptura.attach_us(&captura,200);
00062     timerVisualizacion.attach(&visualizacion,1.0);
00063     boton.rise(&cambiar);
00064     while(1) {
00065         if(flag) {
00066             //Pocesar buffer
00067         }
00068     }
00069 }