



























                          FuzzyOne


             Development System For Fuzzy Logic

                             By

                       Xcentrics Inc










                                 Notice

                        Copyright (c) 1995, 1997
                         Xcentrics Incorporated
                           All rights reserved

  This manual and the software it describes are protected under
  United States copyright laws.  Without written permission from
  Xcentrics, it cannot be reproduced, in whole or part, in any form,
  except as expressly provided below.

  FuzzyOne is a trademark of Xcentrics Inc.




             BY USING THE PROGRAM YOU AGREE TO THE FOLLOWING


    The development system (programs/documentation) will be transferred
     only in its compressed format (Fuzzy.Exe).
    This file will be transferred without modification (to say, you
     will not decompile or change the programs/files in any manner).
    The development system is provided on an as is basis without any
     warranty of any kind.  You accept all risks/responsibility
     associate with its use.
    The development system is provided for your evaluation and you
     agree to buy it if you plan on using it after that evaluation.
     Instead of designing in locks that make it difficult to use, I
     believe most of you will honor the shareware concept.




                           Person To Person


  FuzzyOne was created to provide an affordable way for you to use fuzzy
  logic.  The program's price/performance exceeds any similar product
  that I m aware of.  If you use it without paying for it, you are not
  ripping off some non-existent entity.  You are forcing someone, no
  different from yourself, to work for free.







                                    ii





                       Table of Contents

  Chapter 1 - Introduction                                       1
       How To Contact Me                                                 1
       Program Support                                                   1
       Getting Help                                                      2
  Chapter 2 - Overview                                            5
       Minimum Required                                                  5
       Where To Begin                                                    5
            Setting Up To Run                                            5
       Program Tutorial                                                  5

  Chapter 3 - Graphing                                           15
       (F1) Change Working Graph                                        15
       (F2) Remove Graph                                                18
       (F3) Do Shapes                                                   18
            [A] Add Shape                                                 18
            [R] Redo Shape                                                18
            [D] Delete Shape                                              18
            [N] Change Name                                               19
       (F4) Redo Graph Values                                          19
            [F1] Name                                                     19
            [F2] X Axis Value                                             19
            [F3] Resolution X/Y                                           19
            [F4] Graph Type                                               19
            [F5] Address                                                  19
       (F5) Next Graph                                                  20
       (F6) Highlight Shapes                                            20
       Extending Graphs                                                 20
                                        
  Chapter 4 - Rules                                               23
       (F1) Redo Rule                                                   23
            [F1] Next Rule                                                23
            [F2] Modify                                                   23
            [F3] Delete                                                   23
            [F4] Advance Five                                             23
       (F2) Display All Rules                                           24
       Requirements                                                     24
       Operator Definition                                              24
       
  Chapter 5 - Simulation                                         27
       (F1) Enter Values                                                27
       (F2) Change Output Displd                                        28
       (F3) Learn                                                       28
            [F1] Activate/Deactivate                                      28
            [F2] Change Learn Mode                                        28
            [F3] Change Simulation Mode                                   28
            [F4] Print Data                                               29
       (F4) Auto Simulation                                             29
            [F1] Overlay Graph                                            29
            [F2] Show Input/Output Values                                 29
                                          
                                       iii





            [F3] Regraph                                                  29
       (F5) To Rule                                                     30
       (F6) To Graphing                                                 30
       Learn File Contents                                              32
       Notes On Learn File                                              36

  Chapter 6 - File/Printing                                     39
       (F1) Save Session                                                39
       (F2) Retrieve Session                                            39
       (F3) Print File                                                  39
       (F4) Exit To DOS                                                 39
                                       
  Chapter 7 - Application Generation (Assembly)                41
       Before Generating Assembly Code                                  43
       About Programs                                                   44
       About TSRs                                                       44
       Types of Applications                                            45
            [1] Timer used, your code not included                        45
            [2] Timer used, your code included                            47
            [3] Interrupt system used, no code included                   49
            [4] Interrupt system used, your code included                 51
       Interface Explanation                                            51
       Interface Examples TSRs                                          52
            Assembly                                                      54
            C                                                             56
            Quick Basic                                                   57
       Interface Examples Programs                                      59
            Assembly                                                      59
            C                                                             62
            Quick Basic                                                   67

  Chapter 8 - Application Generation (C Code)               71
       Files Produced                                                   71
       Using The C Application                                          71
       Before Generating C Code                                         72

  Chapter 9 - Starting New                                      75

  Chapter 10 - Standard Menus                                   75
       (F7) Directory Listing                                           75
       (F8) Display Graph/Shape Names                                   75
       (F9) Save File                                                   75
       (F10) Help                                                       75
       
  Chapter 10 - Error Messages                                  77

  Appendix A - Reference Literature                          A-1
       Fuzzy Logic                                                     A-1
       TSR Generation                                                  A-2

  Appendix B - Key List                                         B-1

  Index                                                            I-1

                                   iv



























































                                   v





                      Chapter 1 - Introduction


  FuzzyOne provides an excellent way to quickly gain a complete
  understanding of fuzzy logic.  You can specify inputs and outputs,
  add and modify shapes, formulate rules, then test the system through
  simulation.  If the output is not what is expected, only a few
  keystrokes are required to change the input conditions.  The new data
  can immediately be resimulated.  To aid in the design of the system,
  learn mode can be activated.  The program sends data it is working
  with to a file for your review.  Once the design is proven, an
  application can be created containing everything needed to implement
  your system.




                            How To Contact Me

  One of the best ways to get in touch with me is via e-mail.  Use
  WebCrawler or one of the other search engines to find my home page
  (search for Bud Moss).  If that won t work for you here s the company
  information.

                             Xcentrics Inc.
                               PO Box 1268
                       McMinnville, OR 97128-1268
                             (503) 434-5729



                             Program Support


  The impetus of FuzzyOne was to give you everything you need to learn
  and use fuzzy logic systems. The program was designed specifically
  for the novice while ensuring the advanced user is not limited. 
  Choices had to be made on how to provide this level of functionality
  and still provide excellent support.  This is what I came up with:

  -  The applications are too varied for me to answer questions on fuzzy
     logic.  At times it may be hard to distinguish the difference
     between a program question and fuzzy logic question.  As a rule, it
     is a fuzzy logic question if the output during simulation is not
     what you expect.  It is a program question if you are having
     trouble entering data.
  -  The same is true for questions that relate to the code that you
     include in a TSR.  It is a program question if you do not
     understand the interface between our code and yours; otherwise, it
     is an application question.



                    
                                                        Introduction     1     





               See Appendix A for a list of articles and 
                       books covering the topics.



                                  NOTE
     Before asking me, please read the manual and supporting
     documentation.  I respond to all questions, but time is
     limited.  To receive the highest priority, ensure the answer
     is not readily available.




                              Getting Help


