Implementation of discrete PID on Inverted pendulum

The objective here is to implement the discrete PID on pendulum. The idea is to balance an Inverted pendulum electro-mechanically using Proportional Integral Differential (PID) Control. The heart of the system is a PIC micro-controller (PIC18F4520). Controller commands the motor through PWM signal, which drives the cart to balance the pendulum in an inverted position. Pendulum's angular position is fed back by an incremental encoder mounted on its base, which is read by controller. Controller then calculates error and runs the PID algorithm to generate a new command signal. The exact position of pendulum with the value of its gains are sent to the attached Personal Computer (PC) using RS-232 protocol. The front panel is built in LabVIEW software.