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
main.cpp
00001 #include "mbed.h" 00002 #include "datos.h" 00003 #include "math.h" 00004 00005 Timer timer; 00006 00007 int tiempo; 00008 float resultado=0; 00009 float calcularRMS(int16_t *datos, int longitud); 00010 00011 int main() 00012 { 00013 timer.reset(); 00014 timer.start(); 00015 resultado=calcularRMS(datos, 500); 00016 timer.stop(); 00017 tiempo = timer.read_us(); 00018 printf("****El valor Vrms es %f calculado en %d us ****\n",resultado,timer.read_us()); 00019 } 00020 00021 float calcularRMS(int16_t *datos, int longitud) 00022 { 00023 float constante = 4.503799027e-6;//(3.3/2e15)/sqrt(float(longitud)); 00024 //float constante = 1.007080078e-4; 00025 int32_t producto=0; 00026 int64_t suma=0; 00027 for (int i=0; i<longitud; i++){ 00028 producto = datos[i]*datos[i]; 00029 suma +=producto; 00030 } 00031 00032 return sqrt((float)suma)*constante; 00033 //return sqrt((float)suma/longitud)*constante; 00034 }
Generated on Wed Jul 20 2022 09:12:15 by
1.7.2