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 TextLCD
Revision 1:80ebc024450a, committed 2018-11-29
- Comitter:
- carmenron
- Date:
- Thu Nov 29 13:01:34 2018 +0000
- Parent:
- 0:fcb220c9cf97
- Child:
- 2:f53019a5bd33
- Commit message:
- codigo prueba 1
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Oct 18 10:40:35 2018 +0000
+++ b/main.cpp Thu Nov 29 13:01:34 2018 +0000
@@ -1,14 +1,122 @@
#include "mbed.h"
-DigitalIn boton(PC_13);
+//BUFFERS DE VOLTAJE
+int16_t bufferA [360];
+int16_t bufferB [360];
+
+//BUFFERS DE INTENSIDAD
+int16_t bufferC [360];
+int16_t bufferD [360];
+
+//
+int contador=0 ;
+int nbuffer=0 ;
+int bufferlleno ;
+int mostrarDato=1 ;
+float rms ;
+float Vpp ;
+
+//punteros
+int32_t *pA ;
+int32_t *pB ;
+
+AnalogIn (A0); //ENTRADA DE VOLTAJE
+AnalogIn (A5); //ENTRADA DE INTENSIDAD
+
+void muestreo () //hay que programar que se ejecute la funcion cada X tiempo (siendo X el tiempo de muestreo)
+{
+if (nbuffer==1) //si nbuffer=1 entonces se guardan los datos en el buffer A, else buffer B
+{
+ bufferA[contador]=AnalogRead (A0) ;
+ bufferC[contador]=AnalogRead (A5) ;
+ contador=contador+1 ;
+ if (contador==len(bufferA))
+ {
+ nbuffer=0 ;
+ contador=0 ;
+ }
+ }
+else
+{
+ bufferB(contador)=AnalogRead (A0) ;
+ bufferD(contador)=AnalogRead (A5) ;
+ contador=contador+1 ;
+ if (contador==len(bufferB))
+ {
+ nbuffer=1 ;
+ contador=0 ;
+ }
+}
+}
+
+
+// vamos a programar un boton como una entrada digital que nos permita seleccionar
+// el tipo de dato que queremos visualizar en la lcd
+
+//primero definimos como digitales las entradas en las que estarán los pulsadores
+
+digitalIn (D1);
+digitalIn (D2);
-int main() {
- int contador=0;
- while(1) {
- contador++;
- if (boton==0) {;
- prinf("El contador vale %d\n",contador);
+void boton ()
+{
+ if (digitalRead(D1)==1)
+ mostrarDato=+1;
+ {
+ if (mostrarDato==9)
+ mostrarDato=1;
+ }
+ else
+ {
+ if (digitalRead(D2)==1)
+ mostrarDato=-1;
+ {
+ if (mostrarDato==0)
+ mostrarDato=8;
+ }
}
- wait(0.10);
}
-}
\ No newline at end of file
+
+
+void mostrar ()
+{
+ if (mostrarDato==1)
+ printf("voltaje")
+ else
+ {
+ if (mostrarDato==2)
+ printf("intensidad")
+ else
+ {
+ if (mostrarDato==3)
+ printf("potencia activa")
+ else
+ {
+ if (mostrarDato==4)
+ printf("potencia reactiva")
+ else
+ {
+ if (mostrarDato==5)
+ printf("potencia aparente")
+ else
+ {
+ if (mostrarDato==6)
+ printf("energía activa")
+ else
+ {
+ if (mostrarDato==7)
+ printf("energía reactiva")
+ else
+ {
+ if (mostrarDato==8)
+ printf("factor de potencia")
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+