ST52x400/440/441 are 8-bit Intelligent Control
Units (ICU) of th e ST Five Family, w hich are able
to perform both boolean and fuz z y al gorithms in
an efficient manner, in order to reac h the best performances that the two methodologies allow.
ST52x400/440/441 is produced by STM icroelectronics using the reliable high performa nce CMOS
process, including integrated-on-chip peripherals
that allow maximization of system reliability,
decreasingsystem costs and minimizing the
number of externa l components.
The flexible I/O configuration of ST52x400/440/
441 allows for an interface with a wide range of
external devices, like D /A converters or power
control devices.
ST52x400/440/441 pins are configurable, allowing
the user to set the input or output signals on each
single pin.
A hardware multiplier (8 bit by 8 bit with 16 bit
result) and divider (16 bit over 8 bit with 8 bit
result and 8 bit remainder) is available to implement complex functions by using a s ingle inst ruction, optimizing program memory utilization and
computational speed.
Fuzzy Logic dedicated structures in ST52x400/
440/441 ICU’s c an be exploited to model complex
sys
tems with high accuracy in a useful and easy way.
Fuzzy Expert Systems for overall system manage ment and fuzzy Real time Controls can be
designed to increas e performances at highly com petitive costs.
The linguistic approach charac terizing Fuzzy
Logic is based on a set of IF-THEN rules, which
describe the control behavior, as well as on Membership Functions, which are associated to input
and output variables .
Up to 334 Membership Functions, with triangular
and t ra pez oidal sh apes , or singleton value s are
available to describe fuzzy variables.
The T IMER/PWM peripheral allows the management of pow er devices and timing signals, implementing different operating modes and high
frequency PWM (Pulse W ith Modulation) c ontrols.
Input Capture and Out put Compare functions are
available on the TIMER.
The programmable Timer has a 16 bit Internal
Prescaler and an 8 bit Counter.It can use internal
or external START/STOP signals and clock.
An internal programmable WATCHDOG is available to avoid loop errors and to res et the ICU.
An Anal og Comparator with a 6 channel multiplexer is a vailable on ST52x440/441 family
devices. This analog peripheral allows easy implementation of a high resolution A /D conversion. By
using only an ex ternal capacitor this peripheral
may b e configured in order to achieve up to 12 bit
A/D converter resolution. It includes a 2.5 V bandgapreference forA/D conversion calibration,
which can be used externally for s ignal conditioning.
An on-chip TRIAC driver peripheral allows the
direct management of power devices, implementing two different operating modes: Burs t Mode
(i.e. Thermal Applications), Phas e Angle Partialization (i.e. Motors Control by Triacs). The TRIAC
Driver also generates a PWM signal.
The ST52x400/440/441 family also includes an
on-chip Power-on-Reset (POR), which provides
an internal chip res et during power up situation
and a Brown-Out Detector (BOD), which resets
the ICU if the vol tage source V
dips below a
DD
minimum value.
In order to op timize energy consumption, two different power saving modes are available: Wait
mode and Halt mode.
ProgramMemory(EPROM/OTP)addressing
capability addresses up to 8 Kbytes of memory
locations to store both program instructions and
permanent data.
EPROM can be locked by the user to prevent
external undesired operations.
Operations may be performed on data stored in
RAM, allowing the direct combination of new input
and feedback data. All bytes of RAM are used like
Register File.
OTP (One Time Programmable) version devices
are fully compatible with t he EPROM windowed
version, which may be used for prototyping and
pre-production phases of development.
A powerful development environment consisting
of a board a nd software tools allows an easy c onfiguration and use of ST52x400/440/ 441.
The VISUAL FIVE
TM
software tool allows development of projects through a user-friendly graphical interface and optimization of generated code.
7/94
ST52T400/T440/E440/T441
1.2 Operational Description
ST52x400/440/441 IC U can work in two modes:
■ Memory Programming P has e
■ Work ing Phase
according to RESET and Vpp signals levels (see
pins description) .
Note: When RESET=0 it is advisable not to use
the sequence “101010“ to port PA ( 7 : 2 ).
1.2.1 M emory Programmi ng Phase.
The ST52x400/440/441 memory is loaded in the
Memory Programming Phase. All fuzzy and standard instructions are written inside the memory.
This phase starts by setting the control signa ls as
illustrated in (see Table 1.1).
When t his phase starts, the ST52x400/440/441
core is settoRESET status; then 12V are
applied to the Vpp pin in order to start EPR OM
programming. A signal applied to PB1 is used to
increment the memory address; the data is supplied to PORT A (see E PROM programming for
further details).
Table 1.1Control Signals Setting
Control
Signal
RESET001
Vpp5V /12V00
Pro-
gramming
ResetWorking
1.2.2 Working Mode.
The processor starts the work ing phase following
the inst ructions, which have been previously
loaded in the memory.
ST52x400/440/441’s internal structure includes a
computational block, CO NTRO L UNIT (CU)/DATA
PROCESSING UNIT (DPU), which allows processing of boolean functions and fuzzy algorithms.
The CU/DPU can manage up to 334 different
Membership Functions for the fuzzy ru les antecedent part. The rule consequents are “crisp” val ues (real numbe r s). The maximum number of
rules that can be defined is limited by the dimensions of the implemented standard algorithm.
EPROM is then shared between fuzzy and standard algorithms. The Membership Function data is
stored inside the f irst 1024 memory locations. The
Fuzzy rules are parts of the program instructions.
The Control Unit (CU) reads the in format ion and
the status deriving from the peripherals.
Arithmetic calculus can be performed on these
values by using the internal CU and the 128/256
bytes of RAM, which supports all computations.
The peripheral input can be fuzzy and/or arith metic output, or the values contained in Data RAM
and EPROM locations.
ST52x400/440/441 pins can be set in digital input
mode, digital output mode or in Alternate Functions. The pin configuration is ac hieved by means
of the configuration registers. The functions of the
ST52x400/440/441 pins are described bel ow:
V
Main Power Supply Voltage (5V ± 10%).
DD.
. Digital circuit Ground. All Vss pins must be
V
SS
connected to ground (see ST52 T400 pin-out).
ACSTRT, ACSYNC(*). These pins are us ed to
synchronize the 16-bit counter of the Analog Comparator with an external ramp generator. The
ACSTRT input is us ed to start the counter. The
ACSYNC output is set when the counter is ready
to start a new count.
BG(*). A Bandgap Reference value of 2.5V is
available on this p in. It can be used for analog signal conditioning.
GNDA. Analog c ircuit ground of the Analog Comparator. Must be tied to V
. Main Power Supply for internal E PROM pro-
V
PP
SS
.
gramming and MODE selector. During the Programming phase V
Working phase V
must be set at 12V. In the
PP
must be equal to VSS.
PP
OSCin and OSCout. These pins are internally
connected to the on-chip osc illator circuit. A quartz
crystal or a ceramic resonator can be connected
between these t wo pins in order to allow the correct operations of ST52x400/440/441 with various
stability/cost trade-offs. An external clock signal
canbeappliedtoOSCin:inthiscaseOSCout
must be grounded.
RESET. This signal is used to reset the
ST52x400/440/441 and re-initialize the regist ers
and control signals. It also allows the user to
select the working mode of the device.
PA0-PA7, PB0-PB7,PC0-PC4. These lines are
organized as I/O ports. Each pin can be configured as an input or output. During the Programming phase the ports are used for EP R OM data
read/write operations.
TOUT, TOUTN.These pins output the signal generated by the TIMER peripheral. The T0OUTN
signal is the complement of the T0OUT one.
TRES, TSTRT, TCLK . These pins are related to
the TIMER peripheral and are used for Input Capture and event counting. The TRES pin is used to
set/reset theTimer; theTSTRT pin is used to start/
stop the counter. The Timer can be driven by the
internal clock or by an external signal connected
to the TCLK pin.
TROUT, MAIN1,MAIN2. These pins are related to
the TRIAC DRIVER peripheral. TROUT outputs
the signal generated by t he peripheral. In order to
drive a TRIA C directly w it hout the use of additional c omponents, the TROUT pin can supply up
to 50 mA (2V voltage drop). MAIN1 and MAIN2
pins are used to detect the zero crossing of the
Power Line voltage.
(*) Not available in ST52x400 devices
AC0-AC5(*). These pins are used to input the
analog signals to the Analog Comparator. An analog multiplexer is available to switch these inputs
to the Analog Comparator.
CS(*). This pin outputs the current generated in
the Analog Comparator peripheral by a current
generator, allowing charging of an external capacitor to obtain a v oltage ramp for the A / D conversion.
18/94
ST52T400/T440/E440/T441
Signals
2 INTERNAL ARCHITECTURE
ST52x400/440/441 is composed of the following
blocks and peripherals:
■ Cont rol Unit (CU)
■ Dat a P roc es sing Unit (DPU)
■ ALU
■ Decision Processor (DP)
■ EPROM
■ 256 Byte RAM
■ Clock Oscillator
■ Analog Multiplexer and Analog Comparator
■ 1PWM/Timer
■ 1 Triac/PWM Driver
■ Digital I/O port
2.1 Control Unit and Data Processi ng Unit
The Control Unit (CU) formally includes five m ain
blocks. Each block decodes a set of instructions,
generating the appropriate control signals. The
mainpartsoftheCUareshowninFigure2.1.
The five different parts of the CU manage Loading, Logic/Arithmetic, Jump, Control and Decision
Processor (DP) instructions s ets.
The block called “Collector” manages the signals
deriving from the different parts of the CU then
defines the signals fo r the Data Processing Unit
(DPU) and for the different peripherals of the ICU.
The block called “Arbiter” manages the different
parts of the CU in order to have only one part of
the system activat ed during working mode.
The CU structure is highly flexible, designed with
the objective of easily adapt ing the core of the
microcontroller to market needs. New instructions
sets or new peripherals can be easily included
without changing the structure of the microcontroller, maintaining code compatibility.
The C U reads and decodifies the instructions
stored on the EPROM (Fetch). According to the
instructions type, the Arbiter activates one of the
main blocks of the CU. Afterwards, all the control
signals for the DPU are generat ed.
A set of 55 d ifferent arithmetic, DP and logic
instructions is available. T he arithmetic instructions operate to all the RAM addresses without the
need of using special registers.
The DPU receives, stores and sends the instructions coming from the EPROM, RAM or from the
peripherals in order to execute them .
2.1.1 Program Counter .
The Program Counter (PC) is a 13-bit regi ster that
contains the address of t he next memory location
to be proc es s ed by the core. This memory location may be an opcode, an operand or an address
of an operand.
Figure 2.1 CU Block Diagram
MicroCode
A
R
B
I
T
E
R
Clock Master
Loading
Instruction Set
Logic Arithmetic
Instruction Set
Jump
Instruction Set
Control
Instruction Set
Decision Processor
Instruction Set
C
O
L
L
E
C
T
O
R
Control
19/94
ST52T400/T440/E440/T441
add_EPR
S
C
Figure 2.2 Data Processing Unit (DPU )
U
EPROM
INPUTS
PERIPHERALS
M
U
X
ADDRESS RAM
STACK POINT
PROGRAM COUNTER
RAM
128 Bytes
ACCUMULATOR
FLAGS REG.
PERIPHERAL
REGISTERS
MULTIPLEXER
ALU
Figure 2.3 CU/DPU Block Diagram
E
P
R
Microcode
O
M
RAM
C
U
Con tr ol S ig n a ls
EPR OM Address
RAMData8Bit
RAM A ddr.
8Bit
RAM
Data Out
8Bit
D
P
U
To Peripherals
From
P erip he ra ls
20/94
ST52T400/T440/E440/T441
P
ERIPHERALBLO
ONCHIP
RAL
E
ONF
I
REG
IST
ERS
P
ERIPHERAL
P
ERIPHERALBLO
D
C
LDPR
The 13-bit length allows the direct addressing of
8192 bytes in the program space: jump and call
instruction support the absolute addressing in all
the memory.
After having read the curren t instruction address,
the PC value is incremented. Th e result of this
operation is shifted back into the PC.
The PC can be changed in the following ways:
■ J P (Jump) instruction PC = Jump Address
■ InterruptPC = Interrupt Vector
■ RETI instructionPC = Pop (stack)
■ ResetPC = Reset Vector
■ Norm al InstructionPC = PC + 1
2.1.2 Flags.
The ST52x400/440/ 441 core includes different
sets of flags that correspond to 2 different modes:
normal mode and interrupt mode. Each set of
flags consist of a CARRY flag (C), ZERO flag (Z)
and SIGN f lag (S). One set of f lags (CN, ZN, SN)
is used during normal operation and one is used
during interrupt mode (CI, ZI, SI). Formally, the
user has to manage only one set of flags: C, Z and
S.
The ST52x400/440/441 core uses the flags that
correspond to the actual mode: as soon as an
interrupt is gen erated , the ST FIVE core uses the
interrupt flags instead of the normal flags.
Each interrupt lev el has its own set of flag s, which
is saved in the Flag Stack during interrupt servic-
ing.
These flags are restored from th e Flag Stack automatically when a RETI instruction i s executed.
If the ICU was in the normal mode before an interrupt, a fter the RETI instruction is executed, the
normal flags are restored.
Note:
A CALL subroutine is a normal mode execution. For this reason a RET instruction, consequent to a CALL instruction, doesn’t affect the
normal mode set of flags.
Flags are not cleared during context switchin g and
remain in the state they were located in at the end
of the last i nterrupt routine switching.
The Carry flag is set when an overflow o ccurs during arithmetic operations, otherwise it is cleared.
The Sign flag is set when an und erflow occurs
during arithmetic operations, otherwise it is
cleared.
2.2 Address Spaces
ST52x400/440/441 has four separate address
spaces:
■ RAM: 128 or 256 Bytes
■ 20 Input Registers
■ 6 Output Registers
■ 21 Configuration Registers
■ Program memory:up to 8K Bytes
The Program Memory will be described in further
details in the EPROM section
Figure 2.4 Address Spaces Description
PROGRAM MEMORY
NON VOLATILEMEMORY
LDRE
LDCE
LDPE
DATARAM
INPUT REGISTERS
ST FIVE CORE
LDFR
LDRI
DP
REGISTERS
PROGRAM
COUNTER
CU
DPU
ALU
PERIPHE
OUTPUT
R
GISTER
GURATION
C
L
R
S
CK
CK
BLOCK
21/94
ST52T400/T440/E440/T441
2.2.1 Ram and Stack.
RAM consists of 128 (G0/G1/F0/F1 types) or 256
(G2/G3/F2/F3 t y pes ) general purpos e 8-bit regis ters.
All the registers in RAM can be specified by using
a decimal address, e.g. 0 identifies the first register of RAM.
To read or write in the RAM registers, the LOAD
instructions must be used (see Table 2.5).
When the instructions like Interrupt request or
CALL are executed, a STACK is us ed to push the
PC. The STACK is push directly in the RAM. For
each level of stack 2 bytes of RAM are used. The
values of this stack are stored from the last RAM
register (address 255). The maximum level of
stack must be less than 128. When a subroutine
call or interrupt request occurs, the c ontents of
each level is shifted into the next level while the
content of the PC is shifted into the first level.
When a subroutine or interrupt return o ccurs (RE T
or RETI instructions), the first level register is
shifted back into the PC and the value of each
level is popped back into the previous level. These
operating modes are illustrated in Figure 2.5.
2.2.2 Input Registers Benc h.
The Input Registers (IR) bench c ons ists of 20 8-bit
registers containing data derivi ng from the peripherals and parallel p orts.
All the registers can be sp ecified by using a decimal address, e.g. 0 identifies th e first regist er of
the IR.
The assembler instruction:
the value in the
inp
LDRI reg,inp_teg
loads
IR to the register (RAM location) identified by the address reg.
The first input register is dedicated to store the
value of t he stack pointer. The next 12 registers of
the IR are dedicated to the 6 (for ST52X440G/
441G) or the 4 converted values (for ST52X440F/
441F) in c as e of converted values coming from
the Analog Comparator (in S T52x400 devices
these registers are not used ). Each of these values are s tored on two bytes because of the resolution of the A/D conv ersion process. The last 7
registers contain data from t he I/O ports and
PWM/Timers. Table 2.1 summarizes the IR
address and the relative peripheral. In order to
simplify the concept a mnemonic name is
assigned to the registers. The s ame name is used
in VISUAL FI VE development tools.
Figure 2.5 S tack Operation
WHEN RETI OR RET
OCCURS
REG 0
REG 1
REG 2
REG 3
REG 4
REG 5
REG 252
REG 253
REG 254
REG 255
PROGRAM COUNTER
RAM
WHENCALLOR
INTERRUPT REQ.
OCCURS
Stack
Pointer
STACK LEVEL n
..........................
STACK LEVEL 2
STACK LEVEL 1
22/94
ST52T400/T440/E440/T441
2.2.3 Co nfi gu ration Registers.
The ST52x400/440/441 Configuration Registers
allow the configuration of all the blocks of the ICU.
Table 2.2 describes the functions and the related
peripherals of t he 21 C onfiguration Registers
available: in o rder to simplify the concept a mnemonic name is assigned to each Configuration
Register. The same name is used in VISUAL
TM
FIVE
development tools. By using the load
instructions the Configuration R egisters may be
set by using values stored in the Program Memory
(EPROM) or in the RA M.
The assembler instruction
the Configuration Register
of memory location
LDCE conf,mem
conf
with the contents
mem
, inside the currently set
loads
memory page.
The assembler instructions
the Configuration Register
of the register (RAM location)
LDCR conf,reg
conf
with the contents
reg
.
loads
Use and meaning of e ach register will be
described in further details in the corresponding
section.
2.2.4 Output Registers.
The O utpu t Registers (OR) consist of 6 registers
containing data for the ICU peripherals including I/
OPorts.
All registers can be specified by using a decimal
address, e.g. 1 identifies the second OR.
By using the LOA D type inst ruc ti ons the Output
Registers (OR) may be set with values st ored in
the Program Memory (LDPE) or in the RAM
(LDPR).
The assembler instruction
the OutputRegister
ory location
mem
out
, inside the currently set memory
page. The assembler instruction
LDPE out,mem
with the cont ents of mem-
LDPR out,reg
loads the Output Register out with the contents of
reg
register (RAM location)
.
Table 2. 3 des c ribes the OR: in order to simplify the
concept a mnemon ic name is assigned to e ach of
the Output Registers. The same name is us ed in
VISUAL FIVE
TM
development tools. Use and
meaning of each register will b e described in further details in t he c orresponding section.
Table 2.1 Input Registers
IR MNEMONIC NAMEPERIPHERAL REGISTERADDRESS
STACK_POINTERSTACK POINTER0
AC_CHAN0H(*)Analog Comparator CHANNEL 0 High Byte1
AC_CHAN0L(*)Analog Comparator CHANNEL 0 Low Byte2
AC_CHAN1H(*)Analog Comparator CHANNEL 1 High Byte3
AC_CHAN1L(*)Analog Comparator CHANNEL 1 Low Byte4
AC_CHAN2H(*)Analog Comparator CHANNEL 2 High Byte5
AC_CHAN2L(*)Analog Comparator CHANNEL 2 Low Byte6
AC_CHAN3H(*)Analog Comparator CHANNEL 3 High Byte7
AC_CHAN3L(*)Analog Comparator CHANNEL 3 Low Byte8
AC_CHAN4H (*)(**)Analog Comparator CHANNEL 4 High Byte9
REG_CONF 10PWM/TRIACPWM/TRIAC Working mode Configuration
REG_CONF 11PORT CPORT C digital pin I/O direction
REG_CONF 12PORT APORT A Alternate function settings
REG_CONF 13PORT BPORT B digital pin I/O direction
REG_CONF 14(*)PORT BPORT B settings for digital or analog pin
REG_CONF 15(*)ANALOG COMPARATORAnalog Comparator Prescaler settings
REG_CONF 16(*)ANALOG COMPARATORAnalog Comparator in A/D working mode
REG_CONF 17INTERRUPTInterrupt priorities
REG_CONF 18INTERRUPTInterrupt priorities
REG_CONF 19TRIACTRIAC Pulses Width Configuration
REG_CONF 20TRIACTRIAC Pulses Width Configuration
(*) Not used on ST52x400xx versions
PWM/TIMER Prescaler configuration and
output waveform selection.
PWM/TRIAC Prescaler configuration and
output waveform selection.
Table 2.3 Output Registers
OR MNEMONIC NAMEPERIPHERAL REGISTERADDRESS
PORT_APORT A OUTPUT REGISTER0
PORT_BPORT B OUTPUT REGISTER1
PORT_C (**)PORT C OUTPUT REGISTER2
PWM_COUNTTIMER/PWM COUNTER Value3
PWM_RELOAD (*)PWM/TIMER RELOAD Value4
not used5
not used6
not used7
not used8
TRIAC_COUNTTRIAC DRIVER COUNTER Value9
(*)Used if Peripheral has beenprogrammed inPWM Mode (**) Not used onST52x400F/440F/441Fversions
24/94
2.3 Fu zzy Computation
ST FIVE’s Fuzzy main features are:
■ Up to 8 Inputs with 8-bit resolution;
■ 1 Kbyte of Program/Data Memory available to
store more than 300 to Membership Functions
(Mbfs) for each Input;
■ Up to 128 Outpu ts with 8-bit resolution;
■ Possibility to process fuzzy rules with an
UNLIMITED number of antecedents
■ UNLIMITED number of Rules and FuzzyBlocks.
The limits on the number of Fu zzy Rules and
fuzzy Blocks are only related to the program memory size.
2.3.1 Fuzzy Inference .
The block diagram illustrated in Figure 2.7
describes the different steps performed during a
fuzzy algo rithm. The ST FIVE Core allows the
implementation of a MAMDANI type fuzzy inference with crisp consequents. Inputs for fuzzy
inference are stored in 8 dedicated Fuzzy input
registers. The instruction LDFR is used to set the
input fuzzy registers with values stored in the Register File. The result of a fuzzy inference is stored
directly in a location of the Register File.
ST52T400/T440/E440/T441
Figure 2.6 Alpha Weight Calculation
1
ij
α
2.3.2 Fuzzyfication Phase.
In this phase the in tersection (alpha weight)
between the input values and the related Mbfs is
performed (Figure 2.6).
8 Fuzzy input regist ers are available for fuzzy
inferences.
After loading the input values by using the LDFR
assembler instruction, the user can start fuzzynference by using the assembler instructionFUZZY.
During fuzzyfication: input data is transformed in
the activation level (alpha weight) ofthe Mbfs. i
j-th Mbf
i-th INPUT VARIABLE
Input Value
Figure 2.7 Fuzzy Inference
FUZZYFICATION
Input Values
11
1m
INFERENCE
n1
nm
PHASE
1
2
DEFUZZYFICATION
N rules -1
Nrules
Output Values
25/94
ST52T400/T440/E440/T441
X
2.3.3 Inference Phase.
The Inference Phase manages the alpha weights
obtained during the fuzzyfication phase to c ompute the truth value (
Ω) for each rule.
This is a calculation of th e maximum (for the OR
operator) and/or minimum (for the AND operator)
performed on alpha values according to the logical
connectives of fuzzy rules.
Several conditions may be linked together by linguistic con nec tive s AND/OR, NOT operator and
brackets.
The truth value ω and the related output singletonmove t o the Defuzzyfication phase in order to
complete the inferenc e calculation.
Figure 2.8 Fuzzyfication
IF
INPUT 1
1
IF
INPUT 1
1
IS X1 OR
X1
IS X1 AND
X1
Input 1
Input 1
INPUT 2
α2
OR = Max
INPUT 2
α2
IS X2 THEN .......
X2
Input 2
IS X2 THEN ......
X2
Input 2
Figure 2.9 Output Membership Functions
i0
j-th Singleton
ij
X
i-th OUTPUT
in
1
ω
ij
ω
i0
ω
in
0
X
2.3.4 Defuzzyfication.
In this phase the output crisp values are determined by implementing the conseq uent part of the
rules.
Each consequent Singleton X
weight values ω
, calculated by the Fuzzy Infer-
i
is multiplied by its
i
ence Unit, in order to compute the upper part of
the defuzzification.
Each output value is deduced from the consequent crisp values (X
) by carrying out the follow-
i
ing defuzzification formula:
where:
N
Xijω
j
N
∑
j
ij
ω
ij
Y
=
i
∑
--------------------- -
i = 0,1 ident ifies t he current output variable
N = number of the active rules on the current output
=weight of th e j-t h singleton
ω
ij
Xij = abscissa of the j-th singleton
Fuzzy outputs are stored in the RAM location i-th
specified in the assembler instruction OUT i.
26/94
ST52T400/T440/E440/T441
2.3.5 Input Membership Function.
ST FIVE allows the management of triangular
Mbfs. In order to define an Mbf, three different
types of data must be stored on the Program/Data
Memory:
the vertex of the Mbf: V;
the length of the left semi-base: LVD;
the length of the right semi-base: RVD;
In order to reduce the size of the memory area
and the computational effort the v ertical dimension
of the vertex is set to 15 (4 bits).
By using the previous memorization method different kinds of triangular Membership Functions ma y
be stored. Figure 4.6 illustrates a typical example
of Mbfs that c an be defined in ST FIVE.
Each Mbf is then defined storing 3 bytes in the first
1 Kbyte of the programmemory.
The Mbf is memorized by using the following
instruction:
MBF n_mbf lvd v rvd
where
n_mbf identifies Mbf, l v d, v, and rvd, which are the
parameters that describe the Mbf’s shape.
2.3.6 Output Singleton.
ST FIVE uses a particular kind of membership
function called Singleton for its output variables. A
Singleton doesn’t have a shape, like a traditional
Mbf, and is characterized by a single point identified by the coup le (X, w), where the w is calculated by the Inference Unit as described before.
Often, a Singleton is simply identified with its Crisp
Value X.
2.3.7 Fuzzy Rules.
Rules can have the following structures:
if A op B op C...........then Z
if (A op B) op (C op D op E...)...........then Z
where op is one of the possible linguistic operators (AND/OR)
In the first cas e the rule operators are managed
sequentially; in the second one, the priority of the
operator is fixed by the brackets.
Each rule is codified by using an instruction set,
the inference time for a rule with 4 antecedents
and 1 consequent is about 3 microseconds.
Figure 2.10 Mbfs Parameters
15
0
15
w
0
V
LVDR VD
X
Figure 2.11 Example of valid Mbfs
Input M bf
Input V ariable
Output S ingleton
Output Variable
27/94
ST52T400/T440/E440/T441
The assembler Instruction S et, which manages fu zzy instructions is reported in the following table:
Table 2.4 F uz z y Instruction Set
InstructionDescription
MBF
n_mbf Ivd v rvd
LDP
nm
Stores the Mbf
Fixes the alpha value of the inputnwith the Mbfmand stores it in internal registers
n_mbf
with the shape identified by the parameters
Ivd,v
and
rvd
nm
LDN
FZAND
FZOR
LDKStores the result of the last Fuzzy operation executed in internal registers
SKM
LDMCopies the value of register M in the data stack
crisp
CON
OUT
n_out
FUZZYStarts the Fuzzy algorithm
Calculates the complementary alpha value of the inputnwith the Mbfm. and stores the
result in internal registers
Implements the Fuzzy operation AND between the last two values stored in internal
registers
Implements the Fuzzy operation OR between the last two values stored in internal registers
Loads the result of the last performed Fuzzy operation (stored in the temporary register
K) in the temporary buffer M.
Multiplies the
Performs Defuzzyfication and stores the currently Fuzzy output in the RAM
crisp
value with the last ω weight
n_out
location
28/94
ST52T400/T440/E440/T441
Example 1:
IF Input
is codified by the foll owing instructions:
LDN 1 1calculates the NOT α value of Input
LDP 4 12fixes the α value of Input
FZANDadds the NO T α and α val ues obtained with the operations LDN1 1 and LDP 4 12
LDKstores th e r es ult of the operation FZAND in internal registers
LDP 3 8fixes the α value of Input
FZORimplements the operation OR between the results obtained with the operations LDK and
LDP
CON crisp
Example 2, the priority of the operat or is fixed by the b rackets:
IF (Input
LDP 3fixes the α value of Input3 with Mbf1 and stores the result in internal registers
LDN 4 15calculates the NOT α value of Input
FZANDadds NOT α and α v alues obtained with the operations LDP 3 1 and LDN 4 15 SKM
LDP 1 6fixes the α value of Input
LDN 2 14calculates the NOT α value of Input
FZORimplements the operation OR between the α and NOT α values obtained with the two previ-
LDKstores th e r es ult of the operation OR in internal registers
LDMcopies the value of the memory register M in internal registers
FZORimplements t he operation OR between the last two values stored in internal registers (LDK
CON crisp
IS NOT Mbf1AND Input4is Mbf12OR Input3IS Mbf8THEN Crisp
1
with Mbf1and stores the result in internal registers
1
with M12and stores the result in internal registers
4
with Mbf8and stores the result in internal registers
3
multiplies the result of the last Ω operation with the crisp value Crisp
1
IS Mbf1AND Input4IS NOT Mbf15)OR(Input1IS Mbf6OR Input6IS NOT Mbf14)THENCrisp
3
with Mbf15and stores the res ult in internal registers
4
1
1
stores the result of the operation FZAND in internal registers
with Mbf6and stores the result in internal registers
1
with Mbf14and stores the result in internal registers
6
ous operations (LDP 1 6 and LDN 2 14)
and LDM)
multiplies the result of the last Ω operation with the crisp value Crip
2
2
2
At the end of the fuzzy rul e, by using the instruction OUT RAM_reg, a byte is written. Afterwards, the control of the algorithm goes returns to the CU.
29/94
Loading...
+ 65 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.