Fun Control Experiments with Matlab and a Touchpad or Mouse

Ball and beam
Flexible beam
Inverted pendulum

  • New version of the original demo including all three systems and basic controllers in a single file: newdemo.m.
  • The horizontal position of the cursor on the screen specifies the value of the input (zero in the middle, negative on the left, and positive on the right).
  • In manual mode, the cursor specifies the control input. In automatic mode, the cursor specifies the reference input (different from the original demo).
  •  Easily editable text file. Insert your own controller in the controller initialization and controller sections of the code.
  •  More details on the simulation models and controllers in the original paper paper.pdf * and in the software lab descriptions (bbeam.pdf, invpend.pdf, and flex.pdf) .
  •  Thanks to Professor Arn Stolp (and his students) for suggesting this alternate implementation.
  • * The paper appeared in the Proc. of the IEEE Conference on Decision and Control, Maui, HI, Dec. 2003. ©2003 IEEE. Personal use of this material is permitted. However, permission to reprint/republish this material for advertising or promotional purposes or for creating new collective works for resale or redistribution to servers or lists, or to reuse any copyrighted component of this work in other works must be obtained from the IEEE.

    Hardware implementation of the ball and beam experimentHardware implementation of the flexible beam experiment


    Original version --- Fun Control Experiments with Matlab and a Joystick

  • demo.m Demo with all three systems and basic controllers (m-file).
  • jst.dll Joystick interface to Matlab (dll). May need to use Microsoft's Internet Explorer to download. For newer versions of Matlab, use jst.mexw32 and for 64-bit systems jst.mexw64.
  • bbeam.m Ball and beam simulation (m-file).
  • invpend.m Inverted pendulum simulation (m-file).
  • flex.m Flexible beam simulation (m-file).

  • Create your own fun experiments with a multi-axis joystick interface to Matlab (dll). Download jst.dll (may need to use Microsoft's Internet Explorer).
    Typing h=jst.dll returns:
    h[1]: longitudinal deflection (pitch), from -1 to 1.
    h[2]: lateral deflection (roll), from -1 to 1.
    h[3]: rotational deflection (yaw), from -1 to 1.
    h[4]: slider (thrust), from -1 to 1.
    h[5]: buttons (button1 + button2 * 2 +  button 3 *4...,
          where button1 = 1 if pressed and 0 otherwise.

    Courtesy of Johannes Edrén, extensions of the jst dll allowing the simultaneous use of two joysticks jst.mexw32jst2.mexw32, and the same for 64-bit systems jst.mexw64jst2.mexw64. Test the dll's using testjst.m (stop by typing Ctrl-C).


    This web site is maintained by Professor Marc Bodson, of the Department of Electrical and Computer Engineering at the University of Utah. Please see the University of Utah Web disclaimer. For questions or comments, please send an e-mail to marc.bodson@utah.edu.

    Last updated: November 16, 2023.