There are three ways to get help: mail, phone, and Internet. 
  With your question, include the following:

   -   Product serial (if applicable) and version number.
   -   The brand and model of your system (for example, 25 MHz 386
       clone).
   -   DOS version you are using.
   -   If you are contacting me concerning a problem, include the steps
       needed to reproduce the problem.
   -   I perfer to do everything via the internet.  If I can send you a
       message, please leave me you e-mail address.  If that is not
       possible, leave a phone number where you can be reached.
       Include the best time to call, but leave both a day and night
       number so I can be sure to get back to you.

                                 (MAIL)
  Mail support is available for as long as you need it.  To ensure I
  understand your question, include as much information as possible and
  a return address.  Write to me at the address above.

                                (NETWORK)

  You can find me on the Internet.  Use WebCrawler or a similar search
  program to locate my home page (search on Bud Moss).  Leave me
  message and include as much information as possible so that I fully
  understand your question.


                           NOTE TO PHONE USERS

     To keep the cost of the program reasonable, I didn t add in extra
     to cover phone calls.  If at all possible, please use either e-mail
     or slow mail.




     2     Introduction                   





                                 (PHONE)

  Phone support is provided but it is an expensive method for both of
  us.  This is not available for those that have not purchased the
  program.  If e-mail is not an option for you, leave me a message if
  I m not in and I ll get back to you as soon as I can.  Include the
  best time to call, but leave both a day and night number so I can be
  sure to get back to you.  If you need a response at a specific time,
  let me know and I ll call, but the charges may be reversed.


                      (NOTE TO INTERNATIONAL USERS)

  If you call for help and I m not in, you are welcome to leave me a
  message.  I ll return your call, but the charges will be reversed.






































                    
                                                        Introduction     3     





                                  NOTES

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________













     4     Introduction                   





                         Chapter 2 - Overview




                       Minimum Required

  Minimum requirements are an XT, a 5.25" (1.2M) or 3.5" floppy (a hard
  drive is recommended), 512k bytes of RAM, a CGA/EGA/VGA compatible
  video card, and DOS 3.0. 




                             Where To Begin

  The floppy contains all the files needed to use the program.

     FUZZYONE.EXE  -  The main program.
     FUZZ.ONE      -  Used by FuzzyOne.
     README.DOC    -  Additional information not included in the manual.


                            Setting Up To Run


  Copy the files needed to your hard drive or another floppy (minimum
  required: FuzzyOne and Fuzz.One). 



                            Program Tutorial


  To demonstrate the program, we will use the simplest control system
  possible, one input and one output.  Here is a quick overview of the
  hardware.  An A/D and a sensor are used to convert the temperature of
  the room to digital; that value is processed by the fuzzy system; the
  output from the fuzzy system is sent to a DAC; the DAC and associated
  circuitry are used to vary the frequency of a buzzer.

  To enter the program, type FuzzyOne at the DOS prompt.  The main
  screen is displayed.  Open the menu by pressing F10.  Throughout the
  program the menus are similar.  F1 through ESC can be executed
  directly (the menu can be closed), those below will activate only
  with it open.  Close the menu by pressing the space-bar.  Press F4.
  You are taken to the file menu.  Press F8.  The program beeps to show
  the key is not valid.  Press F10 to open the menu followed by F8.
  The command executes.  To enter help, press ESC to return to the file
  menu then F10.  The help sub-menu is displayed.  You should not
  encounter any errors during the tutorial, but if you do, press F10


                     
                                                           Overview     5     





  followed by 'E' (error message help) with any menu open.  Press ESC
  followed by the space-bar to return to the file section.

  During the following tutorial the menu is not opened, instead the
  commands are executed directly.  As each section of the program is
  entered, it is suggested that F10 be pressed to become familiar with
  the different selections.  Throughout the program ESC can be used to
  return to the previous prompt.

  Let's load the demo file.

        Press F2.  When asked for the file name, type "Art.Fuz" (file
       names are not case sensitive).  Press return.  The file is
       loaded and its name is displayed at the bottom of the screen.
        To view the data in the file, select Print All (F3).  You are
       asked if you want to send it to the screen.  Press 'N' to send
       it to the printer.  At the next prompt, press '1' or '2' to
       select which printer port to use (1 for default).
        When you have returned to the file menu, press ESC to return to
       the main menu.

  Before continuing, let's look at the data just printed.  The printout
  shows data for each graph specified including its name, shapes,
  address, and graph values.  At the end of the printout are the rules.
  Each is explained below.

        Press F1 to go to the graphing menu.

  The input graph is displayed.  Referring to the printout, find the
  data for TempOfRoom (first set).  The values for the end and
  beginning of the graph (Graph value start and Graph value end) are
  displayed on the X axis.  Resolution X and Y are the number of equal
  divisions along each axis.  Address, access type, and hex values are
  used by the application generator (Chapter 7).

  Just below, the data for each shape in the graph is given.

     Shape Name    - The name of the shape.
     LB Val        - The shape's left bottom value.
     LT Val        - Same for the left top.
     RT & RB Val - Same as above for the right side.

  Returning to the screen, each shape is drawn using different colors
  (for EGA/VGA) and line types.  Shape names and associated line types
  are displayed at the bottom of the screen.  Shapes are listed in the
  printout in the same order as they appear on the graph.  The first
  name corresponds to the shape with the smallest value at its left
  bottom, the second, the next largest, and so on.  To highlight the
  shapes, press F6.  As each is highlighted, its name is displayed just
  above the graph.  Press ESC to return to the graphing menu or any
  other key for the next shape.


 
     6     Overview





  Press F1 (Change Graph), then 'Y'.  Type the output graph name,
  "SetSpeaker" and press return.  The output graph is displayed.

  Press F5.  The input is redisplayed.  There are two ways to change to
  another graph.  The name can be entered as above or, if others are
  defined, F5 can be used to switch to the next.

  Let's move to the rule section.

        Press ESC to return to main, F2 to move to the rule menu.

  This is where all new rules are entered.

        Type, "If (I were perfect I would not need this feature)" then
       press return.  Although there is no resemblance to a real rule,
       the first error the program finds is an undefined name was
       given.
        Select Display Rules (F2).  The rules are displayed in the same
       order as they are in the print out.  To return to the rule menu,
       press ESC.
        Press F1 to select Redo Rules.  The menu is changed and the
       first rule is displayed.  Press F1 three times to move to rule
       4.  If wanted, this rule could be deleted by pressing F3.
        Press F2 to modify the rule.  The rule is displayed with the
       cursor positioned at the first character.  Editor functions
       include insert, over type, delete, arrow keys, and so forth.
       Use the arrow keys to move to the OR in the rule.  Press insert
       to change to overtype mode; change the 'O' to an 'A', and press
       return.  The program verifies the rule's syntax, but because the
       OR is now misspelled, an error message is displayed.  To help
       you locate the error, the cursor is positioned near it.  Change
       the 'A' to 'o' and press return.  The rule verifies and is
       stored.
        Press ESC to returned to the rule menu, ESC again to return to
       the main menu.
        Press F3 to enter simulation.  Press F3 to open the learn menu
       followed by F1 to activate.  This instructs the program to send
       data to a file that we will use later to aid in debugging.

  The output, SetSpeaker, is displayed.  Press F2 (Change Output).
  Because there is only one output, SetSpeaker is redisplayed.  If
  there were others, each time F2 is pressed the next would be
  displayed.

  To enter the simulation values manually, press F1.  The display
  changes to the TempOfRoom graph.  The cursor is positioned at the
  start of the X axis; its value is displayed just above the graph.

  Using the left, right, home, and end keys, move the cursor to the
  point that Cold and KindaWarm overlap (value displayed is 32).
  Notice that the left arrow key has five times the resolution of the
  right.  When the cursor is in position, press F1.

                     
                                                           Overview     7     





  After completing the calculations, the rule numbers that fired are
  displayed below the graph.  For this run, rules 2, 3, 4, and 6 are
  displayed.  This means that out of 6 rules, 4 had their input terms
  satisfied.  Above the graph the input value and the final output are
  displayed.  An arrow just below this line shows where the output lies
  on the graph.

  Press F1 to select another run.  Move the cursor to 130.  Press F1.

  The new input and output values are displayed at the top of the
  graph.  Notice the pointers along the bottom.  The one on the left is
  the output for the previous run; the right, this run.  This time,
  rules 1 and 5 fired.

  Press F1 and move to 223.  Press F1.  Rules 2, 3, 4, and 6 fired.
  Because this is the third run, we would expect three arrows below the
  graph.  To see why the other was not displayed, we will check the
  learn file.

        Press F3.
        Press F4 to print the data.
        Select 'N' send it to the printer.

  The printout contains the data used to calculate the output values.
  Each run is separated by a line of '*'.  Refer to the first run.  The
  first table gives the name of the input and its value, 32.  If the
  system had more than one input, the others would be listed.  Next,
  the fuzzy values for each rule that fired are given.  For example,
  rule 2 states, "IF (TempOfRoom KindaWarm) OR (TempOfRoom KindaHot)
  THEN (SetSpeaker FreqMiddle)." The printout indicates with an input
  of 32 the fuzzy value (percent of membership) for the KindaWarm shape
  within the TempOfRoom graph is 52.  Membership for the KindaHot shape
  was 0.

  The next table shows both the fuzzy value picked and the centroid
  calculated for each rule that fired.  Rule 2 had two fuzzy values,
  52% and 0.  According to the "Rules of Fuzzy," the largest, 52%, was
  selected.  After transferring the fuzzy value to the FreqMiddle shape
  of the output, the program calculated the rule's centroid to be 77.

  The next table contains the final output (crisp value).  If other
  outputs were defined, the crisp value for each would be listed.

  Back to the question of why the third arrow was not displayed. 
  Comparing the fuzzy/centroid pairs of the first run with the last, we
  see that the Fuzzy/Centroid pairs are equal; thus, the final output
  was the same.  Two arrows were displayed but the second overwrote the
  first.

  Returning to the program, we could continue to enter the values
  manually, but let's have the program do it. 


 
     8     Overview





        Press F3
        Deactivate learn by pressing F1.  If desired, learn can be left
       active, but the program's speed decreases as data for each input
       value is appended to the file.
        There is only one output so press F4 to enter graphing.  Auto-
       graphing works with the output displayed.  If this system had
       more than one output, F2 would select the one to use.
        We will display the output on the Y axis.  Press 'N'.

  The graph of SetSpeaker versus TempOfRoom is displayed.  The graph
  displays an output value for every possible input (division on
  input's X axis).  As shown, the output is maximum when the input is
  midrange, minimum at each extreme. 

  Press F1 to overlay the input graph.  When designing systems, it is
  often helpful to see exactly what the output does within each shape.
  Whichever graph is on the X axis is used as the overlay.

  Press F2, Show Input/Output Values.  This feature is very useful when
  you are debugging your system.  It enables you to locate exactly
  where the problems occur.  Then, manual simulation in combination
  with learn are used to find the solution. 

  Let's find the minimum and maximum output.  Using the positioning
  keys, move the cursor across the output shape and note the values (21
  and 221 respectively).

  To continue the demonstration, let's expand the system to include the
  time of day.  What we will do is "shift" the output left in the
  morning, in effect, decreasing the amount of warmth needed to reach
  the top of the bell curve.  First let's add the input to track the
  time of day.

        To return to main, press ESC three times.
        Press F1 to go to the graphing menu.
        Select F1, Change Graph.
        We want to add another, press 'N'.
        Type "time."  Press return.
        Yes, 'Y', it will be an input.
        To start the graph at midnight, type '0' followed by return.
       The hex value is also 0.
        End the graph at 24.  Hex value is 18.
        For the resolution of the X axis type "24."  This provides one
       division per hour.
        We will use rectangles for our shapes so only two fuzzy values,
       0 and 100%, are needed.  Enter '1' for resolution Y.
        We will arbitrarily pick the address 0000 (segment) and 0003
       (offset).  The leading zeros are optional.
        It is not a port; press 'N'.

  The new graph is drawn.  Let's add the shapes.


                     
                                                           Overview     9     





        Press F3 (Shapes) then 'A' to add.

  The cursor is positioned at the graph's bottom left.  Above the
  graph, its value is displayed.  To select this point as the shape's
  bottom, press F1.

  The cursor moves to the graph's top.  Press F1 to set this point
  equal to the bottom left.  To set the top right, move the cursor to
  12, press F1.  Press F1 to finish the shape.  Type the name of the
  shape, "AM," followed by return.  Enter the next shape:

        Press F3, 'A' to add.
        Arrow keys to 12, F1 to select.  F1 again to set both points
       equal.
        Press END to move to 24, press F1.
        Press F1 again to finish the shape.
        Type the name "PM."

  Sorry about that.  The AM shape already needs to be modified.  Due to
  the way rectangles are processed (the input value is either
  completely in, fuzzy = 100%, or completely out, fuzzy = 0),the graph
  is saying at 12:00 it is both 100% AM and PM.  No problem for the
  FuzzyOne.  We will just redo it.

        Press F3, 'R', and type "AM."

  The cursor is positioned at the shape's bottom left.  We are not
  modifying this point so press F2 (skip) to move to the next.  The
  cursor moves to the top left of the shape.  Press F2 to move to the
  top right.  This is the point that needs to be repositioned.  Press
  F1.  Use the arrow keys to move to 11.  Press F1 to select.  To
  complete the shape, press F2 or ESC to skip the last point.  The AM
  shape is redrawn.

  The objective is to decrease the amount of heat needed in the morning
  to reach the top of the bell curve.  What we will do is duplicate the
  shapes in the TempOfRoom graph but shift them left 21 values.  Each
  graph can have a maximum of 8 shapes so we cannot add them to
  TempOfRoom.  Instead, we will extend the graph (Chapter 3, Extending
  Graphs) by setting up another graph with the same address and access
  type.  This is already done so let's load the file.

        ESC to main, F4 to file, F2 to retrieve the file.
        'N' to save current file, 'Y' to discard.
        Type "Demo.Fuz."
        Send the file's data to the printer (F3, 'N').

  Comparing the data just printed to the previous printout, notice
  graphs and rules have been added/modified.  To view the new graph,
  return to the graphing section (ESC, F1, F1, 'Y', type "ModIn").  The
  graph is displayed with the shapes shifted 21 values left.


 
     10     Overview





  We will return to simulation (ESC, F3).  Let's go directly to the
  graph section to see if we accomplished what we want.

        F4 to enter graphing.
        'N' to display the output on the Y axis.
        Because there are now two inputs, you are asked for the name of
       the one to use.  Type "ModIn."  Press return.

  Why is the time input displayed?  To answer that we need to know how
  graphing works.  Each auto simulation run consists of one input
  versus one output.  If the system has more than one input, values for
  all must be specified.  Whatever value is entered here will be held
  while ModIn is varied.  Let's see if the output is shifted in the
  morning.

  Move the cursor within the AM shape, press F1.

  The graph is shifted 21 values left, just what we wanted.  To verify
  we did not affect the output in the afternoon, press F3.  Move the
  cursor into the PM shape.  Press F1.  No change.

  Two things before generating an application.

        Return to the graphing section (ESC, F6).
        Press F4, Redo Data.
        Press F2.
        We are changing graph end 'E'.
        Type "100" for the value at the end of the graph.
        Equivalent hex is FF.
        Press ESC to exit the redo section.

  The value at the end is changed to 100.

        Press F5 until the ModIn graph is displayed.

  The value at the end was also changed from 255 to 100.  When an
  extension is set up, any changes to one are automatically transferred
  to the other.

        Press F4.
        Select redo divisions X (F3).
        Type '3', followed by return.
        Enter 100 for divisions Y then press return.
        Press ESC.

  Changing that had a definite effect.  One shape, ModP, is missing and
  others were changed.  When resolution X was reduced to 3, the points
  that make up the shapes had to be moved to the closest division.
  ModP was removed when all four of its points ended up on the same
  division.  Press ESC to return to simulation.

  A message is displayed indicating that a rule was deleted from the

                     
                                                          Overview     11     





  current session.  When a shape or graph is deleted, the program
  rechecks the rules and deletes all that become invalid.  Press any
  key to return to simulation, F5 to enter the rule section.

  Select display rules (F2).  Comparing those displayed to the data
  printed when the file was loaded, we see that rule 5 used the ModP
  shape.  When the shape was removed, the rule was no longer valid.

  Let's load the original file and generate a type 2 TSR (Chapter 7).
  The TSR will be self activating (tied into the DOS timer) and will
  contain the code needed to interface to the article's hardware.  The
  interface routines are covered in Demo.Get and Demo.Put.

        Load the file: press ESC, ESC, F4, F2, 'N', 'Y', and type
       Art.Fuz.
        Press ESC to return to main followed by F5.  Confirm your
       choice by pressing 'Y'.
        Yes, 'Y', the timer will be used.
        We want the TSR to activate every 10 seconds.  Enter 182
       followed by return (each DOS tick is approximately .0549
       seconds).
        Press 'Y'; it will be a TSR.
        Yes, we are including interface code. 
        Enter the file names; Get.Com is the input routine, Put.Com the
       output.  Press return after each.
        We will name the TSR "Demo."  Type the name followed by return.

  The program generates and combines the tables and code.  The next two
  displays indicate the positions within the array the input/output
  will be passed/returned to the interface code.  Press return after
  each screen.

  The TSR is in the current directory under the name Demo.Com.  It can
  be activated at anytime.



















 
     12     Overview





                                  NOTES

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________












                     
                                                          Overview     13     


























































 
     14     Overview





                        Chapter 3 - Graphing




                                  NOTE
        As necessary, names are truncated and values are rounded
        before displaying.  The program uses the entire
        name/value for identification/calculation.


  Pressing F1 at the main menu or F6 in simulation, enters this section
  of the program.  Most of the work is done here.  This is where you
  specify the parameters for the inputs and outputs then add the shapes
  that will become the basis of your system.  You are allowed to
  specify up to twelve graphs (inputs + outputs) with a maximum of
  eight shapes per graph.  There cannot be more than eight outputs
  specified at anytime.  The selections are

  (F1) Change Working Graph.

     If the system has more than two graphs, you are asked if you want
     to change to one previously specified.

           If true, press 'Y' followed by the name of the graph.
           Press 'N' to add another.  You are asked several questions.

          The name of the graph?
          Names for graphs must begin with a letter, be a maximum of 14
          characters long, be unique, and cannot contain spaces or
          parentheses ( ).  Names are case sensitive.

           Is this an input?
          Press 'Y' if the graph will represent an input, 'N' for an
          output.

           Value to start the X axis?
          A decimal number is expected.  The value will be displayed at
          the start of the X axis.  It must be a positive number less
          than 65535.

           What is the equivalent hex value?
          The acceptable range is 00 - FE hex.  Enter the value that
          your application will read at the input/output address.  This
          replaces the value at the start of the X axis when your
          application is generated and is the smallest value that will
          be read/written by your system.

           Value to end the X axis?
          A decimal number is expected.  The value will be displayed at


                    
                                                          Graphing     15     





          the end of the X axis.  It must be greater than graph start
          and less than 65536.

           Equivalent hex value?
          The acceptable range is 1 - FF hex.  Enter the value that your
          application will read at the input/output address.  This
          replaces the value at the end of the X axis when your
          application is generated and is the largest value that will be
          read/written by your system.

           Resolution for the X axis?
          The acceptable range is displayed.  To find the maximum number
          of divisions permitted, the program subtracts hex start from
          hex end (Hex for end - Hex for start).  The value you enter
          will determine the number of equal divisions on the X axis, as
          well as the number of values that are displayed during
          simulation (Chapter 5).  This value also affects where the
          points of a shape may be placed.

          If (EndHex - StartHex) / DivisionsX is not a whole number, the
          program displays/stores the next highest value that is.  If
          the value stored is unacceptable, it can be changed.  See F4
          below.

           Resolution for the Y axis?
          Acceptable range, 1 - 100.  This determines the number of
          unique fuzzy values that the program will use for the graph.
          For example, an input of one tells the program to use 2 fuzzy
          values, 0 and 100.  100/resolution Y must be a whole number.
          If not, the program displays/stores the next highest number
          that is.  If the value stored is unacceptable, it can be
          changed.  See F4 below.





















 
     16     Graphing







                                  NOTE

        Resolution X and Y affect the size of your application.
        If you are not generating an application, the values
        should be set to maximum.  Reducing the resolution
        allows you to decrease the size of the data table used
        by your fuzzy system.  The optimum choice for both is
        the minimum value that achieves the correct output
        shape.  For example, say a graph is set up with 255
        divisions X (hex start = 0, hex end = ff), 100 divisions
        Y.  After simulation, it is found that resolution X can
        be cut in half without adversely affecting the output
        shape.  When the program is generated, 128 values are
        stored instead of 255 (one for each division X).  For
        any value not specified (for example, 1, 3, 5, 7) the
        value is rounded to the nearest division.  Resolution Y
        works the same by controlling the coarseness of the
        fuzzy values.  For example, rectangles use two fuzzy
        values, 0 and 100%.  Increasing resolution Y beyond 1
        does not affect the output shape yet may increase the
        size of your application.

        The above is for explanation and is not always true.
        Data compression is used to keep the table as small as
        possible.  There are many factors that influence the
        extent of the compression.  Changing the number of
        divisions on the X or Y axis may or may not have an
        effect.



                                  NOTE
     The following information (address/port) is required but not
     used unless the application you generate uses them.



           Segment address of the graph?
          The acceptable range is 0000 - ffff hex.  This is the segment
          part of the address that the TSR will use when writing data
          for the graph.  Except for extensions, each graph must have a
          unique address.  (Address is the combination of segment,
          offset, if input or output, and access type.)  If the address
          is for a port (I/O), this value is disregarded.
  
           Offset address?
          The acceptable range is 0000 - ffff hex.  This is combined
          with the segment for memory access or; if for I/O, specifies
          the port.

                    
                                                          Graphing     17     





           Is this a port address (I/O)?
          Press 'Y' if the address you just specified is an I/O port.
          Press 'N' for memory access.

     The graph is drawn and you are returned to the graphing menu.

  (F2) Remove Graph

     Removes (deletes) a graph from the current session.  Press ESC to
     cancel or enter the name of the graph to be removed.  To delete the
     graph displayed, press return.  You are asked to confirm.  Select
     'Y' to continue.

  (F3) Do Shapes

     This sub-menu is where you add and modify shapes. Two types of
     shapes are allowed, trapezoids (including rectangles) and
     triangles.  Press:

     [A] Add Shape
       Use this to add new shapes.  The cursor is positioned at the
       start of the X axis.  A value window is opened above the graph.
       Use the positioning keys to move the cursor to the point that
       will be the bottom left of the shape.  As the cursor is moved,
       the value window is updated to reflect the value relative to
       graph start.  When the cursor is at the correct position, press
       F1.  At anytime, F2 or ESC can be used to cancel.

       The cursor is positioned at the graph's top.  Using the
       positioning keys, move to the point that represents the left top
       of the shape.  Press F1 to select.  Continue this process until
       all four points have been defined.

       You are asked for the name of the shape.  Names must begin with
       a letter, be a maximum of 14 characters long, be unique, and
       cannot contain spaces or parentheses ( ).  Names are case
       sensitive.

     [R] Redo Shape.
       Modifies shapes that were previously specified.  The process is
       similar to adding a new shape.  After entering the name of the
       shape to be modified, the cursor is positioned at its bottom
       left.  To modify this point, press F1.  Use the positioning keys
       to move the cursor to the new point.  Press F1 to select.  If a
       point does not need to be modified, press F2 to advance to the
       next.  Continue this process until all points have been modified
       (F1) or skipped (F2).  After verifying the values, the shape is
       redrawn.

     [D] Delete Shape.
       You are asked for the name of the shape to delete.  It must be
       in the current graph.  Press ESC to cancel or type the name.

 
     18     Graphing





       The shape is removed.

     [N] Change Name.
       Use this to change the name of a shape.  After specifying which
       shape to work with, you are asked for the new name.  It cannot
       contain more characters than the original.


                                  NOTE
        To change the name of a shape or graph without deleting
        rules that contain them, follow this procedure.



           Enter graphing from the main menu.
           Change the names of the shapes/graphs.
           Use ESC to return to the main menu.  Do not make other
          changes.

     The program updates the rules with the new names. Graphing can now
     be re-entered.

  (F4) Redo Graph Values

     Use F4 to modify the values that were entered when the graph was
     set up.  See "Change Graph" for an explanation of the process.
     Press:

       [F1] Name
          Changes the name of the graph.  Before changing the name, see
          the note under the shape menu.
       [F2] X Axis Value
          Modifies the values for the start and end of the X axis.  Both
          the decimal and hex values may be changed.
       [F3] Resolution X/Y
          Modifies the resolution of the X and Y axis.
       [F4] Graph Type
          Changes the type of the graph (input/output).
       [F5] Address
          Modifies the address and access type (memory/port).
       [ESC]
          Returns you to the graphing menu.



                                  NOTE
           Use care when changing the resolution of the X
           axis or the values for hex start and hex end.  If
           the graph contains shapes, modifying any of the
           three may decrease the number of divisions on X


                    
                                                          Graphing     19     





           axis to a point that the shapes distort (See the
           Tutorial).


  (F5) Next Graph

     Switches to the next graph.  When the last is reached, the first is
     redisplayed.

  (F6) Highlight Shapes

     Highlights each shape and displays its name.  Press ESC to return
     to the graphing menu or any other key to highlight the next.

  (ESC) Done

     Before returning you to the previous menu, the rules are rechecked
     (if applicable) to ensure they are still valid.  For example, if a
     shape was deleted and it is used in a rule, the rule becomes
     invalid and is removed.



                            Extending Graphs

  You are allowed up to eight shapes per graph.  If needed, eight more
  may be added to inputs by using a graph extension.  Once set up, the
  fuzzy system views them as if they were superimposed.  Anytime the
  setup data are changed on one, it is automatically transferred to the
  other.  Requirements are

        The extension's setup data (that is, address, access type, and
       if it is an input/output) must be the same as the one being
       extended.  The graph name must be different.
        Each input can be extended once.  An extension cannot be
       extended.
        When extensions are created or removed, a message is displayed.
        During simulation, an extension receives the same input as the
       extended graph automatically.   The graph used is the first
       encountered.  Only one input value is displayed at the top of
       manual simulation's output graph.  In automatic simulation,
       either graph can be used as the input.
        Outputs cannot be extended.
        When defining rules, extensions are viewed as separate entities
       (if it is not specified, it is not used).
        In the learn file, the extension's data is included.
        If extensions exist, they are specified in both the printout
       (File menu, selection F3) and display graph/shape data (Standard
       menu, selection F8).
        Inputs and outputs can have the same address and access type
       without being considered extensions.
        To delete extensions, change the graph's address, access type,

 
     20     Graphing





       or remove the entire graph.

  See the Tutorial (Chapter 2) for an example of setting up an
  extension.
















































                    
                                                          Graphing     21     





                                  NOTES

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________












 
     22     Graphing





                             Chapter 4 - Rules


  There are two ways to get here: F2 at the main menu or F5 in
  simulation. 

  If you have reached the maximum number of rules, you are given two
  choices; redo (F1) or display (F2).  Select F1 to add more rules (by
  deleting others) or modify existing rules.  

  If new rules can be added, "New Rule" is displayed.  This is where
  all rules are entered. To explain the rule syntax, we will use an
  example.

     IF (temp warm) AND (pressure low) OR (temp cool) AND (pressure
     medium) THEN (fire high) (fan low)

  The rule specifies two inputs, temp and pressure, and two outputs,
  fire and fan.  In English it says; "If (the value for the temp input
  is contained within the warm shape) and (the value for the pressure
  input is contained within the low shape) or (if the value for the
  temp input is contained within the cool shape) and (the value for the
  pressure input is contained within the medium shape) then (apply the
  fuzzy value to the fire output using the high shape) and (apply the
  fuzzy value to the fan output using the low shape)."  Fortunately,
  rule input is much simpler.

  Type the new rule and press return.  Before the rule is stored, its
  syntax is verified.  If it is incorrect, an error message is
  displayed and the cursor is positioned near the error.

  The menu selections are

  (F1) Redo Rule

     A sub menu is displayed.  Press

     [F1] Next Rule
       Each time F1 is pressed, the next rule is displayed.

     [F2] Modify
       Modifies the rule that is currently displayed.  After changing
       the rule, press return.  The rule is verified and, if no errors
       are found, it replaces the previous.  If ESC is pressed before
       return, the operation is canceled.

     [F3] Delete
       Deletes the rule displayed.

     [F4] Advance Five
       Same as F1 but advances five rules at a time.


                    
                                                            Rules     23     





     [ESC] 
       Press ESC anytime to return to the rule menu.

  (F2) Display All Rules

     F2 displays the rules.  After each screen, press ESC to quit,
     page/arrow up/down, home or end to continue.

  (ESC) Done

     After completion of the rule input, press ESC.  The rules are
     stored and you are returned to the previous menu.


                            Rule Requirements

        Rules must begin with IF.
        Each rule must contain at least one valid input and output
       combination (graph/shape name), no maximum.
        All inputs must be separated by a valid operator (AND, OR).
        The input side of the equation must be separated from the
       output side with THEN.
        No operators are allowed on the output side.
        Maximum length of any one rule is 178 characters.
        In any one rule, the same input may be specified as often as
       needed, outputs only once.
        It is not necessary to specify all outputs in every rule.
        Graph and shape names must be enclosed with ( ) and separated
       with a space.  They must be exactly as specified in the graphing
       section.
        The keywords: IF, AND, OR, and THEN are not case sensitive.
        The NOT modifier is specified in a rule by using '!' before the
       graph name.  For example, 
         "IF(!Graph Shape1)OR(Graph Shape2)AND(!Graph Shape3),
       indicates that fuzzy values for Shape1 and Shape3 are inverted
       (Noted), Shape2 is not.
        NOT (!) cannot be used with outputs.    
        Spaces are optional except between the graph and shape name.


                           Operator Definition

  AND -   The AND operator specifies a rule will evaluate to true (fire)
          only when the input is within the overlap of two or more
          shapes.  Technically, the AND operator designates that for a
          rule to fire, the fuzzy value for all shapes separated by the
          AND must be greater than 0.  The value used in the output
          calculation is the minimum.  Given this statement,

            IF (g1 s1) AND (g2 s2) AND (g3 s3) THEN (g4 s4),

          for the rule to fire s1, s2, and s3, must all be greater than

 
     24     Rules         





          0.  The fuzzy value for the set of ANDs (the value applied to
          the s4) is the minimum of the three.

  OR -    "OR" works the opposite of "AND."  Instead of using the
          overlap, a rule evaluates to true anytime the input is within
          any of the shapes.  Rules can contain multiple ORs, but only
          one fuzzy value is used in the final calculation.  Given the
          rule,

              IF(g1 s1)OR(g2 s2)OR(g3 s3)OR(g4 s4)THEN(g5 s5),

          the fuzzy value applied to s5 is the maximum of s1, s2, s3,
          and s4. 

          If desired, AND and OR can be combined in one rule.

          IF(g1 s1)AND(g2 s2)OR(g3 s3)AND(g4 s4)OR(g5 s5) . . .

          If s1 = 10% and s2 = 0%, the outcome for the set of ANDs is
          the minimum, 0%.  Further, if s3 = 9% and s4 = 100%, the
          output here, again the minimum, is 9%.  The fuzzy value
          transferred to the output is dependent on s5.  If s5 = 8%, the
          value transferred to the output is 9% (value of s3), if the
          fuzzy value of s5 is larger than 9%, its value is used. 

          In maximum mode (Chapter 5), the OR operator is nothing more
          than a rule connector.  For example, the rule above could be
          separated into three,

            IF (g1 s1) AND (g2 s2) THEN . . .
            IF (g3 s3) AND (g4 s4) THEN . . .
            IF (g5 s5) THEN . . .

          with no change in the output shape.  The reason for this is
          that only one value for each output shape is used for either
          the combined or separate rules.

          Things change in average mode.  Because all centroids are used
          in the final calculation, the rule using the OR would produce
          one centroid; the separate rules, three.  If the rules fire
          simultaneously, the final output may be significantly
          different.

  NOT -   The NOT modifier inverts the shapes.  What happens is the
          fuzzy value is found as outlined above but, before being used,
          it is subtracted from 100%.  Thus, if the fuzzy value is 77%,
          it is inverted and becomes 33%; if 33, it becomes 77. 






                    
                                                            Rules     25     


























































 
     26     Rules         





                          Chapter 5 - Simulation


  Pressing F3 at the main menu moves to simulation.  Simulation is used
  to verify the operation of the system.  Here you prove that all the
  graphs, shapes, and rules that you specified work together to produce
  the desired outcome. 

  The first output graph is displayed.  Press

  (F1) Enter Values

     Use this when you need complete control over the input values.  The
     graph changes to the first input.  The cursor is positioned at the
     start of the X axis; its value is displayed at the top center of
     the graph.  Use the positioning keys to move the cursor to the
     simulator value for the input.  Press F1.

     If other inputs exist, repeat the process for each.  At  anytime,
     F2 or ESC can be pressed to cancel the process and return you to
     the simulator menu.

     After the input values are entered, the program calculates the
     output values.  The rules that fired (that is, their input terms
     were met) are displayed in the lower left of the screen (maximum of
     25 rule numbers displayed).  The rule numbers are the same as shown
     in "Display All" (Chapter 4) or "Print All" (Chapter 6).
  
     Other data is displayed.  Just above the graph, the input values
     for the run and the calculated value for the output are displayed.
     If there is insufficient space to display both, only the outputs
     are displayed.  The order of the inputs, left to right, are the
     same as the printout, top to bottom (Chapter 6, selection F3).
     Just below, an arrow indicates the output value for the run.  If it
     is not the first simulator run, previous outputs are also
     represented below the graph via arrows.  This allows tracking the
     degree of change from one simulation to the next.



                                  NOTE
        There is no requirement to specify all outputs in each
        rule.  If an output does not receive a new value, "No
        Output" will be displayed in place of output value.









                    
                                                        Simulation     27     





  (F2) Change Output Displayed

     If the system has more than one output, press F2.  The graph that
     is displayed changes to next output.  The calculated value for the
     most recent run and the values from previous runs are displayed as
     outlined above.  Press F2 as many times as required to switch
     between the different outputs.


  (F3) Learn


                                  NOTE
        Each time simulation is entered from the main menu,
        learn is deactivated and the previous learn file
        (FUZZY.DOC) is overwritten.



     A sub-menu is displayed.  See Learn File Contents below for an
     explanation of the file.  The selections are

     [F1] Activate/Deactivate Learn.
       Each time F1 is pressed, it toggles learn on/off.  Its current
       status is given at the bottom of the menu. 

       With learn active, the program stores data for each run.  This
       information is helpful in debugging and understanding the
       system. 

       When learn is deactivated, the program stops storing data.  If
       the mode is reactivated, additional data is appended to the old.

     [F2] Change Learn Mode - Auto Simulation.
       Automatic simulation's learn mode is not as comprehensive as
       manual's, but it provides the information you need to rapidly
       determine where the work is needed.  You have two choices:

       Include Rule Numbers -  The rule number of each rule that fires
                               is included.
       Exclude Rule Numbers -  Instead of the rule numbers, the total
                               number of rules that fired are stored.

       Press F2 to toggle from one mode to the other.  The current mode
       is displayed at the bottom of the menu.

     [F3] Change Simulation Mode.
       Each time F3 is pressed, it toggles the method used to calculate
       the final output (Maximum->Average, Average->Maximum) as shown
       at the bottom of the menu.  See Chapter 3, Operator Definition,
       for an explanation of the two methods.


 
     28     Simulation





     [F4] Print Data.
       Press 'Y' to display the data on the screen, 'N' to send it to a
       printer.  If it is sent to a printer, you are asked which port,
       LPT1 (1) or LPT2 (2).  Press '1' for default or '2' for LPT2.

  (F4) Auto Simulation

     Select this to automatically graph any input versus any output.
     The graph is a representation of what the input versus the output
     will be.  If the system has more than one input, those not used on
     the graph are held at a value you specify while the one selected is
     varied.  Before pressing F4, use F2 to display the output to use.
  
     You are asked if the output should be displayed on the X axis.
     Select 'Y' if true.

     If the system has more than one input, you are asked for the name
     of the one to use for the graph.  Enter a valid input graph name.
     If there is more than one input, a value for the others must be
     specified.  As each is displayed, use the positioning keys to move
     to the desired value.  Press F1 to select.  As stated, this value
     will be held constant while the selected input is varied. Continue
     until all inputs have been specified.

     The input versus the output graph is displayed.  ESC can be pressed
     at any time to stop the process.  If learn is active, data for each
     input are sent to the learn file as outlined above.

     When the graph is complete, you have three options

     [F1] Overlay Graph
       Pressing F1 overlays the X axis with its associated graph.  This
       enables you to see exactly what the output does when it is in
       each of the shapes.  If the graph is extended, the shapes for
       both are overlaid.

     [F2] Show Input/Output Values
       This feature allows you to determine the exact output value for
       each division on the input's X axis.  Use the positioning keys
       to move to the point in question.  The values for the input and
       output are displayed just above the graph.  If no rules fired,
       or if the output displayed did not receive a value, the output's
       value is replaced with (No Rules Fired) or (No Output). 

     [F3] Regraph
       If the system has more than one input, select this to regenerate
       the graph using different values.

     See below for an example of the graph.  The input is on the X axis;
     output, on the Y.



                    
                                                        Simulation     29     





                                  NOTE
        Selection F5 and F6 erase the contents of the learn file.



  (F5) To Rule Section

     F5 takes you to the rule menu as outlined in Chapter 4.

  (F6) To Graphing Section

       F6 takes you to the graphing section as outlined in Chapter 3. 

  (ESC) Quit
     ESC returns you to the main menu.






































 
     30     Simulation















               Lines outside the graph's axis indicate no
                  rules fired that contained the output.

                                                max
                                               
                                                   
                                                   
                                                   
                                         
                                                   
                                                   
                                                   
