Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- TMS320C2x DSP - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

      Control systems are concerned with regulating a process and
      achieving a desired behavior or output from the process.  A control
      system consists of three main components: sensors, actuators and a
      controller.  Sensors measure the behavior of the system.  Actuators
      supply the driving force to ensure the desired behavior.  The
      controller generates actuator commands corresponding to the error
      conditions observed by the sensors and the control algorithm
      programmed in the controller. The controller typically consists of
      an analog or digital processor.

      Analog control systems are usually based on fixed components and are
      not programmable.   They are also limited to using single-purpose
      characteristics of the error signal such as P (proportional), I
      (integral), and D (derivative), or their combination.  These
      limitations, along with other disadvantages of analog systems such
      as component aging and temperature drift, are causing digital
      control systems to increasingly replace analog systems in most
      control applications.

      Digital control systems that use a microprocessor/microcontroller
      are able to implement more sophisticated algorithm of modern control
      therapy, such as state models, deadbeat control, state estimation,
      optimal control, and adaptive control.  Digital control algorithms
      deal with the processing of digital signals and are similar to DSP
      algorithm.  The TMS320C2X instruction set can therefore be used very
      effectively in digital control systems.

      The most commonly used algorithm in both analog and digital control
      systems is the PId (Proportional, Integral and Derivative)
      algorithm.  The classical PID algorithm is given by

                                    .               de(t)
            u(t) = K(p)*e(t) + K(i)*|e(t)dt + K(d)* -----
                                    .                dt

      The PID algorithm must be converted into a digital form for
      implementation on a microprocessor.  Using a rectangular
      approximation for the integral, the PID algorithm can be
      approximated as

            u(n) = u(n-1) + K1*e(n) + K2*e(n-1) + K3*e(n-2).

*
*  THIS ROUTINE IMPLEMENTS A PID ALGORITHM.
*

UN    EQU   0           ; OUTPUT OF CONTROLLER
E0    EQU   1           ; LATEST ERROR SAMPLE
E1    EQU   2           ; PREVIOUS ERROR SAMPLE
E2    EQU   3           ; OLDEST ERROR SAMPLE
K1    EQU   4           ; GAIN CONSTANT
K2    EQU   5           ; GAIN CONSTANT
K3    EQU   6           ; GAIN CONSTANT
*
*  ASSUME DATA PAGE 0 IS SELECTED.
*
PID   IN    E0,PAO      ; READ NEW ERROR SAMPLE
      LAC   UN          ; ACC = u(n-1)
      LT    E2          ; LOAD T REG WITH OLDEST SAMPLE
      MPY   K2          ; P = K2*e(n-2)
      LTD   E1          ; ACC = u(n-1)+K2*e(n-2)
      MPY   K1          ; P = K1*e(n-1)
      LTD   E0          ; ACC = u(n-1)+K1*e(n-1)+K2*e(n-2)
      MPY   K0          ; P = K0*e(n)
      APAC              ; ACC = u(n-1)+K0*e(n)+K1*e(n-1)+K2*e(n-2)
      SACH  UN,1        ; STORE OUTPUT
      OUT   UN,PA1      ; SEND IT

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson