Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed CMSIS_DSP_5
Revision 8:99642487de6f, committed 2019-10-17
- Comitter:
- javiervicente
- Date:
- Thu Oct 17 21:12:26 2019 +0000
- Parent:
- 5:8896fc7b612c
- Commit message:
- anadido segundo ejercicio
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Oct 24 20:23:21 2018 +0000
+++ b/main.cpp Thu Oct 17 21:12:26 2019 +0000
@@ -1,21 +1,52 @@
#include "mbed.h"
#include "datos.h"
+#define longitudTrama 500
+
Timer timer;
float resultado;
int tiempo;
+struct estructuraMedidas
+{
+ float vrms;
+ float irms;
+ float potenciaActiva;
+ float potenciaReactiva;
+ float potenciaAparente;
+ float energiaConsumida;
+ float factorDePotencia;
+};
+
float calcularRMS(int16_t *datos, int longitud);
+void calcularDatos(int16_t *datosV, int16_t *datosI, int longitud, estructuraMedidas *medidas);
+
int main()
{
timer.reset();
timer.start();
- resultado=calcularRMS(datos, 500);
+ resultado=calcularRMS(datos, longitudTrama);
timer.stop();
printf("****El valor Vrms es %f calculado en %d us ****\n",resultado,timer.read_us());
+
+ estructuraMedidas medidas;
+ medidas.energiaConsumida=0;
+
+ timer.reset();
+ timer.start();
+ calcularDatos(datosV,datosI,longitudTrama,&medidas);
+ timer.stop();
+ printf("**** Datos calculados en %d us ****\n",timer.read_us());
+ printf("**** El valor Vrms es %f ****\n",medidas.vrms);
+ printf("**** El valor Irms es %f ****\n",medidas.irms);
+ printf("**** La potencia activa es %f ****\n",medidas.potenciaActiva);
+ printf("**** La potencia reactiva es %f ****\n",medidas.potenciaReactiva);
+ printf("**** La potencia aparente es %f ****\n",medidas.potenciaAparente);
+ printf("**** La energia consumida es %f ****\n",medidas.energiaConsumida);
+ printf("**** El factor de potencia es es %f ****\n",medidas.factorDePotencia);
}
@@ -24,3 +55,8 @@
return 0.0;
}
+void calcularDatos(int16_t *datosV, int16_t *datosI, int longitud, estructuraMedidas *medidas)
+{
+
+}
+