I                                  
N                                                  
P                                                  
U             Lines inside the graph indicate      
T               the output received a value.       
                                                  
G                                                  
R                           
A                                                  
P                                                 
H                                                 
                                                   
                                                   
                                                   
                                                   
                                                   
                                                        
 Ŀ
   min                  OUTPUT GRAPH                  max












                    
                                                        Simulation     31     






                           Learn File Contents

There are three types of learn files: one for manual simulation, two for
automatic.  The following is an example of each.  The system contains four
inputs and eight outputs. The meaning of each section is given in
"Comment:."


                              Manual Learn


Comment:  A line of '*' separate each simulation run.

******************************************************************

Comment: The first row is the names for each input; the next, their values.


                                 INPUT VALUES


        i1                   i2                 i3                   i4
       1.00                 1.00                1.00                0.00


                 *****  No rules fired for these inputs  *****

Comment:  Indicates no rules fired for the input values.


******************************************************************

Comment:  2nd run starts.

                                 INPUT VALUES

   i1                  i2                  i3                    i4
 36.00                81.00              2964.43               5138.34













 
     32     Simulation





                                 FUZZY VALUES

Comment: The following is data on each rule that fired.  After the rule
       number, the fuzzy value for each set (graph/shape) is shown.  Each
       set is separated by the rule's logic.  This information enables you
       to quickly see how the final fuzzy value is derived.

RULE  2: (i1 i12 = 67) AND (i2 i22 = 65) AND (i3 i32 = 53) AND (i4 i42 =
         96)
RULE  3: (i1 i12 = 67)
RULE  4: (i1 i12 = 67)
RULE  5: (i1 i12 = 67)
RULE 10: (i1 i12 = 67) OR (i1 i11 = 100)   
RULE 11: (i1 i12 = 67)
RULE 14: (i4 i45 = 94)
RULE 15: (i4 i48 = 80) OR (i3 i34 = 100) OR (i2 i28 = 0) OR (i1 i15 = 0)
RULE 16: (i1 i11 = 100) OR (i2 i22 = 65) OR (i3 i34 = 100)

Comment: The first row of the next table identifies the graph name of each
       output.  The first column contains the rule number; the second, the
       final fuzzy value picked from the rule data above.  The remaining
       columns contain the calculated centroids for each output shape
       specified in the rule.  NA indicates that the output was not
       contained in the rule.

                             FUZZY/CENTROID PAIRS

