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.
Diff: main.cpp
- Revision:
- 4:3663b89a9407
- Parent:
- 2:b60cb847489c
--- a/main.cpp Thu Nov 06 10:13:20 2014 +0000 +++ b/main.cpp Wed Feb 24 19:12:21 2016 +0000 @@ -1,12 +1,65 @@ #include "mbed.h" +Serial pc(USBTX,USBRX); -DigitalOut myled(LED1); +//Declaración de salidas analogicas +//AnalogOut outx(PA_4); +//AnalogOut outz(PA_5); + +//Declaración de constantes +float p = 10.0; +float b = 8/3; +float r = 28; +float ts = 0.00438; //Periodo de mustreo -int main() { +int main() +{ + //Declaración de condiciones iniciales + float x1 = 0.1; + float y1 = -10; + float z1 = 0.1; + float x, y, z; while(1) { - myled = 1; // LED is ON - wait(0.2); // 200 ms - myled = 0; // LED is OFF - wait(1.0); // 1 sec + //Ecuaciones de Lorentz discretas con Euler + x = x1 + ts*(p*(y1-x1)); + y = y1 + ts*(x1*(r-z1)-y1); + z = z1 + ts*(x1*y1-b*z1); + //Imprimir en serial + pc.printf(" %f \n \r ",x); + //Declaracion de salida a puertos + //outx.write(x); + //outz.write(z); + //Reiniciando valores + x1 = x; + y1 = y; + z1 = z; } } + +//Script Para Matlab 2014a + +/*%Borrar conexiones previas +delete(instrfind({'Port'},{'COM3'})); +%Crear una conexion serie +s = serial('COM3','BaudRate',9600); +warning('off','MATLAB:serial:fscanf:unsuccessfulRead'); +%Abrir el puerto +fopen(s); +%Inicializar las variables +Nvalores=10000; %Cantidad de valores que queremos a leer +m1=zeros(1,Nvalores); +i=1; +k=0; + +while k<Nvalores +%Leer el puerto serie +a = fscanf(s,'%d')'; +m1(i)=a(1); +%Dibujar la figura +figure(1); +plot(m1); +%Incrementar el contador +i=i+1; +k=k+1; +end +*/ +