SDKC Operating Modes Manual p. 3gdedel95.free.fr/IUT/AII/Cours/AI/Annexes-PDF-AI/manuel...This...

236
___________________________________________________________________________ 1 Contents ENGLISH SDKC Operating Modes Manual p. 3 Manuel modes opératoires SDKC p.121 FRANÇAIS

Transcript of SDKC Operating Modes Manual p. 3gdedel95.free.fr/IUT/AII/Cours/AI/Annexes-PDF-AI/manuel...This...

  • ___________________________________________________________________________1

    Contents

    Section Page EN

    GLI

    SH

    SDKC Operating Modes Manual p. 3

    Manuel modes opératoires SDKC p.121

    FR

    AN

    ÇA

    IS

  • ___________________________________________________________________________

    2

    Contents

    Section PageEN

    GLI

    SH

  • ___________________________________________________________________________3

    Contents

    Section Page EN

    GLI

    SH

    1 Introduction 9

    1.1 Introduction 9

    1.2 Installation 101.2-1 Target machine 101.2-2 PL7 SDKC product contents 111.2-3 Installation procedure 11

    2 Methodology for creating and using an EF in PL7 13

    2.1 Creation 152.1-1 The EF family 152.1-2 The EF class 152.1-3 The EF 16

    2.2 Automatic version management 17

    2.3 Generating the family in debug mode 17

    2.4 Installing/Uninstalling in the PL7 library for debugging 17

    2.5 Creating an application using the new EFs 18

    2.6 Testing each EF in PL7 18

    2.7 Generating the family in release mode 18

    3 Managing the EF using PL7 SDKC 19

    3.1 Creation 193.1-1 The EF family 193.1-2 The EF class 213.1-3 The EF 23

  • ___________________________________________________________________________

    4

    Contents

    Section PageEN

    GLI

    SH

    3.2 Generating the family in debug mode 28

    3.3 Generating the family in release mode 29

    3.4 Installing/Uninstalling in the PL7 library 30

    4 Testing the EF using the debugging tool 31

    4.1 Accessing EF debugging 314.1-1 Selecting the family of the EF to be tested 314.1-2 Opening the EF debug screen 31

    4.2 Presentation of the tool 33

    4.3 Debugging EFs 344.3-1 Inserting and removing breakpoints 344.3-2 Mixing C code and assembly language 354.3-3 Registers 354.3-4 Local variables 36

    5 Additional SDKC functions 39

    5.1 Setting the tool parameters 39

    5.2 Modifying a family 40

    5.3 Importing/Exporting 415.3-1 Class 415.3-2 C Source 42

    5.4 Archiving/Restoring a family 445.4-1 Archiving 445.4-2 Restoring 455.4-3 Restoring from 46

    5.5 Printing 46

  • ___________________________________________________________________________5

    Contents

    Section Page EN

    GLI

    SH

    6 The EF code 49

    6.1 Rules for implementing EFs 496.1-1 C Language 496.1-2 Managing family and EF versions 536.1-3 Managing the size of the stack 546.1-4 Using floating point numbers 54

    6.2 List of reserved words 56

    7 System functions 59

    value = rd_sysbit ( sysbit_range , status ) 62

    status = wr_sysbit ( sysbit_range , value ) 63

    value = rd_sysword ( sysword_range , status ) 64

    status = wr_sysword ( sysword_range , value ) 65

    value = rd_bit_attrib ( address ) 66

    value = rd_bits ( address , number , status ) 68

    status = wr_bits ( address , number , value , type ) 69

    value = rd_16bits ( address ) 71

    wr_16bits ( address , value ) 72

    value = rd_1bit ( address ) 73

    wr_1bit ( address , value ) 74

    result = phy_ptr_init ( sel_off ) 75

  • ___________________________________________________________________________

    6

    Contents

    Section PageEN

    GLI

    SH

    status = date_and_time ( date_ptr ) 76

    value = cnt_100ms ( void ) 78

    value = cnt_10ms ( void ) 79

    info = proc_type ( void ) 80

    info = proc_indic ( void ) 81

    Res = ADD ( a, b ) 82

    Res = SUB ( a, b ) 83

    Res = MUL ( a, b ) 84

    Res = DIV ( a, b ) 85

    Res = EQU ( a, b ) 86

    Res = SUP ( a, b ) 87

    Res = INF ( a, b ) 88

    Res = ABS ( a ) 89

    Res = CHS ( a ) 90

    Res = SQRT ( a ) 91

    Res = FTOL ( a ) 92

    Res = LTOF ( a ) 93

    Res = EXP ( a ) 94

  • ___________________________________________________________________________7

    Contents

    Section Page EN

    GLI

    SH

    Res = LN ( a ) 95

    Res = SIN ( a ) 96

    Res = COS ( a ) 97

    Res = TAN ( a ) 98

    Res = ASIN ( a ) 99

    Res = ACOS ( a ) 100

    Res = ATAN ( a ) 101

    8 Utilitary functions 103

    value = GET_FLOATPL7 ( fvalPl7 ) 104

    fvalPl7 = FLOAT_TOPL7 ( f ) 105

    value = FLOAT_TO_DBG ( f ) 106

    FLOAT_SETVALUE ( selector, offset, value ) 107

    WORD_SETVALUE ( selector, offset, value ) 108

    DWORD_SETVALUE ( selector, offset, value ) 109

    ptr = GET_ADDR ( selector, offset ) 110

    9 Appendix 111

    9.1 Example 1119.1-1 Defining the EF 1119.1-2 Generating a diskette and installing the family 116

  • ___________________________________________________________________________

    8

    Contents

    Section PageEN

    GLI

    SH

    9.2 Keyboard equivalents 116

    9.3 In the event of a problem 117

  • Introduction

    ___________________________________________________________________________9

    EN

    GLI

    SH

    1.1 Introduction

    An EF (Elementary Function) is a function, designed to fulfil a certain task in the userprogram.

    As it will in due course form part of the PL7 library, like the manufacturer functions, itcan be used in an identical way :

    • accessible in all languages

    • display via the PL7 library tool

    • classified in families/functions

    The development kit in "C" language (PL7 option) is designed to implement the entiredevelopment cycle of an EF family :

    • management of an EF family (creation, modification)

    • development of each EF in “C” language

    • individual debugging of an EF in the target PLC (TSX 37 or TSX 57)

    • generation of an installable form containing the new EF family to be installed in thePL7 library, as well as its installation procedure on a user station.

    The ability to execute an EF on a given PLC depends on the version of the target PLCchosen when this EF was generated (see section 2.1-3).

    EFs created and intended for version 3.0 or later PLCs (with or without coprocessor), cancontain floating point calculations.

    Users of this product will be systems developers and therefore will necessarily befamiliar with :

    • “C” language for development,

    • PL7 (Micro, Junior, Pro) and their languages for debugging.

    Using the access key (*) supplied with the kit, it is possible to manage 5 families (upto 25,500 functions per family) using a code which varies according to the family.These codes are allocated by the manufacturer and are unique, which means thatthe family numbers are exclusive.

    Section 11 Introduction

  • Introduction

    ___________________________________________________________________________10

    EN

    GLI

    SH

    This manual comprises the following sections :

    • Section 1 "Introduction"

    • Section 2 "Methodology for creating and using an EF in PL7"

    • Section 3 "Managing the EF using PL7SDKC"

    • Section 4 "Testing the EF using the debugging tool"

    • Section 5 "Additional SDKC functions"

    • Section 6 "EF code"

    • Section 7 "System functions"

    • Section 8 "Utilitary functions"

    • Section 9 "Appendix"

    1.2 Installation

    1.2-1 Target machine

    The SDK C operates on :

    • IBM PC or compatible microcomputer

    The minimum configuration is as follows :

    • microprocessor 486 DX 33

    • 32 Mb of RAM

    • 20 Mb available on disk

    • VGA monitor

    • COM serial port available (COM1 to COM4) for connecting to the PLC

    • Win95, NT operating system

    • PL7 Micro, Junior or Pro V3.0 minimum

    The typical machine configuration is as follows :

    • microprocessor Pentium at 33 Mhz

    • 48 Mb of RAM

  • Introduction

    ___________________________________________________________________________11

    EN

    GLI

    SH

    1.2-2 PL7 SDKC product contents

    The product which you have just received comprises :

    • installation diskettes (see the procedure on the following page)

    • this manual

    • a Visual C++ 5.0 software pack (supplied for reasons to do with MICROSOFTlicensing). This software must not be installed on the development station. It containsthe tools for generating and editing links used to compile the EF. These tools arealready incorporated on the installation diskettes of the PL7 SDKC product.

    1.2-3 Installation procedure

    The PL7 SDKC product should be installed on a development station, on which PL7Micro, PL7 Junior or PL7 Pro has already been installed.

    Once the diskette has been inserted into the drive, proceed with installation by meansof the following steps :

    • Open the Windows explorer, select drive (A) then double-click on setup.exe or in Runfrom the Start Menu, type a:\setup then click on OK.

    • Register your name and organization

    • Select the installation language

    • Enter the no. (your product's access key ) marked on the delivery box (*). This keyis used to access the five family codes assigned to the product. Installation cannotproceed if the number of this access key is incorrectly entered.

    (*) We strongly recommend making a note of the number of the access key onthe space provided on the following page.

    • Once installation is complete, simply double-click on the icon in the MODICON-TELEMECANIQUE directory to access PL7 SDKC.

    Warning : Following an updating or to a new installation of PL7 Micro, PL7 Junioror PL7 Pro, it is obligatory to proceed to a new installation of PL7 SDKC.

  • Introduction

    ___________________________________________________________________________12

    EN

    GLI

    SH

    Space reserved for recording your products' access key numbers

    1 ........................................................................

    2 ........................................................................

    3 ........................................................................

    4 ........................................................................

    5 ........................................................................

    6 ........................................................................

    7 ........................................................................

    8 ........................................................................

    9 ........................................................................

  • Methodology for creating and using an EF in PL7

    ___________________________________________________________________________13

    EN

    GLI

    SH

    Use

    r st

    atio

    n

    Dev

    elop

    men

    t sta

    tion

    The diagram below outlines the development cycle.

    PL7 SDKCGenerate familyin Debug mode

    error no error

    Develop Install the family onthe family the development station

    Generate family error in release mode

    no error Pl7 Micro/Junior/Pro

    Debug an EF

    EF family +Setup.exe

    Pl7 Micro/Junior/Pro

    EFlibrary

    The object of the following sections is to present the various screens which appearduring this development cycle.

    Section 22 Methodology for creating and using an EF in PL7

  • Methodology for creating and using an EF in PL7

    ___________________________________________________________________________14

    EN

    GLI

    SH

    Clicking on the PL7 SDKC icon displays the following initial screen :

    The left-hand side of this screen, which is empty the first time the kit is used, will be filledwith names of EF families, as they are created (Current and/or Archived).A family consists of one or more classes, which themselves consist of one or more EFsas shown by the diagram below :

    Family name

    Class1

    EF1 EF2

    Class2

    EF1 EF2 EF3

    A family is made up of 100 Classes maximum and 255 EFs per class. The class is anentity which is only used while developing the family and which will not be displayedin the PL7 Library tool.The version, filled in when the description of the family is defined, is as displayed in thePL7 Library tool.

  • Methodology for creating and using an EF in PL7

    ___________________________________________________________________________15

    EN

    GLI

    SH

    2.1 Creation

    2.1-1 The EF family

    It is possible to create a family by selecting the Create function from the Family menu.Five families can be created. They correspond to five codes supplied by the product.

    - The Description tabcontains the familycharacteristics.

    - The Datasheet tabis used to recordadditional informa-tion about the family.

    2.1-2 The EF class

    Once the family has been validated, by selecting the Create Class function from theUtilities menu, it is possible to create one of the classes authorized by the family (1 to100).

    - The Description tabcontains the classcharacteristics.

    - The Class.h tab isused to defineconstants, types orstructures common toall the EF in the class.

  • Methodology for creating and using an EF in PL7

    ___________________________________________________________________________16

    EN

    GLI

    SH

    2.1-3 The EF

    At the end of creation, the name of the class appears on the left-hand side of the screen,and an EF can then be created by selecting the function Create EF from the Utilitiesmenu. 255 EFs can be created per class (1 to 255).

    • The Description tab contains the EF characteristics.

    The ability to execute an EF on a given PLC depends on the version of the target PLCchosen in this tab (see the following table).

    Selection made at generation

    Target V < 3.0 V 3.0 or later V 3.0 or later (no coprocessor) (with coprocessor)

    PLC prior to V 3.0 Yes No No

    V 3.0 or later PLC Yes (if not used(no coprocessor) into a DFB) Yes No

    V 3.0 or later PLC Yes (if not used(with coprocessor) into a DFB) Yes Yes (Optimized)

    EFs created and intended for version 3.0 or later PLCs (with or without coprocessor), cancontain floating point calculations.

    • The Interface tab can be used to enter the EF call parameters.

    • The Source .C tab is used to write the EF C code.

    • The Source .H tab is used to define constants, types or structures specific to the EF.

  • Methodology for creating and using an EF in PL7

    ___________________________________________________________________________17

    EN

    GLI

    SH

    2.2 Automatic version management

    When the Generation Options ... function is selected in the Utilities menu, the followingdialog box is displayed, allowing the user to select the incrementation method for familyand class versions.

    The default option (recommended) is automatic incrementation.

    2.3 Generating the family in debug mode

    Generation is performed on the whole family.

    Once the family has been developed, it is advisable, at first, to generate it by selectingthe Generate Debug function from the Family menu. This then makes it possible to testone of the EF of the family.Generate means compile and then edit the links with the debug options of each EF ofthis family.

    Once generation is complete, a log file summarizing the errors and warnings (resul.log)is created (see section 3.1-3), and the user should return to the .C or .H source screensof any EF(s) which may be causing a problem.

    2.4 Installing/Uninstalling in the PL7 library for debugging

    Once the family has been generated without any errors (compilation or link editing),it is possible to launch the Install function from the Family menu so that it can be enteredin the PL7 library.

  • Methodology for creating and using an EF in PL7

    ___________________________________________________________________________18

    EN

    GLI

    SH

    The family which is being edited can be removed from the PL7 library. To do this, launchthe Uninstall function from the Family menu.

    This installation/uninstallation is only possible if PL7 (Micro, Junior or Pro) is notrunning (active elements in memory).

    2.5 Creating an application using the new EFs

    Once the family has been installed, PL7 (Micro, Junior or Pro) should be launched.The user should test the new EF(s), by developing an application which calls them, andthen transferring this application to the PLC.

    Since this application is designed to test behavior, it is advisable to include only onecopy of each EF to be tested.

    2.6 Testing each EF in PL7

    To test the EF in the application, select Debug EF from the Tools menu of PL7 (Micro,Junior or Pro).It is then possible to insert breakpoints, proceed step by step, display local variablesor registers, etc.If the tests are not conclusive, the user should return to the EF development environmentto review the process and restart the cycle described above.

    2.7 Generating the family in release mode

    Once all the tests on all the EF in the family have proved conclusive, it is then possibleto generate this family, for use, by selecting the Generate Release function from theFamily menu.This action makes it possible to create an installation medium for the selected family(diskette, local or networked hard disk directory, etc). This medium can then bebroadcast.

  • Managing the EF using PL7 SDKC

    ___________________________________________________________________________

    19

    EN

    GLI

    SH

    3.1 Creation

    3.1-1 The EF family

    (*) The value of VV (version) or RR (release) must be between 0 and 99 inclusive.

    Section 33 Managing the EF using PL7 SDKC

    A familynumber willbe assignedautomatically(any of the 5possible)

    Entry of the family name(24 characters)

    Used to manageupdating of the familyby entering a VV.RR (*)type number

    Integer beginningat 1. This is usedto manageupdates whichwould make thetexts (familydatasheet andc o m m e n t s )incompatible

    In family display mode,this will display thecreated and/or archivedfamilies in the list (seesection 5.4)

    Create opens theFamily area defined bythe "Description" tab fordata entry

  • Managing the EF using PL7 SDKC

    ___________________________________________________________________________20

    EN

    GLI

    SH

    Clicking on the "Datasheet" tab opens the following area :

    This area where text can be entered (optional), is used to note down the main dataconcerning the family.This datasheet can, for example, be used to enter log data on the versions of the family.This datasheet only appears in PL7 if there is a conflict in versions between a familyin the library and the same family in the application.

    It is possible to delete a family using the Delete command from the Utilities menu. Whena family is deleted, its contents (class(es) and EF(s)) are also deleted.

    The family is validated by this button, butonly if all the fields in the "Description" tabhave been filled in correctly

  • Managing the EF using PL7 SDKC

    ___________________________________________________________________________

    21

    EN

    GLI

    SH

    3.1-2 The EF class

    (*) The value of VV (version) or RR (release) must be between 0 and 99 inclusive.

    Classes which belong to the same family must, without fail, have different names andcodes.It is only possible to exit from the description tab once all the fields have been filled in.This action confirms the parameters entered.

    It is possible to delete a class using the Delete command from the Utilities menu. Whena class is deleted, the EF(s) which it comprises are also deleted.

    Reminder of theparameters defined forthe family (read-only)

    Number between 1and 100 inclusiveused to ensure theuniqueness of theclass developed. It isfilled in automatically

    Used to enter the name of theclass being created (16alphanumerical characters + theunderscore character)

    Create Class opens theClass fields for data entryand enters information inthe area defined by the"Description" tab

    Used to manageupdates to theclass by enteringa VV.RR (*) formatnumber

  • Managing the EF using PL7 SDKC

    ___________________________________________________________________________22

    EN

    GLI

    SH

    The "Import class" and "Export class" functions in the Utilities menu are used to importa class from another family and export a class to another family (see section 5.3).

    Clicking on the "Class.h" tab opens the following area :

    This area is used to enter the ( .h) interface file source code common to all the EFs inthe class. This file is used to create for example special types or constants which willbe reused in the C sources of all the EFs in the class.This file should be ≤ to 200 Kbytes.

    Toggle button (Normal size/Full screen) reduces/enlarges the entry window

  • Managing the EF using PL7 SDKC

    ___________________________________________________________________________

    23

    EN

    GLI

    SH

    3.1-3 The EF

    EFs developed and installed in library mode must, without fail, have different names. Becareful not to use PL7 key words as names (see section 6.2).It is only possible to exit from the description tab once all the fields have been filled in.This action confirms the parameters entered.

    It is possible to delete an EF using the Delete command from the Utilities menu.

    Reminder ofthe param-eters definedfor the familyand the class(read-only)

    Used to enterthe name ofthe EF beingcreated (16alphanumericalcharacters + theu n d e r s c o r echaracter)

    Used toenter a textcommentaryon the EFcontaininga maximumof 80characters

    Used to define the sizeof the stack. Its defaultvalue is 512 bytes andit is used to store theEF parameters, localvariables, and theparameters andvariables of thefunctions which it calls(see section 6.1-3)

    Create EF opens theEF fields for data entryand enters informationin the area defined bythe "Description" tab

    The EF type isa procedureor a function

    Number between 1 and 100 inclusive usedto ensure the uniqueness of the EFdeveloped. It is filled in automatically

    The size ofthe EFgenerated

    Used toselect theversion of thetarget PLC forwhich this EFis developed

  • Managing the EF using PL7 SDKC

    ___________________________________________________________________________24

    EN

    GLI

    SH

    Clicking on the "Interface" tab opens the following area, comprising three zones whichare used to enter the EF formal parameters.These formal parameters are those for inputs, outputs, and I/O.

    These function call parameters are divided into three fields :

    • the name, which contains a maximum of four characters (no spaces),

    • the parameter type : Inputs, Outputs and I/O. One of the following must be selected :

    BOOL, EBOOL, WORD, DWORD, STRING, REAL, AR_D, AR_R, AR_W and AR_X(to check the meaning of all of these types, see section 6.1 and the PL7 manual).

    • the comment, which contains a maximum of 80 characters.

    Example :

    At the formal parameters level, there is a maximum of 7 inputs, 7 outputs and 17 I/O.It is possible to delete one or more parameter lines by selecting the line and clickingon the corresponding number. Type Ctrl+x on the keyboard (Ctrl+v repastes what hasbeen cut).

    For the correspondence between PL7 types defined in this tab and C types present inthe function header, see the table in section 6.1.

    Reminder of the name of theclass and EF concerned

    Buttons used tochange the orderof the parametersin the selectedgrid

  • Managing the EF using PL7 SDKC

    ___________________________________________________________________________

    25

    EN

    GLI

    SH

    Clicking on the ".C Source" tab opens the following area :

    This tab accesses C code editing. The user can use his own editor if he wishes or if theC file is greater than 200 K, using export and import.

    As with other standard tools on the market, comments containing special key words aregenerated.When PL7 SDKC creates the function header for the first time, the key wordsPL7SDK_BEGIN_FUNCTION_NAME and PL7SDK_END_FUNCTION_NAME areinserted automatically.

    On exiting this tab, or when modifying the interface in the previous tab, PL7 SDKCautomatically generates this header, which ensures consistency between the declaredinterface and the interface in the code.

    Using the Edit menu, the current functions are offered by EditText (cut, copy, paste, find,replace).Other functions are available, such as :

    • Selecting by double-clicking

    • Displaying the line number corresponding to the present position of the cursor, in theStatus Bar.

    These buttons are used to importor export a C file

    Toggle button (Normal size/Full screen) reduces/enlargesthe entry window

  • Managing the EF using PL7 SDKC

    ___________________________________________________________________________26

    EN

    GLI

    SH

    To inform the user of errors resulting from the C source compilation, the source codeline containing the error is indicated.A file giving the results of the compilation is generated. It can be accessed by the Viewgeneration results command in the Family menu and provides information on anyerrors.

    Definition of the EF interface automatically generates the prototype of the latter in theFILE MAINxxyy.C where xx is the class code and yy the EF code. The user can exportthe source if he wishes, work on it, and then re-import it.There is no subsequent check on any manual modifications made to the EF mainfunction interface. If the user modifies the interface, these modifications will be ignored.The interface is automatically regenerated from the interface tab.If the file is too large to be displayed this will be indicated. However, the functionprototype will still be generated automatically.

    • the user works with the editor supplied , and reaches the limit of 200 K for the currentEF.At that moment the following message is displayed :

    «Your file is too large to be edited using PL7SDKC. Please export it, then re-importit».

    • the user prefers to work with his "favorite" editor.This is possible; work is made easier by exporting one file at a time. Use the followingprocedure :

    create your EF,create your interface then enter the code tab,export the C file,work in your editor then save, without changing the name,import into PL7 SDKC.

  • Managing the EF using PL7 SDKC

    ___________________________________________________________________________

    27

    EN

    GLI

    SH

    Clicking on the ".H Source" tab opens the following area :

    This area is used to define constants, types or structures specific to the EF.This file must be ≤ to 200 Kbytes.

    T o g g l ebutton (Nor-mal size/Fulls c r e e n )r e d u c e s /enlarges thee n t r ywindow

  • Managing the EF using PL7 SDKC

    ___________________________________________________________________________28

    EN

    GLI

    SH

    3.2 Generating the family in debug mode

    Once the creation phase is complete, it is possible to proceed to generation of the familyin debug mode. To do this, select Generate Debug from the Family menu as shown inthe screen below.

    The role of this generation is to activate the various software tools used to obtain a newfamily (all classes) and to check data consistency along the whole generation string.

    If there is a problem, a screen indicating the nature of the error(s) to be corrected opens,so that generation can be relaunched.

    It is possible to monitor the generation process from the information line at the bottomof the screen. Once generation is complete, the message "x error(s), y warning(s)" isdisplayed and an audio beep emitted.A "Generated in Debug mode" status followed by a generation date is written in thefamily description zone, and this family can then be installed in the library.

    Information about the generation can be accessed by opening the results file (Viewgeneration results from the Family menu).

    The installation of this family thus generated, is not possible that since the productPL7SDKC.

  • Managing the EF using PL7 SDKC

    ___________________________________________________________________________

    29

    EN

    GLI

    SH

    3.3 Generating the family in release mode

    The last phase is to proceed to generation of the family in release mode (code sizeminimized). To do this, select Generate Release from the Family menu as shown in thescreen below.

    The role of this generation is to activate the various software tools used to obtain a newfamily (all classes) and to create the corresponding files.

    It is possible to monitor the generation process from the information line at the bottomof the screen. Once generation is complete, the message "x error(s), y warning(s)" isdisplayed and an audio beep emitted.A "Generated in Release mode" status followed by a generation date is written in thefamily description zone.

    Information about the generation can be accessed by opening the results file (Viewgeneration results from the Family menu).

    Once generation is complete, the necessary elements (files) are automatically copiedinto the medium selected for broadcasting (diskette, network disk, etc). This space ispart of the parameters defined in the tool customization menu (see section 5.1).

  • Managing the EF using PL7 SDKC

    ___________________________________________________________________________30

    EN

    GLI

    SH

    3.4 Installing/Uninstalling in the PL7 library

    It is possible to install a family generated in debug or release mode on the developmentstation, but only families generated in debug mode can be debugged in PL7.To perform this installation, select Install from the Family menu.

    If the code of the family to be installed already exists in the library, a dialog box opens

    If the family is new and intended to replace an old one, click on "Overwrite".

    If an error is made, or the user is unsure, it is possible to cancel installation in the libraryby selecting Quit.

    When installation is complete, the message "The family has been installed in the library"appears and installation is effective.

    It is possible to uninstall a family from the PL7 library. It is necessary to select theUninstall command from the Family menu when a family is being edited.

  • Testing the EF using the debugging tool

    ___________________________________________________________________________31

    EN

    GLI

    SH

    4.1 Accessing EF debugging

    4.1-1 Selecting the family of the EF to be tested

    As described in the previous section, the EFs of families generated in debug mode canbe debugged, one at a time, in PL7 Micro, Junior or Pro .Once PL7 is launched and the program containing the EF to be tested loaded into thePLC, the Debug EF command in the Tools menu opens the following screen which isused to select the development directory (dvt_ef, by default), then the family containingthe EF.

    Once the family containing the EF to be tested has been found, clicking on OK opens theEF debug environment, described in the next paragraph.

    The EF should only be called once in the application, so that debugging can be performed.

    4.1-2 Opening the EF debug screen

    This screen is made up of two parts :

    • A command part with seven buttons,

    • A part containing information about the test

    Used to searchfor the drive andthe developmentdirectory

    The name of the family (generated in debug mode) and its code number appear

    Section 44 Testing the EF using the debugging tool

    Summary ofinformationabout thefamily

  • Testing the EF using the debugging tool

    ___________________________________________________________________________32

    EN

    GLI

    SH

    Selecting the EF command from the Debug EF menu, or clicking on the button(2nd button from the left), opens the screen used to select the EF to be tested.

    In our example, there is only one EF in the family (the "MAX_TABW" EF which we wishto test), the code of the class to which it belongs, its EF code, its name and its commentappear.Clicking on OK opens a screen which gives the C source of the EF (see section 4.3-1).

    Depending on the complexity of the EF, it may take several seconds to access thisscreen.

    Opening the screen adds a "Debug EF" menu to the PL7 menu bar.

  • Testing the EF using the debugging tool

    ___________________________________________________________________________33

    EN

    GLI

    SH

    4.2 Presentation of the tool

    The tool commands are accessed from a scrollingmenu and/or by buttons.All the commands are described below :

    (1st button from the left) : is used to exitthe EF debug tool.

    (3rd button from theleft) : is used to insert/remove a breakpoint.

    (4th button from the left) or the Go command from the Debug EF menu is usedto relaunch the PLC from the breakpoint or current step.

    (5th button from the left) or the Step Into command from the Debug EF menu :is used to go inside a function (if the function is present in the C source of theEF).

    (6th button from the left) or the Step Over command from the Debug EF menu:is used to skip a function (step over).

    (7th button from the left) or the Step Out command from the Debug EF menu :is used to exit a C function comprising a EF.

    • the Registers command in the Debug EF menu is used to display a list of all theregisters used by the CPU microprocessor (see section 4.3-3).

    • the Local variables command in the Debug EF menu is used to display a list ofvariables used locally (see section 4.3-4).

    • the Mix C/Asm command in the Debug EF menu is used to change from a presentationin C language to a presentation in C language and in assembly language.

    • the Breakpoints command from the Debug EF menu is used to display a screen givinginformation on the position of breakpoints.

    • the Step to Cursor command from the Debug EF menu is used to relaunch the PLC,from the step where it is stopped back to the cursor.

  • Testing the EF using the debugging tool

    ___________________________________________________________________________34

    EN

    GLI

    SH

    4.3 Debugging EFs

    Following the procedure described above (see section 4.2-1), the C source code of theEF is displayed on-screen and debugging can begin.It will be possible, using the tool commands and buttons, to perform all the usual debugoperations, namely :

    • Insert and remove breakpoints,

    • Proceed step by step,

    • Scroll through part of the program,

    • Go inside a function,

    • Analyze using the lists of registers and local variables,

    • Edit the EF in C code and assembly language, to meet the needs of a more preciseanalysis of part of the program which could cause problems.

    4.3-1 Inserting and removing breakpoints

    Select a line by pointing the cursor at it, then press the button to insert abreakpoint on this line. The same button is used to remove a breakpoint. Up to 7breakpoints can be inserted simultaneously.A breakpoint is indicated by a blue line. It is thus possible to insert or remove all thebreakpoints desired.If the PLC is running and if the program moves to one of the breakpoints, the line inquestion becomes yellow.Using the , , buttons, it is easy to enter/exit from a function or skip a function.

    Extract of the EF Csource code with twobreakpoints (one blueline, one yellow line)

  • Testing the EF using the debugging tool

    ___________________________________________________________________________35

    EN

    GLI

    SH

    4.3-2 Mixing C code and assembly language

    The Mix C/Asm command from the Debug EF menu is used to change from apresentation in C language to a presentation in C language and in assemblylanguage .

    4.3-3 Registers

    The Registers command in the Debug EF menu is used to display a list of all the registersused by the CPU microprocessor, as well as the contents of the execution stack whichcontains the local variables and the parameters of the function in which the programhas stopped.

  • Testing the EF using the debugging tool

    ___________________________________________________________________________36

    EN

    GLI

    SH

    4.3-4 Local variables

    The Local variables command from the Debug EF menu is used to display a list of thelocal variables and parameters of the function in which the program has stopped.

    All the numerical values displayed in this screen are expressed in hexadecimalformat (except for FLOAT_TODBG variables) .

    The syntax used to define the types of local variables and parameters is describedbelow :

    +: the "plus" sign indicates that the object on the line can be expanded.

    - : the "minus" sign indicates that the object on the line can be shrunk.

    {...} : indicates that the corresponding object is a structure.

    [ ] : indicates that the corresponding object is a table.

    0xabcd:0xabcd : indicates that the corresponding object is a pointer. Byexpanding it, the type of object pointed to will appear.

    %xxxxxxxx : where x takes the value 0 or 1, this indicates that thecorresponding object is a bit field.

  • Testing the EF using the debugging tool

    ___________________________________________________________________________37

    EN

    GLI

    SH

    To exit at the end of an EF debug session, use either the tool button, or the usual

    commands for exiting a Windows screen.

    If a problem arises during an EF test, and it was not possible to close the debug EFtool, the application will have to be reloaded into the PLC before restarting asession.

  • Testing the EF using the debugging tool

    ___________________________________________________________________________38

    EN

    GLI

    SH

  • Additional SDKC functions

    ___________________________________________________________________________39

    EN

    GLI

    SH

    5.1 Setting the tool parameters

    The Customize command in the Utilities menu opens the following window. Here,parameters can be set for a number of working directories which assist operation of thetool.

    The arrows located to the right of each field open a dialog box where another disk/directory can be selected for that field.

    Section 55 Additional SDKC functions

    Directory where EF family files(by default) will be placed

    Directory (by default) where filesused to install an EF family will beplaced

    Directory (by default) wherethe imported/exported classfiles will be placed

    Directory (by default) where the Clanguage source files, due to beimported/exported, will be placed

    Working disk (C:\) where theprogram creates/deletes itstemporary working files

  • Additional SDKC functions

    ___________________________________________________________________________40

    EN

    GLI

    SH

    5.2 Modifying a family

    Once a family name and version number have been associated with a family code, theonly way to change the parameter(s) is to select the family (shown in reverse video) andthen select Modify from the Family menu.

    This action opens the "Name" and "Version" fields, where data can be entered.

    This step could prove useful, for example, if the version number of a family neededchanging after being updated.

    Clicking on "Confirm" takes this modification into account and opens the family, so thata class/EF can be created/viewed (see section 3.1.2, section 3.1.3).

  • Additional SDKC functions

    ___________________________________________________________________________41

    EN

    GLI

    SH

    5.3 Importing/Exporting

    5.3-1 Class

    When a family is open, two commands in the Utilities menu are used to import and/orexport class(es) into/from this family.

    Exporting a class consists of copying the class into the appropriate directory definedwhen customizing the tool (see section 5.1).

    Example : "Program" family, "Class1" class :(the "import-export class" directory is : C:\SDKCWTMP\IMPCLASS by default)

    When the "Class1" class of this family is exported, a file called " CLASSE01.EXP",containing all the intrinsic elements of this class, is copied into the directory.Once export is complete, the message : The "Class1" class was successfully exportedto "C:\SDKCWTMP\IMPCLASS\CLASSE01.EXP" indicates that the operation iscomplete.

    Caution : The "CLASSE01.EXP" file overwrites any existing "CLASSE01.EXP" andno warning message appears.

    The group of two numbers at the end of the file name "CLASSE01" indicates the codefor the class in hexadecimal format (code 1 class, in this example). "Import-Export class" files are distinguished by the suffix .EXP.

    Importing a class consists of opening the following screen,

    which displays the contents of the "Import-export class" directory referred to earlier, andchoosing the file corresponding to the class you wish to import into a family.

  • Additional SDKC functions

    ___________________________________________________________________________42

    EN

    GLI

    SH

    Example : If you wish to import a class1 into the "Program" family

    Select the " CLASSE01.EXP" file, which contains all the intrinsic elements of this class,and click on OK.

    There are two possible scenarios :

    • No code 1 class existed in this family, clicking on OK causes a copy to be made, andthe code 1 class and its EF appear on the left of the screen.

    • A code 1 class already existed in the "Program" family, clicking on OK brings up thefollowing message :

    Yes will import the new class (all the intrinsic elements of this class) and willoverwrite the old class with the same code (all the intrinsic elements of thatclass).

    No cancels the import instruction and reverts to the initial situation.

    5.3-2 C Source

    From the "C Source" tab of an EF, two buttons can be used to import and/or export theC Source code from another EF.

    Exporting the C Source of an EF consists of copying the code into the appropriatedirectory defined when customizing the tool (see section 5.1).

    Example : "Program" family, "Class1" class, EF "MAX_TABW" :(the C source "import-export directory" is : C:\SDKCWTMP\IMPSRC by default)

    When the content of the C Source tab of the "MAX_TABW" EF is exported, this code iscopied into a file "MAIN0101.C" in the directory.Once export is complete, the message : The "MAIN0101.C" source file has been copiedto "C:\SDKCWTMP\IMPSRC\MAIN0101.C", indicates that the operation is complete.

    Caution : The "MAIN0101.C" file overwrites any existing "MAIN0101.C" and nowarning message appears.

  • Additional SDKC functions

    ___________________________________________________________________________43

    EN

    GLI

    SH

    The two groups of two numbers at the end of the file name "MAIN0101" indicate the classcode followed by the EF code (code 1 class, code 1 EF, in this example). These codesare expressed in hexadecimal format."Import-Export C Source" files are distinguished by the suffix .C.

    This type of MAINxxxx.C file can be opened by a commercial C editor (more sophisticated).

    Once the C file exceeds the limits of the edit zone (64 Kbytes), this type of editor mustbe used.

    Importing the C Source of an EF consists of opening the following screen,

    which displays the contents of the "Import-export C sources" directory referred to earlier,and choosing the file corresponding to the C Source code you wish to import into the EF.

    Example : If you wish to import the C Source contained in the file "MAIN0102.C"

    Select this file and click on OK. This brings up the following message :

    OK imports the new C Source code and overwrites the old one.Cancel reverts to the initial situation.

  • Additional SDKC functions

    ___________________________________________________________________________44

    EN

    GLI

    SH

    5.4 Archiving/Restoring a family

    5.4-1 Archiving

    Once a family has been created, and its class(es) and EF(s) have been created andtheir parameters set, it is advisable to archive it.This operation is performed by activating the Archive command in the Family menu,as indicated on the following screen :

    By default, this archive is transferred to the main EF family directory (DVT_EF) createdat installation. It is possible, using the "Select path" button, to place this archive inanother directory if required.Once the family has been archived, if archive display is selected, the archive appearson the left-hand side of the screen. When the archive is selected, a screen appearswhich contains the main characteristics of the archived family.A zone opens where comments about the archive can be entered ; these commentswill be extremely useful if the archive is ever retrieved.

    Depending on which is selected, these boxes candisplay normal and/or archived families on the left ofthe screen

    Entry zone for comments(4 lines maximum)

  • Additional SDKC functions

    ___________________________________________________________________________45

    EN

    GLI

    SH

    5.4-2 Restoring

    The object of the "Restore" function is to replace a given family with a previouslyarchived one. This function is performed by activating the Restore command on theFamily menu, as indicated on the following screen :

    As the restore operation overwrites the current family, a confirmation messageappears :

    OK restores the family. Cancel reverts to the initial situation.

    When executing the Archive/Restore functions, the files created or manipulated areto be found in the directory defined in the customization screen (see section 5.1) underthe item : General directory of EF families (C:\DVT_EF by default). These files are called,respectively :

    • CRD_xxxx.yyy : for the family datasheet

    • CAT_xxxx.yyy : for information about the family

    • FAM_xxxx.yyy : for the complete archive

    where xxxx corresponds to the family code in hexadecimal format, and yyy to thearchive number.

  • Additional SDKC functions

    ___________________________________________________________________________46

    EN

    GLI

    SH

    5.4-3 Restoring from

    The Restore from a directory ... command in the Family menu, opens the followingscreen for defining the path of the required family (directory, network, disk, etc).

    When the required family has been selected, click on Open to validate the restoration.Warning, a family which is restored will overwrite any family with the same name andversion. In this case, a warning appears and confirmation is required.

    5.5 Printing

    Within a family, the Print command in the Family menu is used for printing. Thefollowing screen is used to define the type of printout required.

  • Additional SDKC functions

    ___________________________________________________________________________47

    EN

    GLI

    SH

    By default, family level information is printed. It is possible to obtain information on theclasses and EF and/or the source programs contained in these classes and EF byselecting them.

    The "Contents of active editor" item is grayed out. This command becomes active whena source program is being written and the cursor is located inside the editor.

    A "Configuration" button is used to activate the print configuration box for defining theprinting parameters.

  • Additional SDKC functions

    ___________________________________________________________________________48

    EN

    GLI

    SH

  • The EF code

    ___________________________________________________________________________49

    EN

    GLI

    SH

    Section 66 The EF code

    6.1 Rules for implementing EFs

    6.1-1 C Language

    No. 1 Static variables must not be defined in an EF.

    No. 2 Unions must not be defined in a structure . They should have been definedearlier, outside the structure.

    No. 3 If a pointer is used as a parameter or local function variable, it must be declaredas a far pointer .

    Example : int far* pVariableLocale

    No. 4 A bit field must not be defined with length 0 .

    No. 5 The C language "switch " instruction must not be used in the code for an EF.

    No. 6 The types of formal parameter for an EF are specific to the PL7 languages (referto the PL7 Micro or Junior documentation), and these are automaticallyconverted in the C function header as shown below :

    PL7 formal Input Output Input/Output parameter parameter parameter parameter

    BOOL short adrNFBIT adrNFBIT

    EBOOL adrFBIT adrFBIT adrFBIT

    WORD short adrSCAL adrSCAL

    REAL unsigned long adrSCAL adrSCAL

    DWORD long adrSCAL adrSCAL

    STRING adrTABLE adrTABLE adrTABLE

    AR_X adrTABLE adrTABLE adrTABLE

    AR_W adrTABLE adrTABLE adrTABLE

    AR_D adrTABLE adrTABLE adrTABLE

    AR_R adrTABLE adrTABLE adrTABLE

    No. 7 The types and constants shown on the next page are an extract from theCSTSYST.H file, which is included automatically at the beginning of each Csource describing an EF.

  • The EF code

    ___________________________________________________________________________50

    EN

    GLI

    SH //Definition of constants

    // Status values listed in the directory#define STATUS_OK#define OUT_OF_BOUNDS#define NULL_RW_SIZE#define CLOCK_UNAVAILABLE#define CLOCK_NOT_SUPPORTED#define INVALID_LENGTH

    #define NIL#define NILL#define INVALID_ADDRESS#define NULL_FPTR

    // Possible types of action on forceable bit strings (wr_bits)#define DATA_WRITE // Write data field#define RVALUE_WRITE // Write fallback value field (TSX57

    only)#define RVALID_WRITE // Write fallback value validation

    // field (TSX57 only)#define DEFAULT_WRITE // Write fault (TSX57 only)#define UNFORCE_ALL // Unforce bits globally

    #define GAMME_TSX37 4#define REFCAT_TSX37_10 1#define REFCAT_TSX37_21 2#define REFCAT_TSX37_22 3

    #define GAMME_TSX57 5#define REFCAT_TSX57_10 1#define REFCAT_TSX57_20 2#define REFCAT_PMX57_20 3#define REFCAT_TSX57_30 4#define REFCAT_TSX57_10_V3 5#define REFCAT_TSX57_20_V3 6#define REFCAT_TSX57_25_V3 7#define REFCAT_TSX57_30_V3 8#define REFCAT_TSX57_35_V3 9#define REFCAT_TSX57_40_V3 10#define REFCAT_TSX57_45_V3 11

  • The EF code

    ___________________________________________________________________________51

    EN

    GLI

    SH

    //Definition of types#define BOOL short#define BYTE unsigned char#define WORD unsigned short#define DWORD unsigned long

    //Definition of structurestypedef struct {

    void __near *off; // Offsetunsigned short sel; // Selector number}PTR_LOG;

    typedef struct {unsigned short selecteur;unsigned short offset;} adrSCAL;

    typedef struct {unsigned short selecteur;unsigned short offset;unsigned short taille; // Size of table or string} adrTABLE;

    typedef struct {unsigned short selecteur;unsigned short offset;} adrFBIT;

    typedef struct {unsigned short selecteur;unsigned short offset;unsigned short rang; // discrete value : 0..15} adrNFBIT;

    typedef struct {unsigned char gamme; // Processor rangeunsigned char version; // OS version present in the

    processorunsigned char codecat; // Catalog reference code for

    the CPU modelunsigned char unused;} PROC_IDENT;

  • The EF code

    ___________________________________________________________________________52

    EN

    GLI

    SH

    typedef struct {unsigned char reserved ;unsigned char Second ;unsigned char Minut ;unsigned char Hour ;unsigned char DayMonth ;unsigned char Month ;unsigned char Year ;unsigned char Century ;unsigned char DayWeek ;} DATE_TIME ;

    typedef struct {unsigned Run : 1; /* 1 if run */unsigned AppliExec : 1; /* 1 if compatibility index between

    appli and processor ok */unsigned CartMemDetect :1; /* 1 if mem. cart. detected */unsigned Reservation : 1; /* 1 if reservation applied */unsigned BrkptSet : 1; /* 1 if brkpt set */unsigned AppliFailure : 1; /* 1 if appli «halted» */unsigned PartialRun : 1; /* 1 if partial run */unsigned CartFlashErase : 1; /* 1 if the FEPROM mem. cart. */

    /* is being erased */unsigned UserMemProtect : 1; /* 1 if the application memory */

    /* is write-protected */unsigned Reserved : 7; /* reserved bits */} PROC_INDIC ;

    #ifdef SDKCV3typedef union {unsigned long ul;float fl;} FLOAT_DBG;

    #ifdef C_486typedef float FLOAT;

    #elsetypedef unsigned long FLOAT;

    #endif#endif

  • The EF code

    ___________________________________________________________________________53

    EN

    GLI

    SH

    6.1-2 Managing family and EF versions

    A version number (VV.RR format) is allocated to an EF family and to each class in thefamily.A text information compatibility index is allocated to an EF family. If the family versionsin the library and an application are inconsistent, this indicator can be used to determinethe validity of help information associated with the EFs (general comment, name andcomment for its parameters) which make up the family.

    No. 8 For a family already installed in the library , any modification within a classmust without fail involve upgrading its version number (the index and/or therelease index), as well as the version number of the family to which it belongs.Adhering to this rule is compulsory in order to be able to update existing PL7applications which contain EFs of the class in an older version.Caution : the version number of a family does not necessarily correspond to thehighest version number associated with the classes it contains.

    Example : a version 2.1 family F, consisting of classes C1, C2 and C3 which areversions 1.0, 2.1 and 1.0 respectively.If class C1 develops from 1.0 to 1.1, the version of family F should change from2.1 to 2.2 at minimum.

    No. 9 A new EF family version must still be completely compatible with the previousversion :

    • no EF must disappear from the family ,

    • an EF must not change its call interface (a new EF must be created, with adifferent name if the prototype is to change, and the old EF must be retained).

    No. 10 The "text information compatibility index" of an EF family must be incrementedif (and only if) this family is updated in such a way that the existing helpinformation is no longer relevant.

    Note : during the EF debug phase, it is advisable to assign version numbers to classesand families starting from 0.01, in order to subsequently be able to assign version 1.0to the marketed product.

  • The EF code

    ___________________________________________________________________________54

    EN

    GLI

    SH

    6.1-3 Managing the size of the stack

    It is the user's responsibility to manage the size reserved for the EF execution stack.It is important to make an accurate calculation, as :

    • if it is too small, the PLC will show an error.

    • if it is too large, there is that much less space for the PLC data memory.

    To calculate the size in bytes, add together the sizes of :

    • the EF parameters and local variables (example : int = 2 bytes, long = 4 bytes, char= 1 byte, ...),

    • the parameters and local variables of the functions which it calls, by examining thelongest call tree.

    6.1-4 Using floating point numbers

    It is possible to enter floating point parameters as arguments of an EF. In the case ofa function EF it is also possible to choose to return a floating point. To do this, REALmust be selected when choosing the type.Floating point calculation can only be accessed on version V3.0 or later PLCs (with orwithout coprocessor). This means that it will not be possible to regenerate the sourcecode of an EF which contains floating point parameters on a target PLC which is priorto version 3 (compilation errors).

    Declaration and initialization of a floating point variable

    It is declared as follows :FLOAT varf ;The variable is initialized with a Structured Text value via the FVALUE macro :varf = FVALUE(2.1e23) ;

    Display of a floating point variable in debug mode

    A floating point variable is displayed in Debug EF using a FLOAT_DBG variable. AFLOAT variable is converted to a FLOAT_DBG value using the FLOAT_TO_DBGfunction.

    Example

    FLOAT_DBG fv ; FLOAT FVAL ;

    FVAL = FVALUE(1.1) ; fv =FLOAT_TO_DBG (FVAL) ;

  • The EF code

    ___________________________________________________________________________55

    EN

    GLI

    SH

    The display of the variable fv in debug will give the following. (It should be noted thatthis is really a union between a floating point and an unsigned long).

    - fv = (union)fl = +1.1000000E+000ul = 0x3F8CCCCD

    Conversion of PL7 floating point variables to SDKC variables and vice-versa

    The type of floating point in PL7 is of the form unsigned long. A conversion must beperformed at the entry to the function as well as the reverse conversion on return.

    Example

    // return declared as REAL unsigned long far pascal MONEF(

    unsigned long IN1 // declared as REAL in SDKC)

    { FLOAT FVAL ; FVAL = GET_FLOATPL7(INI) ; // conversion to a floating point

    /// processing return ( FLOAT_TOPL7 (FVAL) ) ; // reverse conversion }

  • The EF code

    ___________________________________________________________________________56

    EN

    GLI

    SH

    6.2 List of reserved words

    The words in the following list (arranged in columns, in alphabetical order) are or will beused by PL7 , and must not be used as EF names :

    ABSACCEPTACOSACTIONACTIVATE_PULSEACTIVE_TIMEADDADDRESSADD_DTADD_TODADRANDANDFANDNANDRAND_ARXANYANY_BITANY_DATEANY_INTANY_NUMANY_REALARRAYAR_DAR_DINTAR_FAR_INTAR_RAR_WAR_XASINASKASK_MSGASK_VALUEASSIGN_KEYSATATANAUXBCD_TO_INTBIT_DBIT_WBLKBLOCKBODYBOOLBOTTOMBTI

    BTRBYBYTECCALCALCCALCNCALLCALL_COILCANCELCASECDCHARTCH_MCLKCLOSECLOSED_CONTACTCOILCOMMANDCOMMENTSCOMP4COMPCHCONCATCONCATWCONFCONFIGURATIONCONSTANTCONTROL_LEDSCOPY_BITCOSCTDCTUCTUDCUDDATA_EXCHDATEDATE_AND_TIMEDAT_FMTDAY_OF_WEEKDA_TYPEDEACTIVATE_PULSEDECDELETEDELTA_DDELTA_DTDELTA_TOD

    DINTDINT_TO_REALDINT_TO_STRINGDISPLAY_ALRMDISPLAY_GRPDISPLAY_MSGDIVDMOVEDODOWNDRDRUMDSDSHL_RBITDSHRZ_CDSHR_RBITDSORT_ARDDSORT_ARWDTDTSDWORDD_BITEEBOOLELSEELSIFEMPTYEMPTY_LINEENDENDCENDCNEND_ACTIONEND_BLKEND_BLOCKEND_CASEEND_COMMENTSEND_CONFIGURATIONEND_EXPRESSIONEND_FOREND_FUNCTIONEND_FUNCTION_BLOCKEND_IFEND_MACRO_STEPEND_PAGEEND_PHRASEEND_PROGEND_PROGRAM

    END_REPEATEND_RESOURCEEND_RUNGEND_STEPEND_STRUCTEND_TRANSITIONEND_TYPEEND_VAREND_WHILEEQEQUALEQUAL_ARRERREVTEXCHGEXCH_DATAEXITEXPEXPRESSIONEXPTFFALSEFASTFBDFEFIFOFINDFIND_EQFIND_EQDFIND_EQDPFIND_EQRFIND_EQWFIND_EQWPFIND_GTDFIND_GTRFIND_GTWFIND_LTDFIND_LTRFIND_LTWFORFPULSORFROMFTOFFTONFTPFUNCFUNCTION

  • The EF code

    ___________________________________________________________________________57

    EN

    GLI

    SH

    FUNCTION_BLOCKF_BF_EDGEF_TRIGGEGETGET_MSGGET_VALUEGLOBAL_COMMENTGR7GRAY_TO_INTGTGTIHHALTHALT_COILHASH_COILHWH_COMPAREH_LINKIIFILININCINCJUMPINDEX_CHINFOINITIAL_STEPINIT_BUTTONSINPUTINPUT_CHARINSERTINTINTERVALINT_TO_BCDINT_TO_REALINT_TO_STRINGITBITSJMPJMPCJMPCNJUMPJUMP_COILLLADLANGAGELANGUAGELDLDFLDN

    LDRLELEFTLENLENGTH_ARDLENGTH_ARRLENGTH_ARWLENGTH_ARXLIFOLIMITLINTLISTLITLNLOCATIONLOGLREALLTLWLWORDMMACRO_STEPMAINMASKEVTMASTMAXMAX_ARDMAX_ARRMAX_ARWMAX_PAGESMAX_STEPMCRMCR_COILMCSMCS_COILMIDMINMIN_ARDMIN_ARRMIN_ARWMNMODMONOMOVEMPPMPSMRDMSMULMUXM_CHM_MACRO_STEP

    NN1NAMENB_ACTIVE_STEPSNB_ACTIVE_TIMENB_BLOCKSNB_COMMON_WORDSNB_CONSTANT_WORDSNB_CPTNB_DRUMNB_INTERNAL_BITSNB_INTERNAL_WORDSNB_MACRO_STEPSNB_MONONB_PAGESNB_REGNB_TIMERNB_TMNB_TRANSITIONSNENILNONON_STOREDNOPNOTNOT_ARXNOT_COILNOT_READABLENO_GR7NO_PERIODN_CONTACTOOCCUROCCUR_ARDOCCUR_ARROCCUR_ARWOFONOPENOPEN_CONTACTOPERATEORORFORNORROR_ARXOTHERSOUTOUTIN_CHAROUTPUTOUT_BLKOUT_IN_CHAR

    PP0P1PAGEPAGE_COMMENTPANEL_CMDPERIODPHRASEPHRASE_COMMENTPIDPID_MMIPLCPOSTPRESETPRINTPRINT_CHARPRIO0PRIO1PRIORITYPRLPROGPROGRAMPROG_LANGAGEPROG_LANGUAGEPTPTCPUTPVPWMP_CONTACTQQUERYRR1RCV_TLGREREADREAD_EVT_UTWREAD_ONLYREAD_PARAMREAD_STSREAD_VARREAD_WRITEREALREAL_TO_DINTREAL_TO_INTREAL_TO_STRINGREGREMREPEATREPLACEREQ

  • The EF code

    ___________________________________________________________________________58

    EN

    GLI

    SH

    RESETRESET_COILRESOURCERESTORE_PARAMRETRETAINRETCRETCNRETURNRET_COILRIGHTROLROLDROLWROL_ARDROL_ARRROL_ARWROL_DWORDROL_WORDRORROR1_ARBRORDRORWROR_ARDROR_ARRROR_ARWROR_DWORDROR_WORDRRTCRSRTBRTCRTSRUNGR_EDGER_TRIGSS1SAVESAVE_PARAMSCHEDULESCOUNTSDSEARCHSECTIONSELSEMASENDSENDERSEND_ALARMSEND_MBX_ALARMSEND_MBX_MSG

    SEND_MSGSEND_REQSEND_TLGSERVOSETSET_COILSFCSHIFTSHLSHOW_ALARMSHOW_MSGSHOW_PAGESHRSHRZSINSINGLESINTSLSLCWORDSMOVESOFT_CONFIGURATIONSORTSORT_ARDSORT_ARRSORT_ARWSQRTSRSTSTANDARDSTARTSTDSTEPSTISTNSTOPSTRSTRINGSTRING_TO_DINTSTRING_TO_INTSTRING_TO_REALSTRUCTSUBSUB_DTSUB_TODSUMSU_TYPESWAPS_T_AND_LINKS_T_OR_LINKTTANTASK

    TASKSTHENTIMETIMERTIME_OF_DAYTMTMAXTMOVETOTODTOFTOFFTONTOPTPTRANSITIONTRANS_TIMETRUETRUNCTYPETYPEST_S_AND_LINKT_S_OR_LINKUUDINTUINTULINTUNMASKEVTUNTILUPUSINTUSORT_ARDUSORT_ARWUTIN_CHARVARVAR_ACCESSVAR_EXTERNALVAR_GLOBALVAR_INPUTVAR_IN_OUTVAR_OUTPUTVAR_PUBLICVERSIONV_COMPAREV_LINKWWHILEWITHWORDWRITEWRITE_CMDWRITE_PARAM

    WRITE_VARWRTCWSHL_RBITWSHRZ_CWSHR_RBITW_BITXMXM_MONOXM_MULTIXORXORFXORNXORRXOR_ARXYES

  • System functions

    ___________________________________________________________________________59

    EN

    GLI

    SHSystem functions present in the PLC CPU can be called within the body of an EF.They are as follows :

    • rd_sysbit : read a system bit %Si

    • wr_sysbit : write a system bit %Si

    • rd_sysword : read a system word %SWi

    • wr_sysword : write a system word %SWi

    • rd_bit_attrib : read a bit from the forceable memory

    • rd_bits : read several consecutive bits in the forceable memory

    • wr_bits : write several consecutive bits in the forceable memory

    • rd_16bits : read the value of 16 consecutive bits in the forceable memory

    • wr_16bits : write the value of 16 consecutive bits in the forceable memory

    • rd_1bit : read the value of a bit in the forceable memory

    • wr_1bit : write the value of a bit in the forceable memory

    • phy_ptr_init : convert a logic address to a physical address

    • date_and_time : read the current PLC date and time

    • cnt_100ms : read the value of an internal counter with a rate of 100 ms

    • cnt_10ms : read the value of an internal counter with a rate of 10 ms

    • proc_type : read the processor type

    • proc_indic : read memory configuration data

    • ADD : add two floating point numbers

    • SUB : subtract two floating point numbers

    • MUL : multiply two floating point numbers

    • DIV : divide of two floating point numbers

    • EQU : test whether two floating point numbers are equal

    • SUP : test whether one floating point is greater than another floating point

    • INF : test whether one floating point is less than another floating point

    • ABS : calculate the absolute value of a floating point number

    • CHS : change the sign of a floating point number

    • SQRT : calculate the square root of a floating point number

    • FTOL : convert a double word to a floating point number

    • LTOF : convert a floating point number to a double word

    • of_passw_check : reading the signature on a PCMCIA card to protect an application(see Help)

    Section 77 System functions

  • System functions

    ___________________________________________________________________________60

    EN

    GLI

    SH

    Trigonometric and exponential functions

    • EXP : exponential of a floating point number

    • LN : calculation of the logarithm of a floating point number

    • SIN : calculation of the sine of a floating point number

    • COS : calculation of the cosine of a floating point number

    • TAN : calculation of the tangent of a floating point number

    • ASIN : calculation of the arc sine of a floating point number

    • ACOS : calculation of the arc cosine of a floating point number

    • ATAN : calculation of the arc tangent of a floating point number

    Exceptions and errors which may occur

    The mathematical functions which are offered do not provide any execution report.However, it is possible to obtain this report using the GET_STATUS(status) macrowhich must be used immediately after a function is called. The result contained instatus gives the result of the execution of this function .The meanings of the various values which are returned are described in the tablebelow :

    #define value meaning

    STATUS_OK 0 operation correctly executed

    flag_InvalideOp 1 invalid operand

    flag_Denorm 2 non-standard operand

    ZeroDivide 4 division by zero

    flag_Overflow 8 overflow

    flag_Underflow 16 underflow

    Example of using the GET_STATUS macro

    FLOAT fa, fb ;unsigned short status ;

    fa = ADD( fa, fb);GET_STATUS (status) ;if (status!= STATUS_OK){// error processing}

  • System functions

    ___________________________________________________________________________61

    EN

    GLI

    SH

    Conventions for representing exceptional values (Standard IEEE 754)

    0.#DN : represents a non-standard number1.#INF : represents + infinity (Hexadecimal value 7F800000)-1.#INF : represents - infinity (Hexadecimal value FF800000)1.#NAN : represents a positive undefined result ( Not A Number ). (Hexade-

    cimal value 7FC00000)-1.#NAN : represents a negative undefined result ( Not A Number ). (Hexade-

    cimal value FFC00000)

    Note : As it is possible, using these functions, to write to the PLC memory, the usershould take certain access precautions.Example : Once a table has become an EF parameter, be careful not to access wordsoutside this table. This can be checked by testing the length of the table.

    The following pages describe these functions, their parameters and the types used,with the help of examples.

  • System functions

    ___________________________________________________________________________62

    EN

    GLI

    SH

    value = rd_sysbit ( sysbit_range , status )

    unsigned short valueunsigned short sysbit_rangeunsigned short far * status

    Description

    Reads system bit %Si identified by its number.The consistency of the bit number is checked.

    Input parameters

    sysbit_range : Logical address of the bit to be read.status : Far pointer on the system status word.

    Return

    When the status is STATUS_OK, the bit value is entered in the least significant bit ;Bits numbers 1..15 are set to zero.A bit number outside these limits produces the status value OUT_OF_BOUNDS.

    Examples

    //Reading system bit %S4

    unsigned short Value;unsigned short far Status;Value = rd_sysbit (4,(unsigned short far *) & Status);

  • System functions

    ___________________________________________________________________________63

    EN

    GLI

    SH

    status = wr_sysbit ( sysbit_range , value )

    unsigned short statusunsigned short sysbit_rangeunsigned short value

    Description

    Writes system bit %Si identified by its number.The consistency of the bit number is checked.

    Input parameters

    sysbit_range : Logical address of the bit to be written.value : Value to be written ; only the least significant bit is taken into

    account.

    Return

    The bit write report.This is STATUS_OK when the write operation is accepted by the system.A bit number outside these limits produces the status value OUT_OF_BOUNDS.

    Examples

    //Writing value 0 in system bit %S10

    unsigned short Status;Status = wr_sysbit (10,0);

  • System functions

    ___________________________________________________________________________64

    EN

    GLI

    SH

    value = rd_sysword ( sysword_range , status )

    unsigned short valueunsigned short sysword_rangeunsigned short far * status

    Description

    Reads system word %SWi identified by its number.The consistency of the word number is checked.

    Input parameters

    sysword_range : Logical address of the word to be read.status : Far pointer on the system status word.

    Return

    When the status is STATUS_OK, the word value is entered in the function return value.A word number outside these limits produces the status value OUT_OF_BOUNDS.

    Examples

    //Reading system word %SW48 (event number)

    unsigned short Value;unsigned short far Status;Value = rd_sysword (48,(unsigned short far *) & Status);

  • System functions

    ___________________________________________________________________________65

    EN

    GLI

    SH

    status = wr_sysword ( sysword_range , value )

    unsigned short statusunsigned short sysword_rangeunsigned short value

    Description

    Writes system word %SWi identified by its number.The consistency of the word number is checked.

    Input parameters

    sysword_range : Logical address of the word to be written.value : Value to be written.

    Return

    STATUS_OK when the write operation is successful.A word number outside these limits produces the status value OUT_OF_BOUNDS.

    Examples

    //Writing value 10 in system word %SW48

    unsigned short Status;unsigned short Value;Status = wr_sysword (48,10);

  • System functions

    ___________________________________________________________________________66

    EN

    GLI

    SH

    value = rd_bit_attrib ( address )

    unsigned char valueadrFBIT address

    Description

    Reads a bit from the forceable memory identified by its address. The bits in the forceablememory are : %Si, %Mi, %Xi, %Ii.j and %Qi.j.

    Input parameters

    address : Address of the bit to be read, type adrFBIT (see section 6.1-1).

    Return

    The attributes of the referenced bit, conforming to the structure of the forceable bitmemory.

    TSX37 forceable bit : 3 significant bits

    bit2 bit1 bit0F H V

    V : ValueH : HistoricF : Forcing

    TSX57 forceable bit : 8 significant bits

    bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0Def. VR ER R r.F. F H V

    V : ValueH : HistoricF : Forcing (local)r.F. : Remote forcingR. : Fallback valueER : Fallback state only significant for I/O bitsVR : Fallback validation (Ii,j ; Qi,j)Def. : Fault

  • System functions

    ___________________________________________________________________________67

    EN

    GLI

    SH

    Examples

    //Reading the attributes of the bit corresponding to input 1 of slot 2void far pascal FUNCTION(adrFBIT BitAddress){

    unsigned char Valeur;::Valeur = rd_bit_attrib(AdresseBit);::

    }

  • System functions

    ___________________________________________________________________________68

    EN

    GLI

    SH

    value = rd_bits ( address , number , status )

    unsigned long valueadrFBIT addressunsigned short numberunsigned short far * status

    Description

    Reads several consecutive bits in the forceable memory.

    Input parameters

    address : Address of the first bit to be read, type adrFBIT (see section 6.1-1).number : Number of bits to be read, the length cannot exceed 32 bits.status : Far pointer on the system status word.

    Return

    The value of the referenced bit string.The function will not perform any processing if the number of bits requested is greaterthan 32.status is then INVALID_LENGTH.

    Examples

    //Reading 17 consecutive bits starting at %M1 which has become a parametervoid far pascal FUNCTION(adrFBIT FirstBit){

    unsigned short far status;unsigned long Valeur;::Valeur = rd_bits(PremierBit,17,(unsigned short far *) & Status);::

    }

  • System functions

    ___________________________________________________________________________69

    EN

    GLI

    SH

    status = wr_bits ( address , number , value , type )

    unsigned short statusadrFBIT addressunsigned short numberunsigned long valueunsigned short type

    Description

    Writes consecutive bits of the forceable memory ; the function can be used to write upto 32 bits located at the address provided on input.

    Input parameters

    address : Address of the first forceable bit to be written, type adrFBIT (see section6.1-1).

    number : Number of bits to be written ; this value must not exceed 32.value : Values to be written to a double word.type : Type of write operation to perform :

    00h : DATA_WRITE : update values

    04h : RVALUE_WRITE : write the fallback value

    06h : RVALID_WRITE : write the fallback validation field

    07h : DEFAULT_WRITE : write the fault to specified values

    08h : global unforcing of bits (UNFORCE_ALL) : the «value» parameter is not therefore significant

    Return

    The write report : STATUS_OK if the operation is successful.The function will not perform any processing if the number of bits to be written is greaterthan 32.The function then returns INVALID_LENGTH.The system returns UNAVAILABLE_SERVICE if it does not recognize the type of actionto be performed.

  • System functions

    ___________________________________________________________________________70

    EN

    GLI

    SH

    Examples

    void far pascal FUNCTION(adrFBIT BitAddress){

    unsigned short Status;::Status = wr_bits (AdresseBit,17,0x194AC,DATA_WRITE);::

    }

  • System functions

    ___________________________________________________________________________71

    EN

    GLI

    SH

    value = rd_16bits ( address )

    unsigned short valueadrFBIT address

    Description

    Reads the value (data bit) of 16 consecutive bits in the forceable bit memory.The EF using this utility must ensure the validity of the address which has become aparameter ; the system does not check that the address refers to the PLC forceable bitspace, nor that the 16 bits are in this space.

    Input parameters

    address : Address of the first bit to be read, type adrFBIT (see section 6.1-1).

    Return

    The value of the referenced bit string.

    Examples

    void far pascal FUNCTION(adrFBIT BitAddress){

    unsigned short Valeur;::Valeur = rd_16bits (AdresseBit);::

    }

  • System functions

    ___________________________________________________________________________72

    EN

    GLI

    SH

    wr_16bits ( address , value )

    adrFBIT addressunsigned short value

    Description

    Writes the value of 16 consecutive bits of the forceable memory.As the system does not perform any checks, the EF using this utility must ensure thevalidity of the 16-bit address which has become a parameter.

    Input parameters

    address : Address of the first forceable bit to be written, type adrFBIT (see section6.1-1).

    value : Values to be written to a word.

    Return

    None

    Examples

    void far pascal FUNCTION(adrFBIT BitAddress){

    ::wr_16bits (AdresseBit,0xAFC1);::

    }

  • System functions

    ___________________________________________________________________________73

    EN

    GLI

    SH

    value = rd_1bit ( address )

    unsigned short valueadrFBIT address

    Description

    Reads the value (data bit) of a forceable bit.The EF using this utility must ensure the validity of the address which has become aparameter ; the system does not check that this is included in the PLC forceable bitspace.

    Input parameters

    address : Address of the bit to be read, type adrFBIT (see section 6.1-1).

    Return

    The value of the referenced bit (0 or 1).

    Examples

    void far pascal FUNCTION(adrFBIT BitAddress){

    unsigned short Valeur;::Valeur = rd_1bit (AdresseBit);::

    }

  • System functions

    ___________________________________________________________________________74

    EN

    GLI

    SH

    wr_1bit ( address , value )

    adrFBIT addressunsigned short value

    Description

    Writes the value of a forceable bit.As the system does not perform any checks, the EF using this utility must ensure thevalidity of the address of the bit which has become a parameter.

    Input parameters

    address : Address of the forceable bit to be written, type adrFBIT (see section6.1-1).

    value : Values to be written to a word : this is 0 or 1.

    Return

    None

    Examples

    void far pascal FUNCTION(adrFBIT BitAddress){

    ::wr_1bit (AdresseBit,0);::

    }

  • System functions

    ___________________________________________________________________________75

    EN

    GLI

    SH

    result = phy_ptr_init ( sel_off )

    void far* resultPTR_LOG sel_off

    Description

    This function determines a physical address from a logical reference in the formatselector : offset .

    Input parameters

    address : Logical address, type PTR_LOG, to be converted to a 32-bit physicalpointer (see section 6.1-1).

    Return

    The far pointer corresponding to the logical address provided on input.In the event of failure (logical address not valid for this configuration), the functionreturns INVALID_ADDRESS.

    Examples

    //Converting a logical address type adrTABLE to a physical addressvoid far* CalculAdrPhy(adrTABLE far* pwTable){

    PTR_LOG SLog;

    SLog.sel = pwTable->selecteur;SLog.off = (unsigned short near *)pwTable->offset;return(phy_ptr_init (SLog));

    }

    //Example of an EF for adding 2 wordsvoid far pascal ADDITION(short A, short B, adrSCAL Result){

    PTR_LOG SLog;void far* pSomme;

    SLog.sel = Result.selecteur;SLog.off = (unsigned short near *)Resultat.offset;pSomme = phy_ptr_init (SLog);*pSomme = A+B;

    }

  • System functions

    ___________________________________________________________________________76

    EN

    GLI

    SH

    status = date_and_time ( date_ptr )

    unsigned short statusDATE_TIME far * date_ptr

    Description

    Reads the current PLC date and time.The data is coded in BCD on 9 usable bytes (ie. 18 digits), in the format below.Leap years can be handled.

    D. / wk. Year Month Day Hour Minute Second reserved

    [ 01..07 ] [ 0000...9999 ][ 01...12 ] [ 01...31 ] [ 00...23 ] [ 00...59 ] [ 00...59 ] 00

    x x x x x x x x x x x x x x x x x x

    byte 8 byte 7&6 ............ ............ byte 2 byte 1 byte 0

    Word 3 Word 2 Word 1 Word 0

    Key : x is a digit = [ 0..9 ]D./wk. is the day of the week = 01 : Monday

    02 : Tuesday03 : Wednesday04 : Thursday05 : Friday06 : Saturday07 : Sunday

    Input parameters

    date_ptr : A far pointer on the current date and time copy zone (9 bytes). TheDATA_TIME type is described in section 6.1-1

    Return

    The function returns CLOCK_UNAVAILABLE if it has not been able to update the resultzone (difficulty in accessing the realtime clock).If the operation is successful (the date and time fields are filled in correctly), the statusis STATUS_OK.The PLC responds with CLOCK_NOT_SUPPORTED if it has no realtime clock.

  • System functions

    ___________________________________________________________________________77

    EN

    GLI

    SH

    Examples

    DATE_TIME Buffer;Status = date_and_time(&Buffer);

  • System functions

    ___________________________________________________________________________78

    EN

    GLI

    SH

    value = cnt_100ms ( void )

    unsigned long value

    Description

    The system reads the value of an internal counter with a timebase of 100ms.

    Input parameters

    None

    Return

    The value of the counter, which has the following characteristics :

    • unsigned value, from 0 to 4 294 967 295

    • reset to zero on cold restart and when system bit %S0 is set to 1

    • not incremented during power outages

  • System functions

    ___________________________________________________________________________79

    EN

    GLI

    SH

    value = cnt_10ms ( void )

    unsigned long value

    Description

    System counter with a timebase of 10ms.

    Input parameters

    None

    Return

    The value of the counter, which has the following characteristics :

    • unsigned value, from 0 to 4 294 967 295

    • reset to zero on cold restart only

    • not incremented during power outages

  • System functions

    ___________________________________________________________________________80

    EN

    GLI

    SH

    info = proc_type ( void )

    PROC_IDENT info

    Description

    Identifies the type of processor executing the application.

    Input parameters

    None

    Return

    A structure type PROC_IDENT (see section 6.1-1) containing various identificationdata :

    • the processor range on one byte :

    04h : TSX3705h : TSX57

    • the SMART software version on the processor, on one byte :

    - on the high order 4-bit byte, the version number- on the low order 4-bit byte, the revision number (release)

    • the CPU model catalog reference code on one word :

    01h : REFCAT_TSX37_1002h : REFCAT_TSX37_2103h : REFCAT_TSX37_2201h : REFCAT_TSX57_1002h : REFCAT_TSX57_2003h : REFCAT_PMX57_2004h : REFCAT_TSX57_3005h : REFCAT_TSX57_10_V306h : REFCAT_TSX57_20_V307h : REFCAT_TSX57_25_V308h : REFCAT_TSX57_30_V309h : REFCAT_TSX57_35_V310h : REFCAT_TSX57_40_V311h : REFCAT_TSX57_45_V3

    Examples

    PROC_IDENT Info;Info = proc_type( );

  • System functions

    ___________________________________________________________________________81

    EN

    GLI

    SH

    info = proc_indic ( void )

    PROC_INDIC info

    Description

    Information about the application memory configuration in the PLC.

    Input parameters

    None

    Return

    A structure type PROC_INDIC (see section 6.1-1) containing information about :

    • the PLC status :- in Run, reserved, in Breakpoint stop, in Halt, in partial Run.

    • the validity of the application

    • the presence of a memory cartridge (if applicable)

    • the type of application memory : non modifiable / modifiable

    Examples

    PROC_INDIC Info;Info = proc_indic( );

  • System functions

    ___________________________________________________________________________82

    EN

    GLI

    SH

    Res = ADD ( a, b )

    FLOAT ResFLOAT aFLOAT b

    Description

    Res = a + b Adds two real numbers (in IEEE single precision format)

    Input parameters

    FLOAT aFLOAT b

    Return

    FLOAT Res

    Examples

    // Example of EF for adding 2 real numbersunsigned long far pascal ADDF (

    unsigned long F1, // value of a %MFunsigned long F2 // value of a %MF)

    {FLOAT f1, f2, f;f 1= GET_FLOATPL7 (F1); // conversion to a floating pointf 2= GET_FLOATPL7 (F2); // conversion to a floating pointf = ADD (f1, f2);

    return (FLOAT_TOPL7(f)); // reverse conversion}

    Special cases and exceptions

    Arguments a and b result res status value meaning ofstatus

    a or b = +-1.#NAN +/- 1.#NAN 1 : flag_InvalideOp invalid operation

    one of the operands is result obtained if 2 : flag_Denorm non-stand. operandnon-standard (0#DN) the operand is +/- 0

    (- ∞) + (+ ∞) - 1. #NAN 1 : flag_InvalideOp invalid operation

    (+ ∞) + (- ∞) - 1. #NAN 1 : flag_InvalideOp invalid operation

  • System functions

    ___________________________________________________________________________83

    EN

    GLI

    SH

    Res = SUB ( a, b )

    FLOAT ResFLOAT aFLOAT b

    Description

    Res = a - b Subtracts two real numbers (in IEEE single precision format)

    Input parameters

    FLOAT aFLOAT b

    Return

    FLOAT Res

    Examples

    // Example of EF for subtracting 2 real numbersunsigned long far pascal SUBF (

    unsigned long F1, // value of a %MFunsigned long F2 // value of a %MF)

    {FLOAT f1, f2, f;f 1= GET_FLOATPL7 (F1); // conversion to a floating pointf 2= GET_FLOATPL7 (F2); // conversion to a floating pointf = SUB (f1, f2);

    return (FLOAT_TOPL7(f)); // reverse conversion}

    Special cases and exceptions

    Arguments a and b result res status value meaning ofstatus

    a or b = +-1.#NAN +/- 1.#NAN 1 : flag_InvalideOp invalid operation

    one of the operands is result obtained if 2 : flag_Denorm non-stand. operandnon-stand. (0#DN) the operand is +/- 0

    (+ ∞) - (+ ∞) - 1. #NAN 1 : flag_InvalideOp invalid operation

    (- ∞) - (- ∞) - 1. #NAN 1 : flag_InvalideOp invalid operation

  • System functions

    ___________________________________________________________________________84

    EN

    GLI

    SH

    Res = MUL ( a, b )

    FLOAT ResFLOAT aFLOAT b

    Description

    Res = a x b Multiplies two real numbers (in IEEE single precision format)

    Input parameters

    FLOAT aFLOAT b

    Return

    FLOAT Res

    Examples

    // Example of EF for product of 2 real numbersunsigned long far pascal MULF (

    unsigned long F1, // value of a %MFunsigned long F2 // value of a %MF)

    {FLOAT f1, f2, f;f 1= GET_FLOATPL7 (F1); // conversion to a floating pointf 2= GET_FLOATPL7 (F2); // conversion to a floating pointf = MUL (f1, f2);

    return (FLOAT_TOPL7(f)); // reverse conversion}

    Special cases and exceptions

    Arguments a and b result res status value meaning ofstatus

    a or b = +-1.#NAN +/- 1.#NAN 1 : flag_InvalideOp invalid operation

    one of the operands is result obtained if 2 : flag_Denorm non-stand. operandnon-stand. (0#DN) the operand is +/- 0

    0 * ∞ +/- 1. #NAN 1 : flag_InvalideOp invalid operation

  • System functions

    ___________________________________________________________________________85

    EN

    GLI

    SH

    Res = DIV ( a, b )

    FLOAT ResFLOAT aFLOAT b

    Description

    Res = a / b Divides two real numbers (in IEEE single precision format)

    Input parameters

    FLOAT aFLOAT b

    Return

    FLOAT Res

    Examples

    // Example of EF for dividing two real numbersunsigned long far pascal DIVF (

    unsigned long F1, // value of a %MFunsigned long F2 // value of a %MF)

    {FLOAT f1, f2, f;f 1= GET_FLOATPL7 (F1); // conversion to a floating pointf 2= GET_FLOATPL7 (F2); // conversion to a floating pointf = DIV (f1, f2);

    return (FLOAT_TOPL7(f)); // reverse conversion}

    Special cases and exceptions

    Arguments a and b result res status value meaning ofstatus

    0