RULE   FUZZ    o1      o2        o3        o4        o5     o6     o7    o8
  2     53    25.88  2383.4     78.34     63.00      NA     NA    NA     NA
  3     67    16.47    NA        NA        NA        NA     NA    NA     NA
  4     67    16.47    NA        NA        NA      520.75   NA    NA     NA
  5     67    16.47    NA        NA        NA        NA     NA    NA     NA
 10    100    15.69  2133.7    104.58    111.00      NA     NA    NA     NA
 11     67    16.47    NA        NA        NA        NA     NA    NA     NA
 14     94    60.78    NA       83.11      NA      645.75   NA    NA   6514.9
 15    100     NA      NA        NA        NA      708.25   NA    NA     NA
 16    100    27.45  2133.7    104.58    105.00    308.25  21.00 10420 5213.1



Comment: The following table is present only if the method of simulation is
       set to use the maximum of the shape's centroid.  It is a replica of
       the table above but only the maximum value for each shape remains.
       All centroids that were less than the largest are set to NA.


                    
                                                        Simulation     33     





               FUZZY/CENTROID PAIRS AFTER FINDING MAX OF SHAPES

RULE    FUZZ   o1      o2     o3        o4        o5    o6     o7        o8
 2      53     NA      NA    78.34     63.00      NA    NA     NA        NA
 3      67     NA      NA     NA        NA        NA    NA     NA        NA
 4      67     NA      NA     NA        NA      520.75  NA     NA        NA
 5      67     NA      NA     NA        NA        NA    NA     NA        NA
10      100   15.69  2133.7 104.58    111.00      NA    NA     NA        NA
11      67     NA      NA     NA        NA        NA    NA     NA        NA
14      94    60.78    NA    83.11      NA      645.75  NA     NA      6514.9
15      100    NA      NA     NA        NA      708.25  NA     NA        NA
16      100   27.45    NA     NA      105.00    308.25 21.00  10420    5213.1



Comment: The last table contains the final (crisp) outputs for the simulation
       run.  The first row has the output names; the next, the values
       calculated from the data above.


                                 FINAL OUTPUTS


  o1       o2        o3       o4        o5        o6        o7       o8
34.12    2133.66    90.27    99.00    545.75     21.00    10420.2  5733.79





                             Automatic Learn
                               Show Number


********************************************************************
                                AUTO RUN STARTS

Comment:If  the system has more than one input, the hold value you specified
       for  each  is  stored.    Next,  the name of the input that is being
       varied and what mode simulation is in are given.

Holds:              i2 = 176.00
                    i3 = 6917.00
                    i4 = 5533.60


 
     34     Simulation





           i1 is being varied.  Mode is set to use maximum of shapes.

Comment: The  following table shows how the input and output(s) are arranged.
       The names are truncated as needed to fit on one line.

                              TABLE ORGANIZATION
[ i1 ][ o1 ][ o2 ][ o3 ][ o4 ][ o5 ][ o6 ][ o7 ][ o8 ]
  ( Number Rules That Fire )

Comment: The  following  is  the input value and the calculated output(s) for
       each  division  on  the  X  axis.  As in manual learn, NA is used to
       indicate  an  output  did  not receive a value.  The total number of
       rules that fire is given.

[ 1  ][179 ][50.78][ 36 ][ 225 ][102.12][ 85 ][ 46 ][  NA  ]
  ( 6 Rules Fired )
[ 2  ][ 174 ][49.85][ 36 ][ 219  ][102.12][ 83 ][ 46 ][ 52 ]
  ( 10 Rules Fired )
[ 3  ][ 169 ][48.92][ 37 ][ 210 ][102.12][ 81 ][ 46 ][  51 ]
  ( 10 Rules Fired )
[ 4  ][ 165 ][ 48 ][ 37 ][ 204 ][101.75][ 79 ][ 46 ][  51  ]
  ( 10 Rules Fired )
[ 5  ][ 162 ][ 48 ][ 37 ][ 198 ][101.75][ 78 ][ 46 ][  51  ]
  ( 10 Rules Fired )

                                 AUTO RUN ENDS


                             Automatic Learn
                              Rule Numbers

Comment: The  only  difference  between  this  method  and  the above is that
       instead of specifying the number of rules that fire, the actual rule
       numbers are stored.

******************************************************************
                                AUTO RUN STARTS

Holds:              i2 = 176.00
                    i3 = 6917.00
                    i4 = 5533.60

           i1 is being varied.  Mode is set to use maximum of shapes.         










                    
                                                        Simulation     35     





                              TABLE ORGANIZATION

[ i1 ][ o1 ][ o2 ][ o3 ][ o4 ][ o5 ][ o6 ][ o7 ][ o8 ]
  ( Rules That Fire )

[ 1  ][ 179 ][50.78 ][ 36 ][ 225 ][102.12][ 85 ][ 46 ][  NA  ]
  ( 14, 15, 22, 23, 27, 28 )
[ 2  ][ 174 ][49.85][ 36 ][ 219 ][102.12][ 83 ][ 46  ][  52  ]
  ( 1, 10, 14, 15, 16, 18, 22, 23, 27, 28 )
[ 3  ][ 169 ][48.92][ 37 ][ 210 ][102.12][ 81 ][ 46  ][  51  ]
  ( 1, 10, 14, 15, 16, 18, 22, 23, 27, 28 )
[ 4  ][ 165 ][ 48 ][ 37 ][ 204 ][101.75][ 79 ][  46  ][  51  ]
  ( 1, 10, 14, 15, 16, 18, 22, 23, 27, 28 )
