Now, that I got a IDE/SATA USB case, I started looking at my very old HDDs. I found very old codes of mine, this is one of them. PENSE (oPEN Simulation Environment) was my thesis project. It is a framework which you can use to implement simulation easily. I wrote it in C++. Only dependency is GNU’s libmatheval to implement algorithms out of mathematical expressions easily. I even wrote documentation in LaTeX! :)

Anyway here’s libpense and pensedemo. Please note the autoconf masterpiece in the libpense :) it was a bitch to get it working but once it is working… well, it works. I remember compiling these codes on WIN32, Mac OS X and GNU/Linux without a single problem. Yes, I was young and stupid. I developed this on GNU/Linux :)

Oh, the documentation in LaTeX, PDF and the presentation in PPT format is available. Also there’s a reference manual for libpense, I guess I just had too much time :)

A-hem, and you have to excuse any lameness you can spot, since this is a 4-year old code ;)

A sample code from pensedemo;

        Environment env;
	Device::Source::PWM pwm( "pwm", &env );
	pwm.setOn( true );
	pwm.setFrequency( pwm_freq );

	Device::Source::VoltageSource vs( 0, 4.8, "voltage source", &env );
	vs.setOn( true );
	vs["output"] = 4.8;

	Device::Plant::DCMotor motor( "Maxon_118465", &env );
	motor.setLoad( "0.0" );
	motor["J_r"] = 0.0000000503;
	motor["k_n"] = 252.374609;
	motor["I_o"] = 0.029;
	motor["V"] = 0.0;
	motor["R"] = 2.16;

	Device::Controller::FuzzyLogic f( 3, "fuzzy logic controller", &env );

	f.setSetPoint( set_point );
	f.setInputDomainWidth( 5 );
	f.setOutputDomainRange( 0, 100 );

        // This is where we connect the devices together to form a feedback loop.
        // We connect the PWM controller to the Voltage Source so that PWM can turn
        // the VS on and off. Then we connect the voltage source to the DC Motor, so
        // that it can, well, run. Then we connect the angular velocity parameter of the
        // motor to the Fuzzy Logic controller, so that it can adjust the PWM controller
        // and control the speed of the motor.
	connect( &pwm, "output", &vs, "on" );
	connect( &vs, "output", &motor, "V" );
	connect( &motor,"w", &f, "input" );
	connect( &f, "output", &pwm, "duty" );