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
Diff: main.cpp
- Revision:
- 0:2b6bac81f08c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Oct 15 10:04:42 2019 +0000 @@ -0,0 +1,35 @@ +#include "mbed.h" +#include "datos.h" +#include "math.h" + +Timer timer; +float resultado; +int tiempo; + +float calcularRMS(int16_t *datos, int longitud); + + +int main() +{ + + timer.reset(); + timer.start(); + resultado=calcularRMS(datos, 500); + timer.stop(); + printf("****El valor Vrms es %f calculado en %d us ****\n",resultado,timer.read_us()); + +} + +float calcularRMS(int16_t *datos, int longitud) +{ + int64_t sumatorio=0; + for (int i=0; i< longitud;i++) + { + sumatorio =+ datos[i]*datos[i]; + } + + float cte = 0.0001007080078125; + int resultado = cte * sqrt((float)sumatorio/longitud); + return resultado; +} +