[ 5  ][ 162  ][ 48 ][ 37 ][ 198 ][101.75][ 78 ][  46  ][  51  ]
  ( 1, 10, 14, 15, 16, 18, 22, 23, 27, 28 )

                                 AUTO RUN ENDS


                           Notes On Learn File

     The values in the learn file are rounded. 
     Output values are moved to the nearest division of the X axis.
     The fuzzy value shown is for the input.  If the resolution of the Y
     axis  of  the  input  and  output are different, the fuzzy value is
     translated  (moved  to the nearest division on the output's Y axis)
     before  the  centroid is calculated.  If the nearest division is 0,
     the next highest value is used.
     If extensions exist, their values are included.
     Names are truncated as necessary to fit on one line.























 
     36     Simulation





                                  NOTES

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________












                    
                                                        Simulation     37     


























































 
     38     Simulation





                        Chapter 6 - File/Printing


  Pressing  F4 at the main menu enters this section.  The program works
  with  files  in  the  current drive/directory.  There is one reserved
  file name that is used by the program:

  FUZZY.DOC - Created/overwritten  each  time  you request to print the
              data  (F3  below)  or  simulation is entered (Chapter 5).
              The file remains on disk after the program is exited. 

  (F1) Save Session

     If  the  current  session  was  previously saved/retrieved, you are
     asked  if that file should be used.  If true, press 'Y'.  After the
     file is saved, you are returned to the file menu.

     "Store  in  which  file?"  is  displayed.    Type a valid file name
     including  an extension.  If the file already exists, you are asked
     if it should be overwritten.  Pressing 'Y' overwrites the file, 'N'
     selects another. 

  (F2) Retrieve Session

       If  the  data  in  the current session has been changed, you are
       asked if it should be saved before continuing.

           Press 'Y' to go to "Save Session" above.
            Press  'N'  to  continue without saving.  To ensure the data
          should be discarded, you are given another opportunity to stop
          the  process.    Answer 'Y' to continue without saving, 'N' to
          save.

     "Read  from  which file?"  Type the file name, including extension,
     of a file previously saved by the program.

  (F3) Print File

     Use  this  to print the sessions data.  You are asked where to send
     it.

            Press  'Y'  to display it on the screen.  After each screen,
          press  ESC  to return to the file menu, page/arrow up/down, or
          home/end.
     
           Press 'N' to send it to a printer.  You are asked which port,
          LPT1 or LPT2.  Press '1' for LPT1 (default) or press '2'.
  
     When printing is complete, you are returned to the file menu.

  (F4) Exit To DOS


                    
                                                     File & Printing     39     





     This  selection  enables  you  to temporarily exit to DOS to change
     directories, move files, and so on.  When you are done, type "EXIT"
     to return to the program.

  (ESC) Done

     ESC returns you to the main menu.














































 
     40     File & Printing





            Chapter 7 - Application Generation (Assembly)





                                  NOTE
     The  application  maker generates four types of TSRs and code
     that  you  can  load  with your program.  The following is an
     explanation  of  all five types.  Throughout this section the
     following terminology is used:

     TSR        -   Refers to one of the four types of TSRs.

     Program    -   Refers to code that you load with your program.
     Application  -   Refers to both.




  Before  generating  your  application, ensure that all the graphs and
  rules  defined  are  actually needed.  This is not necessary but does
  ensure the smallest and fastest application.  
  
  If  the  data  in the session have been modified, you are asked if it
  should  be saved.  If you choose no, the modifications are discarded.
  The  application  generator uses the data in the file, not in memory.
  If changes are not saved, they will not be included.  If you chose to
  continue without saving, you are asked to verify the decision.  Enter
  the appropriate response.

        Will you be generating C code?
     Type    Y    if  you will be generating C code.  Chapter 8 provides
     information on this type of application.

        Will the application tie into the timer?
     If  you are generating a TSR and it will use the timer to activate,
     type  'Y'.    See  "Types of TSRs" below for an explanation of this
     method.

           How many DOS ticks should elapse between TSR activations? 
       A  decimal value, 0 to 65535, is expected.  The value determines
       the  amount  of  time the TSR will wait between each activation.
       For  example,  182  DOS ticks allows approximately 10 seconds to
       elapse  (182 * .054925493).  An value of 0 will cause the TSR to
       activate  on the next DOS tick after it deactivates (stay active
       continuously).

        If the application is not using the DOS timer, you are asked if
       the interrupt table should be displayed.

            Choose yes if you are unsure what interrupt you want to use.

                    
                                                 Assembly Applications     41     





          The  purpose  of the data is to assist in finding an interrupt
          that  is  not  in use.  The data is displayed, one screen at a
          time, for all 256 interrupt vectors in this format:

          Interrupt X at Seg:Off. First word of code = Data

       Where:

          Interrupt X -   The interrupt number.
          Seg:Off  -  The  address  of  the  interrupt  service  routine
                      (ISR).    The  CPU  jumps to this address when the
                      interrupt is activated.
          Data     -  The first two bytes of the ISR.

       To  select  an  interrupt,  first  look  for the IRET (interrupt
       return)  instruction,  CF  hex,  in  the  low  byte of the code.
       Another  method,  albeit  not  as  reliable, is selecting one of
       several that point to the same address (for example, 0000:0000).
       As a guide, interrupts 80 - F0 hex are used by Basic (do not use
       these  interrupts  if  you will be using Basic), F1 - FF are not
       used.  Generally, choosing one of these is safe.
     
       Press 'Y' to display the next page, 'N' to continue.

           What interrupt (in hex) will be used?
       A  hex  value,  0  -  ff,  is  expected.  Type the number of the
       interrupt that you will use to call the application.

                                 CAUTION

     If an interrupt is chosen that is already in use, the old ISR
     is  not  executed.    This  may  cause erratic operation or a
     system  crash.    If  this  occurs,  reboot.   Regenerate the
     application using another interrupt.


                                 CAUTION

  The  tables  for  your  application  are  generated.   The display is
  updated as each graph/rule is processed.

       Will this be a TSR?

       If  the code that is generated will be loaded with your program,
       press 'N'.  To generate a TSR, press 'Y'.

           Will your code be included in the TSR?

       If  your application will be a TSR, one of the interface methods
       is  to  include  code  that  you  developed.    When  the TSR is
       activated,  your  code  becomes  resident.    See  the following
       section,   "Interface  To  TSRs,"  for  an  explanation  of  the

 
     42    Assembly Applications





       different methods. 
           If you are not including your code in the TSR, press 'N'.

            To include your code, press 'Y'.  You are asked for two file
          names.   Each file must be a memory image (COM program) of the
          code that will be executed.

           Complete file name of code to call before processing?
          Type the file name, including the extension, that the TSR will
          call to organize the input values.

           Complete file name of code to call after processing?
          The same as before processing, but it will be called after the
          output values are calculated.

        File name to use for the application?
     Type  the  file  name for the application.  The program appends the
     .COM  extension  to  the  name.  An error occurs if an extension is
     included.  

  The program generates and combines the tables and code.

  If  you  are including your code or calling via the interrupt system,
  the  next  two  displays  indicate the positions within the array the
  i n p uts/outputs  will  be  passed/returned.    (See  the  interface
  explanation section below for information on the array.)
  
  The  positions can also be found using the data printed in the "Print
  All"  selection  of  the file menu.  Working with the inputs, go down
  the  list  of  graphs.   The first byte of the array is for the first
  input,  second byte the first output, third byte second input, and so
  on.

  You  are  returned to the DOS prompt.  The application is on disk and
  can be activated/used at anytime.



                            Before Generating
                              Assembly Code

         To  increase speed, applications do not calculate fuzzy values
       or  centroids.    Instead,  a table is used.  Resolution X and Y
       directly   affect  the  size  of  this  table.    Although  data
       compression  is used, in general, the higher the resolution, the
       larger  the  table.    Use  the  smallest resolution possible to
       achieve the correct output shape.
        Generally, additional rules require less memory than additional
       graph/shapes.   For minimum size use additional rules instead of
       adding shapes.
         The more rules, the longer it takes the application to process


                    
                                                 Assembly Applications     43     





       the data.  To increase the speed, decrease the number of rules.
         Rules  combined  with  the OR operator require less memory and
       processing time than two separate rules.  When possible, combine
       rules that use the same outputs/shapes.
         If  an  output does not receive a new value (none of the rules
       that fired contained the output), the value from the last run is
       written/returned.
         If the application receives an input value which is not in the
       graph  (for example, hex start = 7, value received = 5), it will
       always  have  a  fuzzy value of 0; thus, it has no affect on the
       output.
         The  application  will not write/return a value that is not in
       the graph (for example, calculated output value = 5, hex start =
       7, value written/returned = 7).
         Minimum  requirements  to  generate  an  application  are  one
       input/output with one shape each and one rule.


                             About Programs

         The  code  that  is generated to be included with your program
       does  not  have a stack.  Ensure there are at least 128 words of
       stack  space  when the program is called and that SS:SP contains
       its address.
         The program does not use any DOS or BIOS calls and, other than
       the interface interrupt you selected, no vectors are hooked.



                               About TSRs

         TSRs  can  be loaded as many times as desired.  No checking is
       done to ensure the same TSR is not reloaded.
         Non-timer  TSRs  can  be  removed  from memory either by using
       ENDIT.COM  (provided)  or  by  loading  DS  =  BX = ffff hex and
       e x ecuting  the  selected  interrupt.    Timer  TSRs  must  use
       ENDIT.COM.    All  memory  used  will be returned to DOS and the
       interrupt  vector(s)  are  restored.    Do not disengage the TSR
       unless it was the last program loaded.
        TSRs tied into the DOS timer cannot be disengaged.
         As  many TSRs as memory permits can be loaded at the same time
       allowing  you  to run multiple systems.  Ensure that each system
       uses  a  unique interrupt if it is called directly.  If in timer
       mode,  verify  that  the  number of ticks between activations is
       sufficient to allow each to come up and complete processing.
         If  the  TSR  is  tied into the DOS timer, it should be loaded
       before other TSRs or programs.  This ensures it will activate at
       the correct time.





 
     44    Assembly Applications





         Once  installed,  the  TSR  does  not  use  DOS or BIOS calls.
       Interrupt  13  hex  is  hooked  to  determine  when  a  critical
       operation  is  in  process.  If the interface method chosen uses
       the DOS timer to activate, interrupt 1C is also hooked.  Neither
       interrupt is called directly.


                          Types of Applications

  There  are  five ways that applications can tie into the system: four
  TSRs  and  one program.  The program is similar to a type 3 TSR which
  does not become resident.  Flow charts for each are given below.





                                 CAUTION

     If  you  include  your code it is up to you to ensure it will
     run  as  a  TSR.  If the TSR is tied into the DOS timer and a
     disk  access is not being performed, it will activate as soon
     as  the count reaches 0.  In general, you cannot use calls to
     DOS or the BIOS.

                                 CAUTION



  There  are  four  ways  that  TSRs  can tie into the system.  Two run
  completely  in  the  background, activating at intervals you specify;
  two wait until called.  Flow charts for each are given below.
  
  Of  the  four,  two  use  code  you develop.  The following terms are
  applicable to them.

         Input Processor:  This routine organizes the next set of input
       values that are passed to the fuzzy system.
        Output Processor:  After calculating the new outputs, the fuzzy
       system passes them to this routine.

  [1] Timer used, your code not included. 
     This  is  the  simplest  of the four types.  The development system
     generates all the code needed by the TSR.









                    
                                                 Assembly Applications     45     





                         (TSR Starts)
           Ŀ                 
            Set tick counter to value specified <Ŀ
                   when TSR was created.        >Ŀ        
                           
                                                                  
         Ŀ                         
                                                 <     
      > At each DOS tick, decrement the counter                
                                                >Ŀ     
                       
                                                                 
                      ͻ                                       
             No                    <     
      <Counter = 0?                                        
                                   >Ŀ     
                      ͼ    Yes                                
                                                                 
                     ͻ                           
    Ŀ Yes                     <     
    Set counter<Is a critical action                       
      to 1              in process?                            
                             >Ŀ     
                      ͼ   No                 
                                                                  
                       ͻ                       
                                         < Yes 
                         Is TSR active?  >Ĵ
                                         >Ŀ     
                       ͼ                       
                                                                  
    Ŀ  No      
             Read the new input values from           <     
              the addresses specified when                       
                 the graphs were set up.              >Ŀ     
              
                                                                  
                                                                  
        Ŀ           
                                                     <     
         Applies the new inputs to the fuzzy system.             
                                                     >Ŀ     
                   
                                                                  
                    ͻ                 
            No                                 <     
  < Errors during processing?                   
                                              >Ĵ
                   ͼ  Yes             

 
     46    Assembly Applications





                                                                  
      Ŀ       
         Write the new outputs to addresses specified           
         when graphs were set up. If an output did not          
  >       get a new value on this run, write                 
                 the value for the last run.              >
              
                                                                   
                                                                   

                                                 

  [2] Timer used, your code included.                               
  
This selection allows the TSR to run completely in the background as in Method
1,  but, instead of reading and writing the input/output values directly, your
code  is  called.    Use  this  when the data to/from the fuzzy system must be
modified  before  it  can  be used.  See the files Demo.Get, Demo.Put, and the
section on the interface below for information and requirements.



































                    
                                                 Assembly Applications     47     



           Ŀ                 
  TSR       Set tick counter to value specified <Ŀ
 Starts            when TSR was created.        >Ŀ        
                           
                                                                  
         Ŀ                         
                                                 <      
      > At each DOS tick, decrement the counter                 
                                                >Ŀ     
                       
                                                                 
                      ͻ                                       
             No                    <      
      <Counter = 0?                                        
                                   >Ŀ     
                      ͼ    Yes                                
                                                                 
                     ͻ                           
    Ŀ Yes                     <      
    Set counter<Is a critical action                       
      to 1              in process?                            
                             >Ŀ      
                      ͼ   No                 
                                                                  
                       ͻ                       
                                         < Yes 
                         Is TSR active?  >Ĵ
                                         >Ŀ     
                       ͼ                       
                                                                  
    Ŀ  No      
        The TSR sets DS and ES to your CS register    <     
        Calls your code (input processor) that was               
            included when the TSR was created.        >Ŀ     
              
                                                                  
                (Your Input Processor Starts)                     
      Ŀ           
        Your code fills the low byte of a word array <     
         with the new input values.  You place the                
         address of the array in DS:BX and perform               
                       a FAR RETURN.                 >Ŀ     
                 
                                                                  
        Ŀ           
  TSR                                                <     
Restarts New inputs are applied to the fuzzy system.             
                                                     >Ŀ     
                   
                                                                  
                    ͻ                 

 
     48    Assembly Applications


            Yes                                <      
  < Errors during processing?                   
                                              >Ŀ      
                   ͼ  No             
                                                                 
      Ŀ      
       Put the new outputs in the high byte of the array <     
        set up by input processor.  If an output did not        
             get a new value on this run, write                 
                the value for the last run.              >     
             
                                                                 
                Ŀ                
  > If error occurred put 1 in AX <     
                        else put 0.             >Ŀ      
                                  
                                                                  
    Ŀ      
     Sets the DS register to your code segment.  Puts the        
      segment and offset of the array set up by your input<     
         processor into ES:BX.  Calls your code (output          
           processor) that was included when the                  
                     TSR was created.                     >     
          
                                                                  
              (Your Output Processor Starts)                       
     Ŀ          
                                                      <     
      Your code is executed.  Return via a FAR RETURN.                     
                                                      >
                
                                                                    
   [3] Interrupt system used, no code included.

  This  method  is  applicable to both TSRs and programs.  It allows you to
  call  the  fuzzy  system  at  any  time,  from any program written in any
  language.    The  only thing the TSR/program expects is, when called, the
  DS:BX  pair contain the address of the first byte of the array containing
  the  new  inputs.  The high byte of the array will receive the calculated
  outputs.
















                    
                                                 Assembly Applications     49     


                          (Your Code)
           Ŀ                 
             Your code fills the low byte of a                   
              word array with the new input     <Ŀ      
               values.  The segment address                      
                is put in DS, offset in BX.                         
                           
                                                                   
         Ŀ                          
              Perform the software interrupt     <     
                that was selected when the                       
                 application was set up.         >Ŀ      
                         
                                                                  
                                                                  
                     (Application Starts)                          
        Ŀ           
                                                     <      
        Applies the new inputs to your fuzzy system.             
                                                     >Ŀ     
                   
                                                                  
                    ͻ                 
            Yes                                <     
  < Errors during processing?                   
                                              >Ŀ      
                   ͼ  No             
                                                                 
      Ŀ       
       Put the new outputs in the high byte of the array <     
          set up by your code.  If an output did not            
             get a new value on this run, write                  
                the value for the last run.              >     
            
                                                                 
                Ŀ                
  > If error occurred put 1 in AX <     
                        else put 0.             >Ŀ     
                                 
                                                                  
                                                                  
             (Application Ends Your Code Starts)                  
     Ŀ          
                                                                
        Returns to you. Only register changed is AX.  <                
                                                                 
                
                                                 







 
     50    Assembly Applications





  [4] Interrupt system used, your code included.

  This  is  a replica of Method 2 (your code included) except it is not
  tied  into  the  DOS  timer.    It  is activated the same as method 3
  (called  through  the  interrupt  system).  This method allows you to
  call the TSR at intervals that cannot be accommodated by DOS timer.


                          Interface Explanation

  If  you  have not already, go through the flow charts above to get an
  understanding  of  the  application's  operation.   The communication
  between  your  code  and  the application is fairly straight forward.
  The following applies to all types except method 1:
         Communication  is  done  through  registers AX, BX, DS, and an
       array of words.
           AX is used to inform your code of the outcome of the run. 

       0 -  Output value(s) in array are valid.
       1 -  Error occurred.  Output values invalid.

           Except for AX, the application leaves all registers intact.
           Passed array arrangement:

                              LOWEST MEMORY


                            Data for input 1

                             Data for output
                                    1
                            Data for input 2

                             Data for output
                                    2

                                 Others
                                   As
                                Required

                            Data for input X
                             Data for output
                                    X


                             HIGHEST MEMORY

       Where:
             Data for input X: Input  values that the fuzzy system will
                               use to calculate the new outputs.
             Data for output X:   The calculated values returned to you.


                    
                                                 Assembly Applications     51     



       The  array  can be as small as 1 word (1 input and 1 output) but
       must  be  large enough to hold all output values returned by the
       application.    For  example,  if  you  have one input and three
       outputs, the size of the array must be a minimum of 3 words.

           DS:BX pair
       The  array's address must be in the DS:BX pair.  DS contains the
       segment;  BX,  the  offset.  The address must point to the first
       byte (lowest memory location) of the array.
           The input values are not changed by the application.

     The  following is applicable only if your code is a TSR and you are
     including code.

            Any  language/compiler/assembler  that can generate a memory
          image  file  (COM program) can be used to create the interface
          code.
            When  your code is called, SS:SP contains the address of the
          TSR's  stack.    Its  size is sufficient for most applications
          (128  words).   If the stack will be used extensively (such as
          in  C),  you should switch to another on entry, switch back on
          exit.
            The  DS  and  ES registers are set equal to your CS register
          when  the  input  processor  (input part of interface code) is
          called.
            The  DS  register is set equal to your CS and the ES:BX pair
          has the address of the first byte of the array when the output
          processor (output part of the interface code) is called.
           There is no program segment prefix (PSP).
           Your code must preserve all segment registers and the SP (the
          same  value  that was in them when your code is called must be
          in  them when you return to the TSR).  All other registers can
          be changed.
            Both  the  input  and  output routines must use a FAR RET to
          return to the TSR.
            It is your input routine's responsibility to set the address
          in  DS:BX and to fill it with the new input values. As stated,
          the  DS  register  is  set  equal to your CS register when the
          input processor is called.  If this is not the correct segment
          for the array, your code must change it.
            The TSR calculates the new values for the outputs and passes
          them  to  the  output  processor.   It is the output routine's
          responsibility to use them as required.



                           Interface Examples
                                  TSRs

  The  following  code fragments provide examples of interfacing to the
  TSR  using  C,  Quick  Basic, and Assembly.  They pertain to the TSRs
  activated  via  the  interrupt  system.  If you are including code to
  become resident with the TSR, see the files Demo.Put and Demo.Get for
  examples of the input and output routines.

 
     52    Assembly Applications






  The  fuzzy  system  used  in  the  examples  contains  3 inputs and 4
  outputs.  They use interrupt FD hex.


















































                    
                                                 Assembly Applications     53     





                                Assembly


   NumIns  equ 3          ;Number of inputs
   NumOuts equ 4          ;Number of outputs
   TotalBytes equ 8          ;Array must be 2 * the larger
              ; of the inputs or outputs
   IntNum equ 0fdh        ;Interrupt used to call the TSR
   ValueArray db TotalBytes dup 0     ;Set up an array to pass to TSR

          ;;;CODE STARTS;;;

   mov cx,NumIns          ;Number of loops
   mov bx,offset ValueArray       ;Address of array to bx
   push bx            ;Save for below.
   xor ax,ax            ;Start with first input

  GetInputLoop:

   call GetNextInputValue
        ;This routine is not included.  Assume that it
        ; returns a value in the AH register that
        ; should be sent to the TSR. The input number
        ; is passed in AL.

   mov [bx],ah          ;Move the new value
              ; to the array
   inc al             ;Next input
   inc bx
   inc bx             ;Add 2 to get to the
              ; position of the next input
   loop GetInputLoop         ;Continue until all inputs stored
   pop bx             ;Address back
   int IntNum           ;Call the TSR
   cmp ax,0
   jne EndIt            ;If TSR returns anything but 0 an
              ; error occurred. Output values in
              ; the array are not valid.
   mov cx,NumOuts
   mov bx,offset ValueArray
   inc bx             ;Bx now points to 1st output
   xor ax,ax            ;Process first output

  DoOutsLoop:
   mov ah,[bx]          ;Get the output value into ah
   call PutNextOutValue
        ;Not included.  Assume routine does whatever is
        ; required with the outputs returned by the
        ; TSR.  AL contains the  number of the output,  AH the value.

   inc al             ;Next output


 
     54    Assembly Applications





   inc bx
   inc bx             ;Add 2 to get to the position of
                                    ; the next output
   loop DoOutsLoop        ;Continue until all outputs are stored

  EndIt:















































                    
                                                 Assembly Applications     55     





                                    C

 Assume the caller passes the input values and does whatever is required
                         with the output values.

  #include <dos.h>

  #define NumIns 3      /* Number of inputs  */
  #define NumOuts 4       /* Number of outputs */
  #define ArraySize 8     /* Array must be 2 * the larger of the
                                         inputs or outputs */
  #define IntNum 0xfd     /* Interrupt to call TSR */
  #define FALSE 0
  #define TRUE 1

  int DoTsr(unsigned char *InVals,  /* New inputs for TSR */
        unsigned char *OutVals)   /* Gets outputs from TSR */
  {
    unsigned volatile char PassArray[ArraySize], *cPtr = PassArray;
            /* Array to pass to TSR */
    unsigned char LoopCnt;
    struct SREGS SegReg;
    union REGS Regs;

    for(LoopCnt=NumIns; LoopCnt ;LoopCnt--,InVals++,cPtr+=2)
      *cPtr = *InVals;    /* Inputs to pass array */

    segread(&SegReg);     /* Assumes data segment = stack */
    Regs.x.bx = (unsigned)(PassArray);
            /* TSR wants DS:BX to point to first byte of the array */

    int86x(IntNum,&Regs,&Regs,&SegReg);  /* Call the TSR */
    if(Regs.x.ax)
       return(FALSE);     
            /* TSR returned error.   New outputs invalid */

    cPtr = PassArray+1;   /* Points to 1st output */

    for(LoopCnt=NumOuts;LoopCnt;LoopCnt--,OutVals++,cPtr+=2)
      *OutVals = *cPtr;   /* Outputs to caller */
    return(TRUE);
  }











 
     56    Assembly Applications





                               Quick Basic


DECLARE FUNCTION DoTsr ()
DECLARE SUB FillArrayWithNewInputs ()

'$INCLUDE: 'QB.BI'
' Include the header file that has definitions needed

'Set up some constants used in the TSR interface
' IntNum is interrupt TSR uses - NumIns & NumOuts are
' how many of each.  ArraySize is the largest of NumIns
' or NumOuts

  CONST IntNum=&HFD, NumIns=3, NumOuts=4, ArraySize=4,
          TRUE=1, FALSE=0

'Set up the array that will be passed to the TSR.  The
' low byte of each integer gets the new value for each
' input, the high byte receives the output values from the TSR.
    DIM SHARED PassArray(1 TO ArraySize) AS INTEGER

'The following sub does not exist.  Assume it fills
' PassArray with the new input values.

    CALL FillArrayWithNewInputs
    Results=DoTsr         'Results gets TRUE or FALSE from TSR.


FUNCTION DoTsr
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function deals directly with the TSR.  Passes the new
' input values in PassArray to the TSR.  TSR returns
' the new output values in the high byte of the array.
'   Passed  - Nothing
'   Returns - TRUE if the data in the array is valid else FALSE.
',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

'Set up the registers used in the call to the TSR
    DIM InRegs AS RegTypeX, OutRegs AS RegTypeX

'TSR wants address of array in DS:BX pair
    InRegs.bx = VARPTR(PassArray(1))
    InRegs.ds = VARSEG(PassArray(1))
 
'Call the TSR through the interrupt system
    CALL INTERRUPTX(IntNum, InRegs, OutRegs)
 
'TSR returns result in AX.  If it is not 0, a failure occurred.
 
   IF OutRegs.ax <> 0 THEN


                    
                                                 Assembly Applications     57     





      DoTsr = FALSE
    ELSE
      DoTsr = TRUE
    END IF

END FUNCTION















































 
     58    Assembly Applications






                           Interface Examples
                                Programs


  The  following  code fragments provide examples of interfacing to the
  program  using  C,  Quick  Basic,  and Assembly.  They pertain to the
  program you load with your code.  

  The  fuzzy  system  used in the examples contains 3 inputs, 4 outputs
  and uses interrupt FD hex.


                                Assembly

                             ;;; EQUATES ;;;

   NumIns  equ 3          ;Number of inputs
   NumOuts equ 4             ;Number of outputs
   TotalBytes equ 8            ;Array must be 2 * the larger
                                    ; of the inputs or outputs
   IntNum equ 0fdh           ;Interrupt used to call the TSR
   StoreFuzzyHere equ 09000
     ;This is the segment address where the fuzzy system
     ; will be loaded.  The offset will be 0.  This method
     ; assumes your code is a .COM program and was allotted all
     ; the memory available up to the end of user RAM (09ffff hex).
     ; If your code is an .EKE program, use DOS functions 48h, 49h,
     ; and 4ah to allocate/return the memory needed.  See the Basic
     ;  example  for  information.    If  desired,  the  value  could be
calculated
     ; at run time loading the system just beyond the end of your code

                             ;;;; DATA  ;;;;

   ValueArray db TotalBytes dup 0   ;Set up an array to pass to TSR
  FileName db 'Fuzzy.Com',0    ;The name of the Fuzzy system file.
                               ; Change this to whatever name you
                               ; used when the system was created.

                           ;;; CODE STARTS ;;;

  call LoadFuzzySystem       ;Load the system into memory.
  cmp ax,0
  je CantLoadFuzzy           ;The routine could not load the system
                          ; into memory.  It cannot be used.
  call DoFuzzy               ;Process the new inputs and outputs.  This
                          ; routine can be called as many times as
                          ; desired.
  CantLoadFuzzy:             ;Routines end.
  
;;;;;;;;;;  LoadFuzzySystem  ;;;;;;;;;;

                    
                                                 Assembly Applications     59     





;;
;  Loads the system into memory and hooks the interrupt vector specified
;   by IntNum.  The routine uses the StoreFuzzyHere equate to determine
;   where the Fuzzy system should be loaded.  This method was chosen to
;   keep the routine as simple as possible. 
;
;  Passed  - Nothing
;  Returns - AX = 1 if system was loaded successfully, else AX = 0.
;
; Registers Destroyed - May be all except segment registers.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LoadFuzzySystem:
  xor bp,bp               ;Used as value to return below.
  mov ax,03d00h         ;DOS function to open file
  mov dx,offset FileName  ;Need address of file name in DS:DX.
                        ;  Assumes that DS has data segment.
  int 021h              ;Call DOS to open file.
  jc LoadFuzzyEnds        ;If carry is set could not open file.
                        ; Return the 0 in BP.
  mov bx,ax               ;File handle returned by DOS to bx. 
  mov ax,04202h         ;Function to position file pointer.
  xor cx,cx
  mov dx,cx               ;Want offset of 0 from end of file.
  int 021h              ;Move the file pointer.
  push ax                 ;DOS returns the size of the file in
                        ; DX:AX.  Fuzzy system is never larger
                        ; than 64K so only need the low word.
                        ; Save it for later.
  mov ax,04200h         ;Position the file pointer back to the
                        ; start of file.
  xor cx,cx
  mov dx,cx               ;Offset from beginning of file is 0.
  int 021h              ;BX still has file pointer.  Position 
                        ; the file pointer at start of file.
  mov ax,03f00h         ;Function to read from file.
  pop cx                ;Number of bytes to read to CX.
  push ds                 ;Save it for restore.
  mov dx,StoreFuzzyHere   
  mov ds,dx               ;Segment address of where to store the
                        ; file to DS.
  xor dx,dx               ;Offset of the segment is 0.
  int 021h              ;Call DOS to read the file. 
                        ; BX has file handle.
  pop ds                ;Get segment register back.
  cmp cx,ax             
  jne LoadFuzzyCloseFile  ;DOS did not read all the bytes in the file.
  inc bp                ;Add one to indicate all ok.

  LoadFuzzyCloseFile:
  mov ax,03e00h         ;Function to close file.
  int 021h              ;Close the file.  BX has handle. 

 
     60    Assembly Applications





  cmp bp,0
  je LoadFuzzyEnds        ;Jump if error occurred. 
  mov ah,025h           ;Set interrupt function.
  mov al,IntNum         ;The interrupt number to call the system.
  mov dx,StoreFuzzyHere   
  sub dx,010h           ;Want the offset at 0100 hex so subtract
                        ; 010 hex from the segment.
  push ds                 ;Save for later restore.
  mov ds,dx               ;Segment to ds.
  mov dx,0100h          ;Offset to dx.
  int 021h              ;Set the vector to point to the Fuzzy system.
  pop ds

LoadFuzzyEnds:
  mov ax,bp             ;Get the return value in AX.
  ret                 ;All done.  Return code in AX.

;;;;;;;;;;;;;  DoFuzzy  ;;;;;;;;;;;;;;;;
;;
; Routine  organizes  the  input values, calls the Fuzzy system through
the
;    interrupt system, and works with the outputs.  As indicated, the
;      routines that deal directly with the input and output values must
be
;    created.
;
; Passed  - Nothing
; Returns - AX = 1 if all ok, AX = 0 if error occurred.
;
; Registers Destroyed - May be all except segment registers.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
DoFuzzy:
  mov cx,NumIns           ;Number of loops
  mov bx,offset ValueArray   ;Address of array to bx
  push bx                    ;Save the address
  xor ax,ax                  ;Start with first input

  GetInputLoop:
   call GetNextInputValue
        ;This routine is not included.  Assume that it
        ; returns a value in the AH register that
        ; should be sent to the TSR. The input number
        ; is passed in AL.

   mov [bx],ah                      ;Move the new value
                          ; to the array
   inc al                           ;Next input
   inc bx
   inc bx                           ;Add 2 to get to the
                                      ; position of the next input
   loop GetInputLoop              ;Continue until all inputs stored

                    
                                                 Assembly Applications     61     





  pop bx                  ;Address back
   int IntNum                       ;Call the TSR
   cmp ax,0
   je ValuesOk                 ;If TSR returns anything but 0, an
                                         ; error occurred. Output values
in
                          ; the array are not valid.
  xor ax,ax                  ;Pass error back to caller.
  ret                     ;Back to caller.

  ValuesOk:
   mov cx,NumOuts
   mov bx,offset ValueArray
   inc bx                           ;Bx now points to 1st output
   xor ax,ax                        ;Process first output

  DoOutsLoop:
   mov ah,[bx]                    ;Get the output value into ah
   call PutNextOutValue
      ;Not included.  Assume routine does whatever is
      ; required with the outputs returned by the
      ; TSR.  AL contains the number of the output,  AH the value.

   inc al                             ;Next output
   inc bx
   inc bx                           ;Add 2 to get to the position of
                          ; the next output
   loop DoOutsLoop             ;Continue until all outputs are stored
  mov ax,1                ;Indicate all ok.
  ret                     ;Back to caller



                                    C

  #include <dos.h>
  #include <malloc.h>
  #include <stdio.h>

  #define NumIns 3           /* Number of inputs  */
  #define NumOuts 4          /* Number of outputs */
  #define ArraySize 8        /* Array must be 2 * the larger of the
                               inputs or outputs */
  #define IntNum 0xfd        /* Interrupt to call TSR */
  #define FALSE 0
  #define TRUE 1
  #define FileName "Fuzzy.Com"
     /* The name of the file created by the application generator. 
        Change it if not correct for your file.  */

  unsigned LoadFuzzy(unsigned Seg,FILE *fPtr);


 
     62    Assembly Applications





  int LoadUnloadFuzzy(int Load,FILE *fPtr);
  unsigned LoadFuzzy(unsigned Seg,FILE *fPtr);

main(void)
{
  unsigned char InVals[NumIns],OutVals[NumOuts];
  FILE *fPtr;

  if((fPtr = fopen(FileName,"rb")) == NULL)
     exit(1);
  fclose(fPtr);              /* All done with file */
  if(LoadUnloadFuzzy(TRUE,fPtr)) {
     DoFuzzySystem(InVals,OutVals);
     LoadUnloadFuzzy(FALSE,fPtr);
     exit(0);
     }
}

/*==================================
                            LoadUnloadFuzzy()

Function  loads/unloads  the  Fuzzy system. If called to load, hooks the
interrupt  vector specified by IntNum.  If called to unload, returns the
memory used to C.

  Passed  - Load   = TRUE to load the system into memory.
           Load  = FALSE to unload and return the memory.
           fPtr    = Fuzzy system file open for binary read.

  Returns -   If  loading,  TRUE  if  Fuzzy  system  can be used; else,
              FALSE.
            If unloading, always returns TRUE.

  NOTE:   Because this function uses farmalloc(), it cannot be used with
          the  tiny memory model.  In this case malloc() should be  used
          in its place.

  Several  calls  are  not  defined  by  ANSI C.  Most compilers supply
  equivalent  functions  but  their names may be different.  Check your
  compiler's documentation.

==================================*/
int LoadUnloadFuzzy(int Load,FILE *fPtr)
{

  unsigned long FileSize;
  static void far *FarMemoryPtr = NULL;

  if(Load) {                 /* If loading the system */
     if(!fseek(fPtr,0L,SEEK_END))
                          /* Move file pointer to end of the file. */
       if(ftell(fPtr) <= farcoreleft()) {

                    
                                                 Assembly Applications     63     





                          /* If there is enough memory in the far core.
*/

          FileSize = ftell(fPtr);   /* Get file size. */

          if((FarMemoryPtr = farmalloc(FileSize+16)) != NULL) {
            /* If C gave up the memory.  Add 16 to
                ensure we get a paragraph boundary */

            unsigned Seg = FP_SEG(FarMemoryPtr),
                   Off = FP_OFF(FarMemoryPtr);
            /* Get the segment and offset of the pointer. */

            Seg += Off >> 4;
            /* Put as much of the address as possible into the
                segment.  Offset must be 0 */

            if(Off & 0xf)  ++Seg;
            /* If the low nibble of the offset is not 0, need to
              add a paragraph so writes to the correct area. */

            return(LoadFuzzy(Seg,fPtr));
            /*   Finish  loading  the system.  Return whatever LoadFuzzy
                 returned. */
            }
          }
     return(FALSE);    /* An error occurred. */
     }

  /* Return the memory. */
  if(FarMemoryPtr != NULL)
     farfree(FarMemoryPtr);
  FarMemoryPtr = NULL;
  return(TRUE);
}

/*=================================
                               LoadFuzzy()

Uses DOS to load the program into memory and hook the interrupt
vector.  Do not call directly.  Use LoadUnloadFuzzy.

  Passed  - Seg = The segment address where the Fuzzy system should
                     be loaded.  Offset will be 0.
           fPtr = Fuzzy system file open for binary read.

  Returns - TRUE if the Fuzzy system can be used else FALSE.

==================================*/




 
     64    Assembly Applications





unsigned LoadFuzzy(unsigned Seg,FILE *fPtr)
{
  struct SREGS SegReg;
  union REGS Regs;
  char far *FP;

  FP = (char far *)(MK_FP(Seg,0));  /* Set the pointer. */
  rewind(fPtr);              /* Get back to the start of the file. */
  for(;!feof(fPtr);FP++) {
     if(ferror(fPtr))             /* If a file error occurred. */
       return(FALSE);
     *FP = fgetc(fPtr));       /* Put the system into memory. */
     }

  SegReg.ds = Seg - 0x10;
  Regs.x.dx  = 0x0100;
     /* Fuzzy needs an offset of 0100 hex so subtract 010 hex
         from segment and move it to the offset */

  Regs.h.ah = 0x25;          /* DOS function to set interrupt */
  Regs.h.al = IntNum;
  int86x(0x21,&Regs,&Regs,&SegReg);      /* Set the vector. */
  return(TRUE);
}


