Top Banner
Reference manual EPL programming language Book E5 - Version 2.05
122
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • Reference manual EPL programminglanguage

    Book E5 - Version 2.05

  • Reference manual EPL programming language E5 2.05

    2014 E.D.&A. 1HPC

    Version

    Table of contents

    Chapter 1 Introduction 5

    Chapter 2 Elements of the EPL Language 6

    ................................................................................................................................... 61 Spacing

    ................................................................................................................................... 62 Punctuation: the semicolon

    ................................................................................................................................... 63 Punctuation: the comma

    ................................................................................................................................... 74 Statements

    ................................................................................................................................... 75 The compound statement

    ................................................................................................................................... 86 Operators and operands

    ................................................................................................................................... 87 Constants

    ................................................................................................................................... 88 Global and local variables

    ................................................................................................................................... 99 Predefined variables

    ................................................................................................................................... 910 Names of variables and functions

    ................................................................................................................................... 911 Reserved keywords

    ................................................................................................................................... 912 Comments

    Chapter 3 Structure of an EPL program 11

    ................................................................................................................................... 111 A minimum EPL program

    ................................................................................................................................... 112 A more extended EPL program

    ................................................................................................................................... 123 Description

    Chapter 4 Callback functions 14

    ................................................................................................................................... 141 Callback function main()

    ................................................................................................................................... 142 Callback function init()

    ................................................................................................................................... 143 Callback function initremanent()

    ................................................................................................................................... 144 Callback functions EventTimer1() and EventTimer2()

    Chapter 5 Kernel functions and kernel variables 15

    ................................................................................................................................... 151 Kernel functions

    ................................................................................................................................... 152 Kernel variables

    Chapter 6 Compiler directives 17

    ................................................................................................................................... 171 Directive: #target

    ................................................................................................................................... 182 Directive: #include

    ................................................................................................................................... 193 Directive: #config

    ................................................................................................................................... 224 Directive: #define

    ................................................................................................................................... 235 Directive: #undefine

    ................................................................................................................................... 246 Directive: #if, #else, #endif

    ................................................................................................................................... 267 Directive: #ifdef, #ifndef

  • Reference manual EPL programming language E5 2.05

    2014 E.D.&A. 2HPC

    Version

    ................................................................................................................................... 278 Directive: #abort

    ................................................................................................................................... 289 Directive: #pragma

    ................................................................................................................................... 2810 Directive: #pragma debug

    ................................................................................................................................... 2911 Directive: #pragma mathcheck

    ................................................................................................................................... 3012 Directive: #pragma boundcheck

    Chapter 7 Numerical types 32

    ................................................................................................................................... 321 The binary number system

    ................................................................................................................................... 332 The 'Boolean' numerical type

    ................................................................................................................................... 343 The 'char' numerical type

    ................................................................................................................................... 344 The 'short' numerical type

    ................................................................................................................................... 345 The 'long' numerical type

    ................................................................................................................................... 346 Survey of the numerical types

    Chapter 8 Constants 35

    ................................................................................................................................... 351 Decimal constant

    ................................................................................................................................... 352 Hexadecimal constant

    ................................................................................................................................... 353 Binary constant

    ................................................................................................................................... 364 Character constant

    ................................................................................................................................... 365 String constant

    ................................................................................................................................... 376 ASCII table

    ................................................................................................................................... 377 Escape sequences

    Chapter 9 Variables 39

    ................................................................................................................................... 391 Variable: Mx

    ................................................................................................................................... 392 Variable: Cx

    ................................................................................................................................... 403 Variable: Sx

    ................................................................................................................................... 404 Variable: Lx

    ................................................................................................................................... 405 Variable: Ex.y

    ................................................................................................................................... 416 Variable: Ax.y

    ................................................................................................................................... 417 Variable: AEx.y

    ................................................................................................................................... 428 Variable: AAx.y

    ................................................................................................................................... 439 Global variables by names

    Chapter 10 Operators 45

    ................................................................................................................................... 451 Operator: equation or assignment

    ................................................................................................................................... 462 Operator: addition

    ................................................................................................................................... 473 Operator: subtraction

    ................................................................................................................................... 494 Operator: multiplication

    ................................................................................................................................... 505 Operator: division

    ................................................................................................................................... 516 Operator: remainder or modulus

    ................................................................................................................................... 517 Operator: AND operation

    ................................................................................................................................... 538 Operator: EXOR operation

    ................................................................................................................................... 549 Operator: OR operation

  • Reference manual EPL programming language E5 2.05

    2014 E.D.&A. 3HPC

    Version

    ................................................................................................................................... 5510 Operator: increment

    ................................................................................................................................... 5511 Operator: decrement

    ................................................................................................................................... 5612 Operator: shift-left

    ................................................................................................................................... 5713 Operator: shift-right

    ................................................................................................................................... 5814 Operator: bit complement

    ................................................................................................................................... 5915 Operator: logical complement

    ................................................................................................................................... 6016 Operator: relational testing on equality

    ................................................................................................................................... 6117 Operator: relational testing on inequality

    ................................................................................................................................... 6118 Operator: relational less than

    ................................................................................................................................... 6219 Operator: relational less than or equal to

    ................................................................................................................................... 6320 Operator: relational greater than

    ................................................................................................................................... 6421 Operator: relational greater than or equal to

    ................................................................................................................................... 6422 Operator: positive edge detection

    ................................................................................................................................... 6623 Operator: negative edge detection

    ................................................................................................................................... 6724 Operator: positive and negative edge detection

    ................................................................................................................................... 6825 Operator: positive numerical change detection

    ................................................................................................................................... 6826 Operator: negative numerical change detection

    ................................................................................................................................... 6927 Operator: Address-of

    ................................................................................................................................... 7028 Operator: Contents-of or pointer indirection

    ................................................................................................................................... 7129 Operator: Array indexing or subscript

    ................................................................................................................................... 7230 Operator: Type conversion to the Boolean type

    ................................................................................................................................... 7331 Operator: Type conversion to the CHAR type

    ................................................................................................................................... 7432 Operator: Type conversion to the SHORT type

    ................................................................................................................................... 7433 Operator: Type conversion to the LONG type

    ................................................................................................................................... 7534 Operator: Type conversion to the 'pointer-to-' type

    ................................................................................................................................... 7635 Operator: The (direct) type conversion

    ................................................................................................................................... 7736 Operators: Order of operations

    ................................................................................................................................... 7937 Operators: Arithmetic overflows are not checked

    ................................................................................................................................... 7938 Operators: Attention with operators for edge and change detection

    Chapter 11 Arrays 82

    ................................................................................................................................... 821 Defining arrays

    ................................................................................................................................... 832 Using arrays

    ................................................................................................................................... 843 Multidimensional arrays

    Chapter 12 Pointers 86

    ................................................................................................................................... 861 Defining pointers

    ................................................................................................................................... 862 Using pointers

    Chapter 13 Strings 91

    ................................................................................................................................... 911 Defining a string

    Chapter 14 Statements 94

    ................................................................................................................................... 941 Conditional statement: if - else

  • Reference manual EPL programming language E5 2.05

    2014 E.D.&A. 4HPC

    Version

    ................................................................................................................................... 962 Conditional statement: while

    ................................................................................................................................... 983 Conditional statement: switch

    ................................................................................................................................... 1014 Statement: break

    ................................................................................................................................... 1015 Statement: continue

    ................................................................................................................................... 1026 Statement: asm

    Chapter 15 Type-casting 103

    ................................................................................................................................... 1031 Type-conversion rules

    ................................................................................................................................... 1042 Operations with different numerical types

    Chapter 16 Data retention: remanent variables 106

    ................................................................................................................................... 1061 Using the '#config remanent' compiler directive

    ................................................................................................................................... 1062 Using the 'remanent' keyword

    ................................................................................................................................... 1073 The number of remanent groups is limited

    Chapter 17 Functions 108

    ................................................................................................................................... 1081 Function declaration

    ................................................................................................................................... 1082 Function definition

    ................................................................................................................................... 1083 Function call

    ................................................................................................................................... 1094 Functions without parameters or return value

    ................................................................................................................................... 1095 Functions with return value

    ................................................................................................................................... 1106 Functions with parameters

    ................................................................................................................................... 1117 Functions with local variables

    ................................................................................................................................... 1138 Testing functions with local variables

    ................................................................................................................................... 1139 Functions with pointers as parameters

    ................................................................................................................................... 11510 Functions with multiple return values

    ................................................................................................................................... 11511 Functions with a variable number of parameters

    ................................................................................................................................... 11612 Libraries with functions

    Chapter 18 Versions Book E05 118

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 5HPC

    1 Introduction

    This manual describes the basis of the EPL programming language.

    Elements of the EPL LanguageStructure of an EPL programCallback functionsKernel functions and kernel variablesCompiler directivesNumerical typesConstantsVariablesOperatorsArraysPointersStringsStatementsType-castingData retention: remanent variablesFunctions

    6

    11

    14

    15

    17

    32

    35

    39

    45

    82

    86

    91

    94

    103

    106

    108

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 6HPC

    2 Elements of the EPL Language

    2.1 Spacing

    Spaces, tabulations, carriage-returns and line-feeds are spacing characters. These have no impact on theEPL statements, but are of significant importance when it comes to writing a readable program.The 2 following program examples do exactly the same, but because of the changes in spacing they lookquite different:

    Example of an unreadable program:

    main(){ if( e1.2) a1.1 = e1.1; else a1.1 = ~e1.1;}

    Example of a readable program:

    main(){ if( e1.2) a1.1 = e1.1; else a1.1 = ~e1.1;}

    2.2 Punctuation: the semicolon

    The semicolon character ';' must always be used to close a statement.After a compound statement there is no semicolon, because it is already closed by means of braces.

    Example 1:

    A2.2 = E1.1;

    Example 2:

    if( E1.1){ A1.2 = E1.2; A1.3 = E1.3; A1.4 = E1.4;}

    2.3 Punctuation: the comma

    The comma character ',' can be used to group consecutive statements into 1 statement and to fix the orderof execution from the left to the right.The result of the entire statement has the same type and the same value as the most right statement.

    The comma symbol is also used for separating various parameters in a function call or definition, and for

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 7HPC

    separating consecutive values in the definition of an initialised array.

    Example 1:

    if( S1 == 0) S1 = S2, S2 = S3;

    This is a non-recommend method to group statements. It is better to group the various statements into 1statement by enclosing them with braces.See also chapter The compound statement .

    Example 2:

    if( S1 = S2, S1 > 0)

    ...

    In this case the if-condition comprises 2 statements. Each evaluation of the if-condition includes theexecution of both statements. The first statement assigns variable S1 to S2, the second statement testswhether S1 is greater than 0. It is the result of this test that determines whether the statements within the ifwill be executed.

    2.4 Statements

    The statements of an EPL program are the instructions determining the course of the program. There areconditional statements to execute routines that depend on a condition, to jump to other routines and tomake loops.An EPL statement consists of keywords, expressions and other statements.A statement should always be closed by means of a semicolon.

    Example 1:

    A1.1 = E1.1;

    This is more or less the simplest statement in an EPL program. Here digital output A1.1 is set equal toinput E1.1.

    Example 2:

    if( E1.1) A1.1 = 1;

    An 'if' statement consists of two parts. The first part is the condition determining whether or not the secondpart will be executed.

    2.5 The compound statement

    A compound statement is the grouping of several consecutive statements into 1 statement.The typical use of a compound statement is the grouping of several statements for conditional executionwith a conditional statement. Of course a compound statement in its turn can also comprise a compoundstatement.

    7

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 8HPC

    Example 1:

    if( E1.1){ A1.2 = E1.2; A1.3 = E1.3;}

    Statements 'A1.2 = E1.2' and 'A1.3 = E1.3' constitute a compound statement, because both have to beexecuted conditionally.Without the braces, only statement 'A1.2 = E1.2' would be within the if-condition. Statement 'A1.3 = E1.3'would always be executed.

    Example 2:

    if( sec > 59){ sec = 0; min = min + 1; if( min > 59) { min = 0; hour = hour + 1; if( hour > 23) hour = 0; }}

    2.6 Operators and operands

    Operators are the symbols executing operations on numbers. The numbers, on which operations areexecuted, are called operands. Operands may be constants or variables, as well as the results of otheroperations.See also chapter Operators for a description of all operators.

    2.7 Constants

    A constant is a number, character or a string that is entered into the program as a fixed value. Constantscannot be changed during the execution of the program.When for example a variable is set to zero, actually, the constant 0 replaces the contents of the variable.Constants always have a numerical type such as char or short, and a sign bit or not (signed or unsigned).See also chapter Constants for a description of all types of constants.

    2.8 Global and local variables

    Variables are defined locations so that these locations can be used for storing numbers or other informationin a simple way.A global variable is a variable that is defined beyond a function. It is known and can be used throughout theprogram.Local variables however, are variables that are defined within a function. These variables are temporaryvariables that are known and can be used only within that specific function. Local variables are therefore

    45

    8

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 9HPC

    extremely suitable for the storage of intermediate results in more complex functions.

    2.9 Predefined variables

    In EPL language a number of variables are predefined, their widths varying from 1 to 32 bits.

    The variables of types Mx, Cx, Sx and Lx are internal variables for general use.The variables of types Ex.x, Ax.x, AEx.x and AAx.x are related to the physical in- and outputs of the HPC.They indicate the state of the physical inputs and determine the state of the physical outputs.

    These are all global variables so that they are known and can be used throughout the program.

    The number of predefined variables is determined by the HPC memory configuration.See also chapter Directive: #config .

    2.10 Names of variables and functions

    The name of a variable or function must begin with a letter and may further comprise a sequence of letters,figures and the underscore character '_'.The maximum length of a name is 16 characters. If longer names are defined, the EWB programmingsystem will shorten the name to 16 characters, giving a warning.

    Variables or functions cannot be defined with names starting with the name of predefined global variable.So, names such as 'l1counter' or 'ae5test' are not allowed.Variables and functions can neither be defined with names that are reserved as keywords.

    The EWB programming system makes no distinction between lower-case letters and upper-caseletters.

    2.11 Reserved keywords

    Reserved keywords are words that have a special meaning in the EPL language. That is why no variablesor functions can be defined with names that are reserved as keywords. However, a keyword can appear aspart of a longer word.

    The reserved keywords are:

    bool float kernel while break return

    char void callback switch continue auto

    short signed if case static direct

    long unsigned else default remanent asm

    on off

    2.12 Comments

    Comments allow a clarification of the HPC program. For example, anywhere in the program descriptions orfull explanations can be inserted, without any further consequences. Especially when an earlier writtenprogram must be modified, it will appear useful that the program was documented with some comments.

    During the compiling process (converting your program into machine codes which will be executed by theHPC), any comments will be fully ignored. So, they will not take any storage space in the HPC memory.

    19

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 10HPC

    The start of each block of comments, is indicated by two characters '/*', the end with '*/'. It can be a 1-linecomment or it can span multiple lines.

    Nesting of comments is discouraged! Older versions of the EWB32 program still allow it. Newer versions donot allow nested comments by default, but they have a compiler option to allow it. It is recommend not toturn it on. It is provided only to allow compilation of older programs that contain nested comments. Nested comments were used to comment-out a piece of program code but we recommend to use the "#if 0/ #endif" method instead! It is much easier to search a program for "#if 0" blocks then for commented-outblocks. The "/*" sequence will appear much more then "#if 0". See also Directive: #if, #else, #endif .

    Example 1:Behind a line some comments can be placed:

    a1.1 = e1.1; /* pump 1 */a1.2 = e1.2; /* pump 2 */a1.3 = e1.3; /* fan 1 */a1.4 = e1.4; /* fan 2 */

    Example 2: A comment may contain several lines. Often, * or ** characters are used at the beginning of each line of amulti-line comment to make it more visible:

    /* drive the pumps* a1.1 is pump1* a1.2 is pump2*/a1.1 = e1.1;a1.2 = e1.2;

    /* drive the fans** a1.3 is fan1** a1.4 is fan2*/a1.3 = e1.3;a1.4 = e1.4;

    24

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 11HPC

    3 Structure of an EPL program

    3.1 A minimum EPL program

    #include /* standard includes */#include

    main() /* definition main() function */{ a1.1 = e1.1 & e1.2; /* program lines */}

    init() /* definition init() function */{ /* may be empty */}

    3.2 A more extended EPL program

    #include /* standard includes */#include #include /* add libraries */

    #define tist s1 /* name variables */#define tsoll s2

    set temp(); /* declare set function */

    main() /* definition main() function */{ tist = AE1.1 / 164; /* program lines */

    set temp(); /* call the set function */

    a1.2 = ton( &L1, a1.1, 60000); /* alarm if a1.1 stays on */}

    set temp() /* definition set function */{ if( ^/b1s)/* set once every second */ { if( tist < tsoll) /* command heating on/off */ a1.1 = 1; else a1.1 = 0; }}

    init() /* definition init() function */

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 12HPC

    { tsoll = 60; /* single initialization */}

    initremanent()/* definition initremanent() function */{}

    3.3 Description

    #target:The compiler preliminary operation '#target' indicates for which HPC model the program is made.This way the compiler (conversion program) can generate the correct code for that HPC.

    #include:The compiler preliminary operation '#include indicates that the mentioned file must be included in thecompilation.On the one hand, include files can be files with definitions, such as:

    stdcfg.h: the standard memory and i/o configuration for the program.kernel.h: the definitions of the HPC kernel. This describes a number of HPC-built-in systemfunctions such as the triggering of a display or communications port.

    On the other hand, also library files can be included, such as:

    timers.h: a library with timer functions

    #define:With the compiler preliminary operation '#define' a name can be assigned to a variable or constant.This way the name can be used later on in the program.

    settemp():Functions which have been defined by the user must be declared first. This way the EWBprogramming system is told whether parameters need to be included with the functions and whetherthe function has a return value.

    main():Then follows the definition of the main() function. The main() function is a function which is written bythe user and which is continuously called by the HPC system. So it contains the principal part of theHPC program which needs to be executed every cycle.See also chapter Callback function .

    settemp():In this example the proper settemp() function is defined. This definition establishes the statements ofthe function.

    init():As the init() function is only called once when starting up the HPC, even prior to execution of themain() function, the user can now write the program lines which need to be executed once whenstarting up the HPC. So, here the typical initialization statements are placed, such as giving aninitial value to variables or opening a communications port.See also chapter Callback functions .

    initremanent():The initremanent() function operates similar to the init() function, but is only called in case of a coldstart.

    14

    14

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 13HPC

    See also chapter Callback functions .14

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 14HPC

    4 Callback functions

    Callback functions are functions which are written by the user but which are called by the HPC system. Bydoing so, the HPC requests for a section of the program to be executed.

    The execution of an HPC program is effected in terms of cycles. Therefore the program must be written insuch a way that it can run through each cycle in a smooth way. If for example an event is due, the programshould not be kept in a loop until the event finally happens. Instead, it should test each and every cyclewhether or not that event has happened.

    See also chapter Structure of an EPL program .

    4.1 Callback function main()

    The callback function main() is the most important. It is continuously called by the HPC. It contains thestatements that are executed each HPC cycle.

    4.2 Callback function init()

    The callback function init() is only called once, i.e. when starting up the HPC. It is therefore basicallyqualified to write the program lines that need to be executed once, when starting up the HPC. So, here thetypical initialisation statements are placed, such as giving an initial value to variables or opening acommunications port.When the HPC is started up, the init() function is executed once, prior to main() being called for the firsttime.

    4.3 Callback function initremanent()

    The callback function initremanent() is only called once, upon a cold start of the HPC. It can therefore beused to (re)initialize remanent (non-volatile) variables after a cold start.In case of a cold start of the HPC, the initremanent() function is executed once, prior to init() being called.

    4.4 Callback functions EventTimer1() and EventTimer2()

    The callback functions eventtimer1() and eventtimer2() are timer interrupt functions. The HPC may hold 2timers that can be set to expire periodically, at the pre-set times. Each time a timer expires, an interrupt(interruption of the running program) occurs and the according timer event function is called. Because thesefunctions are executed as an interrupt, they cannot take too long.

    11

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 15HPC

    5 Kernel functions and kernel variables

    Kernel functions are HPC-built-in system functions such as commanding a display or a communicationsport. Kernel variables are HPC-built-in system variables. These are basically variables which are completed bythe system and which can be used by the program.The EWB programming system uses the include file 'kernel.h' which states the declarations of all thesefunctions and variables.

    5.1 Kernel functions

    Kernel functions are located in the HPC system software as such. Nevertheless they are called in thesame way as ordinary library functions or user-written functions.See also the 'Library functions' guide for a description of the kernel functions.

    Example:

    if (^/B1S) RtcRead( &S10);

    Once every second the kernel function RtcRead() is called. It reads the timer and enters the numbers inS10..S16.

    5.2 Kernel variables

    Kernel variables are completed by the system and can be used by the program. A few can also be written.Kernel variables are global variables. A survey in which the type of number and the name of each variable is given:

    unsigned long TimerTicks; Is increased with 1 every 1 millisecond. Can be used for all kinds oftiming. Starts again from 0 when after 49 days the maximumvalue is reached.

    bool b1t; Blinker: blinks continuously with a period of 0.1 second.

    bool b2t; Blinker: blinks continuously with a period of 0.2 second.

    bool b5t; Blinker: blinks continuously with a period of 0.5 second.

    bool b1s; Blinker: blinks continuously with a period of 1 second.

    bool b2s; Blinker: blinks continuously with a period of 2 seconds.

    bool b5s; Blinker: blinks continuously with a period of 5 seconds.

    bool b10s; Blinker: blinks continuously with a period of 10 seconds.

    unsigned short scantimelast; Gives the last measured scan time in milliseconds.

    unsigned shortscantimelongest;

    Gives the longest (since last reset) measured scan time inmilliseconds.

    unsigned shortscantimeforcemin;

    Determines the minimum scan time in milliseconds. At the end ofthe cycle, the HPC keeps lingering for a while until the time isexpired, so as to stimulate a longer scan time.

    unsigned long scannr; Is increased with 1 every program cycle. Is 1 for the first cycle.Blocks when the maximum value is reached.

    short currentrunerror; Indicates the current error code if the HPC is in error.

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 16HPC

    long HsCounter1,HsCounter2;

    Only available on HPC model V5_xxx. These indicate the reading ofthe built-in high-speed-counter. Can also be written.

    Example:

    a1.1 = b5t;

    if (^/B1S) S1++;

    Output a1.1 follows blinker b5t so that the latter blinks at a rate of 2 Hz.S1 is increased with 1 each second.

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 17HPC

    6 Compiler directives

    Compiling means converting the HPC program that was written by you into machine codes which areexecuted by the HPC. The compiler is the software module that will take care of that.Compiler directives are instructions to the compiler. This may have an impact on the compiling process,but also allows for the HPC program to be written in a more readable form.Compiler directives always start with a '#' symbol. They are also known as 'pre-processor commands.Compiler directives are not closed with a ';'

    6.1 Directive: #target

    Purpose:Indicates for which HPC model the program is intended. This command is for compatibility only. It issuperseeded by the target selection in the compiler option dialogue of EWB.

    Syntax:

    #target

    Description:The #target directive specifies for which HPC model the program is intended. The compiler needs this information because different machine codes must be generated for different CPUmodels.

    The standard machine code generated for the CPU is set as 'default target' in the 'Options/Compileroptions' menu. The #target directives, however, have priority over that standard setting.The #target directive must be placed quite in front of the program, even before the #include directives.

    Some examples of targets:

    V5-HPC, 8MHz CPU

    V5-HPC, 20MHz CPU

    V10-HPC, 8MHz CPU

    V10-HPC, the newer CE model, 8MHz CPU

    V20-HPC, 8MHz CPU

    V50-HPC, 8MHz CPU

    V50-HPC, 16MHz CPU

    V50-HPC, the newer CE model, 8MHz CPU

    V50-HPC, the newer CE model, 20MHz CPU

    V50-HPC, the newer CE model, 40MHz CPU

    If during the compiling process an error code appears on this line, it probably means that the targetconcerned is not installed in your EWB programming software. In the 'Options/Compiler options' menu youcan click on the 'Default target' button to achieve a list of the installed targets. Non-installed targets can beordered.

    Example:

    #target

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 18HPC

    #include #include

    main(){ }

    6.2 Directive: #include

    Purpose:Inserting program text.

    Syntax:

    #include

    Description:The #include directive allows to insert files with program text into the program. During the compilingprocess, the text of the include file is literally inserted on that spot, so that an include file may containanything.An include file is mostly of the '.H' type, the '.H' being short for 'header file'. If the type of file is notindicated, the EWB programming system assumes that it is an '.EPL' file.

    The #include directive is used to insert files with definitions or function libraries.

    If the file name indicates an absolute path, that is a directory name starting from the root directory, such as'C:\BIB\SOM.H', of course the file in that directory is used.If the file name however does not indicate any path or only indicates a relative path, the include file is firstsearched for in the project directory. That is the directory where the main .EPL file was opened. If theinclude file was not found there, the file is searched for in the standard include directory. This is usually'\EWB\INCLUDE\80186_01\' and there you will also find the E.D.&A. supplied standard include files.

    An include file, in its turn, can also make use of #include directives to insert other files. Up to a maximumof 8 levels can be operated this way.

    There are also precompiled include files. These are already compiled and are therefore no longerreadable and as such, cannot be edited any more!Precompiled include files normally are provided with the *.PCH file extension.

    Example 1:

    #include #include #include #include

    main(){

    ...}

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 19HPC

    Once the standard include files are inserted, also 'timers.h' and 'display.h' are added. 'Timers.h' is thelibrary with timer functions and 'display.h' contains functions for controlling the display on V5 series HPC's.

    Example 2:

    #include #include #include #include

    main(){

    ...}

    After the standard include files, also the precompiled library 'spec1.pch' is inserted.

    6.3 Directive: #config

    Purpose:Partitioning the RAM data memory.

    Syntax:

    #config

    Description:The #config directive allows to divide the HPC data memory among the various types of variables. Thispartitioning is called the configuration.The configuration determines:

    The global variables: the number of markers (Mx), chars (Cx), shorts (Sx) and longs (Lx)The i/o variables: the number of inputs and outputs per i/o cardThe data retention: what global variables are retained in case of a power failure

    To allow an easy start-up of a program, a standard configuration is supplied. This is found in the 'stdcfg.h'file and can be inserted in the program by means of the #include directive:

    #include

    Memory configuration is limited to the available HPC RAM memory. A configuration of more memorythan available will result in error code E01 when the program is downloaded into the HPC.

    Configuration of the global variables

    For each type of global variable, the amount must be configured. This way an efficient memory usage ispossible. If for example no long variables are used, then also no memory should be wasted on them.

    Syntax:

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 20HPC

    #config :

    With:

    = M configuring the markers (1 bit)

    = C configuring the chars (8 bits)

    = S configuring the shorts (16 bit)

    = L configuring the longs (32 bit)

    specifies the number of variables of that type.This may be an expression, but it must produce a constant value during the compilingprocess.The number must be between 1 and 65536 and depends on the type of HPC and theavailable data memory.

    Example:

    #config m:1000#config c:10*100#config s:500#config l:10

    Although the marker variables have a width of 1 bit, still 1 byte is used per marker. This is for reasonsof processing speed.

    Configuration of the i/o variables

    The configuration of the i/o variables reserves memory where the state of the in- and outputs will be stored.For each i/o card the number of in- and outputs must be configured. If the number of i/o of a card does notcorrespond with the configured number, the system will choose a proper solution, by still using as many i/oas possible from the card.

    Syntax:

    #config :

    With:

    = E configuring the digital inputs

    =AE

    configuring the analogue inputs

    = A configuring the digital outputs

    =AA

    configuring the analogue outputs

    being the i/o card number.The number must be between 1 and 255 and depends on the HPC type and thei/o card.

    specifies the number of i/o variables for the i/o card.This may be an expression, but it must produce a constant value during thecompiling process.

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 21HPC

    The number must be between 1 and 255 and depends on the HPC type and thei/o card.

    Example:

    #config E1:16#config E2:16#config AE1:8#config AE2:8

    When making use of VNET, it is also possible to configure a number of i/o cards as remote i/o. This meansthat the i/o cards are not placed in the HPC, but in one or several 'slave' HPC's which are linked to the'master' through VNET.By indicating in the master i/o configuration that certain i/o cards are 'remote', the system will itself handleall communications with the remote i/o slaves. In the master program, the remote i/o can be used in thesame way as if the i/o cards were placed in the master.

    Syntax:

    #config remote :

    With:

    being the VNET node number of the slave HPC where the respective remotei/o card is located.

    being the same as with the configuration of an ordinary local i/o card.

    Example:

    #config E1:16#config E2:16#config remote 2 E3:16#config remote 2 E4:16#config remote 3 E5:16

    Configuration of data retention: remanent variables

    Remanent variables are variables the value of which is retained in case of power failure. By means of the'#config remanent' directive groups of variables can be made remanent in one effort.

    Of course, the HPC must be provided with the battery-backup option in order to allow retention of datain case of power failure.

    Syntax:

    #config remanent :

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 22HPC

    With:

    = M to make a group of markers remanent

    = C to make a group of chars remanent

    = S to make a group of shorts remanent

    = L to make a group of longs remanent

    the number of variables of that type that is made remanent.This can be an expression, but it must produce a constant value during thecompiling process.The number must be between 1 and the number of configured variables of that type.

    Example:

    #config remanent l1:100 /* makes L1 .. L100 remanent */#config remanent s90:11 /* makes S90 .. S100 remanent */

    In a configuration a maximum of 64 non-contiguous and non-overlapping groups can be configured asremanent. However, 256 groups may be configured as remanent, provided that they can be joined togetherby the EWB programming system, up to a maximum of 64 larger, non-overlapping groups.

    For example:

    #config remanent l1:100 /* makes L1 .. L100 remanent */#config remanent l100:100 /* makes L100 .. L199 remanent */#config remanent S50:20 /* makes S50 .. S69 remanent */#config remanent S70:11 /* makes S70 .. S80 remanent */

    is optimized by the programming system into 2 groups:

    #config remanent l1:199 /* makes L1 .. L199 remanent */#config remanent S50:31 /* makes S50 .. S80 remanent */

    See also chapters Arrays and Data retention: remanent variables for an alternative method tomake variables remanent.

    6.4 Directive: #define

    Purpose:Defining a macro or constant.

    Syntax:#define macro-name replacement-text

    Description:The replacement is not performed if the macro-name:

    appears in a comment field

    82 106

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 23HPC

    appears in a string constant. is part of a larger contiguous text.

    When redefining an already defined macro, you will get an error code, unless the new definition is identicalto the old one.The length of the macro-name is limited to 16 characters. The replacement-text can be so long that theentire line reaches the maximum line length of 512 characters.Up to a maximum of 1000 macros can be fixed by means of #define.

    Example 1:

    #define pump1 A1.1#define start E1.1#define stop E1.2

    pump1 = (start | pump1)& stop;

    Variables can be given symbolic names, so that these names can be used in the program.

    Example 2:

    #define ALEN 10#define DISPLAY 2#define AUTOMATIC

    S100[ ALEN];

    S1 = 0;while (S1 < ALEN) ...

    #ifdef AUTOMATIC if( ^/b1s) S1++;#endif

    comprints( DISPLAY, "Please press START");

    Constants can be given symbolic names, so that these names can be used in the program. An additionaladvantage is that when the definition is changed, the entire program is adjusted. Also a definition can beused to switch program sections on or off.

    6.5 Directive: #undefine

    Purpose:Cancelling a macro or constant definition.

    Syntax:#undefine macro-name

    Description:The #undefine directive deletes an earlier defined macro or constant. As from that moment, it is againundefined. If the macro was not defined, an error code will appear.

    This way an earlier definition can be deleted, in order to redefine the same with another replacement text. It

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 24HPC

    is however not common practice to redefine standard-defined macros such as TRUE or NULL!

    Example:

    #define TEST

    #ifdef TEST /* this is included in the program */#endif

    #undefine TEST

    #ifdef TEST /* this is NOT included in the program */#endif

    6.6 Directive: #if, #else, #endif

    Purpose:Conditional compiling of program sections.

    Syntax:

    #if condition1 #else #endif

    Description:The #if, #else and #endif directives allow conditional compiling. Here, during the compiling process bymeans of a condition it can be determined whether or not a program section is to be compiled, andtherefore, whether or not it is included in the program.The #else leg is optional and therefore can be omitted.The #endif is always required to close the #if or #else leg.

    The leg of the #if section is compiled if condition1 results in a value which is different from 0. If condition1results in a value of 0, only the leg of the #else section is compiled.

    The condition can be written as an equation such as:

    #if NUMBER =50 & NUMBER

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 25HPC

    #if 1

    #if TESTMODE

    The #if and #else directives may be 'nested' so that within an #if or #else several other #if and #else legsmay be included.

    An #if 0 ... #endif block is ofted used to temporary disable a piece of program code. It's easy to turn it backon by replacing the #if 0 with #if 1. It is also easy to find disabled code by searching for "#if 0"...

    Example 1:

    #define DISPLAYPORT 2

    main(){ #if DISPLAYPORT >= 0 comprints( DISPLAYPORT, "Please press START");#endif }

    init(){#if DISPLAYPORT >= 0 comopen( DISPLAYPORT, "1200,n,8,1");#endif}

    'DISPLAYPORT' determines which serial port must be used. If 'DISPLAYPORT' is less than 0, like -1, thenthe serial port is not used.

    Example 2:

    #define SYSTEM 1

    #if SYSTEM==1 #define DISPLAYPORT 1 #define ENGLISH 0 #define START E1.1#endif#if SYSTEM==2 #define DISPLAYPORT 2 #define ENGLISH 1 #define START E1.8#endif

    main(){#if ENGLISH comprints( DISPLAYPORT, "Please press START");#else

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 26HPC

    comprints( DISPLAYPORT, "Druk op START");#endif}

    The definition of 'SYSTEM' determines the correct settings of DISPLAYPORT, ENGLISH and START.

    Example 3:

    main(){

    if( ^/b1s)

    { dispprintf( 1, 1, "Temp1=%4d", S1); dispprintf( 1, 10, "Temp2=%4d", S2);#if 0 dispprintf( 2, 1, "Temp3=%4d", S3); dispprintf( 2, 10, "Temp4=%4d", S4);#endif

    }}

    The '#if 0 ' is used to disable a few lines of code.

    6.7 Directive: #ifdef, #ifndef

    Purpose:Conditional compiling of sections.

    Syntax:

    #ifdef macroname1 #else #endif

    Description:The #ifdef and #ifndef directives allow for conditional compiling. During the compiling process, by whether ornot defining macroname1 it can be determined whether or not a particular section should be compiled, sowhether or not it should be included in the program.The #else leg is optional and therefore can be omitted.The #endif is always required to close the #ifdef, #ifndef or #else leg.

    In a #ifdef directive the leg of the #ifdef section is only compiled if macroname1 is defined. The #elsesection is only compiled if macroname1 is not defined.In a #ifndef directive the leg of the #ifdef section is only compiled if macroname1 is not defined. The #elsesection is only compiled if macroname1 is defined.

    The #ifdef and #ifndef directives may be 'nested' so that they can include one another.

    Example:

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 27HPC

    #define DISPLAYPORT 2

    #ifndef TEXT #define TEXT #define STARTTEXT "Please press START" #define STOPTEXT "Please press STOP"#endif

    main(){ #ifdef DISPLAYPORT comprints( DISPLAYPORT, STARTTEXT);#endif }

    init(){#ifdef DISPLAYPORT comopen( DISPLAYPORT, "1200,n,8,1");#endif}

    If the 'TEXT' macro was not yet defined, it is now defined, together with the STARTTEXT and STOPTEXTmacros. The routines for serial communication are only compiled if DISPLAYPORT is defined.

    6.8 Directive: #abort

    Purpose:Abort compiling with or without message.

    Syntax:

    #abort text1

    Description:The #abort directive allows the compiling to be aborted. During the compiling process, conditions can beverified and the compiling can be stopped if a condition is not met.The text1 is optional and therefore can be omitted.

    Example:

    #define ARRAYLEN 200

    #if ARRAYLEN > 100 #abort ARRAYLEN > 100#endif

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 28HPC

    S100[ ARRAYLEN];S200[ 10];

    The definition of 'ARRAYLEN' determines the size of array S100. The maximum size in this case is 100elements. When a larger array is defined, the compiling process is aborted with message "ARRAYLEN >100".

    6.9 Directive: #pragma

    Purpose:Influencing the compilation by changing compiler settings during the compilation process. Pragma is shortfor pragmatic.

    Syntax:

    #pragma parameter value

    Description:The #pragma directive allows a compiler setting to be modified during the compilation process. It can beused to compile various routines with various settings.

    6.10 Directive: #pragma debug

    Purpose:Switching on or off of inserting debug information in the program.

    Syntax:

    #pragma debug value

    Description:The debug parameter determines whether the compiler should insert debug information in the compiledprogram. Functions with debug information can be traced when the program is tested. Tracing is the line-per-line execution of the statements of a function, and allowing the placing of breakpoints.

    Value 'on': debug information switched on.Value 'off': debug information switched off.No value: the parameter is reset to the settings in the 'Options/Compiler options' menu.

    A typical use is the switching off of debug information in library files. This way it can be prevented thatsuperfluous debug information is inserted in the already tested library functions.

    If this setting is on, the inserted debug information makes the compiled program a little larger and a littleslower.

    In order to allow using this capability, the EWB programming system must contain the optional debugmodule.

    Example:

    /* library with convenient functions */

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 29HPC

    #pragma debug off

    short find_s( short *ps, short val){ }

    long sumlongs( long *pl, short number){ }

    #pragma debug

    In the beginning of the EPL library file '#pragma debug off' is used to switch off the inserting of debuginformation, so as to prevent superfluous debug information. In the end, the standard setting is restored.

    6.11 Directive: #pragma mathcheck

    Purpose:Switching on or off of the overflow checking during calculations.

    Syntax:

    #pragma mathcheck value

    Description:The mathcheck parameter determines whether the compiler should include overflow checking duringcalculations. If for example two short variables with value 20000 are added, an overflow is generated as themaximum value of a signed short is +32767.

    Value 'off': checking is switched off.No value: the parameter is reset to the settings in the 'Options/Compiler options' menu.

    By switching off the mathcheck parameter, it can be prevented that the overflow checking be executed on aroutine where it is not desired, or that superfluous checks are executed on already tested routines.

    Overflow checking is only included with calculations involving the +, - and * operators.

    If this setting is on, the included checks will make the compiled program a little larger and a little slower.

    In order to allow using this capability, the EWB programming system must contain the optional debugmodule.

    Example:

    main(){#pragma mathcheck off

    s3 = s1 * s2;

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 30HPC

    #pragma mathcheck

    s4 = s1 + s2;}

    For the 's3 = s1 * s2' statement the mathcheck parameter is switched off. Then the standard setting isrestored, so that for the 's4 = s1 + s2' statement the overflow checking is executed.

    6.12 Directive: #pragma boundcheck

    Purpose:Switching on or off of the checking of array indexing.

    Syntax:

    #pragma boundcheck value

    Description:The boundcheck parameter determines whether the compiler should include checking on the indexing ofarrays. With each array indexing, it is checked whether the index is valid.

    Value 'off': checking switched off.No value: the parameter is reset to the settings in the 'Options/Compiler options' menu.

    By switching off the boundcheck parameter, it can be prevented that the index checking is executed on aroutine where it is undesired, or that superfluous checking are executed on already tested routines.

    The index checking is only included if it concerns the indexing of an explicitly defined array. An indexingcan also be applied on a pointer for example, but then a checking of the index cannot be included, becausethe size of the array is not explicitly defined.

    If this setting is on, the included checking will make the compiled program a little larger and a little slower.

    In order to allow using this capability, the EWB programming system must contain the optional debugmodule.

    Example:

    main(){#pragma boundcheck off

    s2 = s100[ s1];

    #pragma boundcheck

    s3 = s200[ s1];

    s1++;}

    For statement 's2 = s100[ s1]' the boundcheck parameter is switched off. Then the standard setting is

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 31HPC

    restored so that for statement 's3 = s200[ s1]' the index checking is indeed executed.

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 32HPC

    7 Numerical types

    The E.D.&A. HPC's operating with the EPL language internally use the binary number system. That is whythe binary number system is discussed first.The binary number system is also known as 'Boolean arithmetic'.

    7.1 The binary number system

    The binary number system is based upon the two values zero (0) and one (1). The basic operations onBoolean numbers are AND, OR and NOT. These base operations produce the following results:

    0 AND 0 makes 0

    0 AND 1 makes 0

    1 AND 0 makes 0

    1 AND 1 makes 1

    0 OR 0 makes 0

    0 OR 1 makes 1

    1 OR 0 makes 1

    1 OR 1 makes 1

    NOT 0 makes 1

    NOT 1 makes 0

    In the EPL language the operations AND, OR and NOT are represented by the following symbols (oroperators):

    & for AND| for OR~ for NOT

    Because numbers 0 and 1 are well qualified to represent OFF and ON, or TRUE and FALSE, this numbersystem is ideal for switching technology.

    In order to represent numbers greater than 1, several bits must be used together.Two bits give 4 possible combinations: 00, 01, 10 and 11, which means they can have values 0, 1, 2 and 3.Each time an extra bit is added, the number of possible combinations is doubled.

    In the HPC one memory cell (1 byte) comprises 8 bits, which results in the following possibilities:00000000, 00000001, up to 11111111 by means of which numbers from 0 up to 255 can be represented.The rightmost bit is the bit with value 1. The bit on the left thereof has the double value, that is 2. The thirdbit again has the double value, so 4.We can add up all bit values; when all bits are on, this results in (from right to left) the sum of 1+2+4+8+16+32+64+128 = 255.This also provides us with a method to convert a binary number into a readable decimal number.For example: 01000101 has the following value: 1+4+64 = 69.

    When a memory byte contains value 11111111 or 255, and the byte is increased with 1, it returns to00000000, just like a mileage counter when going from 99999 to 00000.

    When numbers over 255 are needed, the use of 8 bits is no longer sufficient. In this case several memorycells (bytes) must be used. Two bytes result in 16 bits, which is already sufficient to count up to 65535.

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 33HPC

    Until now, we have only discussed positive numbers, but the bits forming a binary number can also beinterpreted differently, so that both positive and negative numbers can be used.Here the most left (highest) bit of the number is used as a sign bit. If the sign bit represents 0, we aredealing with a positive number, if the sign bit is 1, it represents a negative number.This method of presentation is called the '2-complement'.

    A number with a sign bit is called a 'signed' number, whereas numbers without sign bit are called'unsigned'.

    As the utmost left bit now operates as a sign bit, it is no longer possible to represent such large numbers.

    The largest positive number that can be represented, when using 8 bits, will be 01111111 or +127.A negative number can be obtained by subtracting 1 from the number 0 (think about what would happenwith the mileage counter):

    initial value 00000000 or decimal 0subtracting 1 makes 11111111 or decimal -1subtracting 1 more makes 11111110 or decimal -2

    The most negative number of 8 bits that can be represented is 10000000 or -128.Or in a tabular presentation:

    Binary number unsigned value signed value

    00000000 0 0

    00000001 1 1

    00000010 2 2

    ... ... ...

    01111110 126 126

    01111111 127 127

    10000000 128 -128

    10000001 129 -127

    ... ... ...

    11111101 253 -3

    11111110 254 -2

    11111111 255 -1

    In order to find a proper solution for all kinds of commands, the EPL language includes different types ofnumbers, sized 1, 8, 16 and 32 bits.

    7.2 The 'Boolean' numerical type

    'Boolean' types have a width of only 1 bit. Therefore, they can only take two values, that is 0 and 1. So,there is no sign bit.

    In switching technology this type is well qualified for representing open or closed contacts.

    Range: values 0 and 1.

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 34HPC

    7.3 The 'char' numerical type

    'Char' (or 'character' in full) numerical types have a width of 8 bits.They are available with or without sign bit.

    Range:with sign bit (signed): from-128 up to +127.without sign bit (unsigned): from 0 up to 255.

    The 'character' numerical type is quite suitable for the presentation or storage of characters, because theASCII code of characters has a width of 7 or 8 bits.

    7.4 The 'short' numerical type

    'Short' numbers have a width of 16 bits and therefore take 2 bytes of memory space. They are available with or without sign bit.

    Range:with sign bit (signed): from -32768 up to +32767.short without sign bit (unsigned): from 0 up to 65535.

    The 'short' number is quite suitable for general calculating and counting.

    7.5 The 'long' numerical type

    'Long' numbers have a width of 32 bits and therefore take 4 bytes of memory space. They are available with or without sign bit.

    Range:with sign bit (signed): from -2147483648 up to +2147483647.without sign bit (unsigned): from 0 up to 4294967295.

    The 'long' number is suitable for calculating and counting numbers that are too large for the 'short' numericaltype.

    7.6 Survey of the numerical types

    A survey of the various numerical types with their minimum and maximum values:

    signed unsignedmin max min max

    bool 0 1char -128 +127 0 255short -32768 +32767 0 65535long -2147483648 +2147483647 0 4294967295

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 35HPC

    8 Constants

    A constant is a number, a character or a string, which is entered in the program as fixed values. Constantscannot be modified during program execution.Constants always have a numerical type such as char or short, and may have or may not have a sign bit(signed or unsigned).A constant can be entered in various forms, the decimal form being the most commonly used.

    When the standard type of a constant is not sufficient, a type cast can be used to change the type ofthe constant.See also chapter Type-casting .

    8.1 Decimal constant

    Is entered as an ordinary decimal number without prefixes. The standard decimal constant is of the 'short'type with sign bit, so that positive and negative numbers ranging from -32768 up to 32767 can be entered.

    For example: 0, 1, 17, -1000 and 32767 are of the 'signed short' type.

    If the number no longer fits into the 'short' type, such as -40000 or 1000000, then the constant willautomatically become of the 'long' type. If the number is too large for 'signed long' but still fits into 'unsignedlong' then the constant will receive the 'unsigned long' type.It is also possible to give a smaller number a 'long' type by adding a letter 'L'.

    For example: 1000L and 2000000000 get the 'signed long' type4000000000 gets the 'unsigned long' type

    8.2 Hexadecimal constant

    The hexadecimal constant starts with prefix '0x'. The default hexadecimal constant has the 'short' typewithout sign bit.

    For example: 0x11 which equals 17 decimal0x2F0 which equals 752 decimal0xABCD which equals 43981 decimal

    If the number no longer fits in the 'unsigned short' it automatically converts into 'unsigned long'.

    For example:0x12345 which equals 74565 decimal0xEE6B2800 which equals 4000000000 decimal

    8.3 Binary constant

    The binary constant starts with prefix '0b'. The default binary constant is of the 'short' type without sign bit.If the number no longer fits into the 'unsigned short', it is automatically converted into 'unsigned long'.

    For example: 0b111 which equals 7 decimal0b01100111 which equals 103 decimal

    103

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 36HPC

    8.4 Character constant

    The character constant consists of a character enclosed by apostrophes '. The default character constantis of the 'char' type with sign bit.

    For example:'A' which equals 65 decimal'\r' which equals 13 decimal

    See also chapter Escape sequences for entering special characters.It is also possible to enter several characters in a single character constant. Then the constant is convertedinto a 'short' or 'long' type with sign bit. A maximum of 4 characters can appear in 1 character constant.

    For example:'AB' which equals 0x4241 hexadecimal'12EF' which equals 0x46453231 hexadecimal

    8.5 String constant

    A special form of constant is the string constant. A string constant comprises a series of charactersquotation marks, such as for example "a" or "John Smith".A classical use of the string constant is sending a text to a communications port, such as in:

    comprints( 1, "Good Morning");

    In the EPL language a string is always terminated with a zero, indicating the end of a string. Therefore, thestring will always take 1 character more in the HPC memory than the number of characters in the string.The string constant is of the 'address of a char' numerical type, which means that the comprints() functionis not passed all characters of the string, but only the address of the first memory location where the stringwas stored.

    A long string constant can be written over several program lines, so that the long string still remainsconvenient, such as in:

    comprints( 1, "At this moment the " "pump has stopped");

    To that effect a string is to be closed at the end of the line with a quotation mark (") and the followingprogram line is to be restarted with a quotation mark. The consecutive strings are then automatically joinedtogether by the EWB programming system into one string.

    A special form of string constant is the common practice to initialise an array of characters with a text,such as in:

    char c1[20] = "The name is:";

    Here, variables c1 up to c11 will be filled with the consecutive string characters. Variable c12 will be filledwith a 0 (zero) to terminate the string. So the string will take 13 characters of memory space. The 7remaining positions will also be filed with zeros.

    37

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 37HPC

    8.6 ASCII table

    ASCII is a default 7-bit code by means of which 128 different letters, digits and other symbols can berepresented. For storage of an ASCII character 1 byte (8 bits) is used. The highest bit is not used and is 0.The 32 lowest ASCII codes do not contain any printable characters but command codes.

    dec 0 16 32 48 64 80 96 112

    hex 0x 1x 2x 3x 4x 5x 6x 7x

    +0 +x0 NULL DLE Space 0 @ P ` p

    +1 +x1 SOH DC1/Xon ! 1 A Q a q

    +2 +x2 STX DC2 " 2 B R b r

    +3 +x3 ETX DC3/Xoff # 3 C S c s

    +4 +x4 EOT DC4 $ 4 D T d t

    +5 +x5 ENQ NAK % 5 E U e u

    +6 +x6 ACK SYN & 6 F V f v

    +7 +x7 BEL ETB ' 7 G V g w

    +8 +x8 BS CAN ( 8 H X h x

    +9 +x9 HT EM ) 9 I Y i y

    +10 +xA LF SUB * : J Z j z

    +11 +xB VT ESC + ; K [ k {

    +12 +xC FF FS , < L \ l |

    +13 +xD CR GS - = M ] m }

    +14 +xE SO RS . > N ^ n ~

    +15 +xF SI US / ? O _ o DEL

    8.7 Escape sequences

    Special characters such as the 'carriage return', 'line feed' and 'escape' command codes cannot be enteredin the usual way, because they have a reserved meaning. Because for the sending of data these charactersare often needed, for example a 'carriage return' and 'line feed' at the end of each line on a printer, there is asimple method to enter these characters. This method is called 'escape sequences'.An escape sequence always starts with a backslash '\' character, followed by a letter, a symbol or adecimal or hexadecimal number. The most common command codes are indicated with a letter, whereasall others can be entered with a number.

    Escape sequence Meaning Hexadecimal code Decimal code

    \r carriage return 0x0D 13

    \n new line of line feed 0x0A 10

    \f form feed 0x0C 12

    \b backspace 0x08 8

    \t tabulation 0x09 9

    \v vertical tab 0x0B 11

    \a alert of bell 0x07 7

    \e escape 0x1B 27

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 38HPC

    \' the accent ' 0x27 39

    \" the quotation mark " 0x22 34

    \\ backslash \ 0x5C 92

    An escape sequence can be used both as a single character and in a string:

    c100 = '\\';comprints( 1, "Hello world\r\n");comprints( 1, "Name is \"John\"");

    It is also possible to enter special characters by means of their ASCII value.In decimal form the escape sequence consists of a backslash character, followed by 1, 2 or 3 digits:

    \001 the control-A character\27 the escape character\240 ASCII code 240

    In hexadecimal form the escape sequence consists of a backslash character, followed by 0x and 1 or 2hexadecimal digits:

    \0x1 the control-A character\0x1B the escape character\0xF0 ASCII code 0xF0 or 240

    The EWB programming system will try to use the maximum number of digits for the escapesequence, like 3 for the decimal form.To get the following output:

    12

    The following statement is incorrect:

    ComPrintf( 1, "\912");

    But the following statement is correct:

    ComPrintf( 1, "\00912");

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 39HPC

    9 Variables

    Variables are named memory locations so that these locations can be used in a simple way for storage ofnumbers or any other information. The EPL language offers variables of various types, with their widthsvarying from 1 bit up to 32 bits.A number of variables are connected to the physical in- and outputs of the HPC. They indicate the state ofthe physical inputs and determine the state of the physical outputs.

    9.1 Variable: Mx

    Description:A marker is a variable with a width of only 1 bit. Hence, it can take only two positions. This can berepresented by an open or closed contact in relay technology, or by 0 or 1 in digital technology.

    In other words, a marker is an internal logical output.

    The number of available markers is determined by the HPC memory configuration. If for example 1000markers are configured, then they are available as M1 up to M1000.See also chapter Directive: #config .

    Although a marker has a width of only one bit, it still takes 1 byte of memory space. This is forreasons of processing speed.

    It is possible to save the values of some markers in case of power failure. To this effect the HPC is to beequipped with a data memory with battery. In addition it must be indicated which markers must be saved.This can be done in the configuration or upon declaration of the marker variables.See also chapters Directive: #config and Data retention: remanent variables .

    Range:The value can only be 0 or 1.

    9.2 Variable: Cx

    Description:A character is a variable with a width of 8 bits, and is initially provided with a sign bit (signed chars).It is also possible to use character variables without sign bit (unsigned chars).

    The number of available characters is determined by the HPC memory configuration. If for example 1000characters are configured, then these are available as C1 up to C1000.See also chapter Directive: #config .

    Each character takes 1 byte of memory space.

    It is possible to save the values of some characters in case of power failure. To this effect the HPC is to beequipped with a data memory with battery. In addition it must be indicated which characters must besaved. This can be done in the configuration or upon declaration of the character variables.See also chapters Directive: #config and Data retention: remanent variables .

    Range:With sign bit: from -128 up to +127.Without sign bit: from 0 up to 255.

    19

    19 106

    19

    19 106

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 40HPC

    9.3 Variable: Sx

    Description:A short is a 16-bit variable, initially provided with a sign bit (signed shorts).It is also possible to use short variables without sign bit (unsigned shorts).

    The number of available shorts is determined by the HPC memory configuration. If for example 500 shortsare configured, then these are available as S1 up to S500.See also chapter Directive: #config .

    Each short takes 2 bytes of memory space.

    It is possible to save the values of some shorts in case of power failure. To this effect the HPC is to beequipped with a data memory with battery. In addition it must be indicated which shorts must be saved.This can be done in the configuration or upon declaration of the short variables.See also chapters Directive: #config and Data retention: remanent variables .

    Range:With sign bit: from -32768 up to +32767.Without sign bit: from 0 up to 65535.

    9.4 Variable: Lx

    Description:A long is a 32-bit variable, initially provided with a sign bit (signed longs).It is also possible to use long variables without sign bit (unsigned longs).

    The number of available longs is determined by the HPC memory configuration. If for example 250 longs areconfigured, then these are available as L1 up to L250.See also chapter Directive: #config .

    Each long takes 4 bytes of memory space.

    It is possible to save the values of some longs in case of power failure. To this effect the HPC is to beequipped with a data memory with battery. In addition it must be indicated which longs must be saved. Thiscan be done in the configuration or upon declaration of the long variables.See also chapters Directive: #config and Data retention: remanent variables .

    Range:With sign bit: from -2147483648 up to +2147483647.Without sign bit: from 0 up to 4294967295.

    9.5 Variable: Ex.y

    Description:Variable Ex.y is a variable indicating the status of a physical digital input, with

    x representing the card number.y representing the card input number.

    This is a 1-bit variable, so that it can take only two values: 0 for an open or inactive input, or 1 for a closedor activated input.

    A physical input should always be indicated with card number and input number on that card.On smaller HPC's which do not have a modular construction, the inputs on the base unit are usuallyaddressed as card number 1.

    19

    19 106

    19

    19 106

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 41HPC

    The number of inputs for each input card and the number of input cards must be specified in the HPCconfiguration. For each HPC model there is a standard configuration.See also chapter Directive: #config .

    Range:The value can only be 0 or 1.

    Example:

    E1.1 for the very first digital input on the device.E7.2 for the second input on the seventh digital input card.

    9.6 Variable: Ax.y

    Description:Variable Ax.y is a variable determining the position of a physical digital output, with

    x representing the card number.y representing the output number on that card.

    This is a 1-bit variable, so that it can take only two values: 0 for an open or inactive output, or 1 for a closedor active output.

    A physical output must always be specified with card number and output number on that card.On smaller HPC's which do not have a modular construction, the outputs on the base unit must are usuallyaddressed as card number 1.

    The number of outputs for each output card and the number of output cards must be specified in the HPCconfiguration. For each HPC model there is a standard configuration.See also chapter Directive: #config .

    Range:The value can only be 0 or 1.

    Example:

    A1.1 for the very first digital output on the device.A4.1 for the first output on the fourth digital output card.

    9.7 Variable: AEx.y

    Description:Variable AEx.y is a variable indicating the status of a physical analogue input, with

    x representing the card number.y representing the input number on that card.

    This is a 16-bit variable, provided with a sign bit (signed short).

    The value of an analogue input varies from 0 and +16383, with 0 representing the minimum input value and+16383 representing the maximum input value (full scale).

    For example:An analogue input with a measuring range of 0 up to 10 Volts will result in the following values:

    19

    19

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 42HPC

    0 at 0 volt+16383 at 10 volts

    An analogue input with a measuring range of 0 up to 20 mA will result in the following values:

    0 at 0 mA+16383 at 20 mA

    The maximum value of +16383 depends on the resolution of the analogue input because a conversion isperformed. An analogue input with a resolution of 10 bits converts in 1024 steps. In order to obtain amaximum value of +16383, the system performs a multiplication by 16 (16384/1024). That is why theAEx.y variable will change in steps of 16 if it concerns a 10-bit input. A 12-bit analogue input converts in4096 steps and therefore will change in steps of 4 (16384/4096).

    The input type and range of an analogue input depend on the HPC hardware. Some models are capable ofselecting the input type and range, others are not. See also the HPC hardware manual.

    The value of an analogue input should not be tested on equality! Because the input signal is sampledperiodically and the changes occur in steps, the compared value may be skipped. To avoid this onemust use the greater-or-equal test '>='.

    Some analogue inputs allow a limited overflow, their value exceeding +16383 and reaching up to like+18000, depending on the inputs hardware.

    A physical input must always be specified in the form of card number and input number on the card.On smaller HPC's which do not have a modular construction, the inputs on the base unit are usuallyaddressed as card number 1.

    The number of inputs for each input card and the number of input cards must be specified in the HPCconfiguration. For each HPC model there is a standard configuration.See also chapter Directive: #config .

    Range:From -32768 up to +32767.

    Example:

    AE1.1 for the very first analogue input on the device.AE2.3 for the third input on the second analogue input card.

    9.8 Variable: AAx.y

    Description:Variable AAx.y is a variable determining the status of a physical analogue output, with

    x representing the card number.y representing the output number on that card.

    This is a 16-bit variable, provided with a sign bit (signed short).

    The value of an analogue output varies from -16383 to +16383. The minimum value is 0 for an analogueoutput that can only produce a positive output signal, or -16383 for an analogue output that can alsoproduce a negative output signal. Value +16383 always represents the maximum output value (full scale).

    For example:

    19

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 43HPC

    An analogue output with a range from 0 to 20 mA results in an output of:

    0 mA for value 020 mA for value +16383

    An analogue output with a range from -10 volts to +10 volts results in an output of:

    -10 volt for value -163830 volt for value 010 volt for value +16383

    The maximum value of +16383 (and also the minimum value of -16383) is independent of the resolution ofthe analogue output, input because a conversion is performed. An analogue output with a resolution of 10bits converts in 1024 steps. In order to convert the maximum value of +16383 into 1024 steps, the systemperforms a division by 16 (16384/1024). That is why the AAx.y variable should change with a minimum of16 in order to get some change on the output if it concerns a 10-bit analogue output. An 8-bit analogueoutput converts in 256 steps and therefore will operate in steps of 64 (16384/256).

    Values above the maximum value of +16383 will produce the same output as +16383. Values less than theminimum of 0 or -16383, will produce the same output as the minimum value. The output type and range of an analogue output depend on the HPC hardware. Some models are capableof selecting the output type and range, others are not. See also the HPC hardware manual.

    A physical output should always be specified in the form with card number and output number on that card.On smaller HPC's which do not have a modular construction, the outputs on the base unit are usuallyaddressed as card number 1.

    The number of outputs for each output card and the number of output cards must be specified in the HPCconfiguration. For each HPC model there is a standard configuration.See also chapter Directive: #config .

    Range:From -32768 up to +32767.

    Example:

    AA1.1 for the very first analogue output on the equipment.AA2.3 for the third output on the second analogue output card.

    9.9 Global variables by names

    A global variable is a variable that is defined outside of any function. It is known and can be usedthroughout the program, in all functions. Usually, the predefined global variables of types Mx, Cx, Sx andLx are used in a program.

    A second form of global variable is the variable that is defined by name. It is stored as an extra globalvariable in the memory, outside the memory of the predefined Mx, Cx, Sx and Lx variables.For example:

    long counter1;

    defines a global variable of the long type with the name 'counter1'.Of course also the other types of variables can be used, such as:

    19

  • Reference manual EPL programming languageBook E5 Version 2.05

    2014 E.D.&A. 44HPC