Home | pfodApps/pfodDevices | WebStringTemplates | Java/J2EE | Unix | Torches | Superannuation | | About Us
 

Forward Logo (image)      

SimGauss™ V2.0
Code for Digitally Controlled Spring

/* CTRLSPRG.SGM */
Ts = 0.1;  /* sampling period */
calcT = 0.01; /* 10 ms calculation delay */
stoptime = 4.0; /* stop at 4 sec */

R0 = 1;  /* min. damping Kg/s */
M = 1;   /* Kg mass */
K = 9.8;  /* Kg/(s*s) spring const. */
g = 9.8; /* grav. accel. m/(s*s) */
gain = {0, 0.4, 1.5, 4, 10} /* 5 gains */
x0 = {5, 5, 5, 5, 5} /* length at rest */

i_x = x0 - g./k + x1; /* initial disp. */
i_v = {0, 0, 0, 0, 0} /* the initial v */

INITIAL;
        R = R0; /* initial value for damping */
END_INIT;

DYNAMIC(0.05);   /*  System equations */
        d_v = (K.(x0-x) - R.v)./M - g;
        d_x = v;
END_DYN;

DISCRETE("sample",Ts);
        /* sample every Ts sec */
        /* and calculate damping */
        Rd = R0+abs(v).gain;
        /* Schedule output of controller */
        /* after calculation delay */
        SCHEDULE("control",T+calcT);
END_DISC;

DISCRETE("control",0);
        /* transfer new damping to system */
        R = Rd;
END_DISC;


Forward home page link (image)

Contact Forward Computing and Control by
©Copyright 1996-2020 Forward Computing and Control Pty. Ltd. ACN 003 669 994