/*==================================
                             DoFuzzySystem()

This function deals directly with the Fuzzy system. It organizes the new
input  values  in  an array, passes them to the Fuzzy system via IntNum,
and returns the calculated outputs.

  Passed  -   *InVals - Pointer to array of new inputs.
              First location for first input.
              *OutVals - Pointer to array that gets new outputs.
  Returns -   TRUE if new outputs in array are valid.
              FALSE if Fuzzy system returned error (outputs
              are not valid).

==================================*/
int DoFuzzySystem(unsigned char *InVals, unsigned char *OutVals)
{

  unsigned volatile char
       PassArray[ArraySize],   /* Array to pass to Fuzzy system */
       *cPtr = PassArray;
  unsigned char LoopCnt;
  struct SREGS SegReg;
  union REGS Regs;

  for(LoopCnt=NumIns; LoopCnt ;LoopCnt--,InVals++,cPtr+=2)

                    
                                                 Assembly Applications     65     





     *cPtr = *InVals;                /* Inputs to pass array */

  SegReg.ds = FP_SEG(PassArray);
  Regs.x.bx =  FP_OFF(PassArray);
     /* Fuzzy wants DS:BX to point to first byte of the array */

  int86x(IntNum,&Regs,&Regs,&SegReg);   /* Call the system */
  if(Regs.x.ax)
     return(FALSE);
       /* System returned error.  New outputs invalid */

  cPtr = PassArray+1;       /* Points to 1st output */
  for(LoopCnt=NumOuts;LoopCnt;LoopCnt--,OutVals++,cPtr+=2)
     *OutVals = *cPtr;      /* Outputs to caller */

  return(TRUE);
}




































 
     66    Assembly Applications





                               Quick Basic


DECLARE FUNCTION LoadFuzzySystem ()
DECLARE SUB ReleaseDosMemory ()
DECLARE FUNCTION DoFuzzy ()
DECLARE SUB FillArrayWithNewInputs ()

'$INCLUDE: 'QB.BI' Include the header file that has definitions
'                     needed to use interrupt system.

'Set up some constants used in the Fuzzy system interface.
' IntNum is interrupt the Fuzzy system uses.
' NumIns/NumOuts are the number of each the Fuzzy system has.
' ArraySize is the largest of NumIns or NumOuts.
  
CONST IntNum = &HFD, NumIns = 4, NumOuts = 8
CONST ArraySize = 8, TRUE = 1, FALSE = 0

'Set up the array that will be passed.  The low byte of
' each integer gets the new value for each input; the high byte
' receives the output values from the Fuzzy system.
  
  DIM SHARED PassArray(1 TO ArraySize) AS INTEGER

'Set up the registers used in the call to the Fuzzy system.
    
  DIM SHARED InRegs AS RegTypeX, OutRegs AS RegTypeX

'Set up a variable that holds the segment address returned by Dos.

  DIM SHARED MemorySeg%
    
'First, load the Fuzzy system into memory.
' Returns TRUE if the system was loaded, FALSE if a problem occurred.
  Results = LoadFuzzySystem
     
  IF Results = TRUE THEN
     'Use the following two functions to call the Fuzzy system.

     CALL FillArrayWithNewInputs
     'You need to create this function.  It fills the low
     ' byte of PassArray with the input values for the run.
    
     Results = DoFuzzy
     'Call the Fuzzy system.  Results gets TRUE if the
     ' new outputs in the high bytes of PassArray are valid.
  END IF

'Before exiting your program, call the following to unload
' the Fuzzy system and release the memory it used.


                    
                                                 Assembly Applications     67     





  CALL ReleaseDosMemory

FUNCTION DoFuzzy
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''
'  Function  deals directly with the Fuzzy system.  Using PassArray, the
new
' inputs are passed to the Fuzzy system.  It returns the new outputs
' in the high byte of the same array.
'    Passed - Nothing
'    Returns - TRUE if the data in the array is valid else FALSE.
''
',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

