fuzzystudio tm 3.0 user manual 1 st edition may 1998
ownership stmicroelectronics is the sole owner of the software contained in the package. stmicroelectronics is the holder of the copyright to the software, including without limitation such aspects of the software as its code, sequence, organization, "look and feel", programming language and compilation names. use of the software unless pursuant to the terms of a licence granted by stmicroelectronics or as otherwise authorized by law is an infringment of the copyright. permitted use provided that you fully accept the present conditions, stmicroelectronics grants you a non-exclu- sive non transferable licence to use the product. you are also authorized to: a) install the software on an on-line storage device (for example a hard disk drive); b) maintain an archivial copy of the software on off-line storage media (such as diskettes). prohibited use all uses of the software and other elements of the product not specifically allowed in the permitted uses section of this agreement are prohibited. the following is a partial list of prohibited uses of the package. you are not allowed to: a) decompile or reverse engineer the software; b) modify the software in any manner; c) sublicense, sell, lend, lease or rent the software or any portion of the software. warranties stmicroelectronics makes no warranties, express or implied, including without limitation any warranties of merchantability or fitness for a particular purpose, regarding the software develop- ment tool and any related materials or their performance. limited damages stmicroelectronics shall not be liable for any incidental, special consequential or exemplary damages including, but not limited to loss of anticipated profits or benefits. use in life support devices or systems must be expressly authorized stmicroelectronics products are not authorized for use as critical components in life support devices or systems without the express written approval of stmicroelectronics. as used herein: 1. life support devices or systems are those which (a) are intented for surgical implant into the body, or (b) support or sustain life, and whose failure to perform, when properly used in accordance with instructions for use provided with the product, can be reasonablyexpected to result in significant injury to the user. 2. a critical component is any component of a life support device or system whose failure to perform can reasonaly be expected to cause the failure of the life support device or system, or to affect its safety or effectiveness.
table of contents before you begin i general conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i mouse conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i keyboard conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i installation and configuration ii system requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i installing fuzzystudio ? 3.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . ii starting to use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii user interface iv choosing commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iv clicking a toolbar button . . . . . . . . . . . . . . . . . . . . . . . . . . v choosing commands from menus . . . . . . . . . . . . . . . . . . . . . v using shortcut keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . v using help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vi context-sensitive help . . . . . . . . . . . . . . . . . . . . . . . . . . vi chapter 1- fuzzystudio ? 3.0 1 about st52x301 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 introduction to fuzzystudio ? 3.0 . . . . . . . . . . . . . . . . . . . . . . . 1 system variables overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 programming approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 chapter 2- project management 7 project files management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 working with a new project . . . . . . . . . . . . . . . . . . . . . . . . 7 working with an existing project . . . . . . . . . . . . . . . . . . . . . 8 saving and printing files . . . . . . . . . . . . . . . . . . . . . . . . . 8 the fuzzystudio ? 3.0 main window . . . . . . . . . . . . . . . . . . . . . . 9 the fuzzystudio ? 3.0 window application menus . . . . . . . . . . 9 the fuzzystudio ? 3.0 main windows toolbar . . . . . . . . . . . . 10 the fuzzystudio ? 3.0 main windows status bar . . . . . . . . . . 10 the fuzzystudio ? 3.0 project window . . . . . . . . . . . . . . . . . . . 11 working environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 chapter 3 - initial settings 13 global variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 how to insert a global variable . . . . . . . . . . . . . . . . . . . . . 13 deleting a global variable . . . . . . . . . . . . . . . . . . . . . . . . 14 global variable properties . . . . . . . . . . . . . . . . . . . . . . . . 14 frequency setting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 peripherals configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 timer configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 triac driver configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
sections common to the three modes . . . . . . . . . . . . . . . . . 19 pwm mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 burst mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 phase partialization . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 a/d configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 parallel port configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 serial communication interface (sci) configuration. . . . . . . . . . . . . . . 24 chapter 4 - block editor tool 27 the block editor tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 block editor menus . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 block editor toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 block editor status bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 using the block editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 program starting point . . . . . . . . . . . . . . . . . . . . . . . . . 30 how to insert a block . . . . . . . . . . . . . . . . . . . . . . . . . . 30 how to link two blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 single and multiple selection of a block . . . . . . . . . . . . . . . . . . . . . 31 basic commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 how to use links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 other commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 chapter 5 - fuzzy block 33 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 the fuzzy system editor window . . . . . . . . . . . . . . . . . . . . . . . . 34 fuzzy system editor toolbar . . . . . . . . . . . . . . . . . . . . . . 34 fuzzy system editor status bar . . . . . . . . . . . . . . . . . . . . . 34 fuzzy system editor menus . . . . . . . . . . . . . . . . . . . . . . . 35 about fuzzy variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 variable constraints definition in a fuzzy block . . . . . . . . . . . . . . . . . 36 how to insert a fuzzy variable block . . . . . . . . . . . . . . . . . . 37 how to delete a fuzzy variable block . . . . . . . . . . . . . . . . . . 37 how to close a variable window . . . . . . . . . . . . . . . . . . . . 37 fuzzy variable initialization and storage . . . . . . . . . . . . . . . . . . . . . 38 the fuzzy variable editor window . . . . . . . . . . . . . . . . . . . . . . . . 40 fuzzy variable editor menu . . . . . . . . . . . . . . . . . . . . . . . 40 fuzzy variable editor toolbar . . . . . . . . . . . . . . . . . . . . . . 41 fuzzy variable editor status bar . . . . . . . . . . . . . . . . . . . . 41 how to open a fuzzy variable block . . . . . . . . . . . . . . . . . . . . . . . 42 how to modify the fuzzy variable properties . . . . . . . . . . . . . . 43 creating and managing membership functions . . . . . . . . . . . . . . . . . 44 creating a new mbf . . . . . . . . . . . . . . . . . . . . . . . . . . 45 creating a new mbf using the rule editor (output variables) . . . . . . 45 how to customize a mbf . . . . . . . . . . . . . . . . . . . . . . . . . 45 using autofill mbf (only for input variables) . . . . . . . . . . . . . 46 fuzzystudio ? 3.0 user manual
how to delete a mbf . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 autoshift & semibase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 mbf report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 shared and copied variables . . . . . . . . . . . . . . . . . . . . . . . . . . 50 shared variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 copied variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 how to export data to clipboard . . . . . . . . . . . . . . . . . . . . . . . . . 51 fu.l.l. importer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 rule editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 defining fuzzy rules with rule editor . . . . . . . . . . . . . . . . . . . . . . 54 the rule editor window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 rule editor menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 rule editor toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 rule editor status bar . . . . . . . . . . . . . . . . . . . . . . . . . . 55 how to write a rule using guided editor . . . . . . . . . . . . . . . . . . . . 56 editing the antecedent . . . . . . . . . . . . . . . . . . . . . . . . . 57 editing the consequent . . . . . . . . . . . . . . . . . . . . . . . . . 57 using manual editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 how to write a rule . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 list updating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 how to delete rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 how to print the rules list . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 rule editor view options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 rule editor constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 rule grammar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 error messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 chapter 6 - arithmetic block 65 the arithmetic block window . . . . . . . . . . . . . . . . . . . . . . . . . . 65 arithmetic block menus . . . . . . . . . . . . . . . . . . . . . . . . . 65 arithmetic block toolbar . . . . . . . . . . . . . . . . . . . . . . . . . 66 arithmetic block status bar . . . . . . . . . . . . . . . . . . . . . . . 66 using the arithmetic block . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 instructions grammar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 conditional instructions . . . . . . . . . . . . . . . . . . . . . . . . . 71 how to check the instructions . . . . . . . . . . . . . . . . . . . . . . 73 chapter 7 - peripherals block 75 a/d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 triac . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 port output pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 table of contents
chapter 8 - interrupts service routines 81 interrupts configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 interrupts mask block . . . . . . . . . . . . . . . . . . . . . . . . . . 82 priority configuration block . . . . . . . . . . . . . . . . . . . . . . . 83 chapter 9 - wait for interrupt block 85 chapter 10 - assembler block 87 the assembler block window . . . . . . . . . . . . . . . . . . . . . . . . . . 87 assembler block menus . . . . . . . . . . . . . . . . . . . . . . . . . 87 assembler block toolbar . . . . . . . . . . . . . . . . . . . . . . . . . 88 assembler block status bar . . . . . . . . . . . . . . . . . . . . . . . 88 using the assembler block . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 how to check instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 assembler block instruction syntax . . . . . . . . . . . . . . . . . . . . . . . 90 chapter 11 - conditional block 91 how to insert a conditional block . . . . . . . . . . . . . . . . . . . . . . . . 91 conditional block grammar . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 chapter 12 - send - receive blocks 93 how to use the send and receive blocks . . . . . . . . . . . . . . . . . . . . 93 chapter 13 - restart block 97 chapter 14 - compiler 99 compiler options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 compilation error messages . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 warning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 fatal errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 internal errors . . . . . . . . . . . . . . . . . . . . . . . . . . 105 warnings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 chapter 15 - debugger 109 general description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 debugger menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 debugger toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 wcl source window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 watch view window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 watch edit dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 watch edit signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 locals window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 trace window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 registers window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 asm view window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 status window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 fuzzystudio ? 3.0 user manual
input editor window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 how to use debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 plot view window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 plot view menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 plot view window toolbar . . . . . . . . . . . . . . . . . . . . . . . . 122 print and copy the graphic on the clipboard . . . . . . . . . . . . . . 122 zoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 signals and bus selection . . . . . . . . . . . . . . . . . . . . . . . . 123 changing time base . . . . . . . . . . . . . . . . . . . . . . . . . . 124 changing colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 chapter 16 - how to program st52x301 125 programmer main features . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 hardware installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 chip insertion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 hardware description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 programming phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 error messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 appendix a - fuzzy logic introduction. human language and indeterminacy a - 1 a general overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . a - 2 the linguistic approach. . . . . . . . . . . . . . . . . . . . . . . . . . . . . a - 2 fuzzy logic, fuzzy sets and membership function . . . . . . . . . . . . . . a - 4 fuzzy reasoning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . a - 5 the mathematical definition of fuzzy sets . . . . . . . . . . . . . . . . . . . a - 7 membership functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . a - 9 fuzzy set operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . a - 9 set complement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . a - 10 set union . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . a - 12 set intersection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . a - 13 the mathematical formalism of fuzzy logic . . . . . . . . . . . . . . . . . a - 14 fuzzy reasoning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . a - 16 fuzzy computation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . a - 17 bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . a - 21 appendix b - quick reference w.a.r.p. control language (wcl) b - 23 general features of a wcl program . . . . . . . . . . . . . . . . . . . . b - 23 source code organization . . . . . . . . . . . . . . . . . . . . . b - 23 characters conventions . . . . . . . . . . . . . . . . . . . . . . . b - 23 naming conventions . . . . . . . . . . . . . . . . . . . . . . . . b - 23 standard libraries . . . . . . . . . . . . . . . . . . . . . . . . . . b - 23 conditional expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . b - 24 operands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . b - 24 operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . b - 24 library functions . . . . . . . . . . . . . . . . . . . . . . . . . . b - 25 reference labels . . . . . . . . . . . . . . . . . . . . . . . . . . b - 26 table of contents
predefined names . . . . . . . . . . . . . . . . . . . . . . . . . . b - 26 chip features definition . . . . . . . . . . . . . . . . . . . . . . . . . . . b - 27 global variables declaration . . . . . . . . . . . . . . . . . . . . . . . . . b - 28 membership function definition . . . . . . . . . . . . . . . . . . . b - 28 global crisp variables definition . . . . . . . . . . . . . . . . . . . b - 28 procedure declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . b - 29 arithmetic procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . b - 29 asm procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . b - 31 control procedure . . . . . . . . . . . . . . . . . . . . . . . . . . b - 32 folder procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . b - 35 fuzzy procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . b - 35 fuzzy variables declaration . . . . . . . . . . . . . . . . . . . . . b - 35 fuzzy rules definition . . . . . . . . . . . . . . . . . . . . . . . . b - 36 st52x301 standard library . . . . . . . . . . . . . . . . . . . . . . . . . b - 37 predefined variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . b - 39 peripherals configuration variables . . . . . . . . . . . . . . . . . . . . . b - 39 appendix c - assembler language c - 41 program memory and registers architecture . . . . . . . . . . . . . . . . c - 41 program memory . . . . . . . . . . . . . . . . . . . . . . . . . . c - 41 register file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . c - 41 configuration registers . . . . . . . . . . . . . . . . . . . . . . . c - 42 input registers . . . . . . . . . . . . . . . . . . . . . . . . . . . c - 42 peripherals data registers . . . . . . . . . . . . . . . . . . . . . . . . . c - 43 flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . c - 43 fuzzy programming in assembler . . . . . . . . . . . . . . . . . . . . . . c - 44 membership functions definition . . . . . . . . . . . . . . . . . . c - 44 rule inference . . . . . . . . . . . . . . . . . . . . . . . . . . . . c - 45 the structure of a program . . . . . . . . . . . . . . . . . . . . . . . . . c - 47 structure of a generic code line . . . . . . . . . . . . . . . . . . c - 48 comment sequences . . . . . . . . . . . . . . . . . . . . . . . . c - 48 line label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . c - 48 data definition section . . . . . . . . . . . . . . . . . . . . . . . . c - 48 interrupt vectors definition . . . . . . . . . . . . . . . . . . . . . . c - 49 arithmetic instructions section . . . . . . . . . . . . . . . . . . . . c - 49 fuzzy instructions section . . . . . . . . . . . . . . . . . . . . . . c - 52 appendix d - fs3asm: assembler programming tool. d- 55 fs3asm main window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . d-55 fs3asm menus . . . . . . . . . . . . . . . . . . . . . . . . . . . d - 55 fs3asm toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . d - 56 fs3asm status bar . . . . . . . . . . . . . . . . . . . . . . . . . d - 56 managing and printing files . . . . . . . . . . . . . . . . . . . . . . . . . d - 57 editing commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . d - 57 machine code generation . . . . . . . . . . . . . . . . . . . . . . . . . . d - 58 device programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . d - 58 fuzzystudio ? 3.0 user manual
w3asm error list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . d - 59 appendix e full - fuzzy logic language e- 63 full language elements . . . . . . . . . . . . . . . . . . . . . . . . . . e - 63 token . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . e - 63 white space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . e - 64 comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . e - 64 punctuation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . e - 64 operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . e - 64 keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . e - 65 identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . e - 65 constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . e - 66 expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . e - 66 declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . e - 68 universes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . e - 68 modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . e - 69 shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . e - 70 variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . e - 72 rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . e - 74 full program example . . . . . . . . . . . . . . . . . . . . . . . . . . . e - 76 full language grammar . . . . . . . . . . . . . . . . . . . . . . . . . . e - 78 table of contents
fuzzystudio ? 3.0 user manual
before you begin before you start using fuzzystudio ? 3.0, it is important to understand the terms and notational conventions used in this documentation. general conventions the word "choose" is used to carry out a menu command or a command button in a dialog box. bold type in text indicates words or characters you type. italic type indicates important terms introduced in the section. upper case type in text indicates the names of commands and menus buttons of fuzzy- studio ? 3.0. a numbered list (1, 2, ...) indicates a procedure with two or more sequential steps. a bullet symbol indicates a procedure with only one step. mouse conventions fuzzystudio ? 3.0 requires two mouse buttons. the default one is the left button but you can use the right button to perform some functions. for information on changing the mouse button, see your operating system documentation. "point" means to position the mouse pointer until the tip of the pointer rests on what you want to point to on the screen. "click" means to press and immediately release the mouse button without moving the mouse. "double click" means to press the mouse button twice in rapid succession. keyboard conventions a plus sign (+) used between two key names indicates that you must press both keys at the same time. for example alt+f means that you press the alt key and hold it down while you press the f key; this is the shortcut to choose the file menu. a comma (,) between two keys names indicates that you must press those keys sequentially. for example, "press alt, f, o" means that you press the alt key and release it, press the f and release it, and then press the o and release it. this is the shortcut to choose the file open command. i getting started
i fuzzystudio ? 3.0
installation and configuration the most-commonly-asked installation questions will be answered in the following pages, providing you with everything you ever wanted to know about the installation of fuzzy- studio ? 3.0. system requirements before you install fuzzystudio ? 3.0, make sure you have all the hardware and software you need to run the program: intel type 80386 processor or higher. 8 mbytes ram memory. hard disk with at least 10 mbytes of free space. vga or higher graphics card. mouse. windows 3.1 or windows for workgroups 3.11 or windows 95. installing fuzzystudio ? 3.0 your first step is to use the setup program to install fuzzystudio ? 3.0 on your hard disk. be sure to start microsoft windows before to install fuzzystudio ? 3.0. 1 insert the installation disk 1 into the floppy disk drive a or b. 2 once windows is running, select the run option from the program manager file menu. 3 on the run options command line, type: a:\setup then choose ok or press enter 4 window mask will appear, containing a window with the " initializing setup " message. if you dont want to continue the installation choose the exit button, else choose continue. 5 a dialog box appears to set the directory where you want to install fuzzystudio ? 3.0. if a directory is not specified, the directory c:\fstudio3.0 will be automatically generated along with the device sub-directory 6 after copying the necessary files, the setup program automatically generates the group and the icon to start the program. when the setup procedure is completed, you will return back to the program manager. ii getting started
starting to use after you have installed fuzzystudio ? 3.0, you can use the application. to start fuzzystudio ? 3.0: 1 double-click the fuzzystudio 3.0 group icon in the program manager window, or open the group that contains the fuzzystudio 3.0. 2 double-click the fuzzystudio ? 3.0 icon to run the program. iii fuzzystudio ? 3.0
working area status bar title bar menu bar toolbar and buttons context- sensitive help buttons user interface this chapter provides basic skills on the use of fuzzystudio ? 3.0 and explains the items you see on the screen. youll learn how to choose commands and how to use fuzzystudio ? 3.0 online help. the first window that appears on the screen consists of the working area, the menu bar, the toolbar and the status bar. choosing commands a command is an instruction that tells fuzzystudio ? 3.0 to do something. there are different ways to choose a command: clicking a toolbar button with the mouse. choosing a command from a menu. using shortcut keys. iv getting started
clicking a toolbar button the toolbar consists of a number of icons, each representing a tool or option which you can use to create or modify your project. the toolbar is a user selectable item, it means that you can choose to hide or show it by using the related command of the view menu. choosing commands from menus fuzzystudio ? 3.0 commands are grouped in menus. some commands carry out an action immediately; others display a dialog box so that you can select options. to choose a command with either the mouse or the keyboard, you choose the menu and then the command name. to select a menu or choose a command by using the keyboard, press the key for the underlined letter in a menu or number in the command name. using the mouse if you use the mouse you have to follow these steps to choose a command: 1 to display a menu that contains the command you want, click the menu name in the menu bar. 2 click the command name. you can also point to the menu, drag to the command you want, and then release the mouse button. 3 if the command displays a dialog box, specify the information you need, (see "working in a dialog box" section). 4 when you finish with the dialog box, click the appropriate button to carry out the command. using the keyboard if you want to choose a command by using the keyboard: 1 to activate the menu bar, press alt or f10. the file menu appears selected, indicating that the menu bar is active. 2 to open a menu press the key of the underlined letter of the command name you want to select or use the left or right arrows keys to select the menu name and the down arrow key to open it. 3 if the command displays a dialog box, specify the appropriate information that you need. you can change field pressing the tab key. to close a menu, click anywhere outside the menu and the menu bar or press the esc key. to cancel a command, click the cancel button on the dialog box or press the esc key. a command name followed by the symbol > on a menu indicates that fuzzystudio ? 3.0 displays a sub-menu. using shortcut keys you can choose some commands by pressing the shortcut keys listed on the menu to the right of the command. for example, to save the current project, press ctrl+s. v fuzzystudio ? 3.0
using help fuzzystudio ? 3.0 is provided with a complete online reference tool. help is especially useful when you need information quickly or when your user manual is not available. help contains information about each command and each dialog box. when you are working with fuzzystudio ? 3.0, you can select help using the menu name on the menu bar or choosing the help button that appears on the dialog box. once you are in help, there are two ways you can move to other topics to find exactly the information you want, including: jump terms. jump terms are underlined with a solid line and are used to go to the topics in the help window. back button. the back button is used to step back through all the topics you have viewed since opening the help window. index button. the index button is used to display the list of help topics. context-sensitive help to find out about an item on the screen, click the context-sensitive help button on the toolbar. when the pointer changes to a question mark, choose the command or click the window item on which you want help. fuzzystudio ? 3.0 displays the help topic for the selected command or window item in the help window. vi getting started
vii fuzzystudio ? 3.0
chapter 1 fuzzystudio ? 3.0 about st52x301* st52x301 is an 8-bit fuzzy microcontroller with the following features: 8-bit arithmetic instruction set. fuzzy processing of systems with 4 inputs and 2 outputs. programmable peripherals for the user application driving. instruction set to control the program. programmable interrupts. for more information on st52x301 refer to st52x301 data sheet. introduction to fuzzystudio ? 3.0 fuzzystudio ? 3.0 is the development system that allows to program w.a.r.p. family of fuzzy processors. this high level tool helps you to: develop applications without assembler programming, verify a developed project and program the microcontroller through the programming board supplied with fuzzystudio ? 3.0. thanks to the fuzzy logic approach, fuzzystudio ? 3.0 makes programming fast and easy even for those development phases which follow a traditional kind of approach. since st52x301 is able to manage fuzzy functions, arithmetic calculations and logic instructions, fuzzystudio ? 3.0 allows to develop a project and the management of all the various resources. moreover, fuzzystudio ? 3.0 provides a visual programming approach to graphically define the programs logic flow by means of interconnected blo cks. this can be achieved by des igning the flow-chart which refers to your project by inserting the appropriate blo cks. each block you insert is already designed for a definite type of functionality which can be programmed either in a graphic way or with instructions at high level. the links among the blocks determine the logic flow of the program. a double-click on the single block opens a programming environment specifically dedicated to the type of block. fuzzystudio ? 3.0 is equipped with tools that allow to generate the machine code and to perform the debugging of the program. it is characterized by the following main functionalities: fuzzy programming. arithmetic programming. programs logic flow definition. peripheral configuration and activation. programming and activation of interrupts and routines associated. machine code generation. full chip emulation in graphic environment. chip eprom memory programming. possibility to program at low level using st52x301 assembler. * formerly w.a.r.p.3tc 1
fuzzystudio ? 3.0 main blocks are: start block starting point of the program. fuzzy block allows to performs the fuzzy functions. arithmetic block carries out airthmetic and logic operations. assembler block allows to insert arithmetic instructions in assembler. conditional block it is a conditional block that modifies the program flow in relation to user-defined conditions. interrupt mask block enables interrupts. interrupt priority block manages interrupt priority. peripherals block enables/disables and sets/resets the peripherals. send block sends the value to a peripheral coming from a register. receive block receives a value from a peripheral and stores it in a reg- ister. wait block stops the program until the first interrupt signal. restart block restarts the program. folder block allows to group blocks. links connects two different parts of the program. thanks to these blocks it is possbile to realize the desired project by simply drawing the program flow-chart and fixing each block functionalities. 2 fuzzystudio ? 3.0 user manual
system variables overview the systemvariables are managed through the chips internal registers. the fuzzy variables are those that are in input and output in the fuzzy computational unit. the variables support the following types: signed byte integer values included in the range [-128, 127]. byte integer values included in the range [ 0, 255]. in addition, when you define a fuzzy variable and its associated term set with the fuzzy variables edito r, it is possible to define the universe of discourse respectively in the ranges [-128, 127], [0, 255], [x, y] where x and y are values defined by the user. note there are 256 intervals available (8-bit). the arithmetic operations are performed on 8-bit variables with signed or unsigned values (signed byte [-128, 127] / byte [0, 255]) which refer to the internal registers of the machine. the variables can be global or local . the global variables can be defined by using the "global variable window", while the local variables can be defined within an arithmetic block and can be used only inside that block. the operations between different types of variables are managed in a transparent way by the compiler in order to see at an editor level the signed variable (signed byte type), although at a machine level only the type defined in the interval [0, 255] (byte type) exists. fuzzystudio ? 3.0 also supports another type of variable: predefined variables . these are particular variables having reserved predefined names. they address particular registers of the chip (typically the peripherals ones). the predefined variables must be considered as byte type and can be used to perform ordinary operations. for more information refer to chapter 6 for a list of these variables. 3 chapter 1 - fuzzystudio ? 3.0
programming approach the fuzzystudio ? 3.0 visual programming approach has been designed in order to help you in the development of a project. these are the main phases: peripherals configuration. the peripherals configuration is obtained by means of dialog boxes recalled from the project window. you can choose the peripherals working mode by clicking on the relative check box. the configurations which are not allowed are automatically disabled and in case you do not carry out a choice, default selections are available. for example, the initial state of the peripheral is considered disabled by default and to enable it you have to open the start/stop block of the peripheral at the beginning of the program. global variables definition. you can define the global variables name, type and association to the register through an apposite dialog window recalled from the project window. flow-chart creation. it is possible to design a program formed by a main program and subroutines directly defining the programs flow-chart. after opening the main program window, or a subrouti- nes folder window, to draw the programs flow chart, you must choose the type of block you want to insert by clicking on the relative button of the block editor toolbar, and then click on the client-area to insert as many blocks as you desire. you can perform the same operations with the other blocks and connect them according to the logic flow of the program. the link between two blocks is performed by means of click & drag operations. the blocks designed and interconnected can be selected to be modified, moved, deleted and so on. the links can be extended, shortened, disconnected, or deleted. open each block to be able to establish the operations you want to perform in that block. each block you insert in the flow-chart, corresponds to a peculiar editing environemnt which can be opened by double-clicking on it (except for the wait , start and restart blocks). for example: the editing tool of the arithmetic block is a text editor which allows to write the arithmetic operations that the processor has to perform. it is possible to insert the conditional statement if among the arithmetic instructions inside an arithmetic block of this type. refer to further paragraphs for the description of the possibile operations and for their grammar. all is written by the programmer can be checked by means of a check command which performs a syntactic and semantic check providing a list of the errors: with a double-click on this list you can visualise immediately the code line which has produced the error. a double-click on the fuzzy block allows to open the fuzzy system editor : the environment of the variables definition, of the membership functions and of the fuzzy rules. a project can have more than one fuzzy block defined in different points of the program and this allows to apply fuzzy adaptive control algorithms. the structure of the fuzzy controller and the membership functions are defined in a graphic way, while the rules are defined through the rule editor . the conditional block allows to modify the program flow according to defined conditions. 4 fuzzystudio ? 3.0 user manual
the assembler block allows to perform the programming of the device directly in the assembler of the chip. the folder block allows to insert a group of blocks in a separate folder window, so as to simplify the flow-charts routine. moreover, it is possible to manage the interrupts and peripherals start/stop by means of apposite blo cks. define the interrupts service routines. st52x301 can manage the interrupts which derive from the peripherals (timer, a/d, sci and triac driver) and from the external interrupt pin and perform the relative service routines. to be able to define the service routines, in terms of instructions or commands, you work as in the main program, but inside the client area related to each interrupt, recalled from the project window. compile the project to generate the debugging and the machine codes. the project compilation is carried out choosing compiler from the tools menu. then, a report window will open displaying the program errors, if any, or a message of successful compilation. after the compilation, some files are generated: a file containing the program listing in a wcl (w.a.r.p. control language) script file; an assembler code file; a file containing information used by the debugger ; and the code to be loaded in st52x301 memories in the standard format or in the one specified in the compilation options. in case of errors in the compilation, you have to correct and compile your program again. use the debugger to validate the program. after the compilation has been succesfully completed, the program can be tested by using the debugger. the debugger is a tool that allows to emulate the processor and its on-chip peripherals according to the defined program. the simulation step considered by the debugger is the single clock cycle, then the graphics that it is able to produce are in function of the time. you can choose the signals and/or the registers to visualize, as well as the time interval to simulate. moreover, it is possible to establish the breakpoints on the program and go step by step to better examine the behaviour of the device according to the program. you can also supply the input set to the chip to simulate external connections to the input pins. the registers values and the status of the signals chosen can be visualised in a table through tracing in temporal function. if the results of the simulation are not satisfying, appropriate changes have to be performed to the current program stored in memory. recalling the debugger it automat- ically starts the compilation. program st52x301 with the board supplied with fuzzystudio ? 3.0. the final step is to program st52x301 memory by means of the programming functions and the electronic board connected to the pc through the parallel port. testing of the application. now you can insert the programmed chip in your own application and test it. 5 chapter 1 - fuzzystudio ? 3.0
6 fuzzystudio ? 3.0 user manual
chapter 2 project management project files management fuzzystudio ? 3.0 stores all the project data into a single file with the extension .fs3. to select the commands for the project file management (for example, save or open), choose from the file menu . the content of the file menu is different according if there is an opened project or not. working with a new project if the project has not been opened yet, the commands available for the project file management are the new and the open commands: new the new command allows to start a new project. when you choose this command, fuzzystu- dio ? 3.0 displays the new project dialog box to define the project name, specify the target chip and describe the project (these information can be read later by choosing project info). the file name has to be compatible with a standard file name because to this will be added the extension .fs3 when saving the file. it is also possible to specify a path to locate a project file in a directory different from the default one. the browse button opens a dialog box that allows to quickly select the directory of destination of the project file. note this file is not generated when performing the command new, but after a save or save as command. in particular, the save as command allows to change the name of the file (and the name of the project) and its destination. it is easier to keep the default name i.e. untitled and then de- cide later where to store it and its name. to carry out this command in a quicker way it is possible to use the toolbar button or press ctrl+n . 7
working with an existing project open the open command allows to open a project previously saved. on the open command a dialog box will pop up, allowing you to select the project file to be loaded. acting on the provided scroll down lists, you must choose drive, directory and file name, using the ok button to finally execute command. into a networked environment, the network button can be used to connect to remote drives before selecting the data to be loaded. to carry out this command quickly it is possible to use the toolbar button or press ctrl+o. if there is an active project, the file menu is modified and the following commands are available: close project the close project command allows to quit the current fuzzystudio 3.0 project. the same effect is obtained when fuzzystudio 3 is closed from the main window or when closing the project window. then, you are asked to save the project if you have carried out some modifications not saved yet. saving and printing files save the save command will directly update the project file. a simple backup mechanism is im- plemented by copying the project file to a file with .bak extension before updating it. in this way, you can open the current project data and the previous version. to quickly perform this command use the relative toolbar button or press ctrl+s. if no modification has been carried out after the last saving, the save command is disabled. save as on the save as command a dialog box will pop up, allowing you to change current project name. the dialog box looks as the open project box, but the selected file will be used to store project data and not to retrieve from them. save command will prompt for confirmation before overwriting an existing file. project info allows to read the information relative to the project (target chip, name, working directory) and to read / write the project user description. print to print the project use the print command in file menu. to quickly perform this command press ctrl+p. printer setup and print preview commands are also available in file menu. 8 fuzzystudio ? 3.0 user manual
the fuzzystudio ? 3.0 main window this section provides an overview of the major elements of the fuzzystudio 3.0 main window, such as menus, toolbar and status bar. for additional information, see the index and online help. the fuzzystudio ? 3.0 window application menus file contains commands to create a new project, to open an existing one or to change the printer and printing options, a list of recently used files. view contains commands to show or hide main toolbar and status bar. help contains help commands. 9 chapter 2 - project management
the fuzzystudio ? 3.0 main windows toolbar for convenience, the most frequently used commands can be executed by choosing the corre- sponding buttons available on the toolbar. new open, save cut, copy, paste print, about, context-help the fuzzystudio ? 3.0 main windows status bar the status bar displayed at the bottom of the main window provides a brief description of the currently selected command. compiler, debugger, programmer 10 fuzzystudio ? 3.0 user manual
the fuzzystudio ? 3.0 project window a project definition environment can be accessed by means of the project window, that you see at a first glance when you start a new project or open an existing one. this window contains all the objects that make up the program: main program, sub-routines, interrupt routines, global variables and peripherals settings. in the project window you will find the icons that allow to access the various development and editing environments of the main parts of the project: a double-click on these icons allows to open the relative editing window. project window 11 chapter 2 - project management
working environments the project window icons allow to easily access the fuzzystudio ? 3.0 working environments. the following list briefly describes the function of the each project windows icon: main program opens the block editors main_program window . variables opens the global variables definition and editing environ- ment window. peripherals opens the peripherals programming environment. timer interrupt opens the window for the programming of the timer inter- rupts service routine. triac interrupt opens the window for the programming of the triac inter- rupts service routine. a/d interrupt opens the window for the programming of the a/d inter- rupts service routine. sci interrupt opens the window for the programming of the sci inter- rupts service routine. external interrupt opens the window for the programming of the external in- terrupts service routine. note: any window can be recalled by the window menu . 12 fuzzystudio ? 3.0 user manual
chapter 3 initial settings this chapter explains how to carry out the initial settings of your project. the first actions you have to perform to start a project will be the configuration of the devices peripherals, according to the selection of the target processor, and the definition of the programs global variables. these operations are performed through the dialog boxes which can be invoked from the peripherals and variables icons of the project window. global variables global variables are used in the arithmetic and conditional blocks. at low level, they refer to the processors registers and contain 8-bit values: byte type (from 0 to 255) signed byte type (from -128 to 127) how to insert a global variable the procedure to insert the global variables is the following: 1 click on the icon named variables in the project window to open the global variables dialog box. 2 click add button to open the dialog box add global variables. 3 insert the name of the variable. 4 select the type (byte or signed byte). 5 click ok. the dialog box closes and the variable appears in the defined variables list. 6 repeat for the other variables and then click the button close. 13
deleting a global variable you can delete a global variable in the following way: 1 in the global variables dialog-box select the variable to delete from the apposite list. 2 click the remove button. the variable is deleted from the list and will not be available anymore. 3 click close to exit and confirm the deletion. note in case you delete a global variable which is already being used in arithmetic or conditional blocks, the program remains unchanged and then in case of check or compilation, an error of the kind "not-defined variable" is generated. global variable properties clicking on the button properties, the global variable properties dialog box appears. this is similar to the dialog box for the insertion of a new global variable (add button), and allows to visualize and eventually modify the name and type of the global variable selected. when you select a global variable from the list you are shown its type at the bottom of the dialog- box. note the variables names have to be made up by alphanumeric characters, they cannot start with a number, they must not be equal to keywords (of the wcl description language and the assem- bler) and must have a maximum length of 32 characters. the names are case-sensitive. you can define 14 global variables at most, if you are using two fuzzy antecedent data memory banks. if you are using three or four fuzzy antecedent data memory banks, you can define respectively 13 or 12 global variables at most. a warning message informs you that you are defining too many variables without deleting them. 14 fuzzystudio ? 3.0 user manual
frequency setting from the peripherals icon in the project window, it is possible to specify the microcontrollers clock frequency by selecting the value from the drop-down list available on the peripherals window. note for st52x301 the available frequencies are 5 mhz, 10 mhz and 20 mhz. for more information refer to data-sheets for further information on st52x301 clock frequency. peripherals configuration you can configure st52x301 peripherals by double-clicking on the peripherals icon in the project window and in the appearing dialog-box, selecting the peripheral among the ones available in the following list: a/d converter parallel port timer sci (serial communication interface) triac driver the configuration of the peripherals can be performed by selecting the check-boxes and the radio-buttons in apposite dialog-boxes, in order to set the functionality of the chosen peripheral. to open the peripherals setting dialog-box and to perform the configuration it is necessary to select the peripheral from the list and click on the button config..., or you can directly open the setting dialog box with a double click on the peripheral name. for more information refer to the following paragrahs and st52x301 data sheet for information on a specific peripherals configuration. 15 chapter 3 - initial settings
after having completed the settings of the peripherals, click ok button to confirm the settings (if you press cancel you eliminate the changes performed). if no setting has been made or if the configuration of the peripheral selected has been partially performed, only the default values are activated. the button set default confirms the default configuration of the selected peripheral. the chosen configuration corresponds to a series of assembler instructions of the following type: ldcf reg_conf, value where: reg_conf is a value from 0 to 15 and refers to the address of the peripherals configuration registers. value is a value from 0 to 255 depending from the setting performed and from the configuration register. see appendix c for further information on assembler instructions. 16 fuzzystudio ? 3.0 user manual
timer configuration it is possible to configure the timer through the dialog-box shown below: you can note different sections of configuration each having a different meaning: frequency allows to visualize the selected working frequency of the processor clock. the possible choices are 5 mhz,10 mhz or 20 mhz and can be selected from the peripherals window. prescaler out period allows the setting of the prescaler timer, i.e. the value for which the clock frequency is divided before being passed to the counter. it is possible to specify the value (included in the range 0 and 65535) that is written in the configuration registers of the timer and visualize the corresponding value of the period in m s of the output signal of the prescaler in case the source clock is internal. viceversa, it is possible to specify the time value thus automatically obtaining the value loaded into the register. take care that if you enter a time value, it will be performed a conversion for approximation. then this value can slightly differ during the implementation in the device. output polarity allows to establish if the output signal logic level of the timer in the pin timerout has to be high or low. 17 chapter 3 - initial settings
timerout wave form allows to choose the output wave form of the signal on the timerout pin. the possible selections are square or pulse wave form, as it is shown in the figures present on the dialog-box. in the first case the timer output is equal to a square wave with a duty-cycle equal to 50 % and period equal to the period of the prescaler multiplied by the value of the count to perform. in the second case, the timer output is a pulse with length equal to a the output signal period of the prescaler. start/stop allows to choose if the timer count can be started/stopped by an external signal or by a program and if this occurs on edge or level of the external signal. counter loading from allows to choose the data source to load on the timer counter. the source of this data can be one of the two fuzzy outputs units, or a variable specified from the program. clock source allows to choose the origin of the input clock signal to the prescaler. the possible choices are the internal clock or an external clock coming from the timer_clock pin. in this last configuration the timer can work as an event counter. interrupt signal on allows to establish the event generating the timer interrupt signal. the possible choices are: - interrupt on the counter stop - interrupt on the rising edge of the signal timerout - interrupt on the falling edge of the signal timerout - interrupt on both edges of the signal timerout selecting counter stop the other two possibilities are automatically excluded and viceversa. the counter stop interrupt signal can occur both with an internal stop from the program and external stop from the timer reset pin. in this case, it is possible to use timer interrupt as external interrupt. 18 fuzzystudio ? 3.0 user manual
triac driver configuration the triac driver is a peripheral able to work in three different modes: burst mode,phase partializ- ation , pwm driver (refer to data sheet). the dialog-box used to configure the triac driver changes according to the working modality chosen. sections common to the three modes frequency allows to visualize the processors frequency: 5, 10 or 20 mhz. output polarity allows to establish the polarity of the triac output pulse in the trout pin . the possible choices are positive (logic level high) or negative (logic level low) mode allows to establish the working modality of the triac driver. the possible configurations are pwm, burst and phase partialization. modifying the selection, the lower part of the dialog-box is modified too in order to supply the configurations sections. interrupt source allows to establish the event generating the triac driver interrupt signal. you can choose among the following modes: pwm: the rising edge and/or the falling edge of the counter signals (see data sheets). burst mode:the rising edge and/or the falling edge of the counter signals (see data sheets). phase partialization: the rising edge and/or the falling edge zero crossing signals of the power line positive and negative wave, coming from the main1 and main2 pins. counter loading from allows to choose the data source to load on thetriac driver counter. the data source can be one of the fuzzy unit outputs , or a global variable stored in a register, loaded from the program. 19 chapter 3 - initial settings
pwm mode prescaler setting allows to set the triac driver prescaler. it is possible to specify the value (0 - 65535) that is written in the triac driver configuration registers and visualize the corresponding value in m s of the whole control period, that means 256 *tckp (where tckp is the period of the prescaler output). the value loaded in the counter is proportional to the ton period of the wave. see datasheet for further details. in the same way it is possible to directly set the value of the period in m s. clock source allows to choose the origin of the clock signal in input to the prescaler. the possible choices are: internal clock, external from the main 1 pin or the power line frequency through the main1 and main2 pins. main2 pin setting allows to configure the main2 pin as input/tristate to receive the frequency as external clock (see above) or in output supplying to the pin the prescaler output, that is the clock that drives the triac driver counter. then, if you set a control period of 256 m s, the main2 pin output will have a period of 1 m s. 20 fuzzystudio ? 3.0 user manual
burst mode square wave period allows to set the triac driver prescaler. in this case the the prescaler is driven by the power line frequency through main1 and main2 pins, then it is possible to specify the value (included in the range between 0 and 65535) written in the triac driver configuration registers and visualize the corresponding period value in seconds of the whole control period, that means 256*tckp where tckp is the period of the prescaler output. the value loaded in the counter is proportional to the ton period of the wave. see datasheet for further details. in the same way it is possible to directly set the value of the control period in seconds. trout impulse width allows to establish the output pulse width to drive the triac. it is possible to specify the value (included in the range between 0 and 16383) that is written in the configuration registers of the triac driver and visualise the corresponding value of the period in ms of the pulse. in the same way it is possibl eto directly set the value of pulse width in ms. power line frequency allows to specify the frequency of the mains voltage of the system controlled. the possible choices are 50 hz (european standards) or 60 hz (american standards). modifying such a data, the control period will change. masking time allows to set a minimum delay time between two firing pulses, masking during this period zero crossing signals due to noise. refer to st52x301 data sheet for further information. 21 chapter 3 - initial settings
phase partialization prescaler setting in phase partialization mode this parameter is not required then the check box is disabled. trout impulse width allows to establish the length of the output pulse to drive the triac. it is possible to specify the value that is written in the configuration registers of the triac driver and visualize the corresponding value of the period of the pulse in ms. the minumum value you can specify is 0, while the maximum value depends on the frequency of the clock master: 624 for 5 mhz 1249 for 10 mhz 2499 for 20 mhz (that corresponds to 250 m s) in the same way it is possible to directly set the value of a pulse width in m s. power line frequency allows to specify the the power line frequency. the possible choices are 50 mhz (european standards) or 60 hz (american standards). 22 fuzzystudio ? 3.0 user manual
a/d configuration it is possible to configure the a/d converter by means of the dialog-box shown below: the only information to set is the number of the channels to convert. parallel port configuration it is possible to configure the parallel port through the following dialog box: it is possible to utilize each pin of the parallel port as input or output. it is possible to specify the direction of a single parallel port pin by clicking on the pin button. read arrows mean output pin, blue arrows indicate input pin. 23 chapter 3 - initial settings
serial communication interface (sci) configuration. the sci is a hardware implementation of the standard rs-232 communication protocol. the programming of this peripheral allows to establish the characteristics of the data frame, trans- mission speed and the events that can generate interrupts. it is possible to configure the sci by means of the following dialog-box: baud rate determines the communication protocol speed. the followings are the acceptable values: 600, 1200, 2400, 4800, 9600, 38400 baud. moreover it is possible to specify that the speed is driven by an external clock. data bits determines the data bit length. the possible choices are 8 and 9 bits. it is not possible to choose 9 bits when choosing to use the parity check or 2 stop bits. parity allows to configure the peripheral with or without the parity check. it is possible to choose also the parity type you want to obtain that is to say odd or even. it is not possible to use at the same time the parity check with a number of data bits equal to 9 bits or 2 stop bits. stop bits determines the number of stop bits of the frame: 1 or 2 bits. this last option can be selected only in case the parity check is not used or in case of 8 data bits. 24 fuzzystudio ? 3.0 user manual
interrupt source determines the events generating an interrupt: tx register empty: the transmission buffer has been read by the shift register for the transmission. tx completed: data transmission is complete. rx register full: the data reception has been completed and the reception buffer is full. overrun error: an overrun error occurred. a new data item has been re- ceived before reading the one received previously. line break error: an error due to the interruption of communication has oc- curred. note more than an event can be chosen to generate an interrupt signal. however, this last is unique and to discriminate the event that has generated the interrupt it is possible to use the instruction scistatus with an arithmetic block (see relative paragraph). besides establishing if a specific event has generated the interrupt, allows to manage (in polling) other events that do not generate the in- terrupt: the "frame error", "noise error" and the 9th bit data contents if the peripheral has been set appropriately. for further details refer to related chapters. 25 chapter 3 - initial settings
26 fuzzystudio ? 3.0 user manual
chapter 4 block editor tool the block editor is the tool for the "visual" programming of the chip, that allows to specify the logic flow of the project and the access to the various definition environments of the program. each part of the program (main, interrupt routines and folders) is obtained by inserting logic blocks appositely interconnected that create the routines flow-chart. this operation is performed by the block editor that is activated in the windows related to the main program, interrupt routines and subroutines. the block editor tool this section provides an overview of the major elements of the block editor such as menus, toolbar and status bar. for additional information, refer to the index and on-line help. 27
block editor menus all block editor commands are grouped into a menu hierarchy accessible from the main window menu. menus items are context-sensitive: at each time only relevant commands for the selected objects or for the current project status will be enabled. available menus are: file contains commands to create, open, close,save and print a project and to visualize the projects information. edit provides standard editing commands. view contains commands for toolbar and status bar display or hide. tools contains commands to run debugger, compiler or programmer tools. insert allows to insert the blocks for the creation of a flow-chart. window contains commands related to window management. help contains help commands. 28 fuzzystudio ? 3.0 user manual
block editor toolbar the block editor includes a toolbar to help you perform the most frequently used commands quickly. to execute a task by means of a button, just click the related button on toolbar. the cursor allows to select and move blocks and links within the client area. the blocks you can select from the toolbar are: cursor selects and moves blocks and links within the client area. fuzzy block includes a fuzzy system. arithmetic block inserts arithmetic and logic instructions. assembler block inserts assembler instructions. conditional block determines program jumps according to the specified condi- tions. interrupts mask block enables or disables the processor interrupts. interrupts priority block specifies the interrupt priority level. peripheral block enables or disables the peripherals. wait block stops the processor waiting for an interrupt. restart/return block restarts the main program immediately after the start block or, in a folder returns to the main program. folder block includes a part of the logic flow. link block links the blocks among each other. block editor status bar the status bar displayed at the bottom of the block editor window contains some information about the task you are working on. cursor fuzzy , arithmetic, assembler and conditional blocks interrupt mask and priority, peripheral, send and receive blocks wait and restart/return blocks folder and link blocks 29 chapter 4 - block editor
program starting point when you open the main program, interrupt or folders window the first block in your flow-chart will be the start block. the start block is inserted automatically and is the beginning of the related program. at this point, it is possible to insert the logic blocks and to carry out the actions listed below: how to insert a block 1 from the project window toolbar, you can select the block you want to insert in your project. 2 position the mouse cursor anywhere on the project window. 3 click the left mouse button. the new block is inserted in your project. 4 drag the mouse to the desired position and then release it. how to link two blocks a link is characterized by an arrow indicating the sequence of the program execution. 1 from the project window toolbar, select the link button. in this way you commute to the link insertion modality. 2 position the mouse cursor on the first block to be linked. 3 click the left mouse button 4 drag the mouse on the second block and : if you still havent released the mouse button you can release it now. or click again you can add a link to any block, without necessarily linking the block to another one. to do this, click twice on the clinet area. the links allow to carry out cyclical programs without using restart command simply connecting the last block of the program to the point from which you want to make it proceed. labels a label is associated to each block, i.e a symbolic name. such label is representative of the program address in which the instructions contained in that block start. default names are inserted automatically at the moment of the insertion of the block, but they can be changed anytime by selecting the item rename from the pop up menu that appears when you click on the block with the right mouse button. the labels can be moved around the block by simply click & drag: they can be snapped on the cardinal points or they can be positioned anywhere around the block according to the activation of the item snap on or snap off you can choose from the pop up menu which appears by clicking on the label with the right mouse button. note labels must contain no more than 32 characters. 30 fuzzystudio ? 3.0 user manual
single and multiple selection of a block to select a block, it is necessary to click on it. take note that this operation cannot be performed in link insertion modality. in this case, you will have to make the cursor active before to select the block. in cursor modality, it is possible to simultaneously select more than one block by a click & drag operation. this will open a frame in which the blocks are selected. it is also possible to select more blocks one by one by clicking the mouse on the block and holding down the ctrl button until the end of the selection. the blocks and the links selected can be easily recognized because they change colour: the blocks become grey and the links become green. note you can activate cursor modality by clicking the right mouse button on window client area. when already in cursor modality, ths action will open a pop-up menu. basic commands a block, or a set of items selected at the same time, can be freely moved inside the window by using the mouse. moreover, any block can be: open opens the blocks editing environment. close closes the editing environment if previously opened. rename allows to change the label associated to the block. delete deletes the block and its content (this command can also be perfomed by pressing the delete button on the keyboard). you are asked for confirmation before deleting the block. this command list is a pop up menu obtained by clicking on the selected block with the right mouse button. in case of multiple selection, clicking with the right mouse button on one of the selected blocks (with the exception of the start block since it cannot be deleted), the pop up menu described above will appear. as you can notice, the item delete all selected is added to this list. this command allows to delete all the selected blocks and links. 31 chapter 4 - block editor
how to use links the links interface is similar to the blocks one. a link can be selected,deleted and moved (to move a link involves the moving of the linked blocks at the same time). a link has a pop up menu that can be otained by clicking with the right mouse button over a link to: delete delete the links disconnect from start block disconnect the link from the start block disconnect from end block disconnect the link from the destination block disconnect from both disconnect the link from both blocks moreover, a link can be the target of another link. other commands clicking on the block editor client-area when in cursor modality with the right mouse button a pop up menu appears containing the following items: grid enables or disables the grid line up alignes the block editor objects on the grid 32 fuzzystudio ? 3.0 user manual
chapter 5 fuzzy block the fuzzy block allows to carry out the fuzzy functions to be performed by the program of control implemented in st52x301. the possibility to define more than one fuzzy block allows to use, in the block diagram, the fuzzy system which is more appropriate to the general conditions of the system and then to realize an adaptive fuzzy control system. overview you can insert a fuzzy block in your project by choosing fuzzy block from the insert menu. (or by clicking on the fuzzy block toolbar button from the main program window). the mouse pointer changes its status and allows you to insert one fuzzy block anywhere on the main program window by clicking on the desired position. in this way, you are able to run the fuzzy system editor: the development environment, dedicated to the fuzzy functions, in which it is possible to define the variables and the set of rules associated to the fuzzy function. the fuzzy system editor interface employs a block structure with three different types of blocks: two for the definition of input and output variables and one for the editing of the rules. double-clicking on a variable block, a window pops up allowing you to define the variable properties: name, universe of discourse boundaries and the related mbfs. running the rule editor, it is possible to edit the rules which define a fuzzy function. but before doing this, it is necessary to define at least one input and one output variable. you can run the rule editor by double-clicking on the fuzzy rules block. when you insert a rule containing a new variable, a link between this variable and the relative block of rules automatically appears. 33
the fuzzy system editor window the first time you open a fuzzy block, the fuzzy system editor window shows an empty block named rules block. then it is possible to insert, anywhere on the window, up to 4 input variables and up to 2 output variables. this section provides an overview of the major elements of the fuzzy system editor window, such as menus, toolbar and status bar. for additional information, see the index and online help. fuzzy system editor toolbar the fuzzy system editor includes a toolbar to help you to quickly perform the most frequently used commands. to execute a task by means of a button, just click the related button on the toolbar. cursor input/output var import var fuzzy system editor status bar the status bar displayed at the bottom of the fuzzy system editor window contains information on the fuzzy block you are currently working on and displays a brief description of the selected command. the status bar provides the number of variables (input and output) and and rules in the current fuzzy block. 34 fuzzystudio ? 3.0 user manual
fuzzy system editor menus fuzzy system editor menus are: file provides new, open, save and print file utilities, a list of recently used files and the exit command. edit provides standard editing commands. view contains commands to show or hide block chart toolbar, main toolbar or status bar. tools contains commands to switch to fuzzystudio ? 3.0 tools: debug- ger, compiler and programmer. insert allows to insert input and output variables, link variables from other fuzzy blocks and import fuzzy systems in f.u.l.l. language. window contains commands related to window management allowing to arrange or activate windows. help contains help commands. about fuzzy variables the possibility to define the number of input variables and mbfs, within each block, depends on what has been already defined in the other fuzzy blo cks. this is due to the chip memory area used to store these information, which is limited and common to all the fuzzy blocks (refer to "variable constraints definition in a fuzzy block"). you can open a variable block by double-clicking on it or by activating the menu with the right mouse button. in this way the fuzzy variable editor window will be open. this allows you to enter into the development environment dedicated to the fuzzy variables, in which it is possible to define the universe of discourse and the mbfs. the first step to create a fuzzy project is to define its variables. for each variable you need to define: name universe of discourse (ud) membership function (mbf) default settings are available. during a session an existing variable window could be: open the variable window is open on the fuzzystudio ? 3.0 window. active the variable window is in foreground. all commands working on variable parameters modify it. an open or iconized variable becomes active by clicking on it. iconized the variable window is iconized on the fuzzystudio ? 3.0 window. close the variable window does not appear on the fuzzystudio ? 3.0 window. 35 chapter 5 - fuzzy block
variable constraints definition in a fuzzy block generally, in a fuzzy block it is possible to define up to 4 input and 2 output variables. this possibility is sometimes limited by the presence of other variables defined in other fuzzy blocks. all the input variables defined inside the fuzzy blocks share the same on-chip memory banks. this imposes some constraints in the number of the variables and mbfs to be added in each fuzzy block. the fuzzy system editor automatically prevents to exceed the chip memory limits, according to what has been previously defined in each fuzzy block. in this case, the fuzzy system editor disables the commands which allow to create new variables and mbfs. st52x301 contains 4 memory banks dedicated to the storage of 4 * 16 mbfs each one associated to one input to the fuzzy core. you can define: up to 4 variables, each one may contain up to 16 mbfs up to 3 variables, one of which may contain up to 32 mbfs up to 2 variables may contain up to 32 mbfs 1 variable containing up to 64 mbfs all chip memory is available when you define the first fuzzy block of your project. then, there will be some constraints for the definition of other fuzzy blocks since part of the memory is now busy. in this case, the maximum number of the variables which can be defined is: n = ? i = 1 4 min (1, 16 - m i ) where m i is the number of mbfs defined on each bank of memory from all the variables already present on the previous blocks. if you define n variables, it is possible to associate a maximum number of mbfs 16 - m i (i = 1, ...., n) where i is such that 16 - m i different from 0 n = ? i = 1 n (16 - m i ) where i is such that 16 - m i different from 0 the available mbfs can be used in a different way by defining a number s < n of new variables; in this case it is possible to associate a number greater than 16 m i mbfs. in this case for a single variable it is possible to define a maximum number of mbfs equal to: ? i = 1 n - s + 1 (16 - m i ) where i is such that 16 - m i different from 0 when s=1 all remaining mbfs can be used for the variable in question. 36 fuzzystudio ? 3.0 user manual
how to insert a fuzzy variable block inside the fuzzy block it is necessary to define the variables you need to use in your project. the definition might occur in three different ways: creating a new fuzzy variable, sharing or copying an existing variable. to create a new fuzzy variable : 1 from the insert menu, choose the kind of variable by selecting input varor output var. you can also click the input or output toolbar buttons available on the fuzzy system editor window. after this operation the mouse pointer changes its status. 2 click the mouse button anywhere on the window area in order to insert a new fuzzy variable block. to share an existing fuzzy variable: a variable can be shared among two or more fuzzy blo cks. for more informat ion refer to paragraph " shared and copied variables" in this chapter. to copy an existing fuzzy variable a variable can be copied from another fuzzy block using copy, cut and paste commands. for more information refer to paragraph " shared and copied variables" in this chapter. how to delete a fuzzy variable block you can delete unnecessary or unwanted variables in the following way: 1 from the fuzzy system editor window, select the variable block or the variable blocks you want to delete. in case of multiple selection, you can either use the mouse to create a frame or select each variable block by clicking without releasing the ctrl button. 2 press the delete button on the keyword. you can either choose delete from the edit menu or click the right mouse button to select the item delete or delete all selected from the pop up menu. 3 you are asked for confirmation before deleting. click yes or yes to all to complete the operation; click no to skip current variables deleting. quit to end operations. how to close a variable window an open variable window can be closed via the close active command of the windows menu. this command can only be performed in the current variable window. 37 chapter 5 - fuzzy block
fuzzy variable initialization and storage to assign a value, to be computed, to the fuzzy input variable by using fuzzystudio ? 3.0 it is necessary to associate it to a global variable, or an input register by using a predefined variable (refer to arithmetic block chapter for more information on predefined variables), containing the crisp value . click with the right mouse button on the input variable block you want to initialize. choose initialize from the appearing pop-up menu. a window containing a drop down list box will open. the list-box contains the available global and predefined variables. during the compilation, if the initialization of the variable is omitted, an error message will appear. the same operation can be carried out opening the fuzzy input variable with a double-clicking on the input variable block and choosing var properties from the view menu or from the toolbar. besides the editing fields of the variable name and universe of discourse, you will find a drop down list-box that works in the same way. 38 fuzzystudio ? 3.0 user manual
to store the fuzzy output in a global variable or send it to a peripheral, it is possible to act as for the initialization. click with the right mouse button on the output variable block where you want to store the value. choose "store in ..." from the appearing pop-up menu. a window containing a drop down list-box will be open. the list-box contains the available global or predefined variables (see arithmetic block chapter for explanation about predefined variables). select the one you are interested in. the same operations can be carried out opening the fuzzy output variable double-clicking on the block and choosing var properties from the view menu. besides the editing field of the variable name and universe of discourse, you will find the drop down list-box that works in the same way. after initialization and storage phase, in the fuzzy system editor window, labels linked to the fuzzy variables will appear. such labels will contain the global or predefined variables, or peripherals names, used to initialize and store the fuzzy variables. note the fuzzy outputs can be sent directly to the timer and triac counter automatically by setting the peripherals in the apposite peripherals configuration dialog-boxes (see related chapter). 39 chapter 5 - fuzzy block
the fuzzy variable editor window fuzzy variable editor is the tool devoted to manage with fuzzy variables and their mbfs. this section provides a description of the features of this tool. fuzzy variable editor menu file provides new, open, save, print file utilities, a list of recently used files, the project info and the exit command. mbf allows to choose commands for the creation, modification and deletion of mbfs and the copy on clipboard as bitamap command. view allows to choose commands to show or hide toolbar and status bar; double the size of the window and to open the windows of the variable properties and a mbf report. too ls contains commands to switch to fuzzystudio ? 3.0 tools: compiler, debugger and programmer. options allows to choose commands about the mbfs colours, show/hide of coordinates and hide of printing names. window contains commands related to window management. help contains help commands. 40 fuzzystudio ? 3.0 user manual
fuzzy variable editor toolbar the fuzzy variable editor includes a toolbar to help you to quickly perform the most frequently used commands . to execute a task by means of a button, just click the related button on the toolbar. fuzzy variable editor status bar the status bar displayed at the bottom of the fuzzy variable editor window contains some information about the number of rules you are currently working on and displays a brief description of the selected command. new, delete , auto fill mbfs properties zoom active mbf 41 chapter 5 - fuzzy block
how to open a fuzzy variable block to open a variable block: double-click on the fuzzy variable block. or click on it with the right mouse button and choose open from the pop up menu. the variable window appears allowing you to edit the properties and the mbfs associated. once opened, a variable window can be magnified ( ctrl+z ) via the zoom x 2 command of the view menu. this menu item and the related toolbar button acts as on/off switches, allowing users to magnify and de-magnify a window by repeatedly clicking on it. this command acts only for the active window. note the caption of the variable windos shows the name of the variable and the fuzzy block to which it belongs using the format fuzzyblockname\varname. 42 fuzzystudio ? 3.0 user manual
how to modify the fuzzy variable properties the variable properites are: name universe of discourse boundaries intialize / store in variables once the variable has been created, you can modify its properties so as to associate a more explicative name and to set the lower and upper bound of its universe of discourse according to the range of the physical value. to modify the fuzzy variable properties: 1 open the variable window. 2 from the view menu, choose var properties (or simply click on the apposite fuzzy variable editor toolbar button). 3 modify the name, the lower and upper bound of the universe of discourse by inserting the appropriate information on the dialog box. 4 choose ok. by default the variable name is set to "var x ", where x is a progressive integer value starting from 1, and the universe of discourse is set to [0, 255]. variable names may contain only alphabetical characters, numerical digits and the underscore symbol (_). the first character must be an alphabetical one or the underscore. (names must contain no more than 32 characters). due to its internal resolution, st52x301 takes into account only 256 points in the universe of discourse. since each point is represented with 9 digits and results from the division of the universe width by 256, then the minimum universe width must be 0-255*10 -6 . note you must be aware that, in general, all the existing mbfs, both for input and output variables, are automatically stretched or shrunk to the new universe dimension. only in case the output vari- able mbfs have been defined directly in fuzzy rule editor (see "creating and managing membership functions"), the universe resizing does not modify the mbf crisp value and may cut off the mbf and its related rules, if the mbf value is outside the new universe boundaries. refer to "fuzzy variable initialization and storing" paragraph for the initialization and storing proper- ties. 43 chapter 5 - fuzzy block
creating and managing membership functions as stated earlier, a fuzzy variable is characterized by the name, the universe of discourse and the term set, that is the set of all related mbfs. the mbf related commands are grouped into the edit > mbf menu. these commands allow you to manage the term set of the active variable, so the edit > mbf menu is available only if the window is active. to select one of the existing mbfs you may click on it, in the drawing area, or use the toolbar drop-down list containing all the names of the mbfs defined for the active variable. when a mbfs is selected, its vertices are contained in a little square. when the mouse pointer is into the drawing area, its position coordinates are shown both on top of the drawing area, as x and y values and on the status bar, as value and belief. due to mbf vertical resolution, the y values are given as a x/15, showing mouse pointer position when into variable window drawing area. you can enable/disable x and y values display for the active variable by using the xy on the screen command from the options menu. clicking the right mouse button into the drawing area of a variable window, a pop up menu with the main mbf commands appears. by default, membership shapes are filled up with random coloured patterns. user can enable/dis- able this feature via the hide colors command from the options menu. this menu item acts as an on/off global switch, whose state can be modified. the changes will apply to all the defined variables. after opening a variable window, you can create its mbfs by using: the command new mbf from edit menu (or pop up menu) the autofill utility the rule editor (only in case of output variables) 44 fuzzystudio ? 3.0 user manual
creating a new mbf to create a new mbf, the variable window to which it relates must be open. choose new mbf from edit > mbf menu (ins) or click the toolbar button or click the right mouse button. the mbf position into the variable universe of discourse is set as follows: in the centre of the universe of discourse, if mbf is the first to be defined. coinciding with the current cursor position in the drawing area, if using the right mouse button a menu pops up and if this position does not coincide with an existing mbf. shifted of the autoshift value with respect to the previously defined mbf. for more information see paragraph "autoshift and semibase" chapter for further information. creating a new mbf using the rule editor (only in case of output variables) the definition of mbfs for output variables is also possible by using the rule editor. in this way you can set the output crisp value of the mbf, by writing directly in a rule in editing. however, this mbf does not appear either in the drawing area of the relative output variable nor in the mbf report and cannot be managed through variable editor related commands. the universe of discourse resizing does not modify this mbf crisp value but may cut off the mbf itself and its related rules, if the mbf value is outside the new universe of discourse boundaries. for further information about the definition of a mbf by using the rule editor, see the "rule editor" paragraph. how to customize a mbf to customize a mbf you can change its name, position and shape. membership name is set by default to mbf x , were x is an integer value starting from 1 and it is incremented each time a new membership is created. to change name: 1 select the mbf clicking on it on the drawing area or selecting its name on the drop down list. 2 choose rename mbf from edit > mbf menu or from right mouse button pop up menu. 3 put the new name in the dialog box . 4 choose ok. to change position: 1 select the mbf clicking on it on the drawing area or selecting its name on the drop down list. 2 click into the membership area and drag it to the desired position by moving mouse cursor without releasing mouse button or using the key arrows without releasing the mouse button 3 release the left button. due to variable editor internal organization, a mbf cannot be positioned into the same position of another membership with equal properties (i.e. shape and dimensions). to change shape: 1 select the mbf vertex to be moved, clicking on it with the left mouse button. 2 move the vertex to the desired position dragging it or using the key arrows while retaining the left mouse button. release the left button. if the vertex is forced to go outside the variable domain, mouse cursor leaves x axis to run on the domain boundary, pointing to the intersection between the related shape side and this boundary. 45 chapter 5 - fuzzy block
using autofill mbf (only for input variables) to define a set of mbfs equally spaced, the autofill command can be used. a dialog box allows to specify the desired options. to draw the mbfs set: 1 select the variable, clicking on its window or opening it. 2 choose autofill from edit > mbf menu. 3 enter the desired number of fuzzy sets (num mbf). 4 press the desired filling mode button. the autofill mode defines at least two mbfs. therefore it is active only if less than maxrules-1 mbf have already been defined. max_rules being the maximum allowed number of rules. the max_rules depends on the number and allocation of membership functions already defined inside the same and the other fuzzy blocks. anyway, no more than 16 mbfs per time can be defined. the filling modes work as follows: draws n isosceles triangular mbfs. the semibase of new mbfs is calculated splitting the universe in n+1 equal intervals. since x-values must be integers, the remainder of the integer division of the domain width by n+1 is added to the centrail interval (or is shared out between the two central ones, if n=1 is even). 46 fuzzystudio ? 3.0 user manual
draws two external rectangle trapeziodal mbfs. all other mbfs are triangular. the semibase of new mbfs is calculated splitting the universe in n+1 equal intervals. since x-values must be integers, the remainder of the integer division of the domain width by n+1, if any, is added to the central interval (or is shared out between the two central ones, if n is even). draws two external rectangle triangular mbfs. all other memberships are triangular. the semibase of new mbfs is calculated by splitting the universe in n-1 equal intervals. since x-values must be integers, the remainder of the integer division of the domain width by n-1, if any, is added to the central interval (or is shared out between the two central ones, if n is even). 47 chapter 5 - fuzzy block
how to delete a mbf to delete a mbf: 1 select the mbf clicking on it on the drawing area or selecting its name on the drop down list 2 choose delete mbf from edit > mbf menu or from the right mouse button popup menu or press delete key. when deleting a membership used by existing fuzzy rules you are asked for confirmation. by erasing such a membership these rules are deleted too. the number of fuzzy rules involved into the membership deletion is provided with the confirmation request. note deleting a mbf belonging to a shared variable will cause the elimination of the mbf in each fuzzy system when the variable is used (see shared and copied variables paragraph). autoshift & semibase when a new mbf is generated by means of the mbf new command, the base width and the distance of each mbf is set by default to the semibase and autoshift values. to change these values: 1 choose set autoshift & semibase from edit menu. 2 change values. 3 press ok. the autoshift and semibase options are related to the creation of a new mbf. when a new mbf is generated by means of mbf new command, its centroid will be placed: on the cursor position, if a mbf didnt already defined in the same position. at a distance equal to the autoshift value from the closest mbf, otherwise. triangular mbfs have by default base half-width equal to the semibase value. different bases can be obtained changing semibase option or customizing each mbf. you can modify default values for autoshift and semibase values via the set autoshift & semibase command from the edit menu. on this command a dialog box pops up, showing current default values and allowing users to modify them. these values are set using a st52x301 internal measurement unit, and are independent from the chosen dimension of the variable domain. due to hardware constraints of the st52x301 processor family, the autoshift and semibase values must belong to the [1,255] integer interval. 48 fuzzystudio ? 3.0 user manual
mbf report variable editor gives a textual description of variable term set. to visualize a variable report: 1 select the variable clicking on its windows or opening it. 2 choose mbf report from view menu report window content is organized by rows, each row containing: mbf name and its vertices coordinates, in case of input variable; mbf name and its crisp value, in case of output variable; report window rows are scrollable and mouse selectable. you can run membership related commands either from a variable window or from the related report one. membership pop-up menu can be activated pressing the right mouse command while on the report window. the active report window can be closed by using again the mbf report command from the view menu (this command acts as an on/off local switch, related to the active variable window only) or via the close command from system menu (accessible using the button on the window left upper corner). closing a report window not affects the related variable window, while closing a variable window closes the related report too. when a report window is open, its fonts may be changed, performing the following operations: click the right mouse button and select choose report font from view menu. or when the report window is in foreground select the "choose report font" command from the view menu. 49 chapter 5 - fuzzy block
shared and copied variables besides the creation of a new variable, within a fuzzy block, it is possible to share or copy existing variables within other fuzzy blo cks. shared variables a shared variable is a variable used in several different fuzzy blocks, with the same characteristics, and will therefore use the same memory locations to store the membership functions, this means that the variable is the same. then, each change performed on one of the shared variables will have effect on all of them. to insert a shared variable: select share var from the insert menu in the fuzzy system editor window or click the apposite toolbar button of this window. a selection window is open, where on one side you will find the list of fuzzy systems defined and on the other one there will be the variables defined inside the selected block. choose the fuzzy system to which belongs the variable to share and select it. note the selection of a variable belonging to the current fuzzy block will not produce any effect. the window disappears and the mouse pointer is enabled to insert the variable on the fuzzy system. in both fuzzy systems that share the variable, the icon that represents it change its shape indicating that such a variable is shared by several blo cks. the name of the shared variable is the same in all the blocks in which it is used: a rename of one of them will determine the change in the other fuzzy systems in which it is shared. note it is not possible to insert a shared variable in a fuzzy system that has the same name of an already existing fuzzy variable. in this case, rename this last variable and try again to insert the shared variable. moreover, consider that it might not be possible to insert a shared variable when new variables, using the same address space of the variable to share, have been defined. 50 fuzzystudio ? 3.0 user manual
copied variables the copied variables are variables already defined in a fuzzy system. this means that their characteristics can be copied in other fuzzy systems. the substantial difference between shared and copied variables is that a copied variable is an other variable different from the original one. a copied variable can be inserted provided that a memory space is available (refer to the chapter "variable constraints definition in a fuzzy block). the editing environment of a copied variable is distinct from the variable of origin. if a variable having the same name already exists in the fuzzy system, the name of the variable to be copied is modified adding a progressive number to its name. finally, each change performed on the original variable or on the copied variable is not reflected since, as stated earlier, these are distinct variables. this can be useful whenever you want to define a variable with similar characteristics but not coincident with another: first copy the variable and then make the necessary changes. it is possible to copy, cut and paste a fuzzy variables block with its content as a normal block: select the variable(s) to copy/cut selecting the command in the edit menu or clicking the related toolbar button. open the destination fuzzy block. select paste command from the edit menu or click the related toolbar button. the window disappear and the pointer is enabled to insert the variable in the fuzzy system. how to export data to clipboard the variable editor allows to export data to the system clipboard. both membership drawings and mbf reports can be exported. perform the following commands: 1 select the variable window to export. 2 choose copy on clipboard from edit menu. the copy on clipboard command, invoked by the ctrl+c short key too, acts on the active variable and is available only if at least one variable or a report window are opened or iconized. this is a sensitive command. its label is copy on clipboard as "bitmap", when you are working on bitmap images, or copy on clipboard as "text", when you are working on a text editor. you can then manage these data as any other clipboard content: as the clipboard is a global windows object, shared among all the currently running applications, users can paste these data into documents of other applications such as windows write or microsoft word for windows (e.g., to produce a detailed project documentation), or can put these data in the windows clipboard application to store them for later use. at the same time you must be aware that any copy operation, from any running application, replace the clipboard content with new data. 51 chapter 5 - fuzzy block
fu.l.l. importer fu.l.l. (fuzzy logic language) importer is a tool that allows to import, in a fuzzy block, fuzzy systems generated by the fuzzy software tools produced by stmicroelectronics : a.f.m.1 & 2 (adaptive fuzzy modeller) for the automatic generation of the fuzzy models by starting from the input/output patterns and fuzzystudio ? 2.0, the development system for the programming of w.a.r.p. 2.0 processor. fu.l.l. (fuzzy logic language) is a description language of the fuzzy systems allowing to exchange data between the various fuzzy logic software tools. to import a fuzzy system in the project: 1 insert a fuzzy block, by using the blocks editor. 2 open the block keeping the fuzzy system window in foreground. 3 select the item import fu.l.l. from insert menu. 4 an open file dialog box is open. 5 search and select the file .ful you are interested in. 6 press ok button or double click on the file name. a fuzzy system in fu.l.l., besides being generated automatically by above tools, can also be generated by using a normal text editor. for further information on the f.u.l.l. syntax and semantic refer to appendix e. - f.u.l.l. - fuzzy logic language. 52 fuzzystudio ? 3.0 user manual
rule editor rule editor is the tool devoted to manage with fuzzy rules. to run rule editor, double-click on the rules block from the fuzzy system editor window. the rule editor environment is opened showing, if already defined, the list of the rules. in order to define fuzzy rules, using rule editor, it is necessary to define at least one input and one output variable with associated membership functions. rule editor cannot be activated until these minimal definitions have not been done. 53 chapter 5 - fuzzy block
defining fuzzy rules with rule editor the rules related commands are grouped into the rules menu. there are two ways to write rules: by using guided editing or manual editing. in guided editing a paddle containing keywords, if-then operators, variables and membership functions is used for quick definition. this editing mode allows you to select automatically only syntactically correct objects. in manual editing, rules must be defined manually using the keyboard as a normal text editor. before being inserted on the list, the rule is syntactically checked to guarantee its correctness: if an error occurs, its description is given in the output window. manual editing allows to delete or to modify already defined rule. after being modified, a rule can replace its previous version or be added to the list. multiple deleting is possible if a multiple selection is done. it is possible to go to a precise rule by using edit -> go to command o pressing f5. a dialog is shown allowing the user to choose the rule number. to copy one or more rules onto the clipboard, select them from the rule list using the mouse, then choose copy from edit menu or use ctrl + c. you can also perform the cut commands choosing it from the edit menu or using ctrl + x. you can also print all rules information about the current project by using the print command or ctrl+p . the rule editor window this section provides an overview of the major elements of the rule editor window, such as menus, toolbar and status bar. for additional information, see the index and online help. rule editor menus all rule editor commands are grouped into a menu hierarchy accessible from the main window menu. menus and items are context-sensitive: at each time only relevant commands for the selected object or for the current project status will be enabled. available menus are: file provides save and print utilities, a list of recently used files and the exit command. edit provides standard editing and go to commands. view contains commands for control bars display/hide, font selection and move through the error list. tools contains commands for switching to fuzzystudio ? 3.0 tools: com- piler, debugger and programmer. rules contains rule related commands, for manual and guided editing. window contains commands related to window management. help contains commands for help on topics and information on fuzzystu- dio ? 3.0. 54 fuzzystudio ? 3.0 user manual
rule editor toolbar for convenience, the most frequently used commands of rule editor can be executed by choosing the corresponding buttons on the toolbar. toolbar buttons are context-sensitive: only the commands in relation with current project status are enabled. toolbar is a user selectable item: you can choose to hide or show it by using the related commands of view menu. rule editor status bar a status bar is available at the bottom of the application main window. this bar displays a brief description of the selected command, the number of rules defined by the user, the number of the selected rule in the list, the status of the capslock and numlock keys. to get a quick help on a command item (i.e., a menu command or a toolbar button), just position the mouse pointer on the toolbar without clicking, a brief command description will be shown on the leftmost field of the status bar, in addition to the type shown near the button. 55 chapter 5 - fuzzy block
how to write a rule using guided editor guided editor uses the editing paddle that can be activated choosing rules guided or pressing crtl+g or the toolbar button. select keywords, operators and others by clicking on paddle buttons. note that during guided editing: keywords if and is are automatically included when necessary, that is, respectively, at the start of the rule and after selecting a variable name. the rule is shown in the upper side of the edit box. it is not possible to write in this edit-box during guided editing. it is possible to correct manually the rule switching to manual editing. if a mistake occurs it is possible to undo the previous operations, or abort the rule editing. notice that undo could not be possible after modification of variables or membership functions names using the variable editor. to include comments inside the rule, click the comment button in the paddle to edit the comment text. comments can be included anywhere in the rule. 56 fuzzystudio ? 3.0 user manual
editing the antecedent notice that in this list-box, variables or membership functions are shown according to the syntactical correctness of the rule; in addition, the membership function list is always related with the selected variable. 1 click new button in the paddle: the if keyword is shown on the edit-box. 2 choose one of the input variables listed on the left side of the paddle, double clicking on it. the input variable name will be shown in the edit-box followed by the keyword is, whereas in the list-box the related mbf list appears. note that only variables having at least one membership function are listed. 3 add not modifier, if necessary, clicking on the apposite button. 4 select mbf, double-clicking on its name on the list-box. 5 click and or or button if rule has more antecedent terms and go back to point 2, for further insertion of input variables, otherwise go to the following section editing the consequent. note: and operator has higher priority than or operator. editing the consequent 1 click then on the paddle. 2 select output variable double clicking on the variable name in the list-box. 3 select the variable crisp value, double clicking over the associated label. you can also click over the mbf label or write the crisp value and push enter button or click over accept button. 4 click and if the rule has more consequents and repeat the selection of an output variable and the association of its crisp value. 5 click done: the rule will be added in the rule list and the status bar is updated. note: if the crisp value is written directly in the dialog-box, this operation does not determine its graphical representation in the mbf drawing window because the value is directly translated by com- piler machine code, without the need of a point-by-point graphical definition of the related membership function. 57 chapter 5 - fuzzy block
using manual editor manual editing mode can be activated choosing manual > activate from rules menu or pressing ctrl+m or the toolbar button. an edit box will appear in the upper side of the window. manual editor allows you to edit more than one rule at the same time. these rules might be syntactically checked and/or inserted in the list. by means of the manual editor it is possible to manually edit a new rule or to modify already existing ones. how to write a rule to use manual editor for the definition of fuzzy rules follow these steps: 1 write the rule in the edit-box above the rule. 2 you can now check the rule syntactic correctness, pressing manual check from rules menu or using f3 or clicking the toolbar button. 3 write, if necessary, comments including the text between these characters: /**/ the string between two sequences of characters is excluded by syntactical check .// the string after two sequences of characters is excluded by syntactical check you can write more than one rule at the same time either by writing them on one row and separating each rule by inserting a semicolon or by using one row for each rule. you can also write one or more rules by modifying the existing ones. in this way the rule editing is performed quickly because the selected rule(s) is copied in the edit-box and it wont be necessary to write the entire rule(s) again: 1 if you want to change only one rule: select the one you want to use as a model by double-clicking on it. if you need to modify more than one rule: copy the selected rules in the clipboard and then past them in the manual editor windows. 2 modify the parts of the rule(s) you need to change. 3 you can now check the syntactic correctness, pressing manual check from rules menu or using f3 or clicking on the toolbar button. 58 fuzzystudio ? 3.0 user manual
list updating when the rule(s) definition has been completed, the rule(s) can be inserted in the rule list by means of the following manual commands in the rules manual menu: how to add rule(s) choose rules manual add or click the toolbar button. the current rule is syntactically checked and inserted at the end of the rule list. how to insert rule(s) rule inserting is possible in manual editing mode. it consists in the insertion of the edited rule before the selected ones: 1 select the rule by clicking on it. 2 choose insert from rules manual or use ins or the toolbar button. the current rule is syntactically checked and inserted just before the selected rule(s). how to replace rule(s) rule replacing is possible only in manual editing. 1 select the rules that must be replaced, clicking on it in the rule list. 2 choose rules manual replace or press ctrl+r or the toolbar button. how to delete rules 1 select one or more rules. 2 choose delete from edit menu or use del or click the toolbar button. 3 press yes, on the rule editor confirmation box. to select multiple sequential rules in the list, click the first one and then drag the cursor to the liast item, or click the first rule you want to select, press and hold down shift, and then the last rule ( or via keyboard by pressing shift + arrow keys). to select multiple nonsequential rules in the list, press and hold down ctrl, and click each item you want to select. to cancel the selection, release shift, and then click any item. how to print the rules list 1 check the correctness of the printing options for the printer, choosing file print setup 2 choose print or press ctrl+p or the toolbar button before printing, the user can view the document choosing print preview in the file menu. 59 chapter 5 - fuzzy block
rule editor view options the view menu allows you to customize the rule editor window. you can display or hide the toolbar and the status bar choosing the related command from the view menu. you can set the font used to show the rules by means of the font view command. performing this task a standard ms-windows dialog box will pop up and you can change font type and size. rule editor constraints rule editor allows to write rules having a maximum of 8 antecedents and 2 consequents. however, rules with more than 4 antecedents or more than 1 consequent are splitted, during compilation, into equivalent simpler rules having up to 4 antecedents and one consequent. st52x301 executes partial computations and then evaluates the total antecedent part of the rule. a maximum of 256 rules can be defined. rule grammar ::= if then . ::= and | . ::= is |