Chua chaotic oscillator - 640x480 vga

Dependencies:   fastlib mbed vga640x480g

Committer:
JLS
Date:
Sun Feb 26 12:40:51 2012 +0000
Revision:
0:f2258be4dcd9

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JLS 0:f2258be4dcd9 1 #include "mbed.h"
JLS 0:f2258be4dcd9 2 #include "vga640x480g.h"
JLS 0:f2258be4dcd9 3
JLS 0:f2258be4dcd9 4 int main() {
JLS 0:f2258be4dcd9 5
JLS 0:f2258be4dcd9 6 init_vga();
JLS 0:f2258be4dcd9 7
JLS 0:f2258be4dcd9 8 vga_cls();
JLS 0:f2258be4dcd9 9
JLS 0:f2258be4dcd9 10 vga_box(0,0,639,479,WHITE);
JLS 0:f2258be4dcd9 11
JLS 0:f2258be4dcd9 12 vga_putstring(10,10,"Chua chaotic oscillator",WHITE);
JLS 0:f2258be4dcd9 13
JLS 0:f2258be4dcd9 14 float x = 0.5;
JLS 0:f2258be4dcd9 15 float y = 0.25;
JLS 0:f2258be4dcd9 16 float z = 0.125;
JLS 0:f2258be4dcd9 17 float oldx = 0;
JLS 0:f2258be4dcd9 18 float oldy = 0;
JLS 0:f2258be4dcd9 19 float oldz = 0;
JLS 0:f2258be4dcd9 20
JLS 0:f2258be4dcd9 21 float dt = 0.005;
JLS 0:f2258be4dcd9 22
JLS 0:f2258be4dcd9 23 float alpha = 15.6;
JLS 0:f2258be4dcd9 24 float beta = 28.58;
JLS 0:f2258be4dcd9 25 float a = -1.14286;
JLS 0:f2258be4dcd9 26 float b = -0.714286;
JLS 0:f2258be4dcd9 27 float h = 0;
JLS 0:f2258be4dcd9 28
JLS 0:f2258be4dcd9 29 int xout = 0;
JLS 0:f2258be4dcd9 30 int yout = 0;
JLS 0:f2258be4dcd9 31
JLS 0:f2258be4dcd9 32 while (1) {
JLS 0:f2258be4dcd9 33
JLS 0:f2258be4dcd9 34 oldx = x;
JLS 0:f2258be4dcd9 35 oldy = y;
JLS 0:f2258be4dcd9 36 oldz = z;
JLS 0:f2258be4dcd9 37
JLS 0:f2258be4dcd9 38 h = (b * x) + (0.5 * (a - b) * (abs(x+1) - abs(x-1)));
JLS 0:f2258be4dcd9 39
JLS 0:f2258be4dcd9 40 x = oldx + dt * (alpha * (oldy - oldx - h));
JLS 0:f2258be4dcd9 41 y = oldy + dt * (oldx - oldy + oldz);
JLS 0:f2258be4dcd9 42 z = oldz + dt * (-beta * oldy);
JLS 0:f2258be4dcd9 43
JLS 0:f2258be4dcd9 44 xout = 320+(136*x);
JLS 0:f2258be4dcd9 45 yout = 240+(556*y);
JLS 0:f2258be4dcd9 46
JLS 0:f2258be4dcd9 47 vga_plot(xout,yout,WHITE);
JLS 0:f2258be4dcd9 48
JLS 0:f2258be4dcd9 49 }
JLS 0:f2258be4dcd9 50
JLS 0:f2258be4dcd9 51 }
JLS 0:f2258be4dcd9 52