'Fuzzy wants address of array in DS:BX pair.
  InRegs.bx = VARPTR(PassArray(1))
  InRegs.ds = VARSEG(PassArray(1))
 
'Call the Fuzzy system through the interrupt system.
  CALL InterruptX(IntNum, InRegs, OutRegs)
 
'Fuzzy returns error code in AX.  If AX does not equal 0, an error
' occurred.
  IF OutRegs.ax <> 0 THEN
     DoFuzzy = FALSE
  ELSE
        DoFuzzy = TRUE
  END IF

END FUNCTION

SUB FillArrayWithNewInputs
'This sub needs created.
END SUB

FUNCTION LoadFuzzySystem
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''
' Function loads the Fuzzy system into memory and hooks the selected
' interrupt.  This must be called before calling DoFuzzy.
'
'       Passed  - Nothing
'       Returns - TRUE if the Fuzzy system was loaded; else, FALSE.
''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  FileName$ = "Fuzzy.Com"
     'Change the file to whatever you used when you generated the file.
  DIM ParameterBlock AS LONG
     'Set up four bytes that DOS needs to load the Fuzzy system.
     'Bytes 0 & 1 holds the segment, 2 & 3 the relocation factor.
  
  FileNumber% = FREEFILE

 
     68    Assembly Applications





     'Get the next file number that can be used.
  OPEN FileName$ FOR BINARY AS FileNumber%
     'Open the file to find out its size.
  BytesNeeded& = LOF(FileNumber%) + 16
     'Get the number of bytes needed to load the system.
     ' Add 16 to ensure we can get to paragraph boundary.
     'Assumes the file size is less than 65520 bytes
  CLOSE FileNumber%
     'Close the file.
  BytesGot& = SETMEM(0)
     'Ask Basic how much is in far heap.
  IF (BytesGot& < BytesNeeded&) THEN
     LoadFuzzySystem = FALSE
       'Not enough memory in far heap so return FALSE.
  ELSE
     BytesGot& = SETMEM(0 - BytesNeeded&)
       'Ask Basic to release the memory from its far heap.
     InRegs.ax = &H4800
       'Basic released memory; now tell DOS to allocate it.
     InRegs.bx = BytesNeeded& \ 16
       'Number of paragraphs needed to BX.
     CALL InterruptX(&H21, InRegs, OutRegs)
    
     IF (OutRegs.flags AND &H1) THEN
       LoadFuzzSystem = FALSE
          'DOS could not allocate the memory.
     ELSE
       MemorySeg% = OutRegs.ax
          'DOS returns the segment in the ax register (offset = 0).
          ' Save it so it can be returned before you leave
          ' your program.
       InRegs.ds = OutRegs.ax - &H10
          'Need the offset of interrupt vector at 0100 hex so
          ' subtract 10 hex from segment.
       InRegs.dx = &H100
          'Offset to dx.
       InRegs.ax = &H2500 OR IntNum
          'Dos function to set interrupt vector.
       CALL InterruptX(&H21, InRegs, OutRegs)
          'Set the interrupt vector to point to the Fuzzy system.
       InRegs.ax = &H4B03
          'Use DOS function 04B to load the Fuzzy 
          ' system into memory.
       ParameterBlock = MemorySeg%
          'Offset address to bytes 0 & 1, 0 to bytes 2 & 3.
       InRegs.bx = VARPTR(ParameterBlock)
          'Offset of info block needed by DOS to load program to BX.
       InRegs.es = VARSEG(ParameterBlock)
          'Same for the segment.
       FileName$ = FileName$ + CHR$(0)
          'DOS needs a hex 0 at end of the file name.
       InRegs.ds = VARSEG(FileName$)

                    
                                                 Assembly Applications     69     





          'Need the segment of file name in DS.
       InRegs.dx = SADD(FileName$)
          'The offset in DX.
       CALL InterruptX(&H21, InRegs, OutRegs)
          'Tell DOS to load the program into memory.
       IF (OutRegs.flags AND &H1) THEN
          LoadFuzzySystem = FALSE
            'DOS returned error.  Return FALSE.
       ELSE
          LoadFuzzySystem = TRUE
            'All ok.  Program loaded and ready to use.
       END IF
     END IF
  END IF
END FUNCTION

SUB ReleaseDosMemory
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''
' Sub calls DOS to release the memory got by LoadFuzzySystem back to
' the system then to Basic heap.  This must be called when done with the
' Fuzzy system.  Once the memory is released, the Fuzzy system no longer
' exists and should not be called.
''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  InRegs.ax = &H4900
     'DOS function to release memory.
  InRegs.es = MemorySeg%
     'Segment address to ES.
  CALL InterruptX(&H21, InRegs, OutRegs)
     'Release it.
  Required& = SETMEM(&HFFFF)
     'Return the memory to Basic.  The maximum size of the memory
     '  got  is  64K  bytes,  so  pass  that  size  to ensure everything
returned.
END SUB

















 
     70    Assembly Applications





             Chapter 8 - Application Generation (C Code)

  Before  generating  your  application, ensure that all the graphs and
  rules  defined  are  actually needed.  This is not necessary but does
  ensure the smallest and fastest application. 
  
  If  the  data  in the session have been modified, you are asked if it
  should  be saved.  If you choose no, the modifications are discarded.
  The  application  generator uses the data in the file, not in memory.
  If changes are not saved, they will not be included.  If you chose to
  continue without saving, you are asked to verify the decision.  Enter
  the appropriate response.

        Will you be generating C code?
       Type    Y    if  you  will  be  generating  C  code.  If you are
       generating assembly, see chapter 7.

        File name to use for the application?
     Type the file name for the application.  The program appends the .C
     and  .H  extensions  to the files generated.  An error occurs if an
     extension is included.  

  Three files are produced and left on disk:   Files Produced
           YourName.C - Contains the code that is the basis of the fuzzy
                        system.
           YourName.H   - Contains  data  declarations, defines, and so
                          on used internally by the fuzzy system.
           FuzzSys.H    - T h e   same   as   YourName.H   except   the
                          declarations  are used by YourName.C and your
                          code. 



                               Using The C
                               Application


           To incorporate the fuzzy system into your program:

            Add YourName.C to your make file (where YourName is the name
          you gave the application).  
            Add  FuzzSys.H  to  any  of  your  files  that  access  the
          inputs/outputs of the fuzzy system.










                    
                                                      C Applications     71     





                                 To use:

           Set up two  arrays:
            Input array   -    u se  type  FuzzyInputVals  (defined  in
FuzzSys.H)
            Output array  -   use   type   FuzzyOutVals   (defined   in
FuzzSys.H)

            Fill  the  input  array  with  the  new  input values.  (See
          FuzzySys.H for array organization).

           Call FuzzyMain() (the fuzzy system s entry point) passing the
          address of the input array as the first parameter, the address
          of the output array second.
              FuzzyMain(&YourInputArray, &YourOutputArray);

            Using  the  values  in  YourInputArray,  the  fuzzy  system
          c a l culates  the  new  output  values  and  stores  them  in
          YourOutputArray.

            The  fuzzy  system  returns  a  non-zero  value  if no error
          occurred during processing; zero if an error occurred. 
                 I f    F uzzyTrue  is  returned,  the  values  in  the
              YourOutputArray  are  the outputs calculated by the fuzzy
              system.
               If FuzzyFalse is returned, the values in YourOutputArray
              are not valid and should not be used.


                                 CAUTION
     Unless  you  have  studied the fuzzy system throughly, do not
     modify  any  of  the  fuzzy  system s data structures or code
     listings.    It is up to you to ensure that any modifications
     you make do not affect the system s performance.
                                 CAUTION



                           Before Generating C
                                  Code


         To  increase speed, applications do not calculate fuzzy values
       or  centroids.    Instead,  a table is used.  Resolution X and Y
       directly   affect  the  size  of  this  table.    Although  data
       compression  is used, in general, the higher the resolution, the
       larger  the  table.    Use  the  smallest resolution possible to
       achieve the correct output shape.
        Generally, additional rules require less memory than additional
       graph/shapes.   For minimum size use additional rules instead of
       adding shapes.
         The more rules, the longer it takes the application to process


     72    C Applications





       the data.  To increase the speed, decrease the number of rules.
         Rules  combined  with  the OR operator require less memory and
       processing time than two separate rules.  When possible, combine
       rules that use the same outputs/shapes.
         If  an  output does not receive a new value (none of the rules
       that fired contained the output), the value from the last run is
       written/returned.
         If the application receives an input value which is not in the
       graph  (for example, hex start = 7, value received = 5), it will
       always  have  a  fuzzy value of 0; thus, it has no affect on the
       output.
         The  application  will not write/return a value that is not in
       the graph (for example, calculated output value = 5, hex start =
       7, value written/returned = 7).
         Minimum  requirements  to  generate  an  application  are  one
       input/output with one shape each and one rule.





































                    
                                                      C Applications     73     





                                  NOTES

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________












     74    C Applications





                         Chapter 9 - Starting New

  To  start  a  new  system by erasing all data in the current session,
  press  F6  at  the  main menu.  You are asked if you want to save the
  current  session.  If you select no, you are asked to verify that you
  want  to  discard  all data. Select 'N' to return to the menu, 'Y' to
  erase.





                       Chapter 10 - Standard Menus

  The  following  applies to the selections displayed below ESC in each
  pull-down menu. 

  (F7) Directory Listing

     Displays the files in the current directory.  You are asked for the
     extension of the file(s) to use as a filter.  DOS wildcards * and ?
     are  permitted.  The period is not required (for example, doc, ?oc,
     *).    

  (F8) Display Graph/Shape Names

     Displays all graphs/shapes defined in the current session.

  (F9) Save File

     Takes you to save file function as outlined in Chapter 6.

  (F10) Help

     A  sub  menu  is  displayed.  Press 'E' for an explanation of error
     messages, or, for help on a menu selection, press the corresponding
     function key. 
















                    
                                             Start New & Standard Menus     75     





                                  NOTES

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________













     76     Start New & Standard Menus





                       Chapter 10 - Error Messages


  If  an error is detected, one of the following messages is displayed.
  The  program  waits for any key to be pressed before continuing.  The
  error number is given within the <>.

  <1> No data entered.
     You  are  requesting  a  selection that relies on data that are not
     present.
 
  <2> Must increase graph/shape before proceeding.   
     You  are requesting a function that requires a minimum of one input
     and  output  with  at  least  one  shape  each.  Add the graphs and
     shapes.

  <3> No rules have been specified.
     The rules must be entered before the request can be fulfilled.

  <4> No file loaded.
     Your  request cannot be fulfilled until you load a file.  This also
     can  occur  if you are requesting the application generator without
     saving the current session and no file was previously loaded.

  <5> Names cannot contain spaces or ( ).
     The  name  you  specified contains space(s) or parentheses.  Retype
     the name.

  <6> Names must begin with a letter.
     You specified a name for a graph or shape that did not begin with a
     letter.

  <7> Name must be specified.
     A name was requested but none was entered.  Type a valid name.

  <8> The name is already in use.
     All names for graphs and shapes must be unique.  Change the case of
     one or more of the letters.

  <9> Unable to create extension.
     You are either attempting to add an extension to an input which was
     previously  extended, or trying to extend an output.  See Chapter 3
     under Graph Extensions.

  <10> Invalid name.
     The  name  could not be found in the current session or did not fit
     the  expected type (for example, shape name was entered but a graph
     name was expected).  Check the spelling and redo.

  <11> Change value at other end.
     The  values  at  the  beginning  of the graph must be less than the


                    
                                                      Error Messages     77     





     corresponding values at the end of the graph.  Graph value start is
     less than graph value end and hex at start is less than hex at end.
     Correct the value.

  <12> Maximum number of graphs already specified.
     The maximum number of inputs plus outputs is 12.  Maximum number of
     outputs is 8.  You are attempting to add another.

  <13> Maximum number of shapes has been reached.
     The  maximum  number  of  shapes  per  graph  is  eight.    You are
     attempting to add the ninth.  If you need more shapes to completely
     specify an input, add a graph extension.  See Chapter 3 under Graph
     Extensions.

  <14> Shape values cannot be used.
     You  added or modified a shape but the new data was not acceptable.
     Shapes can be trapezoids/rectangles or triangles. 

  <15> Value(s) are unusable.
     This is a catchall error that indicates that the values you entered
     did  not  meet  what  was expected (for example, program expected a
     number but got a character).  Re-enter the data.

  <16> Invalid logic in rule.
     There  is  something  wrong  with  the  rule's  logic.  Valid logic
     includes  IF,  OR,  AND, NOT (!), and THEN.  This may also indicate
     that the operators are being used incorrectly.

  <17> Rule contains an invalid name.
     You  have  probably  misspelled  either  a  graph  or a shape name.
     Remember that names are case sensitive and must be enclosed in ( ).
     Check the names.

  <18> Rule has operators on output side.
     You  are  trying to use an operator on the output side of the rule.
     Remove the operator.

  <19> Output specified on the input side of the rule.
     Remove the output name from the input side of the equation.

  <20> Input specified on the output side of the rule.
     Same as above but an input is used as an output.

  <21> Rules min/max length violated.
     The  minimum  for  any rule is at least 1 input and 1 output.  Redo
     the rule.

  <22> Incorrect number of outputs.
     Outputs can be used once per rule.  Re-enter the rule.

  <23> Rule contains error.
     This  is  a  catchall message.  An error was found in the rule that

  
     78     Error Messages    





     did not fit the categories above.  Check the rule for syntax.

  <24> The maximum number of rules have been entered.
       The maximum number of rules allowed is 200.  If more are needed,
       combine as many rules as possible using the OR operator.

  <25> (Number) rules became invalid and were removed.
     While  in  graphing,  graphs/shapes  were  deleted  or  names  were
     changed.    Due  to the modifications, the rules became invalid and
     were removed.

  <26> No file exists with the extension.
     You are requesting directory information and using a file extension
     as a filter.  No files with the extension were found.  Re-enter the
     correct extension or use '*' to display all.

  <27> File name is reserved.
     You are attempting to use a file name that the program uses. Change
     at least one of the characters and redo.

  <28> Could not read, write, open, close, file.
     These  messages  indicate  that  an attempt was made to perform the
     function but the request could not be fulfilled.  The errors can be
     caused by a variety of reasons:
            The file does not exist.
            Disk cannot be accessed or is full.
            The file's data was corrupted (see Error 32).
     In general, there is something wrong with the file/disk.

  <29> Unable to open temporary file.
     The  program  was  unable  to open/create a file to store temporary
     data.  See above.

  <30> Unable to write learn file.  Mode deactivated. 
     The  program  attempted  to  write data to the learn file but could
     not.    Depending  on the error's severity, the file's contents may
     not  be  valid.    To prevent further errors, learn is deactivated.
     See Error 28 for possible reasons.

  <31> File(s) do not exist.
     You  input  one or more file names for the program to use, but they
     are not in the current directory.  You may have misspelled the name
     or not included the file's extension.  Retry.

  <32> File format is incorrect.
     The  program  attempted  to load the file but its contents were not
     usable.  The only files that can be loaded are those created by the
     program.    Check the file name.  If it is correct, the file's data
     is unusable.




                    
                                                      Error Messages     79     





  <33> Learn not active.
     You  are  requesting  a  function that requires learn to be active.
     Select activate, F1, from the learn sub menu.

  <34> Printer is not responding.
     The  printer  is not accepting data.  Correct the problem and press
     return.  If the problem cannot be corrected, press ESC to cancel.

  <35> Not enough memory to fulfill request.
     The  program  requested additional memory but the request could not
     be filled.  This can be caused if too many programs are loaded (for
     example,  TSRs),  the machine having insufficient memory installed,
     or  by  Error  47 being displayed and you choose to continue.  Save
     the  current  session,  exit  the program, correct the problem, and
     restart.

  <36> An internal error occurred.
     The  program  found  an  error that should never occur. You have no
     choice  but  to  press  any  key  to  abort.  The program exits and
     returns  control  to  DOS.  If this error is displayed, please note
     any additional information and let us know.

  <37> An error occurred.  Retry (Y/N)?
     An  error  message  was  previously  displayed.   Select 'Y' if the
     program should try again.

  <38> Closest usable value is X.
     The  value  you picked for resolution X or Y could not be used. See
     Chapter 3, F1, for information.

  <39> An unexpected error occurred during execution.
     Your options depend on the error.

            Retry
       If  the  message  indicates  you  have  the  option of retrying,
       pressing  'R'  returns you to the point in the program where the
       error occurred.
            Abort
       Pressing  'A'  returns  you  to  the  main  menu  or, if you are
       generating  an  application,  returns  you  to  the  DOS prompt.
       Depending  on  where  the error occurred and the severity of the
       error,  the  current  session's  data  may  not be valid and the
       program's  status is unknown.  Unless you are in the application
       generator,  you  are  not  forced  to exit the program but it is
       highly  recommended  that  you  do.    Before  exiting, save the
       session under a different name from the original.  Exit then re-
       enter  the  program.  Reload the file and verify the data before
       continuing.

     Possible errors:

            Unrecoverable error

  
     80     Error Messages    





       This  message is displayed when the problem cannot be corrected.
       Errors  include  math  errors  (for  example,  divide  by 0) and
       processor errors. 
            DOS Error
       The  operating  system  detected  an  error  while attempting to
       access  a  device (for example, disk not in drive).  Correct the
       problem and choose retry.
            Break Pressed
       Ctrl break was pressed.  If you want to exit the program, choose
       abort to return to the main menu.

  <40> An unknown problem occurred (rest of message).
     The  program  attempted  to  fulfill your request but the operating
     system returned an error.  Retry the selection.

  <41> Cannot find Fuzz.One.
     You are requesting the function to generate an application, but the
     file  required  is  not  in  the  current  directory,  DOS path, or
     FuzzyOne's directory.  Exit the program (or use selection F4 in the
     file menu) and move Fuzz.One.

  <42> The application is larger than 64K bytes.
     The  maximum  size of an application is 64K bytes.  After combining
     everything  (required  tables,  fuzzy  code,  and,  if  applicable,
     interface   code)  the  limit  was  surpassed.    To  generate  the
     application,  you  must decrease either the size of the tables (see
     Chapter 7 for suggestions) or the interface code.

  <43> Error setting video mode.
     The  program was unable to set the video mode.  Your video hardware
     must be CGA, EGA, or VGA.  See error 45.

  <44> No shapes entered.
     You  are  requesting a selection that requires shapes.  Specify the
     shapes, then retry.

  <45> Video hardware is not recognized.
     The  program could not identify your video hardware as CGA, EGA, or
     VGA.   You will be asked which of the three is compatible with your
     system.    If  you  are  unsure, check your hardware documentation.
     Your  selection  will  be  stored.    If desired, the option can be
     changed  by  deleting the configuration file, FuzzyOne.cfg, located
     in the same directory as the program.

  <46> Insufficient memory to execute FuzzyOne.
     There  is not enough memory available for the program to run.  Free
     memory and retry. (See Error 35)

  <47> Due to problem, session's data may not . . .
     Error  39  was  displayed  and you chose abort.  This is a reminder
     that  you  should exit and re-enter the program.  Press 'Y' to exit
     the  program  immediately (You will not be given the option to save

                    
                                                      Error Messages     81     





     the current session.), 'N' to continue.

  <48> DOS version must be 3.0 or above.
     The version of DOS you are using is too low.  Change to version 3.0
     or above.

  <49> Name cannot be longer than original.
     When a graph or shape is renamed, the length of the new name cannot
     be longer than the original.

  <50> Only files in current dir can be used.
     The  program  only works with files in the current directory.  Exit
     the program, move the file, and re-enter.

  <51> Could not verify rules.
     While  in  graphing,  graphs/shapes  were  deleted  or  names  were
     changed.    Due  to a file error, the program could not verify that
     the  rules were still valid (see Error 25).  Enter the rule section
     and delete/modify the rules as needed.


































  
     82     Error Messages    





                   Appendix A - Reference Literature



                               Fuzzy Logic


