I’ve made a simple PID simulator to help teach and explain how PID loops, and how to properly tune the gains for different systems. It is a nice way to introduce PID loops to newer programmers. The model behaves surprisingly realistically, and the output vs. time graphs look almost identical to graphs from robots.
The program simulates a CIM motor driving a 1 meter long arm with a 150:1 reduction. The mass on the end of the arm can be adjusted, and gravity can be toggled on and off, so you could simulate something not affected by gravity, like a turret. The simulation takes into account an accurate motor curve (where motor torque is a function of motor speed and applied voltage), and the angular momentum of the arm.
You can download the simulator from here:
https://drive.google.com/file/d/0BzfxWVZUp3DNMG9Ld1Q4NEM5bkE/view?usp=sharing
Or look at the source code here: