Ooooh, another exciting stamp project
Hi Al,
Talking about PID control.
Perhaps you've heard of the Fuzzy Construction Unit (by Zetec, Germany)
Check out http://www.oktogon.com/index-e.htm
Click software->fcu 2.5
I got this software about one year ago for the C-control/Basic
microcontroller
(comparable to basic stamp, larger pcb, 68HC11, onboard AD and DA)
The great thing about this software is that it generates basic code for any
fuzzy control (like P, PD, PI, PID) you graphically design. You set
boundaries
for inputs and outputs, define some rules and the code is generated.
Take a look at some sample code for a PD controller.
'
'Zentrum fuer Fuzzy- & InformationsTechnik GmbH
'Baumhofweg 4
'D-44267 Dortmund
'
'Copyright (C) by ZeTec
'All rights reserved.
'Dieser Basic-Code wurde automatisch mit der FCU generiert und beinhaltet
'den gesamten Algorithmus zur Berechnung des Fuzzy-Reglers.
'
DEFINE Set_Param WORD
DEFINE Summe_Efg WORD
DEFINE Rest_Summe WORD
DEFINE Rest_Dummy WORD
DEFINE Aus_Wert BYTE
DEFINE Akt_Efg BYTE
DEFINE Min_Efg BYTE
DEFINE Reg_Anzahl BYTE
DEFINE Akt_Regel BYTE 'Erfuellungsgrade = Efgs
DEFINE A BYTE
DEFINE B BYTE
DEFINE C BYTE
DEFINE D BYTE
DEFINE Eingang BYTE
DEFINE Akt_Eing BYTE
DEFINE Eingang_2 AD[noparse][[/noparse]1]
DEFINE Eingang_3 AD[noparse][[/noparse]2]
#ANFANG
LOOKTAB Fuzzy_Sets, 0, Reg_Anzahl
Reg_Anzahl = Reg_Anzahl-1
Summe_Efg = 0
Aus_Wert = 0
Rest_Summe = 0
Rest_Dummy = 0
FOR Akt_Regel = 0 TO Reg_Anzahl
Akt_Efg = 0
Min_Efg = 100
FOR Akt_Eing = 0 TO 2
IF Akt_Eing = 0 THEN Eingang = Variable_1?
IF Akt_Eing = 1 THEN Eingang = Eingang_2
IF Akt_Eing = 2 THEN Eingang = Eingang_3
Set_Param = 13 * Akt_Regel + Akt_Eing * 4 + 1
LOOKTAB Fuzzy_Sets, Set_Param, A
IF A > Eingang THEN GOTO FOR_ENDE_1
Set_Param = Set_Param + 3
LOOKTAB Fuzzy_Sets, Set_Param, D
IF D < Eingang THEN GOTO FOR_ENDE_1
Set_Param = Set_Param - 2
LOOKTAB Fuzzy_Sets, Set_Param, B
Set_Param = Set_Param + 1
LOOKTAB Fuzzy_Sets, Set_Param, C
Akt_Efg = 100
IF Eingang < B THEN GOSUB EFG_LINKS
IF Eingang > C THEN GOSUB EFG_RECHTS
NEXT
Summe_Efg = Summe_Efg + Min_Efg
#FOR_ENDE_1
NEXT
IF Summe_Efg = 0 THEN GOTO ANFANG
FOR Akt_Regel = 0 TO Reg_Anzahl
Akt_Efg = 0
Min_Efg = 100
FOR Akt_Eing = 0 TO 2
IF Akt_Eing = 0 THEN Eingang = Variable_1?
IF Akt_Eing = 1 THEN Eingang = Eingang_2
IF Akt_Eing = 2 THEN Eingang = Eingang_3
Set_Param = 13 * Akt_Regel + Akt_Eing * 4 + 1
LOOKTAB Fuzzy_Sets, Set_Param, A
IF A > Eingang THEN GOTO FOR_ENDE_2
Set_Param = Set_Param + 3
LOOKTAB Fuzzy_Sets, Set_Param, D
IF D < Eingang THEN GOTO FOR_ENDE_2
Set_Param = Set_Param - 2
LOOKTAB Fuzzy_Sets, Set_Param, B
Set_Param = Set_Param + 1
LOOKTAB Fuzzy_Sets, Set_Param, C
Akt_Efg = 100
IF Eingang < B THEN GOSUB EFG_LINKS
IF Eingang > C THEN GOSUB EFG_RECHTS
NEXT
Set_Param = 13 * Akt_Regel + 13
LOOKTAB Fuzzy_Sets, Set_Param, A
Aus_Wert=Aus_Wert+(A*Min_Efg)/Summe_Efg
Rest_Dummy = Rest_Dummy + (A * Min_Efg) MOD Summe_Efg
IF Rest_Dummy < 0 THEN GOSUB ZWISCHEN_REST ELSE Rest_Summe = Rest_Dummy
#FOR_ENDE_2
NEXT
Aus_Wert = Aus_Wert + Rest_Summe / Summe_Efg
'*************
'Variable_?? = Aus_Wert 'Aus_Wert = neuer Ausgangswert(0...255)
'*************
'
GOTO ANFANG
END
#EFG_LINKS
Akt_Efg = (Eingang - A) * 100 / (B- A)
IF Akt_Efg < Min_Efg THEN Min_Efg = Akt_Efg
RETURN
#EFG_RECHTS
Akt_Efg = 100 - (Eingang - C) * 100 / (D - C)
IF Akt_Efg < Min_Efg THEN Min_Efg = Akt_Efg
RETURN
#ZWISCHEN_REST
Rest_Summe = Rest_Summe / Summe_Efg
Aus_Wert = Aus_Wert + Rest_Summe
Rest_Dummy = (A * Min_Efg) MOD Summe_Efg
Rest_Summe = Rest_Summe MOD Summe_Efg
Rest_Summe = Rest_Summe + Rest_Dummy
RETURN
TABLE Fuzzy_Sets
22
0 0 255 255
0 0 128 128
0 0 128 128 128
0 0 255 255
0 0 128 128
128 128 128 189 217
0 0 255 255
0 0 128 128
127 189 189 250 236
0 0 255 255
0 0 128 128
189 250 255 255 255
0 0 255 255
128 128 128 159
0 0 128 128 217
0 0 255 255
128 128 128 159
128 128 128 189 217
0 0 255 255
128 128 128 159
127 189 189 250 236
0 0 255 255
128 128 128 159
189 250 255 255 255
0 0 255 255
128 159 159 191
0 0 128 128 236
0 0 255 255
128 159 159 191
128 128 128 189 236
0 0 255 255
128 159 159 191
127 189 189 250 255
0 0 255 255
128 159 159 191
189 250 255 255 255
0 0 255 255
159 191 255 255
0 0 128 128 255
0 0 255 255
159 191 255 255
128 128 128 189 255
0 0 255 255
159 191 255 255
127 189 189 250 255
0 0 255 255
159 191 255 255
189 250 255 255 255
0 0 0 51
0 0 255 255
0 0 255 255 No Set
0 51 51 102
0 0 255 255
0 0 255 255 No Set
51 102 102 153
0 0 255 255
0 0 255 255 No Set
102 153 153 204
0 0 255 255
0 0 255 255 No Set
153 204 204 255
0 0 255 255
0 0 255 255 No Set
204 255 255 255
0 0 255 255
0 0 255 255 No Set
Welcome to the world of PID control.
***********
I know it is not pbasic, but it is close enough to adjust manually.
As the software supports a great variety of hardware, then if there
is enough response they may perhaps consider to support basic stamps.
Check it out, I'd say.
Greetings peter
Talking about PID control.
Perhaps you've heard of the Fuzzy Construction Unit (by Zetec, Germany)
Check out http://www.oktogon.com/index-e.htm
Click software->fcu 2.5
I got this software about one year ago for the C-control/Basic
microcontroller
(comparable to basic stamp, larger pcb, 68HC11, onboard AD and DA)
The great thing about this software is that it generates basic code for any
fuzzy control (like P, PD, PI, PID) you graphically design. You set
boundaries
for inputs and outputs, define some rules and the code is generated.
Take a look at some sample code for a PD controller.
'
'Zentrum fuer Fuzzy- & InformationsTechnik GmbH
'Baumhofweg 4
'D-44267 Dortmund
'
'Copyright (C) by ZeTec
'All rights reserved.
'Dieser Basic-Code wurde automatisch mit der FCU generiert und beinhaltet
'den gesamten Algorithmus zur Berechnung des Fuzzy-Reglers.
'
DEFINE Set_Param WORD
DEFINE Summe_Efg WORD
DEFINE Rest_Summe WORD
DEFINE Rest_Dummy WORD
DEFINE Aus_Wert BYTE
DEFINE Akt_Efg BYTE
DEFINE Min_Efg BYTE
DEFINE Reg_Anzahl BYTE
DEFINE Akt_Regel BYTE 'Erfuellungsgrade = Efgs
DEFINE A BYTE
DEFINE B BYTE
DEFINE C BYTE
DEFINE D BYTE
DEFINE Eingang BYTE
DEFINE Akt_Eing BYTE
DEFINE Eingang_2 AD[noparse][[/noparse]1]
DEFINE Eingang_3 AD[noparse][[/noparse]2]
#ANFANG
LOOKTAB Fuzzy_Sets, 0, Reg_Anzahl
Reg_Anzahl = Reg_Anzahl-1
Summe_Efg = 0
Aus_Wert = 0
Rest_Summe = 0
Rest_Dummy = 0
FOR Akt_Regel = 0 TO Reg_Anzahl
Akt_Efg = 0
Min_Efg = 100
FOR Akt_Eing = 0 TO 2
IF Akt_Eing = 0 THEN Eingang = Variable_1?
IF Akt_Eing = 1 THEN Eingang = Eingang_2
IF Akt_Eing = 2 THEN Eingang = Eingang_3
Set_Param = 13 * Akt_Regel + Akt_Eing * 4 + 1
LOOKTAB Fuzzy_Sets, Set_Param, A
IF A > Eingang THEN GOTO FOR_ENDE_1
Set_Param = Set_Param + 3
LOOKTAB Fuzzy_Sets, Set_Param, D
IF D < Eingang THEN GOTO FOR_ENDE_1
Set_Param = Set_Param - 2
LOOKTAB Fuzzy_Sets, Set_Param, B
Set_Param = Set_Param + 1
LOOKTAB Fuzzy_Sets, Set_Param, C
Akt_Efg = 100
IF Eingang < B THEN GOSUB EFG_LINKS
IF Eingang > C THEN GOSUB EFG_RECHTS
NEXT
Summe_Efg = Summe_Efg + Min_Efg
#FOR_ENDE_1
NEXT
IF Summe_Efg = 0 THEN GOTO ANFANG
FOR Akt_Regel = 0 TO Reg_Anzahl
Akt_Efg = 0
Min_Efg = 100
FOR Akt_Eing = 0 TO 2
IF Akt_Eing = 0 THEN Eingang = Variable_1?
IF Akt_Eing = 1 THEN Eingang = Eingang_2
IF Akt_Eing = 2 THEN Eingang = Eingang_3
Set_Param = 13 * Akt_Regel + Akt_Eing * 4 + 1
LOOKTAB Fuzzy_Sets, Set_Param, A
IF A > Eingang THEN GOTO FOR_ENDE_2
Set_Param = Set_Param + 3
LOOKTAB Fuzzy_Sets, Set_Param, D
IF D < Eingang THEN GOTO FOR_ENDE_2
Set_Param = Set_Param - 2
LOOKTAB Fuzzy_Sets, Set_Param, B
Set_Param = Set_Param + 1
LOOKTAB Fuzzy_Sets, Set_Param, C
Akt_Efg = 100
IF Eingang < B THEN GOSUB EFG_LINKS
IF Eingang > C THEN GOSUB EFG_RECHTS
NEXT
Set_Param = 13 * Akt_Regel + 13
LOOKTAB Fuzzy_Sets, Set_Param, A
Aus_Wert=Aus_Wert+(A*Min_Efg)/Summe_Efg
Rest_Dummy = Rest_Dummy + (A * Min_Efg) MOD Summe_Efg
IF Rest_Dummy < 0 THEN GOSUB ZWISCHEN_REST ELSE Rest_Summe = Rest_Dummy
#FOR_ENDE_2
NEXT
Aus_Wert = Aus_Wert + Rest_Summe / Summe_Efg
'*************
'Variable_?? = Aus_Wert 'Aus_Wert = neuer Ausgangswert(0...255)
'*************
'
GOTO ANFANG
END
#EFG_LINKS
Akt_Efg = (Eingang - A) * 100 / (B- A)
IF Akt_Efg < Min_Efg THEN Min_Efg = Akt_Efg
RETURN
#EFG_RECHTS
Akt_Efg = 100 - (Eingang - C) * 100 / (D - C)
IF Akt_Efg < Min_Efg THEN Min_Efg = Akt_Efg
RETURN
#ZWISCHEN_REST
Rest_Summe = Rest_Summe / Summe_Efg
Aus_Wert = Aus_Wert + Rest_Summe
Rest_Dummy = (A * Min_Efg) MOD Summe_Efg
Rest_Summe = Rest_Summe MOD Summe_Efg
Rest_Summe = Rest_Summe + Rest_Dummy
RETURN
TABLE Fuzzy_Sets
22
0 0 255 255
0 0 128 128
0 0 128 128 128
0 0 255 255
0 0 128 128
128 128 128 189 217
0 0 255 255
0 0 128 128
127 189 189 250 236
0 0 255 255
0 0 128 128
189 250 255 255 255
0 0 255 255
128 128 128 159
0 0 128 128 217
0 0 255 255
128 128 128 159
128 128 128 189 217
0 0 255 255
128 128 128 159
127 189 189 250 236
0 0 255 255
128 128 128 159
189 250 255 255 255
0 0 255 255
128 159 159 191
0 0 128 128 236
0 0 255 255
128 159 159 191
128 128 128 189 236
0 0 255 255
128 159 159 191
127 189 189 250 255
0 0 255 255
128 159 159 191
189 250 255 255 255
0 0 255 255
159 191 255 255
0 0 128 128 255
0 0 255 255
159 191 255 255
128 128 128 189 255
0 0 255 255
159 191 255 255
127 189 189 250 255
0 0 255 255
159 191 255 255
189 250 255 255 255
0 0 0 51
0 0 255 255
0 0 255 255 No Set
0 51 51 102
0 0 255 255
0 0 255 255 No Set
51 102 102 153
0 0 255 255
0 0 255 255 No Set
102 153 153 204
0 0 255 255
0 0 255 255 No Set
153 204 204 255
0 0 255 255
0 0 255 255 No Set
204 255 255 255
0 0 255 255
0 0 255 255 No Set
Welcome to the world of PID control.
***********
I know it is not pbasic, but it is close enough to adjust manually.
As the software supports a great variety of hardware, then if there
is enough response they may perhaps consider to support basic stamps.
Check it out, I'd say.
Greetings peter