ORIGINAL PAPERS

 -   Zadeh, Lotfi, "Fuzzy Sets," Information and Control 8:338-353, 1965

 -   Zadeh, Lotfi, "Outline of a New Approach to the Analysis of Complex
     Systems," IEEE Trans. on Sys., Man and Cyb. 3, 1973

 -   Zadeh,  Lotfi,  "The Calculus of Fuzzy Restrictions," in Fuzzy Sets
     and  Applications  to  Cognitive  and  Decision  Making Processes,"
     Academic Press, New York, 1975, pages 1-39.


ARTICLES/PAPERS
 
 -   Brubaker,  David, "Fuzzy-Logic System Solves Control Problem," EDN,
     June 18, 1992.

  -  Brubaker,  D.I.,  "Fuzzy-Logic  Basics:  Intuitive  Rules  Replace
     Complex Math," EDN, June 18, 1992. 

 -   Klir,  George,  "Generalized  Information  Theory,"  Fuzzy Sets and
     Systems 40:127-142, 1991.

 -   Kosko,  B.,  "Fuzziness  vs. Probability," International Journal of
     General Systems 17(2-3):211-240,1990

 -   Moss,  Bud,  "Fuzzy  Logic  -  Evolution  or  Hype,"  The  Computer
     Applications Journal, March, 1995.

 -   Moss,  Bud,  "Fuzzy  Logic  -  The  Next  Generation  of  Control,"
     MicroComputer Journal, November/December, 1994.

 -   Puri, M.L., and Ralescu, D.A., "Fuzzy Random Variables," Journal of
     Mathematical Analysis and Applications, 114:409-422, 1986.

 -   Roberts,  D.W.,  "Analysis  of  Forest  Succession with Fuzzy Graph
     Theory," Ecological Modeling, 45:261-274, 1989.

 -   Z a d eh,  Lotfi,  "Fuzzy  Sets  as  the  Basis  for  a  Theory  of
     Possibility," Fuzzy Sets and Systems 1:3-28, 1978.






                    
                                                 Reference Literature     A-1     





BOOKS

 -   Dimiter  Driankov,  Hans  Hellendoorn,  and  Michael Reinfrank, "An
     Introduction to Fuzzy Control," Springer-Verlag, New York, 1993.

 -   Dubois,  Didier,  and Prade, Henri, "Fuzzy Numbers: An Overview," *
     Analysis of Fuzzy Information 1:3-39, CRC Press, Boca Raton, 1987.

 -   Dubois, Didier, and Prade, Henri, "Mean Value of a Fuzzy Number," *
     Analysis of Fuzzy Information 1:3-39, CRC Press, Boca Raton, 1987. 
     * Volume  1  of  3.    Papers presented orally at IFSA conference,
       July, 1984.

 -   Earl  Cox,  "The  Fuzzy Systems Handbook: A practitioner's guide to
     building,  using,  and  maintaining fuzzy systems," Academic Press,
     1994.

 -   Kaufmann,  A., and Gupta, M.M., "Introduction to Fuzzy Arithmetic,"
     Reinhold, New York, 1985.

 -   Kosko,  Bart,  "Fuzzy  Thinking:  The  New Science of Fuzzy Logic,"
     Warner, 1993.

 -   McNeill,  Daniel, and Freiberger, Paul, "Fuzzy Logic: The Discovery
     of a Revolutionary Computer Technology," Simon and Schuster, 1992.

 -   Negoita,  C.V.,  "Fuzzy  Systems,"  Abacus  Press, Tunbridge-Wells,
     1981.

 -   Smithson, Michael, "Ignorance and Uncertainty: Emerging Paradigms,"
     Springer-Verlag, New York, 1988.

 -   Wang, Zhenyuan, and Klir, George J., "Fuzzy Measure Theory," Plenum
     Press, New York, 1991.

 -   Yager,  R.R.,  and  Zadeh,  L.A.,  "An  Introduction to Fuzzy Logic
     Applications  in  Intelligent Systems," Kluwer Academic Publishers,
     1991.


                             TSR Generation


 -   Tischer,  Michael,  "PC  System Programming," Abacus, Grand Rapids,
     MI, 1989.

 -   Tischer,  Michael,  "PC  Intern  System Programming," Abacus, Grand
     Rapids, MI, 1992.

 -   Wadlow,  Thomas,  "Memory  Resident  Programming  on  the  IBM PC,"
     Addison-Wesley, Reading, MA, 1987.


 
     A-2     Reference Literature   


























































                    
                                                 Reference Literature     A-3     





                                  NOTES

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________












 
     A-4     Reference Literature   











                           Appendix B - Key List




      Main                                                  Redo Rules
F1  - Work With Graphs                               F1  - Advance To Next Rule
F2  - Work With Rules                                F2  - Redo This Rule
F3  - Simulate Data                                  F3  - Remove This Rule
F4  - File And Print                                 F4  - Advance 5 Rules
F5  - Generate TSR                                   ESC - Return To Rule Input
F6  - Start A New Session                            
ESC - Exit Program                                          Simulation 
                                                     F1  - Manual Simulation
   Graphing                                          F2  - Display Next Output
F1  - Change/Add Graph                               F3  - Open Learn Menu
F2  - Remove Graph                                   F4  - Automatic Simulation
F3  - Work With Shapes                               F5  - Go To Rule Section
F4  - Redo Graph Data                                F6  - Go To Graphing Section
F5  - Change To Next Graph                           ESC - Return To Main Menu
F6  - Highlight Shapes                               
ESC - Return To Previous Menu                                  File
                                                     F1  - Save Session
Redo Graph Data                                      F2  - Retrieve Session
F1  - Change Name                                    F3  - Display/Print Data
F2  - Change Values Start/End                        F4  - Exit To DOS
F3  - Change Divisions X/Y                           ESC - Return To Main Menu
F4  - Change Graph Type                              
F5  - Change Graph Address                               Standard Menus
ESC - Return To Graphing Menu                        F7  - Directory Listing
                                                     F8  - Display Graphs/Shapes
      Rule                                           F9  - Save Current Session
F1  - Redo Rules                                     F10 - Help
F2  - Display Rules                                  
ESC - Return To Previous Menu                        












                    
                                                         Key List     B-1     





                                    Index

 Application Generation                     Resolution X/Y 16
  Data table/compression 17                 Resolution   X/Y   Affect   On
  C Code Generator 71                         Shapes 11, 16, 19
  Data table/compression 17                 Resolution   X/Y   Affect   On
  Files Produced 71                           Simulation 6, 9, 16
  Graph Address Unused 17                   Resolution  X/Y  Affect On TSR
  Incorporation 71                            17, 43
  Input Not In Graph 73                     Type 15
  Minimum Requirements 73                   Value Start/End 15, 16
  Optimization 71, 72                     Help
  Output Calculation 73                     Hours 2
  Output  Did  Not Receive Value            In Program 75
    73                                      International 3
  Resolution  X/Y Affect On Size            Methods 2
    72                                      Interrupt
  Specifying Name 71                        Displaying Information On 42
  Using 72                                  Selecting 42
  Value Returned 72                       Learn Mode
  Error                                     Activate 28
  Messages 77-82                            And Auto Sim 28, 34, 35
 File                                       And Extensions 20, 36
  Demo.Get 12, 47, 52                       And Manual Sim 32
  Demo.Put 12, 47, 52                       Deactivate 28
  Displaying 39                             File Explanation 8, 32-34, 36
  Fuzzy.Doc 28, 39                          Menu 28
  FuzzyOne.cfg 81                           Printing 29
  Get.Com 43                              Minimum Requirements
  Loading 6, 39                             For Program 5
  Names 6                                 Printer
  Printing 6, 39                            Printing Data 29, 39
  Reserved Name 39                        Program
  Saving 39                                 And Data Compression 17
  FuzzyOne                                  Assembly Example 59
  Overview 1                                Basic Example 67
  Graphing                                  BIOS/DOS Used 44
  Acceptable Resolution X/Y 16              C Example 62
  Addresses 9, 17, 20                       Communication 51
  Changing 15, 20                           Defined 41
  Creating  Extensions  10,  11,            Errors 51
  17, 20, 21                                Graph Address Unused 17
  Deleting 18                               Input Not In Graph 44
  Deleting Extensions 20                    Interrupts Used 44
  Hex Start/End 15, 16                      Minimum Requirements 44
  I/O (Port) Addresses 17, 18               Optimization 43, 44
  Inputs/Outputs    With    Same            Output  Did  Not Receive Value
  Address 20                                    44
  Maximum Allowed 15                        Passed Array 51, 52
  Names 15, 36                              Passed Array Size 52
  Redo Values 19                            Preserving Registers 51


                    
                                                           Index     I-1     





  Quick Basic Example 67                    To Graphing 30
  Returned Value 44, 51                     To Rules 30
  Selecting 42                              Translating Fuzzy values 36
  Stack 44                                Standard
  Type 45, 49                               Menus 5, 75
 Rules                                    Truncating
  And "AND" 24                              Names 15
  And "NOT" 25                              Values 15, 36
  And "OR" 25                             TSR
  And Extensions 20                         Activating 44, 45
  And Inputs 24                             Active Continuously 41
  And Outputs 24                            And Critical Operation 45, 46,
  And Spaces 24                               48, 51
  Becoming Invalid 11, 12, 20               And Data Compression 43
  Deleting 23                               Assembly Example 54
  Displaying 7, 24, 27                      C Example 56
  Editor 7                                  Communication 51
  Example 23                                Deactivating 44
  Firing 8, 27                              DOS Tick 41
  Length 24                                 Errors 51
  Maximum Entered 23                        Graph Address Unused 17
  Maximum/Average Mode 25                   Including Code 42, 43, 45, 52
  Modifying 7, 23                           Input Not In Graph 44
  Operators 24                              Input Processor 48, 52
  Requirements 24                           Interrupt 41
 Shapes                                     Interrupt Selection  42
   Adding 10, 18                            Loading 44
   Deleting 18                              Minimum Requirements 44
   Highlighting 6, 20                       Optimization 41, 43, 44
   Maximum Allowed 10, 15                   Output  Did  Not Receive Value
   Modifying 10, 18, 23                      44
   Names 18, 19                             Output Processor 52
   Rectangles 10, 17                        Passed  Array  43, 48, 49, 51,
   Simulation                                 52
   And Extensions 20                        Passed Array Size 52
   Automatic 8, 9, 29                       Preserving Registers 51, 52
   Automatic With Learn Active 9            Program Segment Prefix 52
   Automatic With Multiple Inputs           Quick Basic Example 57
    11, 29                                  Returned Value 44, 51, 54, 56,
   Changing Output 7, 28, 29                 57
   Direct Control 7, 27                     Returning  From  Your Code 49,
   Fuzzy Values 33, 36                       52
   Maximum/Average Mode 25                  Selecting 42
   Method Used 28, 33                       Specifying Name 43
   No Rules Fired 31, 32                     SS:SP 52
   Output Calculation 28                    Stack Size 52
   Output Graph Explanation 9, 31           System Resources Used 45
   Output Indicator 8, 27                 Type  -  No  Timer No Code Via
   Outputs not on division 36               Interrupt 49
   Overlaying Output Graph 9, 29          Type  - No Timer With Code Via
   Purpose 27                               Interrupt 51
   Show Input/Output Values 9, 29          Type   -   Timer   Used   Code
           
I-2     Index





  Included 12, 47                   
  Type - Timer Used No Code 45
 Video
   Hardware 5, 81
   Xcentrics
   Address and Phone 1














































                    
                                                           Index     I-3     
