This investigation presents the construction of a Real-time rotary inverted pendulum system using MATLAB, the description of the materials and methods for the construction are presented. To estimate the non-measurable parameters of the system a method based on the non-linear model, a set of data and a nonlinear least squares algorithm is carried out, the implementation of an energy based swing-up controller and a LQR stabilization controller is used to show the performance of the system.