PID tuning using a genetic algorithm

H

Thread Starter

harkirat singh

Hi all:)
Im a graduate student mechanical engg. and i am trying to implement a genetic algorithm which tunes the gains of a PID controller on a motorola 68HC11 EVB Does anyone have any experience in that field.

the PID loop is as follows::

;PIDLOOP.ASM
REGUL EQU 060H
ERROR EQU 062H
CONTROL EQU 064H
OUTPUT EQU 066H
SUM EQU 068H
PIINT EQU 06AH
PIPROP EQU 06CH
PLANTY EQU 06EH
PLANTU EQU 070H
STACK EQU 00AAH
ITER EQU 01FH

ORG 0000H
LDS #STACK
LDAA #2
STAA REGUL ;set the regulation value
LDAA #0 ;set the initial values for:
STAA ERROR ;regulation error
STAA CONTROL ;control quantity
STAA OUTPUT ;output, controlled quantity
STAA SUM ;sum for the integral part of the pi control
LDAA #3 ;set the valuation for the following constants
STAA PIINT ;PI integration constant
LDAA #4
STAA PIPROP ;PI proportional constant
LDAA #1
STAA PLANTY ;plant output constant
LDAA #2
STAA PLANTU ;plant control constant

LDX #0 ;initialize the counter

LOOP LDAA REGUL
SUBA OUTPUT
STAA ERROR ;error = control - output

LDAA SUM
ADDA ERROR
STAA SUM ;sum = sum + error
LDAB PIINT
MUL
PSHB ;stack <- sum * Ki (integration constant of the PI controller)

LDAA ERROR
LDAB PIPROP
MUL ;ACCD <- error * Kp

PULA
ABA
STAB CONTROL ; u (control) = Ki * sum + Kp * error

LDAA PLANTU
MUL
PSHB ;stack <- b (plant control constant) * u
(control

LDAA PLANTY
LDAB OUTPUT
MUL ;ACCD <- a (plant output constant) * y
(output)
PULA
ABA
STAA OUTPUT ;y = a * y + b * u

INX ;check the number of iterations
CPX #ITER
BLT LOOP

STOP

I would love to see some GA's or PID algos in C or assembly language which might serve the above purpose if anyone has them or any links to any such sources which might be of help

Thanx a heap in advance:)
Warm Regards
Harkirat Singh
 
Top