#pragma chip PIC18C252 #include "math24f.h" uns16 ad_data; float tx, av, mg, a, vx, prev, kp; void main(void) { InitFpFlags(); // enable rounding as default vx = 3.127; tx += ad_data; // automatic type cast ad_data = kp; // assign integer part if (tx < 0) tx = -tx; // make positive av = tx/20.0; mg = av * 1.25; a = mg * 0.98; prev = vx; vx = a/5.0 + prev; kp = vx * 0.036; kp = vx / (1.0/0.036); }