Docs | Documents | Johnson Controls

255
JC-Basic Programmer’s Manual JC-Basic Programmer’s Manual ............... 1 Welcome to JC-BASIC............................... 1 Introduction ................................................ 3 JC-BASIC Features ................................................ 3 Writing Processes vs. Writing Programs ............ 4 About this Manual .................................................. 5 System Requirements ............................... 7 Writing a Process .................................................. 7 Compiling the Process .......................................... 7 Downloading the Process..................................... 8 Storing the Process .............................................. 8 Summaries ........................................................... 8 Getting Started ........................................... 9 Minimum Configuration ........................................ 9 Installing JC-BASIC .............................................. 9 JC-BASIC Programming............................ 1 Programming Overview ............................ 3 Creating a Process ................................................ 3 Write Processes ................................................... 4 Compile ................................................................ 4 Download ............................................................. 4 Changing a Process .............................................. 5 Edit Source Code ................................................. 5 Compile ................................................................ 5 Disable Process ................................................... 6 Download Process ............................................... 6 The JC-BASIC Process.............................. 7 Syntax ..................................................................... 8 Structure ................................................................. 8 Format .................................................................. 8 Process Header Format ..................................... 10 Process Header Rules ....................................... 10 Remarks Section Syntax .................................... 10 Remarks Section Rules...................................... 10 Process Declarations Section Format................ 11 Process Declarations Section Rules .................. 11 Executable Statements Section Format............. 11 © January Johnson Controls, Inc. 1 Executable Statements Section Rules ............... 11

Transcript of Docs | Documents | Johnson Controls

Page 1: Docs | Documents | Johnson Controls

JC-Basic Programmer’s Manual

JC-Basic Programmer’s Manual............... 1 Welcome to JC-BASIC............................... 1 Introduction................................................ 3

JC-BASIC Features................................................3 Writing Processes vs. Writing Programs ............4 About this Manual..................................................5

System Requirements ............................... 7 Writing a Process ..................................................7 Compiling the Process..........................................7 Downloading the Process.....................................8

Storing the Process..............................................8 Summaries ...........................................................8

Getting Started........................................... 9 Minimum Configuration ........................................9 Installing JC-BASIC ..............................................9

JC-BASIC Programming............................ 1 Programming Overview ............................ 3

Creating a Process ................................................3 Write Processes ...................................................4 Compile ................................................................4 Download .............................................................4

Changing a Process ..............................................5 Edit Source Code .................................................5 Compile ................................................................5 Disable Process ...................................................6 Download Process ...............................................6

The JC-BASIC Process.............................. 7 Syntax .....................................................................8 Structure .................................................................8

Format ..................................................................8 Process Header Format .....................................10 Process Header Rules .......................................10 Remarks Section Syntax....................................10 Remarks Section Rules......................................10 Process Declarations Section Format................11 Process Declarations Section Rules..................11 Executable Statements Section Format.............11

© January Johnson Controls, Inc. 1

Executable Statements Section Rules...............11

Page 2: Docs | Documents | Johnson Controls

Process Footer Section Format .........................12 Process Footer Section Rules............................12

Physical and Logical Lines.................................13 Other Background Information ..........................13

File Names .........................................................13 Example .............................................................13 Limitations ..........................................................14

The Components of a Process...................15 Reserved Symbols...............................................15 Statements............................................................15

Declarations .......................................................16 Executable Statements ......................................16 Assignment and Command Statements ............17 Branching Statements........................................17 Loop Statements ................................................18 Conditional Statement........................................18 Comment Statement ..........................................18 Halting and Delay Statements............................18 Output Statements .............................................19

Functions..............................................................19 Date and Time Functions ...................................20 HVAC Related Functions ...................................20 Numeric Functions .............................................21 Psychrometric Functions....................................21 Reliability Functions ...........................................21 Special Input Functions......................................22

Components of an Expression...........................22 Constants .............................................................22

Numeric Constants.............................................22 Logical Constants...............................................23 Time Constants ..................................................23 Reserved Constants...........................................24

Variables ...............................................................24 Local Variables...................................................25 Shared Variables................................................25 Variable Names..................................................26

Types of Expressions..........................................26 Numeric Expressions and Operators .................27 Logical Expressions and Operators ...................28 Relational Expressions and Operators ..............29 Relational Expressions and Operators Examples30 More Relational Expressions and Operators Examples............................................................30 Differential (DIFF) Operator ...............................30

Evaluating Expressions ......................................33 System References (Attributes) .........................35

Example 1 ..........................................................35 Example 2 ..........................................................36

2 JC-Basic Programmer’s Manual

Page 3: Docs | Documents | Johnson Controls

Arrays....................................................................36 Format ................................................................36 Example .............................................................37

Loops ....................................................................38 Subroutines ..........................................................38

Writing a Process .....................................39 The Components of a Process...........................39

Example 1: Ramp..............................................40 Example 2: Reset of a Setpoint.........................41 Example 3: Economizer ....................................42

The Restart Process .................................43 Format...................................................................44 Concerns ..............................................................44 Examples ..............................................................45

Compiler Directives ..................................49 Overview ...............................................................49 Using Directives...................................................49 #INCLUDE.............................................................50

Format ................................................................50 Details ................................................................51 Example .............................................................51

#LIST #NOLIST.....................................................51 Format ................................................................51 Details ................................................................51 Example .............................................................52

#REMARKS #NOREMARKS................................52 Format ................................................................52 Details ................................................................52 Examples............................................................53

#REPLACE............................................................53 Format ................................................................53 Details ................................................................53 Rules ..................................................................54 Examples............................................................56

Runtime and User Operations .................. 1 Runtime Operations .................................. 3

Process Execution.................................................3 Process Timers ......................................................4

Example ...............................................................4 Unreliable Data Handling ......................................5

Attribute Values....................................................6 Trigger Values......................................................6 Unreliable Results from Inputs.............................7 Effect of Reliability................................................7 Arrays ...................................................................8 Process ................................................................8

JC-Basic Programmer’s Manual 3

Page 4: Docs | Documents | Johnson Controls

User Operations..........................................9 Compiler .................................................................9

Processing............................................................9 List File Sections ................................................10

Process Download...............................................10 Process Upload....................................................12 Process Deletion..................................................12 Process Backup and Restore.............................12 Process Enable and Disable...............................13 Triggering a Process ...........................................13 Process Summary................................................13 Process Focus .....................................................14

Process Status ...................................................14 Revision Information ..........................................15

Command Reference..................................1 Statements, Functions, Loops, and Subroutines ................................................3

Overview .................................................................3 Statements ...........................................................3 Functions..............................................................4 Loops and Subroutines ........................................4

ABORT Statement..................................................4 Purpose ................................................................4 Format ..................................................................4 Details ..................................................................4 Process Example .................................................4

ABS Function .........................................................4 Purpose ................................................................5 Format ..................................................................5 Details ..................................................................5 Usage Example ....................................................5

ADVISORY and ADVISORY USING Statements..5 Purpose ................................................................5 Formats ................................................................5 Details ..................................................................5 Usage Example ....................................................8 Process Example .................................................8

AVG Function .......................................................10 Purpose ..............................................................10 Format ................................................................10 Details ................................................................10 Usage Example ..................................................10 Process Example ...............................................10

CANC_PULSE Function ......................................12 Purpose ..............................................................12 Format ................................................................12 Details ................................................................12

4 JC-Basic Programmer’s Manual

Page 5: Docs | Documents | Johnson Controls

Process Example ...............................................13 COS Function.......................................................14

Purpose ..............................................................14 Format ................................................................14 Details ................................................................14 Process Example ...............................................14

DATE$ Function...................................................15 Purpose ..............................................................15 Format ................................................................15 Details ................................................................15 Usage Example..................................................15 Process Example ...............................................15

DAY Function .......................................................17 Purpose ..............................................................17 Format ................................................................17 Details ................................................................17 Usage Example..................................................17 Process Example ...............................................17

DEF FN and END DEF Functions .......................18 Purpose ..............................................................18 Formats ..............................................................18 Details ................................................................19 Usage Example..................................................19

DEWPT Function..................................................20 Purpose ..............................................................20 Format ................................................................20 Details ................................................................21 Process Example ...............................................21

DIM Statement ......................................................22 Purpose ..............................................................22 Format ................................................................22 Details ................................................................22 Usage Example..................................................23

ENTHALPYDP Function ......................................24 Purpose ..............................................................24 Format ................................................................24 Details ................................................................24 Process Example ...............................................25

ENTHALPYRH Function ......................................26 Purpose ..............................................................26 Format ................................................................26 Details ................................................................27 Process Example ...............................................27

EXEMPT and EXEMPT ALL Statements ............29 Purpose ..............................................................29 Formats ..............................................................29 Details ................................................................29

JC-Basic Programmer’s Manual 5

Page 6: Docs | Documents | Johnson Controls

Usage Example ..................................................29 EXIT DEF Statement ............................................30

Purpose ..............................................................30 Format ................................................................30 Details ................................................................30 Usage Example ..................................................30

FILTER Function ..................................................31 Purpose ..............................................................31 Format ................................................................31 Details ................................................................31 Process Example ...............................................32

FOR-NEXT Loop...................................................33 Purpose ..............................................................33 Format ................................................................33 Details ................................................................33 Process Example ...............................................35

FORCE_REL Function.........................................36 Purpose ..............................................................36 Format ................................................................36 Details ................................................................36 Usage Example ..................................................36

FORCE_UNREL Function....................................36 Purpose ..............................................................36 Format ................................................................37 Details ................................................................37 Usage Example ..................................................37

GOSUB and RETURN Statements......................37 Purpose ..............................................................37 Format ................................................................37 Details ................................................................37 Process Example ...............................................38

GOTO Statement ..................................................40 Purpose ..............................................................40 Format ................................................................40 Details ................................................................40 Process Example ...............................................40

IF-THEN-ELSE and ENDIF Statements ..............42 Purpose ..............................................................42 Formats ..............................................................42 Details ................................................................42 Usage Example ..................................................43 First Pass Example ............................................44

INT_TO_TIME Function .......................................44 Purpose ..............................................................44 Format ................................................................44 Details ................................................................44 Usage Examples ................................................45

LASTTOT Function ..............................................45

6 JC-Basic Programmer’s Manual

Page 7: Docs | Documents | Johnson Controls

Purpose ..............................................................45 Format ................................................................45 Details ................................................................45 Usage Example..................................................45

LET Statement......................................................46 Purpose ..............................................................46 Formats ..............................................................46 Details ................................................................46 Usage Examples ................................................47

LOG Function.......................................................48 Purpose ..............................................................48 Format ................................................................48 Details ................................................................48 Process Example ...............................................48

MAX Function.......................................................49 Purpose ..............................................................49 Format ................................................................49 Details ................................................................49 Process Example ...............................................49

MIN Function ........................................................50 Purpose ..............................................................50 Format ................................................................50 Details ................................................................50 Process Example ...............................................51

MONTH Function .................................................51 Purpose ..............................................................51 Format ................................................................51 Details ................................................................51 Usage Example..................................................52 Process Example ...............................................52

N_CANC_PULSE Function..................................52 Purpose ..............................................................52 Format ................................................................52 Details ................................................................52 Usage Example..................................................53 Process Example ...............................................53

ON GOSUB Statement.........................................54 Purpose ..............................................................54 Format ................................................................54 Details ................................................................54 Usage Example..................................................54 Process Example ...............................................55

ON GOTO Statement ...........................................56 Purpose ..............................................................56 Format ................................................................56 Details ................................................................56 Usage Example..................................................56

JC-Basic Programmer’s Manual 7

Page 8: Docs | Documents | Johnson Controls

PERIOD Statement...............................................57 Purpose ..............................................................57 Format ................................................................57 Details ................................................................57 Usage Example ..................................................58

PI_RESET Statement ...........................................59 Purpose ..............................................................59 Format ................................................................59 Details ................................................................60 Process Example ...............................................60

PRINT and PRINT USING Statements................61 Purpose ..............................................................61 Formats ..............................................................61 Details ................................................................61 Usage Example ..................................................64

PRIORITY Statement ...........................................64 Purpose ..............................................................64 Format ................................................................64 Details ................................................................64 Usage Example ..................................................64

PROCESS and END PROCESS Statements ......65 Purpose ..............................................................65 Format ................................................................65 Details ................................................................65 Usage Example ..................................................66 Process Example ...............................................66

RAMP Function ....................................................67 Purpose ..............................................................67 Format ................................................................67 Details ................................................................68 Process Example ...............................................68

REL_HUM Function .............................................69 Purpose ..............................................................69 Format ................................................................69 Details ................................................................70 Process Example ...............................................70

REM Statement.....................................................71 Purpose ..............................................................71 Format ................................................................71 Details ................................................................71 Usage Example ..................................................72

SHARED Statement .............................................72 Purpose ..............................................................72 Formats ..............................................................72 Details ................................................................73 Usage Example ..................................................73

SIN Function.........................................................74 Purpose ..............................................................74

8 JC-Basic Programmer’s Manual

Page 9: Docs | Documents | Johnson Controls

Formats ..............................................................74 Details ................................................................74 Process Example ...............................................74

SPAN Function.....................................................76 Purpose ..............................................................76 Format ................................................................76 Details ................................................................76 Usage Example..................................................77 Process Example ...............................................78

SQR Function.......................................................79 Purpose ..............................................................79 Format ................................................................79 Details ................................................................79 Process Example ...............................................79

STOP Statement...................................................80 Purpose ..............................................................80 Format ................................................................80 Details ................................................................80 Usage Example..................................................80

TAN Function .......................................................80 Purpose ..............................................................80 Format ................................................................80 Details ................................................................80 Process Example ...............................................81

TELL Statement....................................................83 Purpose ..............................................................83 Formats ..............................................................83 Details ................................................................83 Usage Example with START Command............84 Usage Example with SET_AOS (Adjust) Command............................................................................84 Usage Example with ALARMS and DELETE Commands .........................................................84 Usage Example with SET_PIDL Commands.....84 Process Example ...............................................85

TIME Function ......................................................94 Purpose ..............................................................94 Format ................................................................94 Details ................................................................94 Process Example ...............................................94

TIME$ Function ....................................................95 Purpose ..............................................................95 Format ................................................................95 Details ................................................................95 Process Example ...............................................95

TIME_TO_INT Function .......................................97 Purpose ..............................................................97

JC-Basic Programmer’s Manual 9

Page 10: Docs | Documents | Johnson Controls

Format ................................................................97 Details ................................................................97 Usage Examples ................................................97

TODAY Function ..................................................98 Purpose ..............................................................98 Format ................................................................98 Details ................................................................98 Usage Example ..................................................98 Process Example ...............................................98

TOTAL Function...................................................99 Purpose ..............................................................99 Format ................................................................99 Details ..............................................................100 Usage Example ................................................100 Process Example .............................................100

UNRELIABLE Function .....................................101 Purpose ............................................................101 Format ..............................................................101 Details ..............................................................101 Usage Example ................................................101

WAIT Statement .................................................101 Purpose ............................................................101 Format ..............................................................101 Details ..............................................................101 Usage Example ................................................102

WETDP Function................................................102 Purpose ............................................................102 Format ..............................................................102 Details ..............................................................103 Process Example .............................................103

WETRH Function................................................104 Purpose ............................................................104 Format ..............................................................104 Details ..............................................................104 Process Example .............................................105

WHILE END-WHILE Loop .................................106 Purpose ............................................................106 Format ..............................................................106 Details ..............................................................106 Usage Example ................................................106 Process Example .............................................107

YEAR Function...................................................108 Purpose ............................................................108 Format ..............................................................108 Details ..............................................................108 Usage Example ................................................108 Process Example .............................................108

Reference ....................................................1 10 JC-Basic Programmer’s Manual

Page 11: Docs | Documents | Johnson Controls

Reference Overview .................................. 3 Application Example ................................. 5

Specification...........................................................5 Source Code...........................................................6

First Process ........................................................6 Second Process ...................................................6 Third Process .......................................................7

Syntax Rules .............................................. 9 Syntax for Statements and Functions ...............11 Syntax for Numbers.............................................13 Syntax Maximums................................................13 Guidelines.............................................................14 Programming Recommendations .........................14 Programming Tips ...............................................14

Syntax in Backus-Naur Form...................15 Notation Overview ...............................................15 Rules .....................................................................16 Lexical Considerations .......................................22 Compiler Directives .............................................23 Semantic Notes....................................................23

Error Messages.........................................25 Compiler Error Messages ...................................25

Quick Reference Tables ...........................31 Keywords..............................................................31 Reserved Constants ............................................32 Operators..............................................................33 Statements............................................................33 Functions..............................................................34 Special Characters ..............................................35 JC-BASIC NCM Data Attribute and Command Descriptions .........................................................36

JC-BASIC Process Status..................................38 Glossary ..................................................... 1

AC ........................................................................1 Access Controller Object (AC) .............................1 Accumulator Object (ACM) ..................................1 ACM .....................................................................1 AHU Controller .....................................................1 Analog Data Object (AD)......................................1 Analog Input Object (AI).......................................1 Analog Output Digital Object (AOD) ....................1 Analog Output Setpoint Object (AOS) .................1 Archive Data Base ...............................................1 Array.....................................................................2 Attribute (System Reference)...............................2

JC-Basic Programmer’s Manual 11

Page 12: Docs | Documents | Johnson Controls

Binary Data Object (BD).......................................2 Binary Input Object (BI) ........................................2 Binary Output Object (BO) ...................................2 Branching Statements..........................................2 Card Reader Object (READER)...........................2 Change-of-State (COS)........................................2 Cold Start .............................................................2 Comment Statement ............................................3 Compiler ...............................................................3 Compiler Directives ..............................................3 Conditional Statement..........................................3 Constants .............................................................3 Control System (CS) ............................................3 COS......................................................................3 Data Definition Language (DDL)..........................3 Date And Time Functions.....................................3 DCM .....................................................................3 DCDR Object........................................................4 DDL ......................................................................4 Deadband.............................................................4 Declaration Statement..........................................4 Delay Statements .................................................4 Differential Operator .............................................4 Digital Control Module (DCM) ..............................4 Directives..............................................................4 Disable .................................................................4 DOS......................................................................4 Download .............................................................4 Enable ..................................................................4 Executable Statement ..........................................5 Expression............................................................5 Facility Management System (FMS)....................5 FMS......................................................................5 Focus....................................................................5 Function................................................................5 GPL ......................................................................5 Graphic Programming Language (GPL) ..............5 Halting Statements ...............................................5 HVAC-Related Functions .....................................5 Input Functions.....................................................5 Integer Constants .................................................6 Laptop Computer..................................................6 Line Continuation Character ................................6 List File .................................................................6 Local Variables.....................................................6 Logical Constants.................................................6 Logical Expressions .............................................6 Logical Line ..........................................................6

12 JC-Basic Programmer’s Manual

Page 13: Docs | Documents | Johnson Controls

Logical Operators.................................................6 Loop .....................................................................6 Loop Statements ..................................................6 MCO .....................................................................7 Message...............................................................7 Metasys ................................................................7 Multiple Command Object (MCO)........................7 N2OPEN Object ...................................................7 NCM .....................................................................7 NCU......................................................................7 Network ................................................................7 Network Control Module (NCM)...........................7 Network Control Unit (NCU).................................7 Network Expansion Unit (NEU)............................7 NEU......................................................................7 Normalband..........................................................7 Numeric Constants...............................................8 Numeric Expressions ...........................................8 Numeric Functions ...............................................8 Numeric Operators...............................................8 Object ...................................................................8 Object File ............................................................8 Operand ...............................................................8 Operator Workstation ...........................................8 Output Statements ...............................................8 Period (Process Period) ......................................8 Physical Line ........................................................9 PID Loop Object (PIDL) .......................................9 Point Object..........................................................9 Priority (Process Priority) ....................................9 Process ................................................................9 Process Focus .....................................................9 Process Summary................................................9 Psychrometric Functions......................................9 Reader..................................................................9 Real Constants...................................................10 Relational Expressions.......................................10 Relational Operators ..........................................10 Reliability Functions ...........................................10 Reserved Symbols .............................................10 Shared Variables................................................10 Source File .........................................................10 Standard Functions ............................................10 Statements .........................................................10 Subroutine ..........................................................11 Summary ............................................................11 Syntax ................................................................11

JC-Basic Programmer’s Manual 13

Page 14: Docs | Documents | Johnson Controls

System Name.....................................................11 System Reference..............................................11 Time Constants ..................................................11 Trigger ................................................................11 Upload/Download...............................................11 User-Designed Functions...................................11 Variables ............................................................11 Warm Start .........................................................12

14 JC-Basic Programmer’s Manual

Page 15: Docs | Documents | Johnson Controls

JC-BASIC Programmer’s Manual

Welcome to JC-BASIC

Introduction 3

l JC-BASIC Features 3 l Writing Processes vs. Writing Programs 4 l About this Manual *5

System Requirements 7

l Writing a Process 7 l Compiling the Process 7 l Downloading the Process *8

Getting Started 9

l Minimum Configuration 9 l Installing JC-BASIC *9

* Indicates those sections where changes have occurred since the last printing.

© November, 1996 Johnson Controls, Inc. 1 Code No. LIT-632010

Page 16: Docs | Documents | Johnson Controls

2 Welcome to JC-BASIC

Page 17: Docs | Documents | Johnson Controls

Introduction Welcome to JC-BASIC, the textual programming language designed especially for Facility Management Systems (FMS) applications. This chapter provides an overview of JC-BASIC, its features, functions, installation procedure, and system requirements. JC-BASIC is an optional product of Metasys®. It can be used as an alternative to the standard programming tool for Metasys--the Graphic Programming Language (GPL). JC-BASIC provides the same control strategies as GPL.

JC-BASIC is fashioned after BASIC (Beginner’s All-Purpose Symbolic Instruction Code), the most widely known computer language.

JC-BASIC Features

Like most BASIC languages, JC-BASIC is relatively easy to use and is conversational in nature. JC-BASIC doesn’t consume tremendous amounts of computer memory. It shares many of the same features and benefits offered by standard BASIC but is tailored to the special needs of the FMS market. JC-BASIC provides interlocks, computations, built-in functions, and many control applications. Figure 1 shows just some of the ways JC-BASIC can be used in control applications.

Welcome to JC-BASIC 3

Page 18: Docs | Documents | Johnson Controls

contapp

JC-BASIC

- Interlocks- Computations- Built-in functions- Control applications

Fancontrol logic

Preheat logic

Preheat logic

BASICProgramming Language

Modifications forFMS Applications

Heating and cooling coil logic

Mixing damper logic

Enthalpyswitchover

Supply air reset

Figure 1: JC-BASIC in Control Applications

With JC-BASIC, you write process blocks, not programs. A process is a self-sufficient, modular block of computer instruction. For example, you could write a ramp process to control the damper position on a supply fan during startup or an economizer process to set damper control based on a comparison of the outside air enthalpy to the return air enthalpy.

Writing Processes vs. Writing Programs

PROCBLK

Setpoint Reset Block

Basic Analog Block

Upper Limit

Econimizer Block

Interlock BlockRamp

Block

Figure 2: Process Blocks

4 Welcome to JC-BASIC

Page 19: Docs | Documents | Johnson Controls

This manual explains how to write processes using the JC-BASIC programming language. As a prerequisite, you should have general knowledge and understanding of Metasys terms and concepts.

About this Manual

Also, you need some knowledge of general programming techniques. This manual doesn’t attempt to teach elementary programming. This manual has seven major chapters: Welcome to JC-BASIC, which you are reading now, provides an overview of JC-BASIC, its features, functions, installation procedure, and system requirements. JC-BASIC Programming describes the JC-BASIC process and process components, including statements, functions, loops, subroutines, compiler directives, and others. Runtime and User Operations describes how the Network Communication Module (NCM) executes a process. Each user operation is described in detail. Command Reference describes all JC-BASIC statements, functions, loops, and subroutines. Reference contains examples, syntax rules, the Backus-Naur representation for JC-BASIC, error messages, and quick reference tables. Glossary defines terms specific to JC-BASIC that are used in this manual. Index is a list of JC-BASIC topics, concepts, and terms with a chapter and page number reference.

Throughout the manual, you’ll notice that there may be more than one way to write a process. The helpful hints sections compare different ways of writing processes to achieve the same results and advise which way will save on process time and NC memory.

Helpful Hint

Welcome to JC-BASIC 5

Page 20: Docs | Documents | Johnson Controls

6 Welcome to JC-BASIC

Page 21: Docs | Documents | Johnson Controls

System Requirements

You use JC-BASIC to write a process on your Personal Computer (PC) or laptop, and download the compiled process to the NCM. The NCM then executes the process, as required.

Network Control Module (NCM)

PC/Portable PC

- Straight, ASCII text editor

- JC-BASIC compiler software

pcncm

- Metasys archive data base, including definition of all objects referenced in the process

- JC-BASIC download/upload software

Download

- Disk or other storage medium for office backup

Figure 3: PC to NCM Download

To write JC-BASIC processes, you’ll need the following: Writing a Process • Personal Computer (PC) or portable PC • ASCII text editor, such as Write • job submittal and other related information

To use the JC-BASIC compiler, you’ll need: Compiling the Process • Operator Workstation software

• JC-BASIC compiler software • a defined Metasys archive data base, including definition

of all objects referenced in the processes

Welcome to JC-BASIC 7

Page 22: Docs | Documents | Johnson Controls

Downloading the Process

To download the process: • Select Process Object on Disk. • Select Action--Download. Note: If an NC is downloaded, all processes in the

archive data base are downloaded. To download or upload JC-BASIC processes to the Network Control Module, you’ll need: • Operator Workstation or portable PC online to the

network • Operator Workstation software

To save the process, you'll need an offline storage media, such as a disk or tape.

Storing the Process

With JC-BASIC you have access to summaries of process information.

Summaries

8 Welcome to JC-BASIC

Page 23: Docs | Documents | Johnson Controls

Getting Started The minimum configuration for JC-BASIC is the same as for the Operator Workstation FMS software.

Minimum Configuration

1. Install DOS and Windows® 3.1 or Windows 95 on the Operator Workstation, if they are not already installed.

Installing JC-BASIC

2. Install the Operator Workstation FMS software, then reboot the Operator Workstation. By rebooting the system, the DOS environment variable FMSPATH is set to the location where JC-BASIC will be installed.

Note: If FMSPATH is not set to the correct location, when you try to install JC-BASIC, the install procedure aborts and you’ll get an error message.

3. Insert the JC-BASIC Master Disk in Drive A. 4. For an overview of the installation process and additional

information on using JC-BASIC after it is installed, read the following file: A:\README.JCB.

5. To start the installation, at the DOS A:\ prompt, enter this command:

install 6. Several messages appear on the screen as the installation

proceeds. When installation is complete, a completion message appears.

7. Remove the disk from the drive and put it in a safe place. 8. If other Metasys software is to be installed, refer to the

appropriate documentation. 9. Type the following to execute the software from

Drive C: SETFMS.

Welcome to JC-BASIC 9

Page 24: Docs | Documents | Johnson Controls

10 Welcome to JC-BASIC

Page 25: Docs | Documents | Johnson Controls

JC-BASIC Programmer’s Manual

JC-BASIC Programming

Programming Overview 3

l Creating a Process 3 l Changing a Process *5 The JC-BASIC Process 7

l Syntax 8 l Structure *8 l Physical and Logical Lines 13 l Other Background Information 13 The Components of a Process 15

l Reserved Symbols 15 l Statements *15 l Functions 19 l Components of an Expression 22 l Constants *22 l Variables *24 l Types of Expressions 26 l Evaluating Expressions *33 l System References (Attributes) *35 l Arrays *36 l Loops 38 l Subroutines 38 Writing a Process 39

l The Components of a Process 39

* Indicates those sections where changes have occurred since the last printing.

© November, 1996 Johnson Controls, Inc. 1 Coe No. LIT-632020

Page 26: Docs | Documents | Johnson Controls

The Restart Process 43

l Format 44 l Concerns *44 l Examples *45 Compiler Directives 49

l Overview 49 l Using Directives 49 l #INCLUDE *50 l #LIST #NOLIST 51 l #REMARKS #NOREMARKS 52 l #REPLACE *53

* Indicates those sections where changes have occurred since the last printing.

2 JC-BASIC Programming

Page 27: Docs | Documents | Johnson Controls

Programming Overview

This section describes the JC-BASIC process and process components, including statements, functions, loops, subroutines, compiler directives, and others.

To prepare a JC-BASIC process, you’ll follow certain steps, each of which is described in later sections of this manual.

Creating a process involves the four steps described in the table below.

Creating a Process

Step Task What is Done 1 Write

Processes Write the processes that will control system elements, such as the fans, dampers, and coils. You can use any text editor to write the processes, as long as the output is extended ASCII text with no special control characters.

The process is then stored in a DOS file with a .BAS extension. This file is also called a source file. Each process can be stored in a separate source file, but to save disk memory in the PC, you may want to write multiple processes in a single file.

2 Compile The compiler checks the source file for errors. If an error is found, it is tagged and listed in a file with an .LST extension.

If no errors are found, the compiler creates a process object file for each separate process. For example, if the source file contains three processes, three process object files are created. Object files have an .OBJ extension.

3 Download The process can now be downloaded from the PC to the designated NCM. This is done by manual command at the PC.

The process is downloaded in the enabled state, unless the process has been disabled with the Disk PMI command.

4 Interpret The NCM interpreter then takes over, executing the process as required.

JC-BASIC Programming 3

Page 28: Docs | Documents | Johnson Controls

First, you need to write the processes that will control the system elements, such as the fans, dampers and coils. You write a process using a text editor, then store the process in a DOS file. The file, called a source file, is the storage location for one JC-BASIC process that applies to one Network Control Module (NCM). Each process can be stored in a separate source file, but to save disk memory in the PC, you may want to write multiple processes in a single file. Source files have .BAS extensions.

Write Processes

Note: You can use any text editor to write processes. The only requirement is that it can output extended ASCII text with no special control characters.

Once you write a process, you can check it for errors using the compiler. The compiler scans the process for errors, tagging each one. These errors are indicated in the list file that the compiler produces. The list file also contains helpful summary information. List files have .LST extensions.

Compile

If the compiler finds no errors, it creates a process object file. The compiler produces a process object file only if the process compiles error-free. The compiler creates one object file per process. That means, if a source file contains three processes, the compiler produces three process object files. Object files have .OBJ extensions.

After the process object file is produced, you can download it to the designated NCM. This is done by manual command at the Operator Workstation, or by forcing the NCM to download all the data. The process is downloaded in the enabled state, unless the process has been disabled with the Disk PMI command. The NCM Interpreter then takes over, executing the process as required.

Download

4 JC-BASIC Programming

Page 29: Docs | Documents | Johnson Controls

Changing a Process

The following diagram shows how to change an existing process:

Compile

changpro

Edit source code

Correct any errorsfound by computer

Recompile to create process object file

Disablethe existing process

on the Network Control Module

Download toNetwork Control

Module

Figure 1: Changing an Existing Process

First, edit the source code on the PC to make the changes you want.

Edit Source Code

Then, compile the modified source code into object code on the PC.

Compile

JC-BASIC Programming 5

Page 30: Docs | Documents | Johnson Controls

Before you can download the modified (recompiled) object code on the NCM, you must disable the process on the NCM. The DISABLE command halts the process and prevents it from running on the NCM.

Disable Process

Now you can download the object code for the modified process to the NCM. The object code replaces the old code for the process. Any process downloaded enabled will be queued for execution when download completes.

Download Process

6 JC-BASIC Programming

Page 31: Docs | Documents | Johnson Controls

The JC-BASIC Process

The JC-BASIC process is the heart of the JC-BASIC language. It is an independent block of computer code that provides instructions for the NCM, for instance, to start a fan if a zone needs heating, or report totalization data to a printer.

At the simplest level, a process consists of inputs, logic, and outputs:

OutputsLogicInputs

JCBPROC

Figure 2: JC-BASIC Process

A process is a named object. Since a process is an object, it shares some of the same characteristics as any other object on the system. For example, you can command an individual process to trigger. Or, you can reference a process’ attributes from another process.

JC-BASIC Programming 7

Page 32: Docs | Documents | Johnson Controls

Syntax Like all programming languages, JC-BASIC imposes strict syntax rules that you must follow. Syntax is the set of rules for constructing a valid JC-BASIC process. The rules are required to avoid any ambiguity and to help facilitate proper compiling. Every instruction in a process must be in proper syntax, or the process won’t compile error-free.

Understanding and applying proper syntax is essential to programming effectively in JC-BASIC. The language is not overly complex--learning the syntax is only a matter of remembering and applying the rules.

In this section and throughout the manual, we use these symbols to discuss syntax:

< > Angle brackets; text within is the generic name for what is entered.

[ ] Square brackets; indicate optional items.

A process has a definite structure. To better understand the structure, consider the following process example. The text in the right column indicates the sections of a process.

Structure

PROCESS 'AHU\ADD' “ADD 5 DEGF TO OAT”'\NCM1' PROCESS HEADER

REM ADDS FIVE DEGF TO OUTDOOR AIR TEMP REMARKS

SHARED oda_temp PROCESS DECLARATIONS

LET oda_temp = oda_temp + 5 EXECUTABLE STATEMENTS

END PROCESS PROCESS FOOTER

• The Process Header section identifies the process. It tells the compiler to which NCM and system the process belongs.

Format PROCESS '<SYSTEM NAME>\<OBJECT NAME>' “<PROCESS DESCRIPTION>“ '\<NCM NAME>'

8 JC-BASIC Programming

Page 33: Docs | Documents | Johnson Controls

• The Remarks section, an optional area, is for writing comments. Remarks should briefly describe the purpose of the process, or any other useful explanations. You may write remarks just about anywhere in a process, but we recommend that you write them before the main body of the process or, to explain complicated code, between the process statements.

• In the Process Declarations section, define any declarations used in the process. These statements tell the compiler which shared variables and dimensioned local variables are used, and the process execution priority.

Since declarations only declare information, they don’t produce any executable code. We recommend that you place declarations toward the front of a process, before the executable statements. This convention makes it easier to spot the declarations.

• The Executable Statements section is the main body of the process. These statements cause something to occur during process runtime.

• The last section of a JC-BASIC process is the Process Footer. It tells the compiler it has reached the end of the process. It is analogous to a period at the end of a sentence.

In addition to these sections, a process can have line labels, blank lines, and compiler directives.

• Although Line Labels are characteristic of most BASIC languages, JC-BASIC doesn’t require them. Usually, you’ll use line labels only as pointers with the GOTO and ON GOTO branching statements. In fact, since labels consume memory, you might decide to use line labels for the branching statements only.

• Blank Lines inserted between two processes aid in readability. You can’t label these lines.

• Compiler Directives are instructions for the compiler while it translates a source file into object code. You could write compiler directives within a process, but for clarity, it is best to write them outside the process.

JC-BASIC Programming 9

Page 34: Docs | Documents | Johnson Controls

Process Header Format

PROCESS '<SYSTEM NAME>\<OBJECT NAME>' “<PROCESS DESCRIPTION>“ '\<NCM NAME>'

Process Header Rules

• Put the word PROCESS as the first statement on the first logical line of a process. Logical lines are defined later in this section.

• Use both single and double quotation marks in the Process Header. The syntax for these is very important: you must use single quotes to enclose the system name\process name and the NCM name; double quotes to enclose the process description. Note also that only one type of single quote (') is used. The other single quotation mark (`) available on most keyboards is not allowed.

• Define the system name and NCM name used in the process header in the archive data base. You must precede the NCM name with a backslash (\) within the single quotes. The compiler reads the data base (archive or online) to verify the validity of names used in a process.

Remarks Section Syntax

REM <TEXT>

Remarks Section Rules

• You can use any combination of keyboard characters, and upper and lower case letters within a remark.

• For remarks that go longer than one physical line, repeat the REM keyword on the next line, then continue the remark. Begin every remark line with REM (“rem” in lower case letters is also allowed). You can’t use the line continuation character (\) to continue a remark to the next line. However, you may use it within the text of a remark.

• You can’t use a statement separator (:) to end a remark and start a new statement. You can put a Remark on the same physical line as any other statement by preceding it with a colon (:).

10 JC-BASIC Programming

Page 35: Docs | Documents | Johnson Controls

Process Declarations Section Format

<DECLARATIONS>

Process Declarations Section Rules

• Place multiple declarations on a single physical line. Use a comma followed by a blank space between each item in the declarations list. All variable names declared must have their respective symbols (except for the symbol for real variables, which is optional). These symbols are discussed in the Variables section.

• Declare every item that requires a declaration before its first use. You may declare a variable only once in a process.

Executable Statements Section Format

[[<LABEL>] [<STATEMENTS]] [:[<LABEL>] [<STATEMENT>]]...

The colon character (:) is the statement separator; the three dots at the end indicate that more labels and statements can follow.

Only one Remark is allowed per physical line and it must be the last statement on the line. A Remark can follow any executable statement on a physical line if the Remark is preceded by a colon (:).

Executable Statements Section Rules

• An executable statement may begin with a line label. The label is an integer with a value ranging from 0 to 65535.

Note: The value of a line label doesn’t affect the order of execution. Lines are executed in sequential order. Labels merely serve as pointers for some JC-BASIC statements and line references. You don’t have to enter line labels in numeric order or use the physical line number that the text editor may provide. Also, since a process is an independent block of code, you can’t refer to a line label in another process.

JC-BASIC Programming 11

Page 36: Docs | Documents | Johnson Controls

• When you use the backslash character (\) as a line continuation character, follow it with a carriage return. Don’t use the character in the middle of a keyword, variable name, or string. Also, don’t use it to continue a remark statement across more than one physical line.

• You can write multiple statements on one physical line. To divide one statement from another on the same line, use the statement separator character (:). You must precede the separator character with a blank space if it follows an integer or a time value of hours and minutes. A blank space is not required after the separator, but for easier reading, we recommend it.

• Define all system\object references defined in the process in the archive data base. The compiler reads the archive data base to verify the validity of names used in a process. This procedure is not necessary if you’re verifying against the field data base.

Process Footer Section Format

END PROCESS

Process Footer Section Rules

• On the last line of every process, place the words END PROCESS, which tells the compiler that the process is complete. Separate END and PROCESS with a space. Don’t have any other text on this line.

12 JC-BASIC Programming

Page 37: Docs | Documents | Johnson Controls

Physical and Logical Lines

A process has two types of lines: physical lines and logical lines. A physical line is one line across the CRT screen or page. End a physical line with a carriage return. A logical line is one or more physical lines that consists of one or more statements. To extend a logical line over one or more physical lines, place a backslash character (\) at the end of each physical line. The backslash, when used in this way, is called a line continuation character.

One physical line: IF 'AHU\SPF_STSP\STATUS' = ALARM THEN

One logical line: IF 'AHU\SPF_STSP\STATUS' = ALARM \

OR 'AHU\RTF_STSP\STATUS' = ALARM THEN

This logical line contains one statement written on two physical lines. A logical line, however, may contain two or more statements if it uses the statement separator character. The statement separator is a colon (:) that is placed between two statements.

Note: When you use the line continuation character, the continued line must follow immediately. A blank line after the line continuation character is a syntax error.

Other Background Information File Names

The compiler requires source files to have a .BAS extension.

The easiest way to name source files is to use the process name, plus the .BAS extension, for the file name. Use the name of the first process for multi-process source files. Keep all the processes for a system in that system’s directory.

Example AIR_HAND\DAMP_CTL.BAS

The process name is DAMP_CTL, the system is AIR_HAND, and the file name is DAMP_CTL with a .BAS extension.

JC-BASIC Programming 13

Page 38: Docs | Documents | Johnson Controls

JC-BASIC has these limitations and ranges: Limitations

Item Limitation Physical line 256 characters, maximum

Logical line 1024 characters, maximum

Statement label 0 (minimum) to 65535, maximum

Processes per NCM 255, maximum *

Size of object file for one process

32 Kb, maximum

Line continuation characters 12 consecutive levels, maximum

Array elements 15878, maximum*

* Actual maximum depends on available NCM memory.

14 JC-BASIC Programming

Page 39: Docs | Documents | Johnson Controls

The Components of a Process

This section discusses the components that make up the process.

Each line of a JC-BASIC process is a computer instruction for the NCM. You can compose these instructions of many different elements, including:

• Reserved Symbols

• Statements

• Functions

• Components of an Expression

• System References

• Arrays

• Loops

• Subroutines

Refer to Appendix E in Reference for quick reference tables.

JC-BASIC uses these reserved symbols to provide for specific needs.

Reserved Symbols

+ - * / ( ) = < > “ ' : \ @ % ? ! # $ ^ .

Some of these symbols are used to indicate arithmetic operations, such as add (+), subtract (-), multiply (*) and divide (/). Others are used for specific syntax purposes. For example, the @ mark denotes a time value and the % mark an integer. You may use these reserved symbols freely within remark statements. But within the process, you must use them according to their defined meanings.

Statements are lines of computer instruction within a process. Every logical line in a process is a statement, or several statements separated by a colon (:). There are two types of statements: declaration statements and executable statements.

Statements

JC-BASIC Programming 15

Page 40: Docs | Documents | Johnson Controls

Declaration statements, or declarations, give instructions to the compiler but have no executable code. The declaration statements are:

Declarations

DIM EXEMPT PRIORITY SHARED

Declarations work like this:

• DIM sets up a dimensioned array.

• EXEMPT specifies which objects and shared variables should not trigger a process.

• PRIORITY assigns a priority level to the execution of a process.

• SHARED declares an array or variable that is used in the process.

Executable statements are computer instructions. The executable statements are:

Executable Statements

ABORT IF-THEN-ELSE REM ADVISORY LET RETURN EXIT DEF PERIOD STOP FOR-NEXT PRINT TELL GOSUB-RETURN ON GOSUB WAIT GOTO ON GOTO WHILE-END WHILE

These executable statements can be divided into several categories: assignment and command, branching, loop, conditional, comment, halting and delay, and output statements.

16 JC-BASIC Programming

Page 41: Docs | Documents | Johnson Controls

The statements in this category are LET, PERIOD, and TELL. They work like this:

Assignment and Command Statements

• The assignment statement LET assigns a value to a variable or object attribute.

• PERIOD assigns an execution period to a process.

• The command statement TELL sends a command to another object on the network.

These statements interrupt the normal top-down execution of a process by transferring execution to another area. They include GOTO and ON GOTO, GOSUB and ON GOSUB, RETURN, and EXIT DEF:

Branching Statements

• The GOTO statement transfers process execution to a labeled section of a process. ON GOTO transfers execution to one of several specified labeled lines, depending on the value of an expression.

• GOSUB also transfers execution to a labeled line. The process continues from the labeled line, until it reaches a RETURN statement. Then the process returns to the statement immediately following the GOSUB, and continues at that point. ON GOSUB works the same, but evaluates a conditional expression to transfer the execution to one of several labeled lines.

• The EXIT DEF statement returns control of a process from a user-defined function back to the main flow of the process, to the point of the function call.

JC-BASIC Programming 17

Page 42: Docs | Documents | Johnson Controls

Loop statements run the execution of a process in a repeating loop. They include the FOR-NEXT and WHILE-END WHILE statements:

Loop Statements

• FOR-NEXT repeats a series of statements for a specific number of times. The number of repetitions is counted in a variable, which may be used in expressions within the loop.

• WHILE-END WHILE repeats a series of statements as long as a specified condition is True. When something within the loop causes the condition to be False, the process exits the loop.

The conditional statement directs which statements should be executed based on which conditions are True. The statement is IF-THEN-ELSE (and counterpart, END IF). Within the IF-THEN-ELSE logic, you can use the FIRST PASS-END FIRST PASS option, which executes a block of statements the first time a logical expression in an IF statement changes to True or False.

Conditional Statement

The conditional statements IF delay_done? and IF delay_done?=TRUE perform the same action. However, for faster execution and to save on NCM memory, use IF delay_done?

Helpful Hint

Use the REM (remarks) statement to provide additional comments about the execution of the process. REM statements are valuable to communicate the intended behavior of the details of a process to a different programmer who may have to modify the code sometime in the future.

Comment Statement

The halting and delay statements, ABORT, STOP, and WAIT, work like this:

Halting and Delay Statements

• ABORT abnormally ends a process.

• STOP halts the continued execution of a process.

• WAIT inserts a time delay in process execution.

18 JC-BASIC Programming

Page 43: Docs | Documents | Johnson Controls

The ADVISORY with ADVISORY USING and PRINT with PRINT USING statements are output statements. They work like this:

Output Statements

• ADVISORY sends a change-of-state message to the operator workstation or printer.

• ADVISORY USING is the same as ADVISORY, except it specifies number format.

• The PRINT and PRINT USING (number format) statements send a line of text to a printer.

JC-BASIC has two types of functions you can use in a process: standard functions, which are already built into the language; and user-defined functions, used to create your own functions.

Functions

Standard functions are preprogrammed functions that return a numeric, logical, or time value that can be used in expressions. JC-BASIC provides the following standard functions:

ABS INT_TO_TIME SQR AVG LASTTOT TAN CANC_PULSE LOG TIME COS MAX TIME$ DATE$ MIN TIME_TO_INT DAY MONTH TODAY DEWPT N_CANC_PULSE TOTAL ENTHALPYDP PI_RESET UNRELIABLE ENTHALPYRH RAMP WETDP FILTER REL_HUM WETRH FORCE_REL SIN YEAR FORCE_UNREL SPAN

JC-BASIC Programming 19

Page 44: Docs | Documents | Johnson Controls

Use DEF FN, the user-defined function, to create and name customized functions. It offers two distinct advantages:

1. You need to define the function in only one place, then you can use it many times within a process without redefining it.

2. The function makes a process more memory efficient and easier to read.

A user-defined function has the same general format as processes do, and can use most of the same statements. An example is: DEF FNEXAMPL (A,B?)

in which DEF is the statement, FNEXAMPL is the function name, and A and B? are two variables used in the function.

The standard functions can be classified under these categories: date and time, HVAC-related, numeric, psychrometric, reliability, and special input.

These functions include DATE$, DAY, MONTH, INT_TO_TIME, TIME, TIME$, TIME_TO_INT, TODAY, and YEAR. The DATE$ and TIME$ functions, used in the ADVISORY and PRINT statements, supply the date and time when the advisory or print occurred. The INT_TO_TIME function converts an integer to a time value, and the TIME_TO_INT function converts a time value to an integer. The other functions retrieve the current date or time information within a process.

Date and Time Functions

These functions are FILTER, PI_RESET, RAMP, SPAN, CANC_PULSE, and N_CANC_PULSE:

HVAC Related Functions

• FILTER controls the rate of change in an input variable.

• PI_RESET changes a setpoint using a proportional-plus-integral function.

• RAMP ramps an output in steps.

• SPAN adjusts an analog value in a linear fashion.

• CANC_PULSE and N_CANC_PULSE program the cancelable and noncancelable pulse blocks.

20 JC-BASIC Programming

Page 45: Docs | Documents | Johnson Controls

The numeric functions are ABS, AVG, COS, LOG, MAX, MIN, SIN, SQR, and TAN. Each function is applied to the number or list of numbers beside it. Numeric functions work like this:

Numeric Functions

• ABS returns an absolute value.

• AVG averages up to 12 numbers.

• COS returns the cosine.

• LOG returns the logarithm.

• MAX selects the highest of a list of numbers.

• MIN selects the lowest of a list of numbers.

• SIN returns the sine.

• SQR calculates the square root.

• TAN returns the tangent.

Psychrometric functions include DEWPT, ENTHALPYDP, ENTHALPYRH, REL_HUM, WETDP, and WETRH. Each function asks for several parameter values, which are used in the fixed equation to yield a value.

Psychrometric Functions

These functions are FORCE_REL, FORCE_UNREL, and UNRELIABLE:

Reliability Functions

• FORCE_REL and FORCE_UNREL set the reliability flag of a value, which could be a variable, constant, or the result of an expression or function.

• UNRELIABLE determines the reliability of a value.

JC-BASIC Programming 21

Page 46: Docs | Documents | Johnson Controls

The two special input functions are the totalization functions LASTTOT and TOTAL:

Special Input Functions

• LASTTOT returns the last period totalized value of an attribute.

• TOTAL returns the current totalized value.

An expression is any valid combination of operands, constants, variables, and operators. Here are some examples:

Components of an Expression

A > B

EQUAL?

X = 3.7E15

'AHU1\MSD_AIR\VALUE' = 50

IF TIME > 04:00:00 AND TIME < 19:00

These examples and others are explained in the Types of Expressions section, later in this chapter.

Constants are actual values that JC-BASIC uses during process execution. There are four types of constants: real, integer, logical (Boolean), and time. Real and integer constants are collectively called numeric constants.

Constants

Real constants are positive and negative numbers that may contain decimal places. They may also be numbers expressed in scientific notation. Integer constants are whole numbers without decimal places. Their range is from -999999999 to 999999999. The unary + and unary - signs may precede real and integer constants; unary + is presumed if no sign is given.

Numeric Constants

22 JC-BASIC Programming

Page 47: Docs | Documents | Johnson Controls

Some examples of real and integer constants are:

Number Type 156 Integer

-25 Integer

+7582 Integer

5.6 Real number with fixed decimal point

-.25 Real number with fixed decimal point

+52.91 Real number with fixed decimal point

6. Real number with fixed decimal point

1.62E5 Real number in exponential format with positive exponent

-6.28E+4 Real number (negative) in exponential format with positive exponent

12.82E-3 Real number in exponential format with negative exponent

As shown in the last three examples, numbers in scientific notation are expressed in three parts: the fixed number, the letter E which means “times 10 to the power of,” and the exponent. The constant 1.62E5, for example, is equivalent to 162,000 and 12.82E-3 is equal to 0.01282. The exponential format allows no embedded blanks. Real numbers are stored as single-precision floating point numbers with a range of 3.4 x 10-38 to 3.4 x 1038 and -3.4 x 10-38 to -3.4 x 1038 with six significant digits of accuracy:

OK 3765 Wrong 3,765 OK 419874493 Wrong 419,874,493 OK 1000000 Wrong 1,000,000

Logical constants, also referred to as Boolean constants, are the values True and False.

Logical Constants

Time constants are time-of-day values with a range from 00:00:00 to 23:59:59. The value 00:00:00 is midnight and 12:00:00 is noon. No blanks are allowed around the colons.

Time Constants

JC-BASIC Programming 23

Page 48: Docs | Documents | Johnson Controls

JC-BASIC has a set of reserved constants which have specific meanings and uses. These are defined, so they should not be declared in a process. The following is a complete list of all reserved constants with their types and values:

Reserved Constants

Reserved Constant Type Value ALARM Numeric 2

CLOSED Boolean True

HI_ALARM Numeric 6

HI_WARNING Numeric 5

LO_ALARM Numeric 4

LO_WARNING Numeric 3

NORMAL Numeric 0

OFF Boolean False

ON Boolean True

OPEN Boolean False

PI Numeric 3.14159265359

RESET Boolean False

SET Boolean True

TROUBLE Numeric 1

Variables are names whose values can change during the execution of a process. The names and their values are stored in permanent memory locations.

Variables

JC-BASIC has four different types of variables: integer, real, logical, and time. A symbol at the end of a variable name indicates its type. The variable types with their symbols are:

Type Symbol Examples Real (numeric) ! , or no

symbol present total_air! oa_temp

Integer (numeric) % x% xy_z%

Logical (Boolean) ? low_limit_ovr? equal?

Time @ elapsedtime@ a2@

A variable is categorized as either local or shared.

24 JC-BASIC Programming

Page 49: Docs | Documents | Johnson Controls

A local variable: Local Variables

• is known only to the process in which it is defined. For example, you can use “x” as a local variable in Process A, then use “x” again in Process B as a different local variable.

• may be set to a value in the process using the LET statement.

Examples of local variables:

total_air! oa_temp x% xy_z% low_limit_ovr? equal? elapsed time@ a2@

A shared variable is used when more than one process needs a particular variable. A shared variable:

Shared Variables

• can be accessed by more than one process, but only in a single NCM.

• has the same syntax and naming conventions as local variables, but must be declared in each process that uses it.

• requires declaration in the process before it is first used. The keyword SHARED declares a variable; the variable name or list of variable names follows the keyword.

• retains its value in case of a power failure (warm start).

• can be used to pass data between two or more processes on the same node, or as a way for one process to trigger another.

Examples of shared variables: SHARED flag?, occupied?

JC-BASIC Programming 25

Page 50: Docs | Documents | Johnson Controls

A variable name can be up to 16 characters long. The name must follow these syntax rules:

Variable Names

• It can consist of letters, digits, underscores and a symbol denoting its type (i.e., 15 characters and the symbol).

• It must begin with a letter and end with the variable symbol that denotes its type. A real variable is an exception. It doesn’t need to end with its symbol, since the compiler appends a ! character at the end of variables without symbols. Variable symbols are: ! % ? @.

• It can’t have embedded blanks (e.g., OUT AIR is invalid). Instead, the underscore character may be used to separate two parts of a name (e.g., OUT_AIR).

• It can’t be a keyword (e.g., FOR@ is not a legal variable name). All keywords are listed in the Keywords section of Appendix E.

Two variables may be named the same, but must use different trailing characters. For example, using the variables A! and A@ in a single process is acceptable, since their symbols define them as different variable types.

JC-BASIC has three different types of expressions: numeric (integer and real), logical, and relational. String expressions, offered by many BASIC languages, are not allowed. The type of expression is determined by its end result; that is, if an expression has both time and numeric expressions, and the result is to be numeric, the type of expression would be numeric. Each type of expression has its own set of operators used to combine and compare the data to be evaluated by the expression.

Types of Expressions

26 JC-BASIC Programming

Page 51: Docs | Documents | Johnson Controls

Numeric expressions are operands separated by arithmetic operators. They can be grouped in parentheses. The arithmetic operators are:

Numeric Expressions and Operators

Operator Definition Example + Add A + B

- Subtract A - B

+n Unary Plus +A

-n Unary Minus -A

* Multiply A * B

/ Divide A/B

^ Exponential A^B (i.e., AB)

The division operation for integers is whole number division (the remainder is discarded).

Division by 0 is an error. If the interpreter detects a division by 0, it issues a user advisory and flags the result as unreliable. If the dividend is positive, the result is the largest positive value (999,999,999 for integer divide, 3.4E38 for real divide). If the dividend is negative, the result is the largest negative value (-999,999,999 for integer divide, -3.4E38 for real divide).

The exponential operator is in the form of A^B, where A is raised to the B power. If A=10 and B=5, in regular math denotation this would be 105 = 100,000.

For exponential operators and operands:

If Then A < 0 B must be an integer.

A = 0 B should be greater than 0.

A = 0 and B = negative integer

Result is 999,999,999, flagged unreliable.

A = 0 and B = negative real number

Result is 3.4E38, flagged unreliable.

A and B = 0 Result is 0, flagged unreliable.

A < 0 and B = a fraction Result is 0, flagged unreliable. Calculated result is outside range. Final result = minimum or maximum value, flagged unreliable.

JC-BASIC Programming 27

Page 52: Docs | Documents | Johnson Controls

Integer add, subtract, and divide operations that result in a value greater than 999,999,999 or less than -999,999,999 will return one of these limits, flagged unreliable. Integer multiplication operations act the same unless the multiplication values are so large that the result would be greater than 2,147,483,647 or less than -2,147,483,647; the results of which would be unpredictable.

Real add, subtract, multiply, and divide exponential operations that result in a value greater than 3.4E38 or less than -3.4E38 will cause a fatal floating point error. Any defined function that calculates a real value beyond the supported limits of a real number will also cause a fatal floating point error.

You can use time constants and time variables in a numeric expression. For example: X@ = 10:00 + 11:17:10 - Y@

The mathematics for time is done in 60 minute hours. If Y@ in this example is 1:00:00, this expression would evaluate to 20:17:10 (8:17:10 P.M.) Only the addition, subtraction, and logical operators are allowed in time expressions.

These expressions perform logical (Boolean) operations on logical values, and return a True or False value. Logical operators are:

Logical Expressions and Operators

Operator Definition Example AND Conjunction A AND B

OR Disjunction A OR B

XOR Exclusive OR A XOR B

NOT Negation NOT A

28 JC-BASIC Programming

Page 53: Docs | Documents | Johnson Controls

Truth tables for these operators are as follows (T=True, F=False):

AND NOT XOR OR A B A

AND B

A NOT A

A B A XOR

B

A B A OR B

T T T T F T T F T T T T F F F T T F T T F T F T F F T T F T T F F F F F F F F F

You can use logical operators in relational and logical expressions. For example: (A < 10.4) AND NOT (B > C)

Relational expressions compare two values and determine if the result is True or False. The operators are:

Relational Expressions and Operators

Operator Definition Example > Greater Than A > B

< Less Than A < B

>= Greater or Equal to A >= B

<= Less or Equal to A <= B

= Equal to A = B

<> Not Equal A <> B

DIFF Differential A > B DIFF C

Relational expressions have this format: <expression 1> <relational operator> <expression 2>

<expression 1> is any valid numeric, logical or time expression.

<relational operator> is one of the following operators: < > <= >= = <>

However, if <expression1> is logical, the only valid operators are = and <>.

<expression 2> is any valid numeric, logical or time expression that is the same type as <expression 1>.

JC-BASIC Programming 29

Page 54: Docs | Documents | Johnson Controls

Relational Expressions and Operators Examples

SQR(A-B) < 27.5

'AHU1\MSD_AIR\VALUE' = 50

ABS(A-B) < DELTA

IF TIME > 23:00:00 OR TIME < 2:00

IF TIME > 4:00:00 AND TIME < 19:00

The last two examples determine if a time falls within a certain range. The statement in the first example checks if the current time is after 11:00 p.m. but before 2:00 a.m. The second example checks if the time is between 4:00 a.m. and 7:00 p.m. Note that the OR operator is used in testing ranges crossing midnight.

More Relational Expressions and Operators Examples

'AH1\POINT2\CONTACT' <> 'AH2\POINT7\CONTACT'

UNRELIABLE (A) = UNRELIABLE (B%)

TIME = 8:00:00

Time expressions for = and < > ignore seconds.

Differential (DIFF) is a special type of relational operator that adds a deadband to a comparison. Typically, it is used to control a setpoint.

Differential (DIFF) Operator

DIFF is actually a combination of a logical expression, numeric expressions, and JC-BASIC function. It compares two analog values or constants, and returns a True or False result depending on a relational operator and a differential applied to the relational operator. The format is: <NUMERIC EXPRESSION 1> <RELATIONAL OPERATOR>

<NUMERIC EXPRESSION 2> DIFF <NUMERIC EXPRESSION 3>

<numeric expression 1/2/3> is a constant, variable, or combination of both.

30 JC-BASIC Programming

Page 55: Docs | Documents | Johnson Controls

<relational operator> is one of the following operators: < > <= >= =

<numeric expression 1> and <numeric expression 2> are compared using the relational operator.

If the comparison evaluates to True, then the statement evaluates to True.

If the comparison evaluates to False, the <numeric expression 3> is applied according to the following chart:

Condition Result <numeric expression 3> is less than 0 Runtime error is generated. <numeric expression> is equal to 0 Expression acts as if no

differential was specified. Statement not executed since last processor reboot, full download, process download, or process enable

Expression evaluates to False.

Statement contains the relational operator >= or <= and evaluated to False last time

Expression evaluates to False.

Statement: (a) contains the relational operator =; (b) <numeric expression 1> was less than <numeric expression 2>last time statement was executed, but now it is greater than <numeric expression 2>, and (c) < <numeric expression 2> + <numeric expression 3> is greater than <numeric expression 1>

Expression evaluates to True.

Statement: (a) contains the relational operator =; (b) <numeric expression 1> was greater than <numeric expression 2> last time statement was executed, but now it is less than; and, (c) <numeric expression 1> is greater than <numeric expression 2> minus <numeric expression 3>

Expression evaluates to True.

In addition to the preceding chart, if the statement was True the last time, it will evaluate to True this time if, depending on which relational operator is used, one of the following evaluates to True:

For relational operator <=: <NUMERIC EXPRESSION 1> <= (<NUMERIC EXPRESSION 2> + <NUMERIC EXPRESSION 3>)

For relational operator =: <NUMERIC EXPRESSION 1> <= (<NUMERIC EXPRESSION 2> + <NUMERIC EXPRESSION 3>)

AND <NUMERIC EXPRESSION 1> (<NUMERIC EXPRESSION 2> - <NUMERIC EXPRESSION 3>)

JC-BASIC Programming 31

Page 56: Docs | Documents | Johnson Controls

For relational operator >=: <NUMERIC EXPRESSION 1> >= (<NUMERIC EXPRESSION 2> - <NUMERIC EXPRESSION 3>)

Note: If a DIFF calculation results in unreliable data, the value saved for the DIFF operator’s previous value is not changed. Otherwise, once the value went unreliable, it would stay unreliable because the previous value is used as an input to the calculation.

All math performed by the differential operator will be in real numbers. Integers in the expression are converted to real numbers before the expression is evaluated.

Example ('AH1\FAN' >= 55.0 DIFF 5.0)

This statement will evaluate to True if:

• The value of ‘AH1\FAN’ >= 55.0

• The value of ‘AH1\FAN’ is not >= 55.0, but the statement evaluated to True the last time AND the current value of ‘AH1\FAN’ is between 50.0 and 55.0.

32 JC-BASIC Programming

Page 57: Docs | Documents | Johnson Controls

Evaluating Expressions

Expressions in JC-BASIC are evaluated according to operator precedence. The following table shows the order of execution of the operators, where 1 is the highest and the first executed. In the case of equal rank, the operators are executed from left to right. The evaluation sequence is modified by parentheses, which have precedence over any operator.

Operator Definition Rank Type ( ) Group Operations 0 Any

^ Exponential 1 Arithmetic

- Unary Minus 2 Arithmetic

+ Unary Plus 2 Arithmetic

*,/ Multiply, Divide 3 Arithmetic

+,- Add, Subtract 4 Arithmetic, Time

DIFF Differential 5 Arithmetic

> Greater Than 6 Relational

< Less Than 6 Relational

>= Greater or Equal to 6 Relational

<= Less or Equal to 6 Relational

= Equal to 6 Relational

<> Not Equal 6 Relational

NOT Negation 7 Logical

AND Conjunction 8 Logical

OR Disjunction 9 Logical

XOR Exclusive OR 9 Logical

Take this expression, for example: A = 10 * -20 ^ 4 / 2

The order of evaluation would be:

1. 20 ^ 4 = 160,000

2. Change 160,000 to -160,000

3. 10 * -160,000 = -1,600,000

4. -1,600,000/2 = -800,000

JC-BASIC Programming 33

Page 58: Docs | Documents | Johnson Controls

Parentheses change the precedence. For example: A = (10 * (-20 ^(4/2)))

The order of evaluation would be:

1. 4/2 = 2

2. 20 ^ 2 = 400

3. Change 400 to -400

4. 10 * -400 = -4000

When an expression requires one type of numeric data and another is provided, an automatic conversion takes place. The following are the rules governing the conversion:

• In a simple arithmetic or relational expression, all of the operands are converted to the same type. The type chosen is that of the operand that has the highest precision. In the example:

5.3 + 2 + 6.54

the number 2 will be converted to 2.0 internally before the addition is performed.

• In more complex expressions, not all the operands are converted initially. In the example:

12.3 + (I%*2)

the I%*2 is performed using integer operations. The result is converted to a real number and the addition is performed.

• A real number that is converted to an integer is rounded to the nearest integer. That is, 0.5 is added to positive numbers, 0.5 is subtracted from negative numbers, and the resulting value is truncated.

• To convert time to integers, use one of the following commands: cal_time@=hours% (Converts to hours and

minutes) how_long%=time_dif@ (Rounds time to nearest

minute and then converts hours to minutes)

34 JC-BASIC Programming

Page 59: Docs | Documents | Johnson Controls

System References (Attributes)

Every object in the FMS has a set of attributes which describe the object. These attributes include such things as value, object status (for instance, alarm or normal), and node status (online/offline). You can use attribute references in JC-BASIC wherever the attribute’s data type is syntactically correct and wherever the attribute has a name and is allowed to be read. The attribute types which you can assign to a JC-BASIC variable (of appropriate type) or use anywhere that variable could be used are:

• Boolean (logical)

• real

• integer (scalar, day of week)

• time of day

• arrays of the above data types

In addition, JC-BASIC will support attributes of type character string in PRINT and ADVISORY statements. It doesn’t support arrays of strings. The use of any other attribute types, like date, will generate a compiler error.

The syntax for referring to an object’s single attribute (non-array attribute) is: 'SYSTEM NAME\OBJECT NAME\ATTRIBUTE'

Object and attribute references can’t cross line boundaries.

Note: Do not use Date/Time attributes in JC-BASIC. Use of these attributes will cause a complier error.

Example 1 'AHU1\FAN\STATUS'

' LC1\SWITCH\VALUE'

An attribute whose data type is an array of data has special array handling syntax. JC-BASIC provides two ways of accessing a specific attribute array element.

All elements of an attribute array can be accessed using an integer index. The syntax is:

'SYSTEM NAME\OBJECT NAME\ATTRIBUTE' (INTEGER EXPRESSION)

JC-BASIC Programming 35

Page 60: Docs | Documents | Johnson Controls

Example 2 'LC2\FLOOR3\PATTERN' (3)

'RC3\WESTRM\SETPOINT' (I%)

'LC7\E_WING\OVERRIDE' (J% + K%)

Note: There is no mechanism available to access an entire attribute array in a single statement. If you need an entire array, use a FOR loop for retrieving all the data. For example, to access the first 12 values of an attribute, you could write:

DIM X (12)

FOR I% = 1 TO 12

X (I%) = 'AH2\MTR5\MIN_ON' (I%)

NEXT I%

An array is a group of storage locations in memory in which data elements can be stored.

Arrays

An array and its data elements are like a deck of playing cards. The deck is the array and the 52 cards are the elements. The values of these elements are the names of the cards: jack of spades, nine of hearts, ace of diamonds, and so on.

An array must be “dimensioned” in a process, which assigns the array its number of elements. You can dimension an array in two ways:

• By declaring its size with the DIM or SHARED statement. The maximum size that the compiler allows is 15,878 elements, but the actual maximum size depends on available NCM memory.

Format DIM <NAME> (<NUMBER OF ELEMENTS>)

36 JC-BASIC Programming

Page 61: Docs | Documents | Johnson Controls

Example DIM A(4)

In this example, the array name is A and the number of elements is four. This array would tell the compiler to set aside four memory locations with the name A. These memory locations will hold different values for A.

We could assign values like this:

A(1) = 12.4

A(2) = 35.6

A(3) = 19.1

A(4) = 45.3

35.6 is the second element of array A (the value stored at the second memory location in array A).

• By referencing a variable as an array before declaring it as an array. In this case, the array size is set to the default: 10 elements. Whenever you need a local array with 10 elements, you need not declare it with the DIM statement, though using an array without declaring it is generally a poor programming practice. Declare all arrays, to make sure your code is readable and maintainable.

Arrays greatly simplify the task of naming and referencing individual values in a collection. JC-BASIC offers single dimension arrays only.

Two types of arrays are available: variable arrays and attribute arrays. Variable arrays can also be called subscripted variables, and attribute arrays, subscripted attributes.

Note: All local and shared variable arrays and attribute arrays must start with a subscript of 1. If you use a subscript less than 1, a runtime error results.

If the element designator or subscript is an integer when declaring an array, an integer constant must be used. When referencing an array element, an integer should be used; however, a real number (or real variable) will be converted to an integer.

JC-BASIC Programming 37

Page 62: Docs | Documents | Johnson Controls

Loops A loop is a set of instructions that are executed repeatedly. JC-BASIC offers two loop statements: FOR-NEXT and WHILE-END WHILE.

• The FOR-NEXT loop executes a block of statements for a prescribed number of times, then exits.

• The WHILE-END WHILE loop executes a block of statements while a given condition is True, then exits. Nested loops, which are loops entirely contained within other loops, are allowed.

A subroutine is a block of code accessed by a GOSUB or ON GOSUB statement. A subroutine is local, which means it is used in the same process that calls it. JC-BASIC doesn’t allow a subroutine call to another process. The RETURN statement, always required when using either GOSUB or ON GOSUB, returns execution to the statement that immediately follows the GOSUB.

Subroutines

The first statement of a subroutine can be any valid statement, including a REM statement. The GOSUB doesn’t necessarily have to transfer control to the first line of the subroutine. Instead, you may use several entry points into the same subroutine. Nested subroutine calls are allowed, nested subroutine definitions are not.

The GOSUB statement transfers execution unconditionally to a labeled statement in a subroutine. The ON GOSUB statement transfers process execution to one of several specified labels, depending on the value of an expression.

38 JC-BASIC Programming

Page 63: Docs | Documents | Johnson Controls

Writing a Process

Before you can write a process, you must complete the following:

1. Conduct a site survey.

2. Develop the control strategy for the entire system.

Only after completing these tasks can you begin to write the processes that will control the system elements, such as the fans, dampers, and coils.

Each process consists of an input section, a logic section, and an output section. A process can have one input and one output or multiple inputs and outputs . . . the logic can be simple or complex:

The Components of a Process

Output(s)LogicInput(s)

process

Figure 3: Process

This section discusses three sample processes:

• Example 1: Ramp

• Example 2: Reset of a Setpoint

• Example 3: Economizer

JC-BASIC Programming 39

Page 64: Docs | Documents | Johnson Controls

In this example, a process has been written to ramp an analog input device, such as a supply fan, from a start value to an end value. The ramp operates this way:

Example 1: Ramp

1. When the input changes from False to True, the Ramp is reset to the starting value. In this example, the starting value is 0.

2. The Ramp increases at a fixed rate from the start value of 0 to the end value of 100. The rate of increase is determined by dividing 100 by the period of time defined in the Period statement.

3. The Comparator disables the Period statement when the end value of the Ramp is reached.

4. Once the output equals the end value, the output remains at the end value until the input again changes from False to True.

The functional block diagram for the process is shown below. For the code described by this diagram, see the Command Reference section of this manual.

Ramp:0 - 100

Period

LogicInput Output

Comparator

ramp

InputInputControl of output Output

Constant: =

100

Figure 4: Ramp Functional Block Diagram

40 JC-BASIC Programming

Page 65: Docs | Documents | Johnson Controls

In this example, the process first determines which is the lowest of four analog inputs, then spans that value.

Example 2: Reset of a Setpoint

You could use this process to control or manipulate the setpoint of many applications. For example, you could use it to reset the setpoint of a modulated heating application.

The process operates this way:

1. Up to four analog inputs can be connected to the Selector.

2. The MIN function determines which of these inputs is the lowest. That value is fed to the Span.

3. The Span produces an output proportional to the input. For example, if the input range is 1-10 and the output range is 50-100, an input value of 5 produces an output value of 75.

The functional block diagram for the process is shown below. For the code described by this diagram, see the Command Reference section of this manual.

LogicInput Output

MIN Span Output Control of Output

reset

InputInput 1

Input 2

InputInput 3

InputInput 4

Figure 5: Reset of Setpoint Functional Block Diagram

JC-BASIC Programming 41

Page 66: Docs | Documents | Johnson Controls

This process provides modulated damper economizer control, based on the outdoor air dry bulb temperature, and the economizer’s switchover setpoint.

Example 3: Economizer

After the outdoor air dry bulb temperature is compared to the economizer’s setpoint, one of the following occurs:

• If the outdoor temperature is less than the setpoint, the economizer mode allows the dampers to modulate from the minimum position to the maximum position.

• If the outdoor temperature is greater than the setpoint, the dampers are limited to the minimum position needed to satisfy minimum ventilation requirements.

• An override feature has been included.

The functional block diagram is shown below. For the code described by this diagram, see the Command Reference section of this manual.

LogicInput Output

MinimumDamping

Limit

Economizer Enable

Override

ComparatorOAT>Limit

Switch

AND

OR

Controlof Output

Output:Override

Controlof Output

econom

OutdoorAir Temp

(OAT)

Constant=

1000

OutputMinimum Damping

OutputMaximumDamping

Figure 6: Economizer Functional Block Diagram

42 JC-BASIC Programming

Page 67: Docs | Documents | Johnson Controls

The Restart Process

The RESTART process is a special JC-BASIC process for the NCM. Though it has the same syntax as all other processes, the RESTART process is used exclusively for performing required startup processing. This may include, for example, initializing shared variables and determining occupancy time.

The RESTART process is the first process the NCM executes upon startup. No other processes execute until RESTART finishes executing. This makes it similar to the AUTOEXEC.BAT file in DOS. RESTART is run only if the NCM contains it, and it is run automatically every time the NCM is started (cold or warm start).

If you decide to use a RESTART process, you’ll need to know the initialization values given to items when the NCM starts (cold or warm start). The table summarizes them:

Type Initialization Value Integer 0

Real 0

Logical False

Time 00:00:00

DIFF False (applied to last known value of comparison)

IF Statement False (FIRST PASS flag only)

Period 00:00:00

Attributes Depends on type (0, False or 00:00:00)

Process Reliability Reliable

JC-BASIC Programming 43

Page 68: Docs | Documents | Johnson Controls

Format Any process can be identified as the RESTART process—simply name it RESTART. This is the format of a RESTART process:

PROCESS '<SYSTEM NAME>\RESTART' “ <PROCESS DESCRIPTOR>" '\<NCM NAME>'

<STATEMENTS>

END PROCESS

<system name>

Name assigned to the system that this RESTART process is written for; eight characters maximum.

RESTART

Name that must be used to identify this as a RESTART process; any mixture of upper and lower case letters is allowed.

<process descriptor>

Further describes the RESTART process; 24 characters maximum.

\<ncm name>

Name assigned to the NCM that will store and execute this RESTART process; eight characters maximum. The backslash (\) character is required.

<statements>

Any series of statements that are to be executed before all other statements in the process.

Here are some things to keep in mind concerning the RESTART process:

Concerns

• If the RESTART process uses a WAIT statement, all other processes will be delayed until the specified wait period expires. If you use a WAIT statement, be aware that no other processes will run until its wait time expires. Further, if the RESTART process executes an infinite loop, no other processes would ever run.

• If a RESTART process exists but is disabled at reboot time or while it is executing, then all other processes are not executed until the RESTART process is enabled and the NCM is rebooted. If a RESTART process is not fully downloaded, or is disabled before or during reboot due to an error, no process will run.

44 JC-BASIC Programming

Page 69: Docs | Documents | Johnson Controls

• A single NCM can have at most one RESTART process. If two RESTART processes are written for the same NCM, but have different system names, the download procedure would flag the second RESTART process as an error.

• If a RESTART process already exists in an NCM, and subsequently another RESTART process with the same system name is downloaded, the second RESTART process will replace the first. However, you must disable the process in the NCM and verify that the system name is exact before downloading. You’ll not be notified that the replacement occurred.

• A RESTART process can’t have triggers, a period, or EXEMPT declarations.

• The RESTART process can’t be commanded by a manual operator command, programmed through a JC-BASIC program or through the time manager, or be triggered manually or through a JC-BASIC process.

The following example of a valid RESTART process shows some general processes for an Air Handling System. (This is not a complete system, just a representation of some processes in a system.) Here are the general specifications of these processes:

Examples

Economizer:

The economizer overrides the damper control to the minimum outdoor air position when the outdoor air enthalpy exceeds the return air enthalpy.

Supply fan start stop control:

The supply fan start/stop request is issued based on time scheduled occupancy. If the fan alarm occurs, a stop request is issued and the fan is locked out. This alarm must be manually reset.

Return fan start/stop:

When the supply fan is started, the return fan starts.

Unoccupied Cycle:

During the unoccupied cycle, if the room temperature falls below the night set back heating setpoint of 60°F/15.6°C, the system goes into a low limit override state. The fan will start and the controls will be set for full heat.

JC-BASIC Programming 45

Page 70: Docs | Documents | Johnson Controls

The following processes show how you can program these criteria in JC-BASIC.

10 PROCESS 'AHU3/START_UP' “SUP/RET FAN” '\AHU3_NCM3'

20 REM SUPPLY AND RETURN FAN START-UP/SHUT-DOWN FROM TIME SCHEDULE

REM OR UNOCCUPIED ROOM TEMP LOW LIMIT OVERRIDE. FAN ALARM

REM LOCKOUT WITH MANUAL RESET.

30 SHARED LOW_LIMIT_OVR?

40 IF 'AHU3\OCCUPIED' = ON OR low_limit_ovr? THEN

50 IF 'AHU3/FAN_ALRM' = OFF THEN

60 TELL 'AHU3/SPR_STSP' TO “START” 6

70 END IF

80 ELSE

90 TELL 'AHU3\SPF_STSP' TO “STOP” 6

100 END IF

110 END PROCESSES

PROCESS 'AHU3\RFT_INTL' “RFAN INTRLCK” '\AHU3_NCM3'

REM WHEN SUPPLY FAN IS STARTED THEN RETURN FAN IS STARTED.

IF 'AHU3\SPF_STSP' = ON THEN

10 TELL 'AHU3\RTF_STSP' TO “START” 6

ELSE

20 TELL 'AHU3\RTF_STSP' TO “STOP” 6

END IF

END PROCESS

PROCESS 'AHU3\ALRM_SDN' “ALARM SHUTDOWN” '\AHU3_NCM3'

REM FANS ARE SHUTDOWN ON ALARM STATUS. ALARM MUST BE

REM MANUALLY RESET.

IF 'AHU3\SPF_STSP\STATUS' = ALARM OR 'AHU3\RTF_STSP\STATUS'\

= ALARM THEN

10 TELL 'AHU3\FAN_ALARM' TO “SET_BD” TRUE,3

20 TELL 'AHU3\SPF_STSP' TO “STOP” 7

END IF

END PROCESS

46 JC-BASIC Programming

Page 71: Docs | Documents | Johnson Controls

PROCESS 'AHU3\ECON' “ECONOMIZER CONTROL” '\AHU3_NCM3"

REM RETURN AIR AND OUTSIDE AIR ENTHALPY ARE CALCULATED AND

REM THE OUTSIDE AIR DAMPER IS ALLOWED TO MODULATE IF OA

REM ENTHALPY < RA ENTHALPY OR HELD AT MINIMUM (WITH PROP.

REM LOW LIMIT CONTROL) IF OA ENTHALPY > RA ENTHALPY.

SHARED max_position

PERIOD 00:04:00

IF 'AHU3\SPF_STSP' = ON AND 'AHU3\OCCUPIED' = ON THEN

FIRST PASS

WAIT 00:04:00

END FIRST PASS

TELL 'BLDG\OA_ENTH' TO “SET_AD” \

ENTHALPYRH ('BLDG\OA_TEMP','BLDG\OA_HUM'29.000,ENGLISH), 3

TELL 'AHU3\RET_ENTH' TO “SET_AD” \

ENTHALPYRH ('AHU3\RET_TEMP','AHU3\RET_HUM'29.000,ENGLISH), 3

IF 'BLDG\OA_ENTH' < 'AHU3\RET_ENTH' DIFF 1.0 THEN

TELL 'AHU3\ECON_ON' TO “SET_BD” TRUE, 3

LET max_position = 100

ELSE

TELL 'AHU3\ECON_ON' TO “SET_BD” TRUE, 3

LET max_position = 'AHU3\MIX_MIN: REM AD OBJECT

END IF

ELSE

TELL 'AHU3\ECON_ON' TO “SET_BD” false, 3

LET max_position= 'AHU3\MIX_MIN'

END IF

END PROCESS

JC-BASIC Programming 47

Page 72: Docs | Documents | Johnson Controls

48 JC-BASIC Programming

Page 73: Docs | Documents | Johnson Controls

Compiler Directives

Compiler directives are special instructions to the JC-BASIC compiler. These instructions tell the compiler to do something while translating a JC-BASIC process. The compiler directives are #INCLUDE, #LIST and #NOLIST, #REMARKS and #NOREMARKS, and #REPLACE.

Overview

• #INCLUDE tells the compiler to include a function or block of source code at a certain location within a process source file. The resulting source code will include that external function or block of code.

• #LIST instructs the compiler to include all source lines following it within the list file. #NOLIST tells it to show only those source lines that contained errors. This is useful if you just want to view the lines with errors.

• #REMARKS tells the compiler to translate remarks into object code. #NOREMARKS tells the compiler not to translate remark statements. An NCM can contain a larger object file if the file excludes the remarks.

• #REPLACE substitutes a 16-character identifier with a text string. This is similar to a search and replace function in a word processor.

Compiler directives don’t produce any executable code. Using Directives Directives are “position sensitive,” which means they are not effective until the compiler detects them. For example, if the directive is placed in the middle of a file, only the portion of the file that follows the directive will be affected. They also function sequentially: if the directive is placed at the beginning of a source file, it applies to all the processes in a single source file, not just on an individual process.

JC-BASIC Programming 49

Page 74: Docs | Documents | Johnson Controls

This sequential operation can be beneficial. For example, you may want to turn on the compile #REMARKS option at the beginning of the file, then later in the file, specify #NOREMARKS to turn the option off. Similarly, you may replace a text string with one identifier, then somewhere later and for the same text, specify a different identifier. Compiler directives are applied to a single DOS source file. They can’t cross to other files.

Follow these rules when using compiler directives:

• Place the # character as the first non-blank character on the input line. It distinguishes directives from JC-BASIC statements and functions.

• Don’t use spaces between the # character and the directive keyword.

• Put the directive all by itself on one physical line. Don’t have anything else follow it on the same line.

You may use as many compiler directives as needed.

The following sections describe each compiler directive in detail:

Inserts the contents of an external file at the specified location in the source file. The file may contain a function or block of source code.

#INCLUDE

Format #INCLUDE “<DOS FILENAME>"

<DOS filename>

Full file name for any DOS file that contains a valid function or block of source code that will be inserted at this location when the file is compiled. The file name must indicate the disk drive designator and be written in DOS format (e.g., c:\dir\file1.jcb).

If the INCLUDE file is located on the same directory where the .BAS file resides, only the file name, not the entire path and drive designator, is needed.

50 JC-BASIC Programming

Page 75: Docs | Documents | Johnson Controls

You can use the #INCLUDE directive when you need the same block of source code statements for more than one process. You can store the code in a file, then use the #INCLUDE directive in processes that should reference the file. The #INCLUDE directive offers a more efficient method than retyping or copying the code into each process.

Details

Nested #INCLUDE directives are not allowed. That is, an #INCLUDE directive can’t appear in the include file.

The #INCLUDE directive can appear anywhere within a source file, but must appear before any references are made to any included declarations.

Example #INCLUDE "A:\INCLUDES\AIR_HAND.BAS"

In this example, the contents of the file AIR_HAND.BAS from Drive A: and the INCLUDES directory will replace the directive when the source file is compiled.

Turns the list source file option on or off. #LIST #NOLIST

Format #LIST

#NOLIST

The #LIST directive tells the compiler to include the entire source file in the list file. All other information that is characteristic of a list file is also shown. The #LIST directive is the default for a file that doesn’t specify either #LIST or #NOLIST.

Details

The #NOLIST directive tells the compiler to include in the list file only the source lines with errors. All other lines are missing, but the other information that is characteristic of a list file is shown.

JC-BASIC Programming 51

Page 76: Docs | Documents | Johnson Controls

The #LIST directive functions sequentially; you write it at the point in the source file where it should become effective. This can be either inside or outside a process, as long as the directive is the only item on the physical line. You can also turn off the directive at any location by writing #NOLIST, then turn it on again somewhere else by writing #LIST.

If you want the entire file to use #NOLIST, you must specify #NOLIST at the beginning of the source file before any processes.

Place #LIST or #NOLIST on a line by itself in the source file at the point you want the directive to take effect.

Example

Turns the compile remarks option on or off. #REMARKS #NOREMARKS Format #REMARKS

#NOREMARKS

The #REMARKS directive in a source file tells the compiler to translate all remark statements (comments) into object code. The #NOREMARKS directive is the default for a file that doesn’t specify either #REMARKS or #NOREMARKS.

Details

The #NOREMARKS directive tells the compiler not to translate remarks into object code. This directive is most useful for large processes with many REM statements that, if compiled, would consume a substantial amount of NCM memory.

52 JC-BASIC Programming

Page 77: Docs | Documents | Johnson Controls

The #REMARKS directive functions sequentially; you write it at the point in the source file where it should become effective. You can also turn the directive off at any location by writing #NOREMARKS, then turn it on again somewhere else by writing #REMARKS. If you want the entire file to use #REMARKS, you must specify #REMARKS at the beginning of the source file before any processes.

Place #REMARKS or #NOREMARKS on a line by itself at the point in the source file where you want the directive to take effect.

Examples

Replaces every occurrence of an identifier with a specified character string.

#REPLACE

Format #REPLACE <IDENTIFIER># “<CHARACTER STRING>“

<identifier>

Text that is to be replaced with text in the character string, up to 16 characters. Append the # character to the identifier, with no blank space separating the two.

<character string>

String of characters that will replace every occurrence of the identifier.

This directive is similar to the Replace function typical of most word processors. The text in the character string will replace the text of the identifier in each occurrence. It may be used for replacing generic point names like “OAT” (outdoor air temperature) with actual names which include the system, object, and attribute names. Any string of characters can be replaced, including text within a function.

Details

JC-BASIC Programming 53

Page 78: Docs | Documents | Johnson Controls

The syntax for the identifier is the same as for variable names, except you must add the # character to the end of the identifier (for example, OAT#). The # character is required both within the #REPLACE statement, and within the process for each time you use the identifier. See the examples at the end of this discussion.

The #REPLACE directive functions sequentially. Therefore, you must write the directive at the point in the source file where you want the replacement to start.

If every occurrence of the identifier should be replaced, you should write the #REPLACE directive at the beginning of the file, or just before the identifier is first used. If you want only certain occurrences replaced, write a #REPLACE directive somewhere before the identifier to be replaced, then another #REPLACE directive (assigning the character string to the value of the identifier) where the replace should change.

Follow these rules when using the #REPLACE directive: Rules

• Don’t use keywords as replace identifiers.

• Don’t use cascaded replaces. A cascade replace is a second replace identifier within the first. For example, the second and third replace directives below attempt to use A# incorrectly.

OK #REPLACE A# “ABC”

Wrong #REPLACE BA## “BLD_2A”

Wrong #REPLACE C#A# “A”

• Don’t use two or more replace identifiers cooperatively to build a keyword, constant value, object name, etc. This capability is not available, because a blank space is always added after the replaced text.

54 JC-BASIC Programming

Page 79: Docs | Documents | Johnson Controls

• Don’t use nested replaces. In other words, a character string can’t specify a replace identifier to attain a second nesting level. For example, the second and third replace directives below use D# improperly.

OK #REPLACE D# “ABC”

Wrong #REPLACE B# “BLD_2D#”

Wrong #REPLACE C# “D#_AHU1”

• Don’t place replace identifiers inside single or double quotes or in a remark.

• Don’t use identifiers to form a name. The following is not allowed:

#REPLACE PART1# “ENTHALPY”

Y = PART1#RH(A, B, 29.000, ENGLISH)

Z = PART1#DB(X, Y, 29.000, METRIC)

The compiler would view this as a single variable ENTHALPY followed by an array variable RH.

• Don’t use a replace identifier to replace a compiler directive. The following is not allowed:

#REPLACE INCM# “#INCLUDE”

INCM# filename

• Don’t use a replace identifier to separate an array variable and its subscript. An array variable and its subscript are considered one name. The following is not allowed:

#REPLACE SUBSCRIPT# “(C+D)”

LET E = A SUBSCRIPT#

The compiler would view this as the single variable followed by a parenthesized expression.

JC-BASIC Programming 55

Page 80: Docs | Documents | Johnson Controls

Specified #REPLACE: Examples #REPLACE FAN# “'SYS\OBJ\ATT'”

Typed Text: IF FAN# = ON THEN

Compiled Result: IF 'SYS\OBJ\ATT' = ON THEN

Specified #REPLACE: #REPLACE FIRE# “('FS1\SMOKE'=CLOSED) OR ('FS1\PULL_STA' = CLOSED)”

Typed Text: WHILE FIRE#

Compiled Result: WHILE ('FS1\SMOKE'=CLOSED) OR ('FS1\PULL_STA' = CLOSED)

56 JC-BASIC Programming

Page 81: Docs | Documents | Johnson Controls

JC-BASIC Programmer’s Manual

Runtime and User Operations

Runtime Operations 3

l Process Execution *3 l Process Timers *4 l Unreliable Data Handling *5 User Operations 9

l Compiler 9 l Process Download *10 l Process Upload 12 l Process Deletion *12 l Process Backup and Restore 12 l Process Enable and Disable 13 l Triggering a Process *13 l Process Summary 13 l Process Focus *14

* Indicates those sections where changes have occurred since the last printing.

© November, 1996 Johnson Controls, Inc. 1 Code No. LIT-632030

Page 82: Docs | Documents | Johnson Controls

2 Runtime and User Operations

Page 83: Docs | Documents | Johnson Controls

Runtime Operations

This chapter describes how the Network Control Module (NCM) executes a process. Each user operation is described in detail. This section describes process execution, process timers, and unreliable data handling.

The Interpreter inside the NCM executes the processes. The order in which it executes processes is first by their assigned priorities (1, 2, 3, or 4, where 1 is the highest priority and 4 is the lowest), then on a first-come, first-served basis. A higher priority process is always executed before a lower priority process. Processes of the same priority are executed on a first-come, first-served basis.

Process Execution

The Interpreter executes the statements in a process consecutively; from the top to the bottom, and from the left to the right. The execution order is not consecutive, however, when the Interpreter encounters a loop or branching statement. For a loop, the Interpreter executes the block of statements within the loop for the number of times specified. For a branching statement, the Interpreter transfers execution to another line of the process.

Figure 1 shows events which can cause the NCM’s Interpreter to trigger a process.

Runtime and User Operations 3

Page 84: Docs | Documents | Johnson Controls

Manual command from user

Trigger command fromJC-BASIC or a timed program

Process period expires

User downloads the process

Processor reboots

User enables a disabled process

Network Control Module (NCM)

Triggerable Process

Triggering Events

Process

triggerChange-of-state occurs in a triggerableattribute or a logical shared variable

Interpreter

Figure 1: Triggering a Process

A process can be executed periodically. This is specified by the PERIOD statement. The syntax of the PERIOD statement is:

Process Timers

PERIOD <time expression>

Example PERIOD 00:30 (30-minute period)

The process will execute on a periodic basis as specified by the PERIOD statement. The last period specified by the process will always be used. Once executed, the period specified is used until another period statement is executed. There is no period until the process has executed a PERIOD statement at least once after download, reboot, or enable. A period of 0 will stop the periodic execution but still allow triggers to execute the process. This can be used to “put to sleep” a periodic process, which has no useful work to do until a trigger occurs which “wakes it up” again.

The PERIOD statement is optional. If not included, the process will only execute when one of the triggers changes or another triggering event occurs. To change the period from execution to execution, simply execute the PERIOD statement with a new value.

4 Runtime and User Operations

Page 85: Docs | Documents | Johnson Controls

The period is initialized to 0 when the process is downloaded, the NCM performs a cold or warm start, or the process is enabled. Since, in each of these cases, the process is executed once, it is assumed that the process itself will determine whether it should currently be running periodically and what the current period should be.

The period of the process is used at the END of execution of the process to determine the delay before the next execution of the process. As such, the process won’t execute exactly as often as the period states since some time is taken in executing the process before the period is recalculated and some time may transpire while the process is queued and waiting to execute. This is especially true if the process executes a WAIT statement because the WAIT must expire before the process can end (and, hence, start the next period). In that case, the time between two executions will be equal to the period plus the wait delay plus the execution and queuing times.

A trigger which occurs during a periodic delay will cancel the periodic delay and execute the process. The new period will then start at the end of that execution.

The maximum period you can specify is 23:59:59. If the period exceeds this, a runtime error is generated and 23:59:59 is used. If the period is negative, a runtime error is generated and 0 is used.

Each data value in JC-BASIC has a reliability flag. This flag indicates whether that value was generated under reliable circumstances.

Unreliable Data Handling

Unreliability can originate in two ways:

• either from an unreliable object value coming from the field

• or as the result of a math error (such as divide by 0)

When unreliability is generated, a runtime error message is sent to a device to notify the user.

Runtime and User Operations 5

Page 86: Docs | Documents | Johnson Controls

When a value is tagged unreliable, it can pass its unreliability to expressions. For example, in the statement A = B + C, if B is unreliable, then A would be unreliable as well.

Each JC-BASIC function deals with an unreliable input in its own fashion and describes under what conditions the output is unreliable. These are described fully in the Command Reference section.

This section includes a discussion of a logical function called UNRELIABLE. This function returns a True state if the value passed to it is unreliable.

In addition, the functions FORCE_REL and FORCE_UNREL can affect the reliability of a data value.

An object attribute can become unreliable in one of two ways: Attribute Values

• The object manager can determine its attribute value is unreliable and set the unreliable flag when it returns the requested value.

• The object attribute can be offline and therefore report unreliable, or not report at all.

In either case, the Interpreter will use the last reliable value read for the attribute, and flag it unreliable.

JC-BASIC saves the last reliable value received from each successful attribute read request. On cold start or process download of an object’s attribute not referenced by any other process already downloaded, all object attribute values are set to their initialization values (e.g., False for logical, 0 for numeric). By testing the reliability flag, you may override this last read value with a default or use the ABORT statement in the process. The last known value is not kept for array attributes.

Unreliability works the same way for triggers as for attributes that are read. That is, the last known reliable value for a trigger is always used if the value can’t be read reliably. Note, however, that if a Change-of-State (COS) message is received with unreliable data, the message won’t trigger processes. The same is true for changes to shared logical variables which are or become unreliable.

Trigger Values

6 Runtime and User Operations

Page 87: Docs | Documents | Johnson Controls

The following functions have an unreliable result if any input parameters are unreliable:

Unreliable Results from Inputs

ABS LOG SPAN AVG MAX SQR COS MIN TAN ENTHALPYDP

RAMP TIME_TO_INT

ENTHALPYRH

PI_RESET WETDP

INT_TO_TIME SIN WETRH

The FILTER function is unreliable if the current value or filter weight is unreliable.

The basic philosophy of reliability is that a value will always be used regardless of whether it is reliable or unreliable. For example, the logical result in a WHILE or IF statement and the time value for a PERIOD or WAIT statement will use the value computed without concern for the reliability flag.

Effect of Reliability

The same applies to values printed in the PRINT or ADVISORY statement and to values sent as TELL parameters or assigned to a writable attribute. If you are concerned that an action must not occur if a value is unreliable, then you should write your JC-BASIC processes to take that into account.

Whenever a value is initialized, such as a local variable at reboot or a shared variable at download, the reliability flag is also initialized to reliable. Reliability is sent with the value of an attribute when the attribute is written (by using it on the left side of a LET statement). The individual object managers will determine for which of their attributes they will use that reliability information. At a minimum, the Analog and Binary Data objects will store the reliability information sent with the new value.

The reliability of a parameter in a TELL, ADVISORY, or PRINT statement will have no bearing on the execution of the statement. The reliability value won’t be sent with the parameters in the TELL, nor is the reliability printed in the PRINT and ADVISORY statements.

Runtime and User Operations 7

Page 88: Docs | Documents | Johnson Controls

When a subscript of an array is unreliable, the resulting value obtained for that subscript is also unreliable. That is, if you have the statement:

Arrays

LET A=B(C%)

when C% is unreliable, then A will become unreliable even though B(C%) may be a reliable value.

Also, if you have: LET A(C%)=B

then A(C%) will be unreliable if C is unreliable, even though the value of B may be reliable.

In the case of array attributes, when you have: LET 'AHU1\OBJECT\ARRAYATR' (C%) = B

the value passed to the attribute will be unreliable if C% is unreliable, even though B is reliable.

A process also has a reliability value, which is kept as a logical value. It is unreliable if any reference has been made in the process to an unreliable value. If the value is reliable, it means that the last time the process executed, unreliable data was not encountered. The reliability flag is set to reliable every time a process executes from the beginning, or is set unreliable if the Interpreter encounters any unreliable data while executing the process. The Interpreter will print an advisory whenever it changes a flag from reliable to unreliable, or from unreliable to reliable. The flag is initialized to reliable on download. The flag is not touched when a process returns from a wait or time-slice unless the remaining execution sets the flag unreliable. The flag also is not changed on warm restart or process enable.

Process

8 Runtime and User Operations

Page 89: Docs | Documents | Johnson Controls

User Operations

User operations include compiler functions and these process functions and system features: download/upload, delete, backup, restore, enable/disable, trigger, summaries, and focus windows.

The JC-BASIC compiler translates a source file into one or more object files and a list file. The compiler creates one object file per process. This object file is the executable portion of the process that can be downloaded to an NCM. The list file contains the contents of the source file, plus any errors found and some summary information.

Compiler

The file name assigned to the object file is the process name plus an .OBJ extension. The list file is named the same as the source file, but with an .LST extension. No object file is created if the process contains errors. The compiler will never write to the original source file.

The compiler checks for proper syntax. It verifies that the systems and objects referenced in the processes are defined in the data base you opted to verify against--disk (that is, archive) or field. The compiler also checks attributes and commands to the attributes in the processes and tags any item that doesn’t verify.

The compilation process provides you with several options. You may tell the compiler not to include the source in the list file. To do this, place the #NOLIST compiler directive at the front of the source file. Only the source lines with errors will be duplicated in the list file.

Processing

You can select which processes in a file to compile by using the DOS wildcard character (*). The compiler will compile selected files. New object files may or may not be created, but the selected source files are always compiled.

Runtime and User Operations 9

Page 90: Docs | Documents | Johnson Controls

The list file is composed of five sections: (1) manufacturing file data, (2) header, (3) source file, (4) tables, and (5) totals.

List File Sections

The manufacturing file data identifies the job site for which this product was purchased, and the date and revision number of the JC-BASIC software.

The header is enclosed in asterisks and shows the revision number of the compiler, the date and time of the compile, and the source file. The source file follows, which indicates all errors detected. Each error appears directly under the line where the error occurred. It is numbered and contains a description along with a mark that shows the approximate location of the error.

The tables section shows helpful information about the variables, objects, triggers, and exemptions that are used in the process. The last section, totals, indicates the object size in bytes, number of errors, and number of warnings found.

The download operation sends object files to the proper NCMs over the N1 Bus. You can perform either a full or partial download at the Operator Workstation with the Download command. A network node, however, can also request a download without operator assistance.

Process Download

You can download any combination of object files in the same system to the NCM, including the object for just one process. An object file is downloaded to the NCM that is defined in its PROCESS statement. If this object file already exists in the NCM, the new file replaces the original. The only requirement for downloading a new version of an original object file is to disable the process on the NCM. A new object file can’t replace an original file that is enabled.

10 Runtime and User Operations

Page 91: Docs | Documents | Johnson Controls

You can download all objects for one NCM with one command. When the entire NCM data base is downloaded, each item is given an initialization value. These are:

Type Initialization Value Integer 0

Real 0

Logical False

Time 00:00:00

DIFF False (applied to last known value of comparison)

IF Statement False (FIRST PASS flag only)

Period 00:00:00

Attributes Depends on type (0, False or 00:00:00)

Process Reliability Reliable

Local variables are initialized when the NCM reboots (either cold or warm start), and when the process is downloaded or enabled. Shared variables, however, are initialized only on full download or cold start, or during a single download operation, if the process is defining a new shared variable. You can conditionally initialize shared variables in the RESTART process. For instance, you might want to set up system conditions, such as the season mode (heating or cooling).

Note: When a single (partial) download is done, any process downloaded enabled will be queued for execution except the RESTART process.

Attribute references (whether or not they trigger) are initialized when the NCM reboots or a new reference is downloaded.

Runtime and User Operations 11

Page 92: Docs | Documents | Johnson Controls

Process Upload The upload operation retrieves the object files currently stored in the NCM and places them in the proper system name directory on the Operator Workstation.

You can upload any combination of object files in the same system, including the object for just one process. The file is uploaded to its system name directory on the Operator Workstation.

If the object file already exists, the upload procedure writes over the original file with the retrieved file. If the system name directory that is named in the object file doesn’t exist, a directory of that name is added.

You can specify a process name or list of names to be deleted from the process’ NCMs. Each process you specify is found in the field and deleted. The system object directory for that process’ system is updated (the process object name is deleted). If this can’t be done, then the deletion is not allowed.

Process Deletion

You must disable the process before deleting it from a field data base. If you choose to remove the process from the disk data base but not from the NCM, then the NCM copy is not removed until you download the entire node. Also, in this case, the process in the field will continue to execute if triggered.

If the field version of a process is deleted but it is not deleted from the archive, then the next full download of that node will download the process once again.

The DELETE command requires generation level password access and access to the system name of the process to be DELETED.

If a full DDL NC compile is performed, all processes on the NCM must be recompiled. Any processes not recompiled will not be downloaded to the NCM.

Processes go along when the NCM data base is backed up or restored. There is no separate JC-BASIC command to back up or restore processes.

Process Backup and Restore

12 Runtime and User Operations

Page 93: Docs | Documents | Johnson Controls

Process Enable and Disable

In a warm start of the NCM, the enable or disable status of a process is determined by its retained state; that is, what its status was before the warm start. In a cold start, the status is determined from the archive data base.

These commands allow you to enable or disable a process. The process is enabled or disabled at the NCM containing the object code to be interpreted or in the disk data base. The process maintains its enable/disable status after an upload or download. The compiler defaults the state to enabled.

On the Operator Workstation, select an .OBJ file or files and perform the disable. On the NCM, select a process name or names.

Disabling a process that is executing, waiting, or time-sliced will terminate that process. Enabling a process will cause an execution of that process.

You may command a process in an NCM to be triggered for execution in the same way as if one of its trigger variables or attributes changed. This command may be time programmed. It may also be executed from within another JC-BASIC process or from an MCO.

Triggering a Process

You may select a process name or names and each named process will be triggered. Time programmed MCO and JC-BASIC initiated trigger commands may only trigger one process per command.

A process that is NOT_FULLY_DOWNLOADED, ERROR, HELD, or DISABLED won’t be triggered.

All summaries require “summary” level password access. All summaries require password access to system names specified for the summaries. None of the summaries refresh, but specific fields do. None of the summaries can be time programmed.

Process Summary

The process summary shows a subset of the information for all processes in a given system. It will contain a window for the processes downloaded to the NCM and another window for the source, list, and object files for the processes in the archive data base on the Operator Workstation.

Runtime and User Operations 13

Page 94: Docs | Documents | Johnson Controls

Process Focus To bring up the Focus window for a process, double-click the process in either the Process Disk or Process Field windows. Or select the process, and then select Selected Item from the Go To menu.

The Process Focus provides general information about the process. It can be used to check process information in the disk data base or in the NCM. The Process Focus combines certain static information about the definition of the process and, for the process in the NCM, dynamic information from the NCM concerning its current status of execution.

The Process Focus does not display the local variables and their values.

You may also focus on a source (.BAS) or list (.LST) file from the Disk Process window. In these cases, the focus opens the text editor for that file.

The Process Focus for a field process (in the NCM) shows basically the same static information as the disk version (e.g., name, revision dates), but also includes dynamic information such as execution status, current period, and so on.

Process or execution status, which indicates the current state of the process, can be one of the following:

Process Status

Status Description Not Fully

Down-loaded An error occurred during process download . The process cannot be executed, no commands will work on the process, and only a full download will delete and re-add the process.

Error The process cannot be triggered or executed. The process is placed in the Error state when a fatal error occurs while executing the process, or when an ABORT statement is executed. The process can only be enabled by an operator command, a download of an enabled version of the process, or a PRC_ENA command sent by another JC-BASIC process or MCO that enables the process.

Disabled The process cannot be triggered or executed. The process can only be enabled by an operator command or a download of an enabled version of the process.

Held The process is being downloaded or is waiting for the RESTART process to finish execution. Once the download or RESTART finishes, the process is set to READY and queued for execution.

Continued on next page . . .

14 Runtime and User Operations

Page 95: Docs | Documents | Johnson Controls

Status (Cont.) Description Ready The process is enabled and is waiting for a

reason to execute, such as an event trigger, a period expiration, or a Trigger command.

Executing The process is currently executing.

Waiting The executing process is delayed by a WAIT statement. The process will remain delayed until the WAIT delay timer expires, or the process is triggered, or a Disable command cancels the WAIT statement.

Time-Sliced The executing process has exceeded the maximum instructions any process is allowed to execute before exiting or implementing a WAIT statement. The process is placed in a Time-slice queue, which is the lowest priority queue. The process will remain in this state until it is executed (in priority order), or is issued a Disable operator command. Processes are placed in the Time-sliced state to prevent large or infinite loops from degrading the performance of other processes.

The Process Focus displays the revision information for both the disk and field copies of a process.

Revision Information

The revision information shown in the Process Focus is used to determine whether the version of the object code in the field matches that in the disk data base. For each process object, the following information is kept:

• date and time of source used to compile

• date and time of compile

This data is saved in the .OBJ file on the disk and the process data base on the NCM.

Runtime and User Operations 15

Page 96: Docs | Documents | Johnson Controls

The date and time of the source is the DOS date and time of the source file from which the process was compiled. Any edit to the DOS source file will change its date. The compiler moves the date and time of the DOS source file into the process. The date and time of compile is the date and time the compiler last compiled the process. This information is also stored in the process.

The compile dates may be compared to determine if the process that is downloaded is the same version as in the disk data base. The source date may be compared against the date of a particular DOS file by examining the .BAS file in the process window. In this way, you can determine if the source date saved in the object code matches the last change date of a particular DOS source file. You can compare the source and compile dates to see if the source has been updated since the last compile.

16 Runtime and User Operations

Page 97: Docs | Documents | Johnson Controls

JC-BASIC Programmer’s Manual

Command Reference

Statements, Functions, Loops, and Subroutines 3

• Overview 3 • ABORT Statement 4 • ABS Function 5 • ADVISORY and ADVISORY USING Statements 5 • AVG Function 10 • CANC_PULSE Function 12 • COS Function 14 • DATE$ Function 15 • DAY Function 17 • DEF FN and END DEF Functions 18 • DEWPT Function 20 • DIM Statement 22 • ENTHALPYDP Function 24 • ENTHALPYRH Function 26 • EXEMPT and EXEMPT ALL Statements 29 • EXIT DEF Statement 30 • FILTER Function 31 • FOR-NEXT Loop 33 • FORCE_REL Function 36 • FORCE_UNREL Function 36 • GOSUB and RETURN Statements 37 • GOTO Statement 40 • IF-THEN-ELSE and ENDIF Statements 42 • INT_TO_TIME Function 44 • LASTTOT Function 45 • LET Statement 46 • LOG Function 48

© August 5, 2003 Johnson Controls, Inc. 1 Code No. LIT-632040

Page 98: Docs | Documents | Johnson Controls

• MAX Function 49 • MIN Function 50 • MONTH Function 51 • N_CANC_PULSE Function 52 • ON GOSUB Statement 54 • ON GOTO Statement 56 • PERIOD Statement 57 • PI_RESET Statement 59 • PRINT and PRINT USING Statements 61 • PRIORITY Statement 64 • PROCESS and END PROCESS Statements 65 • RAMP Function 67 • REL_HUM Function 69 • REM Statement 71 • SHARED Statement 72 • SIN Function 74 • SPAN Function 76 • SQR Function 79 • STOP Statement 80 • TAN Function 80 • TELL Statement 83 • TIME Function 94 • TIME$ Function 95 • TIME_TO_INT Function 97 • TODAY Function 98 • TOTAL Function 99 • UNRELIABLE Function 101 • WAIT Statement 101 • WETDP Function 102 • WETRH Function 104 • WHILE/END-WHILE Loop 106 • YEAR Function 108

2 Command Reference

Page 99: Docs | Documents | Johnson Controls

Statements, Functions, Loops, and Subroutines

This section contains descriptions of all JC-BASIC statements, functions, loops, and subroutines.

The descriptions include the following information: Overview Purpose Explains what the statement, function,

loop, or subroutine does.

Format Shows the correct format and syntax. Some statements have more than one format. These symbols are used:

[ ] optional items

< > generic name for what is actually entered

You must use all punctuation marks, except the symbols just mentioned, exactly as presented. Any deviation would result in a syntax error.

Details Describes in detail how this statement, function, loop, or subroutine is used.

Example Shows a usage example and/or an accurate and tested process example of this statement, function, loop, or subroutine.

Statements ABORT EXIT DEF PRIORITY ADVISORY FIRST PASS PROCESS DIM GOSUB REM ELSE GOTO RETURN END FIRST PASS IF-THEN SHARED END PROCESS LET STOP END WHILE PERIOD TELL EXEMPT PRINT WAIT

Command Reference 3

Page 100: Docs | Documents | Johnson Controls

Functions ABS FORCE REL SIN AVG FORCE UNREL SPAN CANC_PULSE INT_TO_TIME SQR COS LASTTOT TIME DATE$ LOG TIME$ DAY MAX TIME_TO_INT DEF FN MIN TODAY DEWPT MONTH TOTAL END DF N_CANC_PULSE UNRELIABLE ENTHALPYDP PI RESET WETDPN ENTHALPYRH RAMP WETRH FILTER REL HUM YEAR

Loops and Subroutines

FOR-NEXT WHILE-END WHILE GOSUB-RETURN ON GOSUB

ABORT Statement

Purpose Abnormally ends a process.

Format ABORT

Details This statement allows you to terminate a process abnormally, usually due to the detection of some error condition. You would typically use a conditional statement with an ABORT to end the process if a specific condition goes beyond limits.

When the ABORT is executed, the process ends and is disabled from execution. Use the ADVISORY statement with ABORT to notify the operator of this condition. An aborted process can be enabled by manual command, or by a PRE_ENA command from another process or MCO, or by re-downloading the process in the enabled state.

Process Example

IF A > B THEN

ADVISORY CRITICAL4 “LOOP OUT OF CONTROL. SETPOINT IS “,\

'AHU1\PID_LOOP\SET_POINT'

ABORT

END IF

ABS Function

4 Command Reference

Page 101: Docs | Documents | Johnson Controls

Purpose Returns an absolute value of an expression.

Format ABS(<EXPRESSION>)

<expression>

Any numeric expression.

Details The number returned is either integer or real, depending on the input, but it is always greater than or equal to zero.

The reliability of the result is equal to the reliability of the expression.

Usage Example LET X = ABS(A - B)

IF ABS(X - Y) < DELTA THEN...

ADVISORY and ADVISORY USING Statements Purpose Creates a Change-of-State (COS) message to be routed to

one or more devices.

Formats ADVISORY <type> “<text of advisory>“

ADVISORY <TYPE> USING “<FORMAT CHARACTERS>“ “<TEXT OF ADVISORY>“

<type>

Type of advisory; choices: CRITICAL1, CRITICAL2, CRITICAL3, CRITICAL4, FOLLOW_UP, or STATUS.

<text of advisory>

Any sequence of strings and expressions that will be sent to the designated device; 60 characters maximum.

<format characters>

Symbols that format the printing of numbers. (See Details below.)

Details Use the ADVISORY statement to report system conditions that would not be reported by software features, such as Report Router.

Command Reference 5

Page 102: Docs | Documents | Johnson Controls

The NCM handles the ADVISORY statement just as it does any other user advisory. It formats the message and routes it to the correct devices based on the access/report group to which the process’ system name has been assigned.

The text of the advisory message can be composed of any sequence of strings and expressions (integer, real, time, or logical), including object attributes. The strings and expressions must be separated by commas. Expressions are evaluated and converted to ASCII.

Logical expressions are printed as TRUE or FALSE.

Each string or expression is followed by an automatic blank in the output line.

The ADVISORY USING statement formats the printing of numbers in an advisory. The valid format characters are:

Format Character Formats # One digit . One decimal point - A negative sign for negative numbers, blank

for positive numbers

For example:

#.# prints a number like 1.2

-##.## prints a number like -12.34

The ADVISORY USING statement uses -######.# as the default.

6 Command Reference

Page 103: Docs | Documents | Johnson Controls

Follow these rules when using format characters:

• Specify at least one # character in the format string.

• Specify a # character before the decimal point to print a digit. For example:

Format string: #.##

Number to print: .23

Number as printed: 0.23

• Use only one decimal point in a format string. Also, use only one negative sign, which must be either at the beginning or the end of the format string. A negative sign at the beginning will place the - character in front of a negative number, and a negative sign at the end will place a - character after a negative number. If you don’t specify the - character and the number to be printed is negative, the - character is printed at the front of the number.

• Make sure you specify enough # characters before the decimal point. Otherwise, a % character will be printed in front of the number. For example:

Format string: ##.##

Number to print: 123.456

Number as printed: %123.46

• Make sure you specify the correct number of # characters. If you specify more # characters before the decimal point than there are numbers to print, the extra # characters will have blanks filled in. For example (b means blank space):

Format string: ####.##

Number to print: 12.34

Number as printed: bb12.34

If you specify more # characters after the decimal place than there are numbers to print, the remaining spaces are filled with zeros. For example:

Format string: #.##

Number to print: 8.3

Number as printed: 8.30

Command Reference 7

Page 104: Docs | Documents | Johnson Controls

If you don’t specify enough # characters than there are numbers to print, the number is rounded. For example:

Format string: #.##

Number to print: 3.876

Number as printed: 3.88

Usage Example

PROCESS'AH1\AH1_CTRL' “AIR HANLR 1” '\AH1'

<STATEMENTS>

ADVISORY CRITICAL4 “LOOP OUT OF CONTROL. SETPOINT IS “,\

'AHU1\PID_LOOP\SET_POINT'

If the current setpoint is 55°F, the message requiring acknowledgment for this example would be:

AH1\AH1_CTRL LOOP OUT OF CONTROL. SETPOINT IS 55.0

Process Example The following is a periodic process triggered every 5 minutes as defined by PERIOD 00:05:00. It calculates the room air and outside air enthalpies and determines the mode of economizer.

The TELL commands store the return air, outside air enthalpies, and economizer mode (economizer?) in objects ECON\RM_ENTH, ECON\OA_ENTH and ECON\ECONOMIZ respectively for display by the operator.

The ADVISORY functions cause one of the following messages to be written to the follow-up file: USING ROOM AIR; OA ENTH= 23.2; ROOM ENTH= 21.9

USING OUTSIDE AIR; OA ENTH= 23.2; ROOM ENTH= 24.2

where the values are those calculated by the ENTHALPYRH functions.

PROCESS 'ECON\ECON_CAL' “ECONOMIZER CALCULATION” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: DETERMINE IF OUTSIDE AIR SHOULD BE USED FOR COOLING.

REM CALCULATE ROOM & OA ENTHALPIES

REM SET STATE ON ECONOMIZ & ECONOMIZER?

REM ECONOMIZER ALLOWED ONLY DURING SUMMER.

REM

8 Command Reference

Page 105: Docs | Documents | Johnson Controls

REM

REM --------------------------------------------------------------------

REM

SHARED economizer?, summer?

EXEMPT economizer?

PERIOD 00:05:00 :REM CALCULATE EVERY 5 MINUTES

RM_TMP=AVG('RTU_1\ROOM_TMP','RTU_2\ROOM_TMP','RTU_3\ROOM_TMP',\

RTU_4\ROOM_TMP','RTU_5\ROOM_TMP','RTU_6\ROOM_TMP','RTU_7\ROOM_TMP',\

RTU_8\ROOM_TMP')

RM_ENTHALPY=ENTHALPYRH(RM_TMP,'BUILDING\ROOM_HUM',30,ENGLISH)

OA_ENTHALPY=ENTHALPYRH('BUILDING\OA_TMP','BUILDING\OA_HUM',30,ENGLISH)

TELL 'ECON\RM_ENTH' TO “SET_AD” RM_ENTHALPY,3

TELL 'ECON\OA_ENTH' TO “SET_AD” OA_ENTHALPY,3

economizer?=OA_ENTHALPY<RM_ENTHALPY AND OA_ENTHALPY<'ECON\ECON_SP'\

AND summer?=TRUE

TELL 'ECON\ECONOMIZ' TO “SET_BD” economizer?,3

IF economizer?=TRUE THEN

ADVISORY FOLLOW_UP \

“USING OUTSIDE AIR; OA ENTH=“,'ECON\OA_ENTH',”; ROOM ENTH=“,\

'ECON\RM_ENTH'

ELSE

ADVISORY FOLLOW_UP \

“USING ROOM AIR; OA ENTH=“,'ECON\OA_ENTH',”; ROOM ENTH=“,\

'ECON\RM_ENTH'

ENDIF

END PROCESS

RTU_1\ROOM_TMP through RTU_8\ROOM_TMP--Analog Input objects of room temperatures for area served by each roof top unit.

BUILDING\ROOM_HUM--Analog Input object of room air humidity.

BUILDING\OA_TMP--Analog Input object of outside air temperature.

BUILDING\OA_HUM--Analog Input object of outside air humidity.

ECON\OA_ENTH--Analog Data object to display outside air enthalpy.

Command Reference 9

Page 106: Docs | Documents | Johnson Controls

ECON\RM_ENTH--Analog Data object to display room air enthalpy.

ECON\ECONOMIZ--Binary Data object to display economizer mode.

ECON\ECON_SP--Analog Data object, which allows operator to set economizer enthalpy limit.

economizer?--A shared binary variable, which allows this process to communicate the economizer mode to other processes.

summer?--A shared binary variable representing the seasonal mode status.

AVG Function Averages from 2 to 12 numbers. Purpose

Format AVG(<E1,E2, ... , EN>)

(<e1,e2, ... , en>)

Expression 1, expression 2 and up to expression n; a minimum of two and a maximum of 12 numeric expressions can be averaged.

Details The averaged number is real if any of the expressions are real. If all the expressions are integer, the average is calculated using integer division, and the result will be integer.

A reliable number is returned if all the expressions are reliable; otherwise the result is unreliable.

Usage Example LET X=AVG (A,B+C,'AHU1\PID_LP2\SETPT', 75.8)

IF AVG(A,B,C) > 25 THEN GOTO 10 ELSE GOTO 20

Process Example The following is a periodic process triggered every 5 minutes as defined by PERIOD 00:05:00. It uses the average room air temperature, as calculated by the AVG function, to determine room enthalpy. No attribute is specified for the Analog Input and Analog Data objects. The compiler will use the default attribute, VALUE, for these objects.

10 Command Reference

Page 107: Docs | Documents | Johnson Controls

The TELL commands store the return air, outside air enthalpies, and economizer mode (economizer?) in objects ECON\RM_ENTH, ECON\OA_ENTH and ECON\ECONOMIZ respectively for display by the operator.

PROCESS 'ECON\ECON_CAL' “ECONOMIZER CALCULATION” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: DETERMINE IF OUTSIDE AIR SHOULD BE USED FOR COOLING.

REM CALCULATE ROOM & OA ENTHALPIES

REM SET STATE ON ECONOMIZ & ECONOMIZER?

REM ECONOMIZER ALLOWED ONLY DURING SUMMER.

REM

REM

REM --------------------------------------------------------------------

REM

SHARED economizer?, summer?

EXEMPT economizer?

PERIOD 00:05:00 :REM CALCULATE EVERY 5 MINUTES

RM_TMP,[=AVG('RTU_1\ROOM_TMP','RTU_2\ROOM_TMP','RTU_3\ROOM_TMP',\

' RTUU_4\ROOM_TMP','RTU_5\ROOM_TMP','RTU_6\ROOM_TMP','RTU_7\ROOM_TMP',\

'RTU_8\ROOM_TMP')

RM_ENTHALPY=ENTHALPYRH(RM_TMP,'BUILDING\ROOM_HUM',30,ENGLISH)

OA_ENTHALPY=ENTHALPYRH('BUILDING\OA_TMP','BUILDING\OA_HUM',30,ENGLISH)

TELL 'ECON\RM_ENTH' TO “SET_AD” RM_ENTHALPY,3

TELL 'ECON\OA_ENTH' TO “SET_AD” OA_ENTHALPY,3

economizer?=OA_ENTHALPY<RM_ENTHALPY AND OA_ENTHALPY<'ECON\ECON_SP'\

AND summer?=TRUE

TELL 'ECON\ECONOMIZ' TO “SET_BD” economizer?,3

END PROCESS

RTU_1\ROOM_TMP through RTU_8\ROOM_TMP--Analog Input objects of room temperatures for area served by each roof top unit.

BUILDING\ROOM_HUM--Analog Input object of room air humidity.

BUILDING\OA_TMP--Analog Input object of outside air temperature.

Command Reference 11

Page 108: Docs | Documents | Johnson Controls

BUILDING\OA_HUM--Analog Input object of outside air humidity.

ECON\OA_ENTH--Analog Data object to display outside air enthalpy.

ECON\RM_ENTH--Analog Data object to display room air enthalpy.

ECON\ECONOMIZ--Binary Data object to display economizer mode.

ECON\ECON_SP--Analog Data object, which allows operator to set economizer enthalpy limit.

economizer?--A shared binary variable, which allows this process to communicate the economizer mode to other processes.

summer?--A shared binary variable representing the seasonal mode status.

CANC_PULSE Function

Purpose Outputs a True state for a period of time, then returns to False.

Format CANC_PULSE(<INPUT?>,<TIME_DELAY@>)

Details The CANC_PULSE function outputs a True state as long as the input remains True and the pulse time_delay@ has not yet expired. The output varies according to the following:

Change of Input Output False -> True True for pulse time specified, or until input

returns to False. True -> True False until input changes to True.

12 Command Reference

Page 109: Docs | Documents | Johnson Controls

Process Example The following is an event triggered process which is triggered when AHU_3\FAN_EN changes. When AHU_3\FAN_EN goes True, the CANC_PULSE function will start a timer that will cause this process to be triggered again in two minutes. The TELL statement will issue the start command when delay_done? is True. The value of delay_done? will be True when the process is retriggered, since CANC_PULSE will return a value of False when time_delay@ has expired. If AHU_3\FAN_EN goes False before the two minutes have expired, this process will be triggered. CANC_PULSE will cancel the timer and the TELL command won’t be executed, since the result of the IF statement is False.

PROCESS 'AHU_3\START' “Fan Start Process” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: START THE FAN 2 MINUTES AFTER THE ENABLE HAS BEEN COMMANDED.

REM

REM

REM

REM

REM --------------------------------------------------------------------

REM

delay_done?=NOT(CANC_PULSE('AHU_3\FAN_EN',00:02:00))

IF delay_done? AND 'AHU_3\FAN_EN' THEN\

TELL 'AHU_3\FAN_SST' TO “START” 4

END PROCESS

delay_done?--Local variable of type Boolean used to store the result of the CANC_PULSE function.

AHU_3\FAN_EN--Binary Data object that allows the AHU 3 fan to be started.

AHU_3\FAN_SST--Binary Output object, which is the start/stop for the fan of air handling unit 3.

Command Reference 13

Page 110: Docs | Documents | Johnson Controls

COS Function

Purpose Calculates the cosine of a numeric expression.

Format COS (<EXPRESSION>)

<expression>

Any numeric expression.

Details The expression represents an angle in radians. The result of this function is a real number, and its reliability is the same as the reliability of the expression.

As the value of the numeric expression gets larger, this function may start to lose precision. When this happens, the function returns an imprecise value, flagged unreliable. When the value of the expression gets too large for the function to calculate a value, it returns 0, flagged unreliable.

Process Example The following is a periodic process which executes every 20 minutes as defined by PERIOD 00:20:00. The line with the COS function will calculate height. This value is stored in an Analog Data object so it can be displayed.

PROCESS 'PROGRAMS\HGT_CAL' “HEIGHT CALCULATION” '\NC1'

REM --------------------------------------------------------------------

REM

REM

REM

REM

REM --------------------------------------------------------------------

REM

PERIOD 00:20:00

height='MECH_SYS\DISTANCE'*cos('MECH_SYS\ANGLE')

TELL 'MECH_SYS\HEIGHT' TO “SET_AD” height,3

END PROCESS

height--Local variable of type real.

MECH_SYS\DISTANCE--Analog Input object of distance being measured.

MECH_SYS\ANGLE--Analog Input object of angle.

MECH_SYS\HEIGHT--Analog Data object of height.

14 Command Reference

Page 111: Docs | Documents | Johnson Controls

DATE$ Function

Purpose Places the current date at the end of an ADVISORY (or ADVISORY USING) or PRINT (or PRINT USING) statement.

Format DATE$

Details For a system installed in the United States, the date format is MM/DD/YYYY. MM is the month represented by a number 1 to 12, where:

1 January 7 July

2 February 8 August

3 March 9 September

4 April 10 October

5 May 11 November

6 June 12 December

DD is the day with a range of 1 to 31, and YYYY is the year. Alternate versions are produced for different country codes.

Note: This function can only be used with the ADVISORY, ADVISORY USING, PRINT, and PRINT USING statements.

Usage Example PRINT “TODAY IS”, DATE$

If the current date is December 15, 1989, this statement would print: TODAY IS 12/15/1989

Process Example The following is an event triggered process. When the building changes to the occupied mode, BUILDING\OCCUPIED is True, this process will start the four roof top fans, release the room temperature setpoints to their normal value, and print the following message: THE BUILDING IS IN OCCUPIED MODE AT 6:30:15 03/23/1990.

The date is inserted by the DATE$ function.

Command Reference 15

Page 112: Docs | Documents | Johnson Controls

When the building changes to the unoccupied mode, BUILDING\OCCUPIED is false, this process will stop the four roof top fans, change the room setpoints to the night setback value, and print: THE BUILDING IS IN UNOCCUPIED MODE AT 18:00:05 03/23/1990.

PROCESS 'BUILDING\OCC_UNOC' “OCCUPIED/UNOCCUPIED” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: SET INITIAL CONDITIONS FOR OCC/UNOC MODES OF OPERATION.

REM THIS PROCESS WILL BE TRIGGER WHEN WEEKLY SCHEDULE

REM COMMANDS BUILDING\OCCUPIED.

REM

REM --------------------------------------------------------------------

REM

IF 'BUILDING\OCCUPIED' THEN :REM START THE FANS

TELL 'RTU_1\FAN_SST' TO “START” 7

TELL 'RTU_2\FAN_SST' TO “START” 7

TELL 'RTU_3\FAN_SST' TO “START” 7

TELL 'RTU_4\FAN_SST' TO “START” 7

TELL 'RTU_1\ROOM_SP' TO “RELEASE” :REM ROOM SETPOINT TO NORMAL

TELL 'RTU_2\ROOM_SP' TO “RELEASE”

TELL 'RTU_3\ROOM_SP' TO “RELEASE”

TELL 'RTU_4\ROOM_SP' TO “RELEASE”

PRINT '\PC_PTR' “THE BUILDING IS IN OCCUPIED MODE AT”,TIME$,DATE$

ELSE :REM STOP THE FANS

TELL 'RTU_1\FAN_SST' TO “STOP” 7

TELL 'RTU_2\FAN_SST' TO “STOP” 7

TELL 'RTU_3\FAN_SST' TO “STOP” 7

TELL 'RTU_4\FAN_SST' TO “STOP” 7

:REM ROOM SETPOINT TO NIGHT SET BACK

TELL 'RTU_1\ROOM_SP' TO “SET_AD” 'BUILDING\SETBACK',2

TELL 'RTU_2\ROOM_SP' TO “SET_AD” 'BUILDING\SETBACK',2

TELL 'RTU_3\ROOM_SP' TO “SET_AD” 'BUILDING\SETBACK',2

TELL 'RTU_4\ROOM_SP' TO “SET_AD” 'BUILDING\SETBACK',2

16 Command Reference

Page 113: Docs | Documents | Johnson Controls

PRINT '\PC_PTR' “THE BUILDING IS IN UNOCCUPIED MODE AT ”,TIME$,DATE$

END IF

END PROCESS

BUILDING\OCCUPIED--A Binary Data object, which contains the occupied/unoccupied status of the building.

RTU_1\FAN_SST through RTU_4\FAN_SST--Binary Output objects, which start and stop roof top unit fans.

RTU_1\ROOM_SP through RTU_4\ROOM_SP--Analog Data objects, which contain room temperature setpoints for areas served by the roof top units.

DAY Function

Purpose Retrieves the current day of the month.

Format DAY

Details This function retrieves the current day of the month in integer form from 1 to 31. The reliability of the result will be based on the reliability returned by the time-of-day manager.

Usage Example IF DAY=PAYDAY% THEN . . .

Process Example The following is a periodic process as defined by PERIOD 23:59:59. It will run once per day and print the run time of AHU\FAN_STAT on the first (DAY=1) and fifteenth (DAY=15) of each month.

PROCESS 'AHU\RUN_PRTR' “PRINT FAN RUN TIME” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: PRINT FAN RUN TIME ON THE 1ST & 15TH OF EACH MONTH.

REM

REM

REM

REM --------------------------------------------------------------------

REM

PERIOD 23:59:59

IF DAY=1 OR DAY=15 THEN

Command Reference 17

Page 114: Docs | Documents | Johnson Controls

runtot=TOTAL('AHU\FAN_STAT\VALUE')

PRINT '\PC_PTR' “FAN RUN TIME = “,runtot,”HOURS”

END IF

END PROCESS

runtot--Local variable of type real.

AHU\FAN_STAT\VALUE--Attribute of HU\FAN_STAT being totalized.

DEF FN and END DEF Functions

Purpose Defines and names a user-defined function.

Formats DEF FN<NAME> [(<P1,P2, ... , PN>)] = <EXPRESSION>

DEF FN<NAME> [(<P1,P2, ... , PN>)]

<STATEMENTS>

END DEF

<name>

Name assigned to the user-defined function, up to 16 characters including the FN prefix and type symbol. The name may consist of letters, digits, or underscores. The type symbol indicates whether the function type is a real (!; optional), integer (%), logical (?), or time (@) type. The minimum length of the name, including the FN prefix, is three characters without a symbol and four characters with a symbol (e.g., FN_ and FN2% are valid, but FN and FN@ are not).

[(<p1,p2, ... , pn>)]

Optional list of parameters, enclosed in parentheses and separated by commas. They pass data between the process and the user-defined function. These parameters can be any of the types: real, integer, logical, or time.

<statements>

Any valid statement or set of statements.

<expression>

A numeric, logical, or time expression to evaluate. The variable type of the expression and the function name must match.

18 Command Reference

Page 115: Docs | Documents | Johnson Controls

Details The parameters specified must follow the naming conventions of the variable. All parameters are passed by value, which means their values can’t be modified and passed back to the calling process. A parameter value is passed by inserting an expression of that type in the same location in the function call. A single array element, not a whole array, may be passed.

Parameters defined inside a function can’t be accessed by any other process or function. If the parameter name you assign is identical to a previously assigned local or shared variable, that variable can’t be accessed inside that function.

The statements that this function is to execute immediately follow the DEF FN line. These can be any statements, except the following, which can’t be used in a user-defined function: PROCESS-END PROCESS

DEF FN-END DEF

GOSUB-RETURN

GOTO and ON GOTO statements are allowed in a user-defined function, but they can’t reference a label outside the function. Likewise, a GOTO or ON GOTO statement outside a function can’t reference a label inside a user-defined function.

Below is an example of an invalid user-defined function. It is invalid because the GOTO 10 statement accesses a line outside the function, and GOTO 20 accesses a line inside of the function.

Usage Example An Invalid User-Defined Function DEF FNEXAMPLE (A,B,C)

GOTO 10

20 END DEF

10 A = B + C

X = A * 75

GOTO 20

To use a function, call it from within some expression in the process. When the function is executed, the value returned is the expression assigned to the name of the function.

Command Reference 19

Page 116: Docs | Documents | Johnson Controls

The name of the function may not be used as an operand in an expression. For example, FNX = N * (FNX-1)

is not allowed.

Note: Somewhere in the list of statements, you should have at least one assignment statement assigning a value to the user-defined function name. Otherwise, the function will return its initialized value. Each time a function is called, its return value is initialized to False, 0 or 00:00:00 (depending on type) and flagged reliable.

The statement END DEF must appear as the last line of a multiple line user-defined function. It is not allowed for a single line user-defined function.

DEWPT Function

Purpose Calculates dew point based on dry bulb temperature (a real value) and relative humidity (integer value).

Format

DEWPT(<DRY BULB TEMPERATURE>, <RELATIVE HUMIDITY>, <UNITS>)

<dry bulb temperature>

Real expression representing the current value of the dry bulb temperature. Range: -80.0 to 150.0°F (-62.2 to 65.6°C).

<relative humidity>

Current floating point value of the relative humidity sensor; integer or real. Range: 0 to 100% (if 0 is entered, 0.1 will be used).

<units>

Units of measurement, either English or metric. Entire word must be spelled out; any combination of lower and upper case letters is allowed.

20 Command Reference

Page 117: Docs | Documents | Johnson Controls

Details The sensed dry bulb temperature and relative humidity are entered into the enthalpy dew point equation. This equation is equivalent to the ASHRAE standard for calculating dew point. (For details, see ASHRAE Handbook of Fundamentals, American Society of Heating, Refrigerating and Air Conditioning Engineers, Atlanta, Chapter 6, 1985.)

The reliability of the inputs determines the reliability of the output. An input that is outside its range would cause an unreliable output. If any input is deemed unreliable, the output is flagged unreliable and a user advisory is issued.

Process Example The following is a periodic process, which executes every 20 minutes as defined by PERIOD 00:20:00. The dew point of the outside air is calculated by the DEWPT function, which uses the outside air dry bulb temperature and the outside air relative humidity. ENGLISH specifies the units of the parameters and the result.

The result of the DEWPT function is stored in Analog Data object BUILDING\OA_DEWPT by the TELL command so that it can be displayed by an operator.

PROCESS 'BUILDING\DP_CAL' “DEW POINT CALCULATION” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: CALCULATE THE OUTSIDE AIR DEW POINT & DISPLAY AS OBJECT

REM BUILDING\OA_DEWPT.

REM

REM

REM --------------------------------------------------------------------

REM

PERIOD 00:20:00 :REM CALCULATE DEW POINT EVERY 20 MINUTES

oa_dewpt=DEWPT('BUILDING\OA_TMP','BUILDING\OA_HUM',ENGLISH)

TELL 'BUILDING\oa_dewpt' to “SET_AD” oa_dewpt,3

END PROCESS

BUILDING\OA_TMP--Analog Input object of outside air temperature.

BUILDING\OA_HUM--Analog Input object of outside air humidity.

Command Reference 21

Page 118: Docs | Documents | Johnson Controls

BUILDING\OA_DEWPT--Analog Data object of calculated outside air dew point.

oa_dewpt--Local variable of type real, which holds the result of the DEWPT function.

DIM Statement

Purpose Specifies the maximum values for array variable subscripts and reserves the required amount of memory.

Format

DIM <VARIABLE> (<SUBSCRIPT>) [,<VARIABLE>(<SUBSCRIPT>)]...

<variable>

Name assigned to identify this array.

(<subscript>)

Number of elements (reserved memory locations).

Details The three dots at the end of the format indicate that this format is repeatable; a list of variables can be dimensioned on one logical line.

Arrays are most useful for calculating and gathering data on a regular basis; for weekly, monthly, or yearly reports, for instance. Array subscripts begin with 1. Unlike standard BASIC, JC-BASIC doesn’t allow an array element of 0 (e.g., DIM A(0)). Also, only one dimension array is allowed.

An array that doesn’t specify a number of elements defaults to ten elements.

An array can be local to the process or shared between multiple processes within the same NCM. When you wish to maintain an intermediate value between two statements, or between two executions of the same process, use a local array.

On the other hand, use shared arrays when data is to be passed between two or more processes within the same NCM. Unlike local arrays, shared arrays must be declared in the process, preferably at the beginning with other shared variables, if others are used. A corresponding DIM statement is not needed and must not be used.

22 Command Reference

Page 119: Docs | Documents | Johnson Controls

Arrays can use any of the variables--integer, real, logical, or time. For example: DIM A1!(6), B3@(18), A%(6), A?(14)

Arrays can be assigned values with the LET statement. The value can be integer, real, logical, or time. An array can also be assigned the value of an object attribute. Some examples: LET A(1) = 1

DIM X%(3)

LET X% (3) = 'SYSTEM\OBJECT\ATTRIBUTE'

FOR I = 1 TO 10

LET A(I) = I

NEXT I

Arrays and variables can be assigned the same name in the same process if they have different trailing special characters. These trailing characters identify the data type. For example, an array of A!(10) and shared variable of A! in the same process are acceptable.

All elements in a local array are initialized to zero (for integer or real), FALSE (for logical) or 00:00 (for time) when the NCM processor is reset, or when the process is downloaded or enabled. Shared array elements, however, are initialized to these values upon cold start or initial download only.

Usage Example PROCESS 'AH1\AH1_CTRL' “AIR HANLR 1” '\AH1'

DIM C(12) : REM ARRAY OF 12 REAL VALUES

SHARED D(10)

FOR I%=1 TO 5

LET C(I%) = I%

NEXT I%

END PROCESS

Command Reference 23

Page 120: Docs | Documents | Johnson Controls

ENTHALPYDP Function

Purpose Calculates the enthalpy of a dry bulb temperature based on dew point and barometric pressure.

Format

ENTHALPYDP(<DRY BULB TEMPERATURE>, <DEW POINT TEMPERATURE>, <BAROMETRIC

PRESSURE>, <UNITS>)

<dry bulb temperature>

Current floating point value of the dry bulb sensor; real number. Range: -47.9 to 391.9°F (-99.9 to 199.9°C).

<dew point temperature>

Current floating point value of the dew point sensor; real number. Range: -147.9 to 391.9°F (-99.9 to 199.9°C).

<barometric pressure>

Range: 15.00 to 32.00 in. Hg.

<units>

Units of measurement, either English or metric. Entire word must be spelled out; any combination of lower and upper case letters is allowed.

Details The sensed dry bulb temperature and dew point temperature are entered into the enthalpy dew point equation. This equation is equivalent to the ASHRAE standard for calculating enthalpy. (For details, see ASHRAE Handbook of Fundamentals, American Society of Heating, Refrigerating and Air Conditioning Engineers, Atlanta, Chapter 6, 1985.)

The reliability of the inputs determine the reliability of the output. If any input is deemed unreliable, the output is flagged as unreliable. An input would be unreliable if its value is outside the prescribed range.

24 Command Reference

Page 121: Docs | Documents | Johnson Controls

Process Example The following is a periodic process triggered every ten minutes as defined by PERIOD 00:10:00. It uses the room air temperature, outside air dry bulb temperature and room and outside dew points to calculate the enthalpies by the ENTHALPYDP function. No attribute is specified for the Analog Input and Analog Data objects. The compiler will use the default attribute, VALUE, for these objects.

The TELL commands store the room air, outside air enthalpies, and economizer mode (economizer?) in objects ECON\RM_ENTH, ECON\OA_ENTH, and ECON\ECONOMIZ, respectively, for display by the operator.

PROCESS 'ECON\ECON_CAL' “ECONOMIZER CALCULATION” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: DETERMINE IF OUTSIDE AIR SHOULD BE USED FOR COOLING.

REM CALCULATE ROOM & OA ENTHALPIES

REM SET STATE ON ECONOMIZ & ECONOMIZER?

REM ECONOMIZER ALLOWED ONLY DURING SUMMER.

REM

REM

REM --------------------------------------------------------------------

REM

SHARED economizer?, summer?

EXEMPT economizer?

PERIOD 00:10:00 :REM CALCULATE EVERY 10 MINUTES

RM_ENTHALPY=ENTHALPYDP('1ST_FLR\ROOM_TMP','1ST_FLR\ROOM_DP',30,ENGLISH)

OA_ENTHALPY=ENTHALPYDP('BUILDING\OA_TMP','BUILDING\OA_DP',30,ENGLISH)

TELL 'ECON\RM_ENTH' TO “SET_AD” RM_ENTHALPY,3

TELL 'ECON\OA_ENTH' TO “SET_AD” OA_ENTHALPY,3

economizer?=OA_ENTHALPY<R,_ENTHALPY AND OA_ENTHALPY<'ECON\ECON_SP'\

AND summer?

TELL 'ECON\ECONOMIZ' TO “SET_BD” economizer?,3

END PROCESS

1ST_FLR\ROOM_TMP--Analog Input objects of room temperature for the first floor.

IST_FLR\ROOM_DP--Analog Input object of room dew point.

Command Reference 25

Page 122: Docs | Documents | Johnson Controls

BUILDING\OA_TMP--Analog Input object of outside air temperature.

BUILDING\OA_DP--Analog Input object of outside dew point.

ECON\OA_ENTH--Analog Data object to display outside air enthalpy.

ECON\RM_ENTH--Analog Data object to display room air enthalpy.

ECON\ECONOMIZ--Binary Data object to display economizer mode.

ECON\ECON_SP--Analog Data object, which allows operator to set economizer enthalpy limit.

economizer?--A shared binary variable, which allows this process to communicate the economizer mode to other processes.

summer?--A shared binary variable representing the seasonal mode status.

ENTHALPYRH Function

Purpose Calculates the enthalpy of a dry bulb temperature based on relative humidity and barometric pressure.

Format

ENTHALPYRH(<DRY BULB TEMPERATURE>, <RELATIVE HUMIDITY>, <BAROMETRIC PRESSURE>,

<UNITS>)

<dry bulb temperature>

Current floating point value of the dry bulb sensor; real number. Range: -47.9 to 391.9°F (-9.9 to 199.9°C).

<relative humidity>

Current floating point value of the relative humidity sensor; integer or real. Range: 0 to 100%.

Note: If 0% is entered, 0.1 will be used.

<barometric pressure>

Range: 15.00 to 32.00 in. Hg.

26 Command Reference

Page 123: Docs | Documents | Johnson Controls

<units>

Units of measurement, either English or Metric. Entire word must be spelled out; any combination of lower and upper case letters is allowed.

Details The sensed dry bulb temperature and relative humidity are entered into the enthalpy relative humidity equation. This equation is equivalent to the ASHRAE standard for calculating enthalpy. (For details, see ASHRAE Handbook of Fundamentals, American Society of Heating, Refrigerating and Air Conditioning Engineers, Atlanta, Chapter 6, 1985.)

The reliability of the inputs determines the reliability of the output. If any input is deemed unreliable, the output is flagged as unreliable. An input would be unreliable if its value is outside the prescribed range.

Process Example The following is a periodic process triggered every five minutes as defined by PERIOD 00:05:00. It uses the average room air temperature, outside air dry bulb temperature and room air and outside air humidities to calculate the enthalpies by the ENTHALPYRH function. No attribute is specified for the Analog Input and Analog Data objects. The compiler will use the default attribute, VALUE, for these objects.

The TELL commands store the room air, outside air enthalpies, and economizer mode (economizer?) in objects ECON\RM_ENTH, ECON\OA_ENTH, and ECON\ECONOMIZ, respectively, for display by the operator.

PROCESS 'ECON\ECON_CAL' “ECONOMIZER CALCULATION” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: DETERMINE IF OUTSIDE AIR SHOULD BE USED FOR COOLING.

REM CALCULATE ROOM & OA ENTHALPIES

REM SET STATE ON ECONOMIZ & ECONOMIZER?

REM ECONOMIZER ALLOWED ONLY DURING SUMMER.

REM

REM

REM -------------------------------------------------------------------- REM

SHARED economizer?, summer?

EXEMPT economizer?

Command Reference 27

Page 124: Docs | Documents | Johnson Controls

PERIOD 00:05:00 :REM CALCULATE EVERY 5 MINUTES

RM_TMP=AVG('RTU_1\ROOM_TMP','RTU_2\ROOM_TMP','RTU_3\ROOM_TMP',\

'RTU_4\ROOM_TMP','RTU_5\ROOM_TMP','RTU_6\ROOM_TMP','RTU_7\ROOM_TMP',\

'RTU_8\ROOM_TMP')

RM_ENTHALPY=ENTHALPYRH(RM_TMP,'BUILDING\ROOM_HUM',30,ENGLISH)

OA_ENTHALPY=ENTHALPYRH('BUILDING\OA_TMP','BUILDING\OA_HUM',30,ENGLISH)

TELL 'ECON\RM_ENTH' TO “SET_AD” RM_ENTHALPY,3

TELL 'ECON\OA_ENTH' TO “SET_AD” OA_ENTHALPY,3

economizer?=OA_ENTHALPY<RM_ENTHALPY AND OA_ENTHALPY<'ECON\ECON_SP'\

AND summer?

TELL 'ECON\ECONOMIZ' TO “SET_BD” economizer?,3

END PROCESS

RTU_1\ROOM_TMP through RTU_8\ROOM_TMP--Analog Input objects of room temperatures for area served by each roof top unit.

BUILDING\ROOM_HUM--Analog Input object of room air humidity.

BUILDING\OA_TMP--Analog Input object of outside air temperature.

BUILDING\OA_HUM--Analog Input object of outside air humidity.

ECON\OA_ENTH--Analog Data object to display outside air enthalpy.

ECON\RM_ENTH--Analog Data object to display room air enthalpy.

ECON\ECONOMIZ--Binary Data object to display economizer mode.

ECON\ECON_SP--Analog Data object, which allows operator to set economizer enthalpy limit.

economizer?--A shared binary variable, which allows this process to communicate the economizer mode to other processes.

28 Command Reference

Page 125: Docs | Documents | Johnson Controls

EXEMPT and EXEMPT ALL Statements

Purpose Specifies which object attributes and shared variables should not trigger (to cause execution of) a process when their values change.

Formats EXEMPT <OBJECTS/SHARED VARIABLES LIST>

EXEMPT ALL

<objects/shared variables list>

List of object attributes to be exempt from triggering the process (must be in the form ‘system name\object name\attribute name’); list of shared variables to be exempt from triggering the process (must follow shared variable naming rules). Use a comma to separate each entry in the list. You can list the entries in any order.

Details EXEMPT ALL is used to eliminate all triggering due to changes in referenced attributes or logical shared variables within a process. Both EXEMPT and EXEMPT ALL are active for only the process in which they are contained.

If the EXEMPT statement is not declared, then every triggerable attribute or shared single logical variable that is used in a process can trigger the process. The process can still read exempted attributes and shared variables.

The EXEMPT declaration for attributes may be written anywhere in a process. For shared variables that are exempt, however, the EXEMPT declaration must go after the SHARED declaration.

The EXEMPT declaration is effective only for the process in which it is declared. If the next process is to exempt attributes and shared variables also, EXEMPT must be declared again.

Usage Example EXEMPT 'AHU1\RET_FAN\STATUS',flag?, occupied?

In this example, these items won’t trigger the process: the attribute STATUS of the RETurn FAN, and the shared variables FLAG? and OCCUPIED?.

Command Reference 29

Page 126: Docs | Documents | Johnson Controls

EXIT DEF Statement

Purpose Exits a user-defined function before the END DEF statement.

Format EXIT DEF

Details This statement is identical in function to the END DEF statement, except it is used to leave the DEF FN process early, before the END DEF statement is reached.

Usage Example DEF FNEXAMPLE (X,Y,Z,A,B)

IF X > 75 THEN

FNEXAMPLE = 75

EXIT DEF

END IF

X2 = 5 * AVG(Y,Z,X,A,B)

X3 = MAX(X2,75)

FNEXAMPLE = X3 + A

END DEF

DEF FNEXAMPLE (X,Y,Z,A,B)

IF X > 75 THEN

FNEXAMPLE = 75

EXIT DEF

END IF

X2 = 5 * AVG(Y,Z,X,A,B)

X3 = MAX(X2,75)

FNEXAMPLE = X3 + A

END DEF

30 Command Reference

Page 127: Docs | Documents | Johnson Controls

FILTER Function

Purpose Modifies the rate of change of a value.

Format

FILTER (<CURRENT VALUE>, <PREVIOUS VALUE>, <FILTER WEIGHT>)

<current value>

Real expression representing the current filter value.

<previous value>

Real expression representing the previous filter value.

<filter weight>

Factor that determines the rate of change of the filtered value; must be equal to or greater than 1.0.

Details A large filter weight slows down the rate of change of the filtered value. A small filter weight increases the rate of change.

The FILTER function uses this equation:

FILTER = previous value + (current value - previous value) / filter weight

An example of the FILTER is shown below.

Unfiltered Filtered

filter2

Figure 2: FILTER Example

The reliability of the current value and filter weight determines the reliability of the output. If either input is deemed unreliable, the output is flagged as unreliable.

Command Reference 31

Page 128: Docs | Documents | Johnson Controls

Process Example The following is a periodic process with a period of 20 seconds as defined by PERIOD 00:00:20. The velocity of the discharge air is calculated by multiplying 4005 by the square root (SQR) of the velocity pressure (VEL_PRES). The FILTER function will smooth the change in the velocity value. One fifth the difference between the current and previous values will be added to the previous value to make the new current value. The TELL command writes this filtered value to AHU_3\VELOCITY so that it can be displayed by an operator.

PROCESS 'AHU_3\VEL_CALC' “AIR VELOCITY CALCULATION” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: CALCULATE & DISPLAY DISCHARGE AIR VELOCITY FOR AHU_3.

REM

REM

REM

REM --------------------------------------------------------------------

REM

PERIOD 00:00:20

velocity=4005*SQR('AHU_3\VEL_PRES')

filt_vel=FILTER(velocity,'AHU_3\velocity',5)

TELL 'AHU_3\velocity' TO "SET_AD" filt_vel,3

END PROCESS

velocity--Local variable of type real, which holds the result of the velocity calculation.

filt_vel--Local variable of type real, which holds the filtered velocity value.

AHU_3\VEL_PRES--Analog Input object of duct velocity pressure.

AHU_3\VELOCITY--Analog Data object used to display duct air velocity.

32 Command Reference

Page 129: Docs | Documents | Johnson Controls

FOR-NEXT Loop

Purpose Executes a block of statements a number of times.

Format

FOR <VARIABLE> = <INITIAL EXPRESSION> TO <FINAL EXPRESSION> [STEP <COUNTER

EXPRESSION>]

<STATEMENTS>

NEXT [<VARIABLE>]

<variable>

Integer or real variable to be used as a counter; if you specify a variable after NEXT, it must match the variable after FOR.

<initial expression>

Expression whose value is the initial value of the counter.

<final expression>

Expression whose value is the final value of the counter.

<counter expression>

Expression whose value is the increment amount. It can be a positive or negative number, which dictates its operation. (See below.) If not specified, the increment is defaulted to 1.

Details The variable in the FOR and NEXT statements must be a single, local, or shared numeric variable. The FOR statement will convert all expressions to the same data type as the variable. The variable for the NEXT statement is optional; if missing, the variable will default to that of the closest FOR statement. Also, a list of variables, separated by commas, can be used with the NEXT statement. In the list, the first variable must match the closest FOR statement.

Command Reference 33

Page 130: Docs | Documents | Johnson Controls

The operation of the FOR-NEXT loop that uses the STEP counter depends on whether the counter specified is a positive or negative number. If a positive number is used, the loop functions this way:

1. Sets variable to initial expression; evaluates and stores final expression and counter.

2. Asks is variable <= final expression?

3. If yes, executes statements that immediately follow FOR statement.

4. If no (variable > final expression), jumps to statements that immediately follow the NEXT variable statement.

5. When NEXT variable statement is encountered, adds counter to variable and repeats process.

When the counter is a negative value, the FOR-NEXT function functions slightly differently:

1. Sets variable to initial expression; evaluates and stores final expression and counter.

2. Asks is variable >= final expression?

3. If yes, executes statement(s) that immediately follow FOR statement.

4. If no (variable < final expression), executes statements immediately following NEXT variable statement.

5. When NEXT variable statement is encountered, adds counter to variable and repeats process.

When the FOR loop is exited normally, the variable will have a value of at least the final expression, but could be more, depending on the values of the final expression, the initial expression, and the expression counter (less for a negative increment). If the loop is exited via a GOTO, then the variable will equal the current value.

FOR-NEXT loops may be nested, which means one FOR-NEXT loop can be placed inside another. Interleaved FOR-NEXT loops, however, are not legal.

34 Command Reference

Page 131: Docs | Documents | Johnson Controls

Valid Invalid FOR I% = 1 TO 10 Statements FOR J% = 2 TO 20 STATEMENTS NEXT J% NEXT I%

FOR I% = 1 TO 10 Statements FOR J% = 2 TO 20 STATEMENTS NEXT I% NEXT J%

The following two examples execute identically: FOR I% = 1 TO 10

FOR J% = 1 TO 10

FOR K% = 1 TO 10

NEXT K%

NEXT

NEXT I%

FOR I% = 1 TO 10

FOR J% 1 TO 10

FOR K% = 1 TO 10

NEXT K%,J%,I%

Process Example The following process uses a FOR-NEXT loop to initialize an array used to store temperature values. The first execution of the FOR-NEXT loop will set element 1 (I%=1) of max_tmp array to 0.0. The second execution of the FOR-NEXT loop will set element 2 (I%=2) of max_tmp array to 0.0. Execution of the FOR-NEXT loop will continue until I%=31. All elements (1 to 31) of array max_tmp will be set to 0.0. This process must be triggered by another process since it is not periodic or event triggered.

Don’t jump to the middle of a FOR loop with a GOTO statement. The FOR statement must be executed to initialize the loop. Also, every FOR statement must have a matching NEXT statement, or an error will result.

Command Reference 35

Page 132: Docs | Documents | Johnson Controls

PROCESS 'BUILDING\INIMAXT' “INITIALIZE MAX TEMPS” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: INITIALIZE DATA STORAGE AREA FOR DAILY MAXIMUMS.

REM

REM

REM --------------------------------------------------------------------

REM

SHARED MAX_TMP(31)

FOR i%=1 TO 31

max_tmp(i%)=0.0 :REM SET ALL ARRAY ELEMENTS TO ZERO

NEXT

END PROCESS

max_tmp--Shared array of real type data with 31 elements.

i%--Local variable of type integer.

FORCE_REL Function

Purpose Returns the value of an expression, always flagged reliable.

Format FORCE_REL (<EXPRESSION>)

(<expression>)

Expression whose value is to be returned reliable; can be of type numeric, logical, or time.

Details Any expression sent to this function will be returned flagged reliable.

Usage Example LET X = FORCE_REL (Y + Z)

LET X@ = FORCE_REL ('SYS\OBJ\ATTR')

FORCE_UNREL Function

Purpose Returns the value of an expression, always flagged unreliable.

36 Command Reference

Page 133: Docs | Documents | Johnson Controls

Format FORCE_UNREL (<EXPRESSION>)

(<expression>)

Expression whose value is to be returned unreliable; can be of type numeric, logical, or time.

Details Any expression sent to this function will be returned flagged unreliable.

Usage Example LET X = FORCE_UNREL (Y + Z)

LET X@ = FORCE_UNREL ('SYS\OBJ\ATTR')

GOSUB and RETURN Statements Purpose Transfers execution to another location in a process, then

returns to the first statement following the subroutine call.

Format GOSUB <LINE LABEL>

<STATEMENTS>

.

.

.

<LINE LABEL> <STATEMENTS>

<STATEMENTS>

RETURN

<line label>

Number of the process line to which execution will transfer.

<statements>

Any set of valid statements.

Details The GOSUB statement causes execution to transfer to a new location; the RETURN statement then returns execution to the line that immediately follows the GOSUB.

The new location must have its line labeled with the number specified in the GOSUB statement.

Command Reference 37

Page 134: Docs | Documents | Johnson Controls

Nested GOSUB calls are allowed. In these cases, the execution after a RETURN continues with the statement following the most recent GOSUB call.

The GOSUB and RETURN statements must be used together. In other words, a GOSUB statement needs a corresponding RETURN, just as a RETURN needs a corresponding GOSUB statement. However, if you don’t specify the RETURN statement, neither the compiler nor the interpreter will detect the error.

GOSUB can be written as GOSUB or GO SUB.

Note: A computed GOSUB statement called ON GOSUB is also available, which is similar to the computed GOTO statement. Refer to the ON GOSUB discussion.

Process Example The following is an event triggered process. The unit, mixed air temperature, and room temperature are stored in local variables unit%, ma_tmp and room_tmp respectively.

GOSUB 10 will cause process execution to move to the subroutine at label 10. The subroutine consists of the four PRINT statements. After these have been executed, the RETURN statement will cause execution of the process to continue at the statement after the GOSUB 10. This will be the END IF statement. The STOP statement after the last END IF will terminate execution of this process.

PROCESS 'BUILDING\TEMP_REC' “TEMPERATURE RECORDER” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: PRINT RTU TEMPERATURES ON FAN START UP.

REM

REM

REM --------------------------------------------------------------------

REM

oa_tmp='BUILDING\OA_TMP'

IF 'RTU_1\FAN_STAT'=ON THEN :REM GET UNIT 1 TEMPS

FIRST PASS

unit%=1

ma_tmp='RTU_1\MA_TMP'

room_tmp='RTU_1\ROOM_TMP'

END FIRST PASS

GOSUB 10 :REM PRINT TEMPERATURES

38 Command Reference

Page 135: Docs | Documents | Johnson Controls

END IF

IF 'RTU_2\FAN_STAT'=ON THEN :REM GET UNIT 2 TEMPS

FIRST PASS

unit%=2

ma_tmp='RTU_2\MA_TMP'

room_tmp='RTU_2\ROOM_TMP'

END FIRST PASS

GOSUB 10 :REM PRINT TEMPERATURES

END IF

IF 'RTU_3\FAN_STAT'=ON THEN :REM GET UNIT 3 TEMPS

FIRST PASS

unit%=3

ma_tmp='RTU_3\MA_TMP'

room_tmp='RTU_3\ROOM_TMP'

END FIRST PASS

GOSUB 10 :REM PRINT TEMPERATURES

END IF

IF 'RTU_4\FAN_STAT'=ON THEN :REM GET UNIT 4 TEMPS

FIRST PASS

unit%=4

ma_tmp='RTU_4\MA_TMP'

room_tmp='RTU_4\ROOM_TMP'

END FIRST PASS

GOSUB 10 :REM PRINT TEMPERATURES

END IF

STOP

10 PRINT '\PC_PTR' USING “#” “ROOF TOP UNIT”,UNIT%,\

“START UP TEMPERATURES”,DATE$,TIME$

PRINT '\PC_PTR' USING “##.#” “MIXED AIR TEMPERATURE =“,ma_tmp

PRINT '\PC_PTR' USING “##.#” “ ROOM AIR TEMPERATURE =“,room_tmp

PRINT '\PC_PTR' “ “

RETURN

END PROCESS

unit%--Local variable of type integer.

ma_tmp--Local variable of type real.

room_tmp--Local variable of type real.

oa_tmp--Local variable of type real.

RTU_1\FAN_STAT through RTU_4\FAN_STAT--Binary Input object of roof top fan status.

Command Reference 39

Page 136: Docs | Documents | Johnson Controls

RTU_1\MA_TMP through RTU_4\MA_TMP--Analog Input object of roof top mixed air temperature.

RTU_1\ROOM_TMP through RTU_4\ROOM_TMP--Analog Input object of roof top room air temperature.

GOTO Statement

Purpose Transfers execution unconditionally to another location in a process.

Format GOTO <LINE LABEL>

<line label>

Label of the process line to which execution will transfer.

Details A GOTO statement causes execution to continue at the specified line location. This location must be in the same process; the GOTO statement can’t reference a line from an outside process.

You can use a GOTO statement within an IF statement, but you should not use a GOTO to jump into the middle of an IF statement, a loop, or a user-defined function.

GOTO can be written as GOTO or GO TO.

Note: A computed GOTO statement called ON GOTO is also available, which is used to transfer to different lines based on the result of an expression. Refer to the ON GOTO discussion.

Process Example The following is an event triggered process, triggered when FAN_SST is commanded. The variable feature% can take on values of 1 through 6. It will cause execution of the process to move to one of the subroutines. The RETURN statement at the end of each subroutine will cause process execution to continue with the statement after the ON GOSUB, the GOTO statement. The GOTO 100 will cause execution of the process to jump to label 100, the END PROCESS. This prevents any of the other PRINT statements from being executed.

40 Command Reference

Page 137: Docs | Documents | Johnson Controls

PROCESS 'AHU\CMD_FEAT' “COMMANDED BY FEATURE” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: PRINT THE NAME OF THE FEATURE THAT COMMANDED THE FAN.

REM

REM

REM --------------------------------------------------------------------

REM

state%='AHU\FAN_SST'

feature%='AHU\FAN_SST\FEATURE'

ON feature% GOSUB 10,20,30,40,50,60

GOTO 100

10 PRINT '\PC_PTR' “AHU FAN COMMANDED BY OPERATOR”

RETURN

20 PRINT '\PC_PTR' “AHU FAN COMMANDED BY TIME SCHEDULE”

RETURN

30 PRINT '\PC_PTR' “AHU FAN COMMANDED BY PROCESS”

RETURN

40 PRINT '\PC_PTR' “AHU FAN COMMANDED BY DEMAND LIMITING”

RETURN

50 PRINT '\PC_PTR' “AHU FAN COMMANDED BY LOAD ROLLING”

RETURN

60 PRINT '\PC_PTR' “AHU FAN HAS NOT BEEN COMMANDED SINCE LAST DOWNLOAD”

RETURN

100 END PROCESS

state%--Local variable of type integer used to cause process to trigger.

feature%--Local variable of type integer used to hold value of FEATURE attribute of AHU\FAN_SST.

Command Reference 41

Page 138: Docs | Documents | Johnson Controls

IF-THEN-ELSE and ENDIF Statements

Purpose Allows execution of a statement based on a logical expression.

Formats For a Simple IF IF <EXPRESSION> THEN <STATEMENT> ELSE <STATEMENT>

For a Block IF IF <EXPRESSION> THEN

<STATEMENTS>

ELSE

<STATEMENTS>

END IF

<expression>

Any logical expression.

<statement>

Any statement or set of statements.

Details Use a simple IF when the IF statement can be contained on one logical line. Use a block IF for logic that takes multiple lines.

IF y? THEN \ a=b ELSE b=c executes faster and takes less NC memory than IF y? THEN a=b ELSE b=c ENDIF even though the same results occur.

Helpful Hint

For both simple and block IF statements, if the logical expression is True, then the statements immediately following the THEN statement are executed. Otherwise, the statements immediately following the ELSE are executed. The ELSE portion is optional but the END IF statement is not--it must be the last line of any block IF statement.

IF statements can be nested (i.e., one IF statement within another). There is no limit to the number of nested IF statements.

You can use a GOTO statement in an IF statement. However, the GOTO should not jump into the middle of the IF statement.

42 Command Reference

Page 139: Docs | Documents | Johnson Controls

A single-line IF statement allows a shortened version of the GOTO statement. This is done by simply specifying the line number to go to.

Usage Example IF A>B THEN 200 ELSE 300

is equivalent to IF A>B THEN GOTO 200 ELSE GOTO 300

Note: The above version of the GOTO statement is not allowed in the block IF.

A block IF statement can use the FIRST PASS option. This option allows a set of statements to be executed only the first time the expression changes to True or False. It is provided especially for fan or chiller applications, in which equipment startup has a ramp-up period before normal operation begins. Here is the format: IF <EXPRESSION> THEN

FIRST PASS

<STATEMENTS>

END FIRST PASS

<STATEMENTS>

ELSE

FIRST PASS

<STATEMENTS>

END FIRST PASS

<STATEMENTS>

END IF

In this format, the statements between the FIRST PASS and END FIRST PASS are executed once when the logical expression in an IF statement changes to True or False. All the statements execute only when a change occurs. This is in contrast to the rest of the statements after the THEN or ELSE clause, which always execute when the condition is True (for THEN) or False (for ELSE).

Only one FIRST PASS/END FIRST PASS is allowed for the THEN statement and for the ELSE statement. In both cases, FIRST PASS must be the first statement after THEN or ELSE.

Command Reference 43

Page 140: Docs | Documents | Johnson Controls

First Pass Example IF INPUT? THEN

FIRST PASS

OUTPUT? = INPUT

GOTO 10

END FIRST PASS

OUTPUT? = NOT INPUT?

ELSE

OUTPUT? = INPUT?

10 END IF

INT_TO_TIME Function

Purpose Returns a value in time format.

Format INT_TO_TIME(<NUMERIC EXPRESSION>, <UNITS>)

<numeric expression>

Expression whose value is to be returned in time format. Can be real or integer. If real, the value will be converted to integer by rounding.

<units>

Units of time, either seconds or minutes. Entire word must be spelled out; any combination of lower and upper case letters is allowed.

Details If the integer expression is within the valid range (0 to 86399 for seconds, 0 to 1439 for minutes), the reliability of the output is determined by the reliability of the integer expression. If the integer expression is less than 0, the output is 00:00:00 flagged unreliable. If the integer expression is greater than 86399 for seconds or 1439 for minutes, the output is 23:59:59 flagged unreliable.

44 Command Reference

Page 141: Docs | Documents | Johnson Controls

Usage Examples rem convert seconds to time value

timevalue@ = int_to_time(realseconds!, SECONDS)

timevalue@ = int_to_time(intseconds%, SECONDS)

rem convert minutes to time value

timevalue@ = int_to_time(realminutes!, MINUTES)

timevalue@ = int_to_time(intminutes%, MINUTES)

The timevalue@=int_to_time (int minutes%, MINUTES) is the same as timevalue@=intminutes%. Timevalue@ = intminutes% however, runs faster and uses less NC memory.

Helpful Hint

LASTTOT Function

Purpose Retrieves the previous period totalization for a non-array attribute.

Format

LASTTOT ('<SYSTEM NAME>\<OBJECT NAME>\<ATTRIBUTE>')

<system name>

Name of the system which has this object defined; eight characters maximum.

<object name>

Name assigned to identify this object; eight characters maximum.

<attribute>

Data characteristic of the object that can be totalized. This can’t be an array attribute.

Details This function returns a real number. For runtime totalization, this number will be the time count in minutes.

If the attribute you specify is not currently assigned to totalization, the value of the function will be zero and flagged unreliable.

Usage Example A = LASTTOT('AHU1\TEMP\VALUE')

Command Reference 45

Page 142: Docs | Documents | Johnson Controls

LET Statement

Purpose Assigns the value of an expression to a local or shared variable, array element, object attribute, or user function.

Formats

LET <VARIABLE> = <EXPRESSION>

LET '<SYSTEM NAME>\<OBJECT NAME>\<ATTRIBUTE>' = <EXPRESSION>

<variable>

Name of variable or array element that is to be assigned a value.

<expression>

Expression whose value is to be assigned to the variable. The expression type must match the variable type; exceptions to this are noted below.

<system name>

Name of the system under which object name is defined.

<object name>

Name of the object under which attribute is defined; eight characters maximum.

<attribute>

Attribute to assign value of expression; eight characters maximum.

Details The keyword LET in a LET statement is optional.

Within a LET expression, you can mix integer and real numbers, and integers and time values. However, you can’t mix real and time values.

In cases where more than one variable type is used in the expression, the type that is used depends on the variable. For example, if the variable type is real, and both real numbers and integers are used in the expression, the integer values are converted to real and the expression is evaluated.

46 Command Reference

Page 143: Docs | Documents | Johnson Controls

When converting integer into time, the integer value represents a number of minutes. When converting from time to integer, the result represents the total minutes (hours * 60 + minutes). Seconds are rounded. Some examples: LET TIME_VAR@ = 230

sets TIME_VAR@ to 3:50:00 LET INT_VAR% = 14:25:53

sets INT_VAR% to 866

The number of minutes converted can’t be greater than or equal to 24 hours, or an error is generated, the time is set to 23:59:59, and the result is set unreliable. Similarly, if the number of minutes is less than 0, an error is generated, the time variable is set to 00:00:00 and the result is set unreliable.

Only JC-BASIC writable attributes of objects can be assigned values using the LET statement. The expression type must match the data type of the attribute. To use the default attribute, you need not specify the attribute name.

Shared variables and triggerable object attributes are checked when assigned a value, since assignment may cause a process to trigger.

You may also use the LET statement to assign a variable to the value of an attribute, then use the variable in a later statement. Here is an example: LET X = 'AHU1\LC3\SWITCH'

Now you may use x in expressions to refer to the value of the attribute, instead of writing the full name of the attribute out, and forcing the NCM into repeated reads of that point just to get the value.

Usage Examples RAMP_DONE?=FALSE

LET 'AHU1\LC3\SWITCH' = TRUE

REM SINCE LET IS OPTIONAL, ABOVE COULD BE

REM WRITTEN AS FOLLOWS --

'AHU1\LC3\SWITCH' = TRUE

LET 'AHU2\RC3\SETPOINT' = 87.4

LET 'AHU1\RC3' = 87.4

REM DEFAULT ATTRIBUTE WILL BE USED

Command Reference 47

Page 144: Docs | Documents | Johnson Controls

LOG Function

Purpose Calculates the natural logarithm of the expression.

Format LOG (<EXPRESSION>)

<expression>

Any numeric expression that evaluates to a number greater than 0.

Details This function returns a real number. The natural logarithm is the logarithm to the base e.

The reliability of the result is the same as the reliability of the expression. If the numeric expression is 0 or less, the result returned is -3.4E38, flagged unreliable.

Process Example The following is a periodic process with a period of 30 minutes as defined by PERIOD 00:30:00. The two LOG functions are used to calculate the change in entropy. The TELL command will store the value of the calculation in the Analog Data object so that it can be displayed.

PROCESS 'PLANT\ENT_CAL' “SYSTEM ENTROPY CALC” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: CALCULATE THE CHANGE IN ENTROPY OF THE SYSTEM.

REM

REM

REM --------------------------------------------------------------------

REM

PERIOD 00:30:00

entropy=0.24*(LOG('PLANT\LEAV_TMP'+460)-LOG('PLANT\ENT_TMP'+460))

TELL 'PLANT\ENTROPY' TO “SET_AD” entropy,3

END PROCESS

entropy--Local variable of type real.

PLANT\LEAV_TMP--Analog Input object of leaving temperature.

PLANT\ENT_TMP--Analog Input object of entering temperature.

PLANT\ENTROPY--Analog Data object used to display entropy value.

48 Command Reference

Page 145: Docs | Documents | Johnson Controls

MAX Function

Purpose Selects the maximum value of up to 12 numeric expressions.

Format MAX(<E1,E2, ... , EN>)

(<e1,e2, ... , en>)

Expression 1, expression 2, and up to expression n; you can specify a minimum of two and a maximum of 12 numeric expressions.

Details The value returned is real if any of the expressions are real. If all the expressions are integer, the number returned is integer.

A reliable value is returned if all the expressions are reliable; otherwise the result is unreliable.

Process Example The following is a periodic process with a period of five minutes as defined by PERIOD 00:05:00. It calculates a new setpoint for the mixed air PID control loop based on outside air temperature and the heat reclaim signal. The first SPAN function calculates the new setpoint based on outside air. The second SPAN function calculates the new setpoint based on the heat reclaim signal. The MAX function selects the greater of the two calculated setpoints. The last TELL command stores this value in the mixed air PID loop setpoint attribute.

LET X=MAX(A+B, C, 12.3)

PROCESS 'PROGRAM\MA_SETPT' “MIXED AIR SETPOINT CALC” '\NC1'

REM --------------------------------------------------------------------

REM PURPOSE: THIS PROCESS CALCULATES A NEW MIXED AIR SETPOINT FOR

REM THE MIXED AIR CONTROL LOOP.

REM

REM

REM --------------------------------------------------------------------

IF 'C4_FANS\SF1_FAN'=ON OR 'C4_FANS\SF2_FAN'=ON THEN

PERIOD 00:05:00 :REM CALCULATE SETPOINT EVERY 5 MINUTES

OA_MA_SETP=SPAN('C4_MA\OA_TMP',20,40,58,53)

TELL 'C4_MA\MASP_OA' TO “SET_AD” OA_MA_SETP,3

R_MA_SETP=SPAN('C4_RECLM\RECLAIM',0,20,70,53)

TELL 'C4_MA\MASP_RCL' TO “SET_AD” R_MA_SETP,3

Command Reference 49

Page 146: Docs | Documents | Johnson Controls

MA_SETP=MAX(OA_MA_SETP,R_MA_SETP)

IF ABS('C4_MA\MA_SP\SETPOINT' — MA_SETP) > 1.0 THEN \

TELL 'C4_MA\MA_SP\SETPOINT' TO “SET_PIDL” MA_SETP, 3

ELSE

PERIOD 00:00:00 :REM DON’T RUN PROCESS WHEN FANS ARE OFF

END IF

END PROCESS

C4_FANS\SF1_FAN--Binary Input object of supply fan 1 status.

C4_FANS\SF2_FAN--Binary Input object of supply fan 2 status.

C4_MA\OA_TMP--Analog Input object of outside air temperature.

C4_RECLM\RECLAIM--Analog Input object of heat reclaim request signal.

C4_MA\MASP_OA--Analog Data object used to display mixed air setpoint calculated from outside air temperature.

C4_MA\MASP_RCL--Analog Data object used to display mixed air setpoint calculated from reclaim signal.

C4_MA\MA_SP\SETPOINT--Setpoint attribute of mixed air PID loop.

MIN Function

Purpose Selects the minimum value of up to 12 numeric expressions.

Format MIN(<E1,E2, ... , EN>)

(<e1,e2, ... , en>)

Expression 1, expression 2 and up to expression n; a minimum of 2 and a maximum of 12 numeric expressions can be specified.

Details The value returned is real if any of the expressions are real. If all the expressions are integer, the number returned is integer.

A reliable value is returned if all the expressions are reliable; otherwise, the result is unreliable.

50 Command Reference

Page 147: Docs | Documents | Johnson Controls

Process Example The following is a periodic process with a period of ten minutes as set by PERIOD 00:10:00. It executes at a priority of 4. The MIN function selects the lowest of the four zone temperatures, ZONE-1 through ZONE-4, and stores it in variable low_temp! This value is then used by the SPAN function, which calculates the new setpoint setp! The TELL command commands the heating control loop setpoint to the value of setp!

PROCESS 'AHU_9\HTG_SP' “HEATING SETPOINT CALC” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: CALCULATE THE HEATING SETPOINT USING THE LOWEST OF

REM THE FOUR ZONES

REM

REM

REM -------------------------------------------------------------------

REM

PERIOD 00:10:00

PRIORITY 4

low_temp! = MIN('AHU_9\ZONE-1','AHU_9\ZONE-2','AHU_9\ZONE-3','AHU_9\ZONE-4')

SETP! = SPAN(low_temp!,68.0,72.0,95.0,75.0)

TELL 'AHU_9\HTG_CTRL\SETPOINT' TO “SET_PIDL” SETP!,3

END PROCESS

AHU_9\ZONE-1 through AHU_9\ZONE-4--Analog Input objects of air handling unit 9 zone temperatures.

AHU_9\HTG_CTRL\SETPOINT--Setpoint attribute of air handling unit 9 PID heating control loop.

low_temp!--Local variable of type real.

MONTH Function

Purpose Retrieves the current month of the year.

Format MONTH

Details The month is represented by a number from 1 to 12, where 1 is January, 2 is February, and so on.

The reliability of the result is based on the reliability returned by the time-of-day manager.

Command Reference 51

Page 148: Docs | Documents | Johnson Controls

Usage Example IF MONTH=2 OR MONTH=3 THEN . . .

Process Example The following is triggered by another process. It will store the totalized value of AHU\FAN_STAT\VALUE in the element of array fan_run defined by MONTH. In April the value will be stored in element 4.

PROCESS 'AHU\MON_TOT' “MONTHLY FAN RUN TIME” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: STORE THE MONTHLY FAN RUN TIME IN AN ARRAY FOR YEAR END

REM PROCESSING.

REM

REM --------------------------------------------------------------------

REM

SHARED fan_run(12)

fan_run(MONTH)=TOTAL('AHU\FAN_STAT\VALUE')

END PROCESS

fan_run--A shared array of real type elements.

AHU\FAN_STAT\VALUE--Attribute of AHU\FAN_STAT which is being totalized.

N_CANC_PULSE Function

Purpose Outputs a True state for a period of time.

Format N_CANC_PULSE

Details The N_CANC_PULSE function outputs a True state when the input is True, and remains True until the pulse timer expires, regardless if the input return to False. Output varies according to the following:

Change of Input Output False -> True True for pulse time specified. True -> True True until timer expires, then

False.

Usage Example N_CANC_PULSE (<INPUT>?,<TIME DELAY>@)

52 Command Reference

Page 149: Docs | Documents | Johnson Controls

Process Example The following is an event triggered process which is triggered when AHU_3\FAN_EN changes. When AHU_3\FAN_EN goes True, the N_CANC_PULSE function will start a timer that will cause this process to be triggered again in two minutes. The TELL statement will issue the start command when delay_done? is True. The value of delay_done? will be True when the process is retriggered, since N_CANC_PULSE will return a value of False when time_delay@ has expired.

PROCESS 'AHU_3\START' “FAN START PROCESS” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: START THE FAN 2 MINUTES AFTER THE ENABLE HAS BEEN COMMANDED.

REM

REM

REM

REM

REM --------------------------------------------------------------------

REM

delay_done?=NOT(N_CANC_PULSE('AHU_3\FAN_EN',00:02:00))

IF delay_done? AND 'AHU_3\FAN_EN' THEN\

TELL 'AHU_3\FAN_SST' TO “START” 4

END PROCESS

delay_done?--Local variable of type Boolean, used to store the result of the N_CANC_PULSE function.

AHU_3\FAN_EN--Binary Data object that allows the AHU 3 fan to be started.

AHU_3\FAN_SST--Binary Output object which is the start/stop for the fan of air handling unit 3.

Command Reference 53

Page 150: Docs | Documents | Johnson Controls

ON GOSUB Statement

Purpose Transfers execution to one of several specified line labels, depending on the value of an expression.

Format ON <EXPRESSION> GOSUB <LABEL LIST>

<expression>

Any numeric expression.

<label list>

One or more line labels, separated by commas, all of which can be transferred, depending on the numeric expression; range for labels is 0 to 65535.

Details The expression is first evaluated and rounded, if necessary, to obtain an integer. This value is then used to select a label from the label list to which control is transferred.

The line numbers are indexed from left to right, starting with 1. Therefore, if the expression is 2, control would be transferred to the second label in the list. If the expression value is less than 1 or greater than the number of labels in the list, control transfers to the next statement after the GOSUB and a nonfatal error message is generated. Each line label in the ON GOSUB statement should be the label of a subroutine.

A RETURN statement is needed to eventually bring execution back to the line immediately following the ON GOSUB statement.

The GOSUB in this statement can be written as GOSUB or GO SUB.

Usage Example A = 2

B = 1

ON A + B GOSUB 10, 20, 30, 40, 50

In this example, execution would continue at 30.

54 Command Reference

Page 151: Docs | Documents | Johnson Controls

Process Example The following is an event triggered process, triggered when FAN_SST is commanded. The variable feature% can take on values of 1 through 6. It will cause execution of the process to move to one of the subroutines. If feature% is 3, execution will move to label 30. The PRINT statement will output AHU fan commanded by PROCESS to \PC_PTR. The RETURN after label 30 will cause execution of the process to go back to the STOP statement. This will cause the process to end.

PROCESS 'AHU\CMD_FEAT' “COMMANDED BY FEATURE” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: PRINT THE NAME OF THE FEATURE THAT COMMANDED THE FAN.

REM

REM

REM --------------------------------------------------------------------

REM

state%='AHU\FAN_SST'

feature%='AHU\FAN_SST\FEATURE'

ON feature% GOSUB 10,20,30,40,50,60

STOP

10 PRINT '\PC_PTR' “AHU FAN COMMANDED BY OPERATOR”

RETURN

20 PRINT '\PC_PTR' “AHU FAN COMMANDED BY TIME SCHEDULE”

RETURN

30 PRINT '\PC_PTR' “AHU FAN COMMANDED BY PROCESS”

RETURN

40 PRINT '\PC_PTR' “AHU FAN COMMANDED BY DEMAND LIMITING”

RETURN

50 PRINT '\PC_PTR' “AHU FAN COMMANDED BY LOAD ROLLING”

RETURN

60 PRINT '\PC_PTR' “AHU FAN HAS NOT BEEN COMMANDED SINCE LAST DOWNLOAD”

RETURN

END PROCESS

state%--Local variable of type integer used to cause process to trigger.

feature%--Local variable of type integer used to hold value of FEATURE attribute of AHU\FAN_SST.

Command Reference 55

Page 152: Docs | Documents | Johnson Controls

ON GOTO Statement

Purpose Transfers execution to one of several specified line labels, depending on the value of an expression.

Format ON <EXPRESSION> GOTO <LABEL LIST>

<expression>

Any numeric expression.

<label list>

One or more line labels, separated by commas, all of which can be transferred to, depending on the numeric expression; range for labels is 0 to 65535.

Details The expression is first evaluated and rounded, if necessary, to obtain an integer. This value is then used to select a label from the label list to which control is transferred.

The line labels are indexed from left to right starting with 1. Therefore, if the expression is 2, control would be transferred to the second label in the list. If the expression value is less than 1 or greater than the number of labels in the list, control transfers to the next statement after the GOTO and a nonfatal error message is generated.

The GOTO in this statement can be written as GOTO or GO TO.

Usage Example A = 2

B = 1

ON A + B GOTO 10, 20, 30, 40, 50

In this example, execution would continue at 30.

56 Command Reference

Page 153: Docs | Documents | Johnson Controls

PERIOD Statement

Purpose Executes a process once each time a period timer expires.

Format PERIOD <TIME EXPRESSION>

<time expression>

Expression whose value is how often a process is to execute. The format is 00:00:00 (e.g., 00:30:14 is 30 minutes and 14 seconds; 01:00:00 is one hour). Range is 00:00:00 to 23:59:59.

Details The PERIOD statement is optional and can be omitted for processes that need execution only when a trigger changes.

Multiple period statements may be written in one process, but only the last period statement executed will be used. Take for example the following three statements: PERIOD 00:05:00

LET X@ = Y@ + Z@ - 00:01:00

PERIOD X@

The first statement defines a five minute period, the second assigns a time value to X, and the third redefines the period to equal the value of X@ above. The third statement will be the period that is actually used.

The process period is an attribute of the process it is initialized to 00:00:00 at process download, NCM reset, or enable. It is set to the value in the PERIOD when the statement executes. The period attribute value is used as the process completes execution either via STOP or END PROCESS statements. The attribute sets a timer to trigger the process if the period is not 00:00:00.

A period of 00:00:00 stops the periodic execution, but triggers are still allowed to execute the process. This can be used to “put to sleep” a periodic process which has no useful function to do until a trigger occurs, which would “wake up” the process.

Command Reference 57

Page 154: Docs | Documents | Johnson Controls

A process may not execute exactly as often as the period states, or may execute more often. This inexactness is caused by these factors:

• Time is consumed in executing the process before the period is recalculated.

• If the process executes a WAIT statement, the WAIT time must expire before the process can END (STOP or PROCESS END) and, hence, start the period timer. The time between executions is comprised of the period, all wait delays, the execution, and the queue times.

• Higher priority processes may be running, preventing the process from executing on its period expiration (queue time).

• The process may be executed by some other means (e.g., triggered by another process), thus executing before period expires.

A trigger which occurs during a periodic delay will cancel the periodic delay and execute the process. The new period will then start at the end of that execution.

Note: The PERIOD statement can prevent processes from running. For example, if the NCM has two processes, both set at PRIORITY 1 with a PERIOD of 00:00:01, it is possible that no other processes besides PRIORITY 1 processes would ever run. These two processes could be running every second.

Usage Example PERIOD 00:05:00 : REM 5 MINUTE PERIOD

PERIOD X@ - 'AHU1\PID_L3\LATESTOP'

58 Command Reference

Page 155: Docs | Documents | Johnson Controls

PI_RESET Statement

Purpose Calculates a new setpoint value using proportional-plus-integral calculations.

Format PI_RESET (<SETPOINT>, <FEEDBACK>, <PROPORTIONAL_BAND>, <INTEGRAL_ TIME>,

<OFFSET>, <DEADBAND>, <OUTPUT_LOW>, <OUTPUT_HIGH>, <RESTART?>)

<setpoint>

Desired feedback value.

<feedback>

Feedback value.

<proportional_band>

Change in feedback that will cause a full scale change in the value calculated by the function.

<integral_time>

Number of minutes needed for the integral response to equal the proportional response; must be greater than 0, or an error is generated and a default value of 5 is used.

<offset>

Initial value of the reset function if no error is present the first time the function is called.

<deadband>

A value that is twice the acceptable value outside of setpoint that must be crossed before change of state is issued. Value must be greater than or equal to 0, or an error is generated and a default value of 0 is used.

<output_low>

Lowest value that this function will calculate.

<output_high>

Highest value that this function will calculate.

<restart?>

Logical value that, when True, causes the function to reset the integral term to zero.

Command Reference 59

Page 156: Docs | Documents | Johnson Controls

Details The PI_RESET function has three variables that are maintained from call to call of the function. These variables are Iterm, Last Time, and Last Output.

Iterm: integral term, a real value.

Last time: time the function last executed.

Last output: output of the last execution of the function.

These variables are maintained independently for each call; if the PI_RESET function is called twice in a process, each call maintains these internal variables for use by the execution of the call. Like all other local variables, these variables are set to zero (or midnight) on process download, warm start, and process enable.

If any of the inputs into the PI_RESET function are unreliable (or set unreliable because its value is out of range), the output is set to be the last output and flagged unreliable. However, if Iterm is unreliable, its value is zeroed and set reliable.

Process Example The following is a periodic process which executes every 10 minutes as defined by PERIOD 00:10:00. The PI_RESET function will calculate a new setpoint, pi_setpt! This value will be between 55.0° and 70.0°. The TELL command will make the control loop setpoint the value of pi_setpt!

PROCESS 'AHU_1\HDC_SETP' “HTG, DMPT, CLG SETPT CAL” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: DETERMINE A PROPORTIONAL PLUS INTEGRAL SETPOINT FOR THE

REM HEATING/DAMPER/COOLING CONTROL loop.

REM

REM

REM

REM --------------------------------------------------------------------

REM

PERIOD 00:10:00

PRIORITY 4

pi_setpt! = PI_RESET('AHU_1\RM-SPT','AHU_1\RM-T',6.0,120.0, \

63.0,1.0,55.0,70.0,FALSE)

TELL 'AHU_1\HDC-CTRL\SETPOINT' TO “SET_PIDL” pi_setpt!,3

END PROCESS

AHU_1\RM-SPT--Analog Data object of air handling unit 1 room setpoint temperature.

60 Command Reference

Page 157: Docs | Documents | Johnson Controls

AHU_1\RM-T--Analog Input object of air handling unit 1 room temperature.

AHU_1\HDC-CTRL\SETPOINT--Setpoint attribute of air handling unit 1 heating/damper/cooling control loop.

PRINT and PRINT USING Statements

Purpose Sends a line of text to any printer on the system.

Formats PRINT <PRINTER NAME> <TEXT>

PRINT <PRINTER NAME> USING “<FORMAT CHARACTERS>“ <TEXT>

<printer name>

Name of a defined printing device on the system.

<text>

Any sequence of strings and numeric, time, or logical expressions, including object attributes, that will be printed; separate strings with commas. You may print text within quotation marks; to do so, enter two sets of double quotes (e.g., "BLOCKAGE IN ""AHU-1/3 DUCT""" will print: BLOCKAGE IN “AHU-1/3 DUCT”).

<format characters>

Symbols that format how the numbers are printed. (See the Details section.)

Details Use this statement to print information that would not be printed by other software features.

You may use any attribute in the text field that returns a character string. Also, you can use the TIME$ and DATE$ functions in this field.

If this statement sends a message to a printer that is offline, the message is lost.

Command Reference 61

Page 158: Docs | Documents | Johnson Controls

The default format for numeric values is -nnnnnn.n, where “n” is number. Logical expressions are printed as TRUE or FALSE (in all capital letters). Time values are printed as HH:MM:SS in all cases. String attributes and constants (in double quotes) are printed exactly as entered. Strings may contain any valid ASCII characters.

For easy reading, a blank space is always placed between the text and its value. Text is printed in regular-sized print; compressed print is not supported.

The PRINT statement can print a maximum of 80 characters. For output lines longer than 80 characters, the output line will be truncated at 80 characters.

Use the PRINT USING statement for printing numeric values. The valid format characters are:

Format Character Formats # One digit . One decimal point - A negative sign for negative numbers,

blank for positive numbers

For example:

#.# Prints a number like 1.2

-##.## Prints a number like -12.34

The default of the format string for showing numeric data is:

-######.#

Note: When each PRINT statement executes, it acquires memory from the NC to send the message to the printer. Execution of a large number of PRINT statements can use up all of an NCM’s acquired memory and cause the NCM to reboot.

62 Command Reference

Page 159: Docs | Documents | Johnson Controls

Follow these rules when using format characters:

• Specify at least one # character in the format string.

• Specify a # character before the decimal point to print a digit. For example:

Format string: #.##

Number to print: .23

Number as printed: 0.23

• Use only one decimal point in a format string. Also, use only one negative sign, which must be either at the beginning or the end of the format string. A negative sign at the beginning will place the - character in front of a negative number, and a negative sign at the end will place a - character after a negative number. If you don’t specify the - character, and the number to be printed is negative, the - character is printed at the front of the number.

• Make sure you specify enough # characters before the decimal point. Otherwise, a % character will be printed in front of the number. For example:

Format string: ##.##

Number to print: 123.456

Number as printed: %123.46

• Make sure you specify the correct number of # characters. If you specify more # characters before the decimal point than there are numbers to print, the extra # characters will have blanks filled in. For example (b means blank space):

Format string: ####.##

Number to print: 12.34

Number as printed: bb12.34

If you specify more # characters after the decimal place than there are numbers to print, the remaining spaces are filled with zeros. For example:

Format string: #.##

Number to print: 8.3

Number as printed: 8.30

Command Reference 63

Page 160: Docs | Documents | Johnson Controls

If you don’t specify as many # characters as there are numbers to print, the number is rounded. For example:

Format string: #.##

Number to print: 3.876

Number as printed: 3.88

Usage Example PRINT '\LP2' TIME$, “CURRENT OUTDOOR AIR VALUE IS” , 'AHU1\OUT_AIR', "DEGF"

This PRINT statement will print (if current time is 4:00 p.m.):

16:00:00 CURRENT OUTDOOR AIR VALUE IS 68.0 DEGF

PRINT '\LP1' USING “##.##- “ “AVERAGE TEMP.”, X, “BELOW SETPOINT”

The printout for this example would be: AVERAGE TEMP. 5.00 BELOW SETPOINT

PRIORITY Statement

Defines the priority of a process. Purpose

Format PRIORITY <PRIORITY LEVEL>

<priority level>

Integer that defines level of priority; choices are 1, 2, 3, or 4, where 1 is the highest and 4 is the lowest priority.

Details The PRIORITY function determines which process will go first when several processes need to be executed. Processes with higher priorities are executed before processes with lower priorities. Two processes at the same priority level are executed on a first-come, first-served basis.

The priority statement is optional. Use it only in those processes that must be executed before specific other processes. For those processes that don’t have an assigned priority, the default of Priority 4 is used.

The PRIORITY statement can appear anywhere within a process, but must be declared only once in a process.

Usage Example PRIORITY 3

This example assigns a priority of 3.

64 Command Reference

Page 161: Docs | Documents | Johnson Controls

PROCESS and END PROCESS Statements Purpose The PROCESS statement identifies and defines a JC-BASIC

process. The END PROCESS statement identifies the end of the process.

Format PROCESS '<SYSTEM NAME>\<PROCESS NAME>' “<PROCESS DESCRIPTOR>“ '\<NC NAME>'

<STATEMENTS>

END PROCESS

<system name>

Name of system that this process is written for; eight characters maximum.

<process name>

Name to identify this process; also known as a process object name, since a process is also an object; eight characters maximum.

<process descriptor>

Further describes the process name; 24 characters maximum. Two sets of double quotes are needed for text in quotes (e.g., "SAMPLE PROCESS""XYZ""", in which XYZ is actually “XYZ”).

\<nc name>

Name of the NCM that will store and execute this process; eight characters maximum. The \ character is required.

Details Obtain the system and NCM names from the archive data base. If the names you enter don’t match those in the archive data base exactly, the compiler will tag these with errors.

Pay particular attention to the use of single and double quotes within this statement. Use single quotes to enclose the system\process names and NCM name. Use double quotes to enclose the process descriptor.

If the process contains a PERIOD statement, then the END PROCESS statement starts a period timer.

Command Reference 65

Page 162: Docs | Documents | Johnson Controls

Usage Example PROCESS 'AHU1\FAMS' “AHU FAN CONTROL” '\NC2'

. . .

. . .

. . .

END PROCESS

Process Example The following has a system name of AHU_4, a process name of MA_SETPT and process descriptor of Mixed Air Setpoint Calc. It resides in NCM NC1.

PROCESS 'AHU_4\MA_SETPT' “MIXED AIR SETPOINT CALC” '\NC1'

REM --------------------------------------------------------------------

REM PURPOSE: THIS PROCESS CALCULATES A NEW MIXED AIR SETPOINTS FOR

REM THE MIXED AIR CONTROL LOOP.

REM

REM --------------------------------------------------------------------

IF 'C4_FANS\SF1_FAN'=ON OR 'C4_FANS\SF2_FAN'=ON THEN

PERIOD 00:05:00 :REM CALCULATE SETPOINT EVERY 5 MINUTE

OA_MA_SETP=SPAN('C4_MA\OA_TMP',20,40,58,53)

TELL 'C4_MA\MASP_OA' TO “SET_AD” OA_MA_SETP,3

R_MA_SETP=SPAN('C4_RECLM\RECLAIM',0,20,70,53)

TELL 'C4_MA\MASP_RCL' TO “SET_AD” R_MA_SETP,3

MA_SETP=MAX(OA_MA_SETP,R_MA_SETP)

IF ABS('C4_MA\MA_SP\SETPOINT' - MA_SETP) > 1.0 THEN \

TELL 'C4_MA\MA_SP\SETPOINT' TO “SET_PIDL” MA_SETP, 3

ELSE

PERIOD 00:00:00 :REM DON’T RUN PROCESS WHEN FANS ARE OFF

END IF

END PROCESS

66 Command Reference

Page 163: Docs | Documents | Johnson Controls

C4_FANS\SF1_FAN--Binary Input object of supply fan 1 status.

C4_FANS\SF2_FAN--Binary Input object of supply fan 2 status.

C4_MA\OA_TMP--Analog Input object of outside air temperature.

C4_RECLM\RECLAIM--Analog Input object of heat reclaim request signal.

C4_MA\MASP_OA--Analog Data object used to display mixed air setpoint calculated from outside air temperature.

C4_MA\MASP_RCL--Analog Data object used to display mixed air setpoint calculated from reclaim signal.

C4_MA\MA_SP\SETPOINT--Setpoint attribute of mixed air PID loop.

RAMP Function

Purpose Converts a step-change input to a ramp-shaped output at a user-specified rate. The RAMP function is typically used to smooth out setpoint changes.

Format RAMP (<CURRENT VALUE>, <DESIRED SETPOINT>, <INCREMENT>)

<current value>

Current floating point value of the input point; can be an attribute.

<desired value>

Desired setpoint value that you assign.

<increment>

Amount to increase or decrease the output value in steps to reach the desired value.

Command Reference 67

Page 164: Docs | Documents | Johnson Controls

Details When this function is executed, the increment is compared to zero. If it is less than zero, it is set to zero. Then, the current value is compared to the desired value. If they are equal, the output is set equal to the desired value.

If the current value is less than the desired value, the output is set equal to the current value plus the increment value. Then, the output is compared to the desired value; if it is greater, the output is set equal to the desired value to avoid cycling.

If the current value is greater than the desired value, the output is set equal to the current value minus the increment value. Then, the output point is compared to the desired value; if it is less, the output is then set equal to the desired value to avoid cycling.

The reliability of the inputs determines the reliability of the output. If any input is unreliable, the output is flagged as unreliable.

Process Example The following is triggered when the value of AHU1\FAN_STAT changes from ON to OFF and OFF to ON, or every 30 seconds. If the fan status is ON, the selector input of the PIDL is initialized to zero by the TELL command. The process is set to a periodic process with a period of 30 seconds by PERIOD 00:00:30 the first time through the IF statement.

The RAMP function will calculate a new value for ramp_output!, which will increase by 5.0 every 30 seconds (the period of the process).

When ramp_output! equals 100, the process period will be set to zero by PERIOD 00:00:00, making this an event triggered process.

If the fan status is OFF, the period of the process is set to 00:00:00, changing this from a periodic process to an event triggered process.

PROCESS 'AHU1\RAMP_PRC' “MIXED AIR DPR RAMP PROC” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: ON AIR HANDLING UNIT START UP SLOWLY OPEN THE MIXED AIR DAMPERS

REM TO THE POSITION CALCULATED BY THE PID LOOP.

REM

REM --------------------------------------------------------------------

REM

68 Command Reference

Page 165: Docs | Documents | Johnson Controls

PRIORITY 4

IF 'AHU1\FAN_STAT\VALUE' THEN

FIRST PASS

ramp_output!=0.0

TELL 'AHU1\MA_PIDL\SEL_INP' TO “SET_PIDL” ramp_output!,3

PERIOD 00:00:30

STOP

END FIRST PASS

ramp_output!=RAMP(ramp_output!,100.0,5.0)

TELL 'AHU1\MA_PIDL\SEL_INP' TO “SET_PIDL” ramp_output!,3

IF RAMP_OUTPUT! >= 100.0 THEN PERIOD 00:00:00

ELSE

PERIOD 00:00:00

END IF

END PROCESS

AHU1\FAN_STAT--Binary Input object which detects the state of fan AHU1.

AHU1\MA_PIDL--PID loop object which calculates and sets the position of the mixed air dampers.

ramp_output!--Local variable of type real (!) which holds the result of the RAMP function.

REL_HUM Function

Purpose Calculates an integer value representing relative humidity based on dry bulb temperature and dew point temperature.

Format REL_HUM(<DRY BULB TEMPERATURE>, <DEW POINT TEMPERATURE>, <UNITS>)

<dry bulb temperature>

Real expression representing the current values of the dry bulb temperature. Range: -147.9 to 391.9°F (-99.9 to 199.9°C).

<dew point temperature>

Integer expression representing the current values of the dew point temperature. Range: -147.9 to 391.9°F (-99.9 to 199.9°C).

<units>

Command Reference 69

Page 166: Docs | Documents | Johnson Controls

Units of measurement, either English or Metric. Entire word must be spelled out; any combination of lower and upper case letters is allowed.

Details The sensed dry bulb temperature and dew point temperature are entered into the relative humidity equation. This equation is equivalent to the ASHRAE standard for calculating relative humidity. (For details, see ASHRAE Handbook of Fundamentals, American Society of Heating, Refrigerating and Air Conditioning Engineers, Atlanta, Chapter 6, 1985.)

The reliability of the inputs determines the reliability of the output. If any input is deemed unreliable, the output is flagged as unreliable and a user advisory is issued. An input that is outside its range would cause an unreliable output.

Process Example The following is a periodic process, which executes every 20 minutes as defined by PERIOD 00:20:00. The relative humidity of the outside air is calculated by the REL_HUM function which uses the outside air dry bulb temperature and the outside air dew point temperature. ENGLISH specifies the units of the parameters and the result.

The result of the REL_HUM function is stored in Analog Data object BUILDING\OA_HUM by the TELL command so that it can be displayed by an operator.

PROCESS 'BUILDING\RH_CAL' “RELATIVE HUMIDITY CALC” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: CALCULATE THE OUTSIDE AIR RELATIVE HUMIDITY & DISPLAY AS

REM OBJECT BUILDING\OA_HUM.

REM

REM --------------------------------------------------------------------

REM

PERIOD 00:20:00 :REM CALCULATE RELATIVE HUMIDITY EVERY 20 MINUTES

oa_rh=REL_HUM('BUILDING\OA_TMP','BUILDING\OA_DP',ENGLISH)

TELL 'BUILDING\OA_HUM' TO “SET_AD” oa_rh,3

END PROCESS

BUILDING\OA_TMP--Analog Input object of outside air temperature.

BUILDING\OA_DP--Analog Input object of outside air dew point temperature.

70 Command Reference

Page 167: Docs | Documents | Johnson Controls

BUILDING\OA_HUM--Analog Data object of calculated outside relative humidity.

oa_rh--Local variable of type real which holds the result of the REL_HUM function.

REM Statement

Purpose Places comment lines in a process.

Format REM <REMARKS>

<remarks>

Any series of ASCII characters that provides information about the process.

Details The compiler doesn’t produce any executable code from REM statements. However, it does translate the text into object, if you specify the #REMARKS compiler directive in the process.

Note: If you use #REMARKS, make all remarks as brief as possible. Each character, even blank spaces, consumes one byte of memory. For large files, this could be a problem. You may consider not using the #REMARKS directive for large files.

Here are some rules regarding the use of remarks:

• Don’t use the \ character to continue a remark on to the next physical line. If you need to continue the remark, type it on the next physical line, beginning with the REM keyword.

• Don’t use the colon (:), the statement separator, to separate two remark statements on the same physical line. The colon, however, may be used for other reasons within a remark.

• If more than one statement is on a physical line, the REM must be the last statement. The compiler ignores the colon (:) as a statement separator after a REM keyword.

• Enter remarks within a process; don’t type them anywhere outside the process itself.

Usage Example REM

Command Reference 71

Page 168: Docs | Documents | Johnson Controls

REM THIS PROCESS CALCULATES RETURN AIR

REM AND OUTSIDE AIR ENTHALPY AND THE

REM OUTSIDE AIR DAMPER IS ALLOWED TO

REM MODULATE IF OA ENTHALPY < RA

REM ENTHALPY OR HELD AT MINIMUM

REM IF OA ENTHALPY > RA ENTHALPY.

SHARED Statement

Purpose Declares a variable or array that is used to pass data between multiple processes within the same NCM.

Formats SHARED <VARIABLE NAME>

SHARED <VARIABLE NAME (<SUBSCRIPTS>)

<variable name>

Two choices: ASCII identifier for an integer, real, logical, or time value, or an array variable name. The variable can be up to 16 characters long and may consist of letters, digits, and underscores. However, the name must have a letter as its first character and the symbol that denotes its type as the last character. (See Details, next page.)

(<subscripts>)

The number of array elements (reserved memory locations).

72 Command Reference

Page 169: Docs | Documents | Johnson Controls

Details The last character of the variable name identifies its data type:

Last Character Data Type ! Real % Integer ? Logical (Boolean) @ Time

Besides passing data between multiple processes, non-array shared logical variables can also be used as a way for one process to trigger another process.

The SHARED statement is used in the declarations section of a process to tell the compiler which shared variables are used in the process. You must declare all shared variables before using them. Otherwise, they will be treated as local variables.

You may conditionally initialize shared variables in the RESTART process or in any other process which has declared it as shared. For example, several processes may need to know if the building is occupied. The RESTART process could be the central place where occupied time is determined.

Shared single logical variables referenced by a process will trigger that process when they change. You may override this by using the EXEMPT declaration.

You can give two shared variables the same name, as long as their symbols are different. For example, you may define A! and A@ in the same process, because their symbols identify them as different variable types. Also, you may assign the same name to variables and arrays [e.g., A! and A!(10) is allowed].

Usage Example

SHARED flag?, occupied?, total_air!, I%, D(10), elapsed_time@

In this example, the variables flag? and occupied? are declared as logical shared variables, the variable total_air is declared as a real shared variable, I% is an integer shared variable, and D(10) as a shared array of real numbers. Elapsed time@ is a time shared variable.

Command Reference 73

Page 170: Docs | Documents | Johnson Controls

SIN Function

Purpose Calculates the sine of a numeric expression.

Formats SIN (<EXPRESSION>)

<expression>

Any numeric expression.

Details The expression represents an angle in radians. The result of this function is a real number, and its reliability is the same as the reliability of the expression.

As the value of the numeric expression gets larger, this function may start to lose precision. When this happens, an imprecise value is calculated, flagged unreliable. When the value of the expression gets too large for the function to calculate a value, it returns 0, flagged unreliable.

Process Example The following process needs to be triggered externally; either by weekly scheduling or another process. It calculated the times of sunrise and sunset for the current day and stores these times in shared variables sunrise@ and sunset@ respectively. The SIN function is used to calculate the declination and equation of time. The value of the angles is in radians.

PROCESS 'BUILDING\SUNRISE' “SUN RISE, SUN SET CALC” '\NC1'

REM -------------------------------------------------------------------------- REM

REM PURPOSE: CALCULATE SUNRISE AND SUNSET TIMES.

REM Revised: 4/95 added Meridan, simplified Julian date, fixed

REM errors in equation, Today usage

REM REVISED: 1/96, added parenthesis in SUNRISE calculation.

REM --------------------------------------------------------------------

REM

SHARED sunrise@,sunset@

DIM MONTH_OFFSET(12)

IF TRUE THEN

FIRST PASS

MONTH_OFFSET(1)=0

MONTH_OFFSET(2)=31

MONTH_OFFSET(3)=59

MONTH_OFFSET(4)=90

74 Command Reference

Page 171: Docs | Documents | Johnson Controls

MONTH_OFFSET(5)=120

MONTH_OFFSET(6)=151

MONTH_OFFSET(7)=181

MONTH_OFFSET(8)=212

MONTH_OFFSET(9)=243

MONTH_OFFSET(10)=273

MONTH_OFFSET(11)=304

MONTH_OFFSET(12)=334

END FIRST PASS

END IF

MERIDIAN=90.0

REM - MERIDIAN for EASTERN =75.0, CENTRAL =90.0, MOUNTAIN=105.0,

REM PACIFIC =120.0

RAD=57.2956

LATITUDE=43.0 :REM LOCAL LATITUDE

LONGITUDE=87.9 :REM LOCAL LONGITUDE

DAY_OF_WK%=TODAY

IF DAY_OF_WK% > 7 THEN DAY_of_WK%=DAY_OF_WK%-7

REM -- Fix for Alternate days Holiday may still cause a problem.

IF YEAR-YEAR/4*4=0 AND MONTH>2 THEN LEAP_YEAR%=1 ELSE LEAP_YEAR%=0

JULIAN_DATE%=DAY+MONTH_OFFSET(MONTH) +LEAP_YEAR%

REM SET JULIAN DATE TO CURRENT DAY PLUS MONTH OFFSET AND LEAP YEAR.

TOTAL_DAYS%=365+LEAP_YEAR% :REM NUMBER OF DAYS IN THE YEAR

DECLINATION=23.45*SIN(2*PI*(284+JULIAN_DATE%)/TOTAL_DAYS%)

EQ_OF_TIME=-(7.75*SIN(2*PI*(JULIAN_DATE%-4)/TOTAL_DAYS%)+\

10*SIN(4*PI*(JULIAN_DATE%+10)/TOTAL_DAYS%))

ARG=-1*TAN(LATITUDE/RAD)*TAN(DECLINATION/RAD)

TEMP=(PI/2-ARG-0.16667*ARG^3-0.075*ARG^5-0.0446428*ARG^7)*RAD

HALF_DAY=0.0666667*TEMP

IF JULIAN_DATE% -DAY_OF_WK%>=90+LEAP_YEAR% AND JULIAN_DATE%-DAY_OF_WK%\

<297+LEAP_YEAR% THEN DAYLIGHT%=1 ELSE DAYLIGHT%=0

SUNSET=12+HALF_DAY+(5-EQ_OF_TIME)/60+((LONGITUDE-MERIDIAN)*4)/60+\

0.00833+DAYLIGHT%

SUNRISE=12-(HALF_DAY+(5+EQ_OF_TIME)/60-((LONGITUDE-MERIDIAN)*4)/60)\

0.00833+DAYLIGHT%

SUNSET%=SUNSET*60 :REM CONVERT REAL NUMBERS TO TIME FORMAT

SUNRISE%=SUNRISE*60

sunset@=SUNSET%

sunrise@=SUNRISE%

END PROCESS

Command Reference 75

Page 172: Docs | Documents | Johnson Controls

SPAN Function

Purpose Performs a linear adjustment to an analog value that includes a limit saturation.

Format SPAN (<CURRENT VALUE>, <IN-LOW LIMIT>, <IN-HIGH LIMIT>,

<OUT LIMIT 1>, <OUT LIMIT 2>)

<current value>

Real expression representing the current value of the point.

<in-low limit>

Lowest input value to be used in the SPAN equation; must be less than in-high limit.

<in-high limit>

Highest input value to be used in the SPAN equation.

Details The last four parameters of the SPAN function define the slope, intercept, and saturation levels for the span module.

This function first checks if the in-low limit is less than the in-high limit. Then, it compares the current value to the in-high limit and in-low limit. If the value is outside of that range, the function sets the output value equal to the appropriate output limit. If the current value is within this range, the output value is determined as follows:

OUTPUT = OUT LIMIT 1 + ((CURRENT VALUE - IN LOW LIMIT) * (OUT LIMIT 2 - OUT LIMIT 1)) / (IN-HIGH LIMIT - IN LOW LIMIT)

The SPAN function allows for transfer functions with both positive and negative slopes. A positive slope is achieved when out limit 1 is less than out limit 2. A negative slope is achieved when out limit 1 is greater than out limit 2.

76 Command Reference

Page 173: Docs | Documents | Johnson Controls

The function behaves in this way:

Condition Output current value > in-low limit Varies proportionally over the

range of the out limits and < in-high limit Where the proportion associates

in-low with out limit 1 and in-high with out limit 2

current value <= in-low limit Set equal to out limit 1 current value >= in-high limit Equal to out limit

This is illustrated by the two examples that follow. The first specifies a positive slope; the second, a negative slope. They share the same current values, but their outputs differ.

Usage Example IN LOW LIMIT = 0 IN HIGH LIMIT = 10

OUT LIMIT 1 = 20 OUT LIMIT 2 = 30 (POSITIVE SLOPE)

The following applies:

Current Value Output Value -3 20 0 20 5 25 7 27 10 30 15 30

In low limit = 0 In high limit = 10

Out limit 1 = 30 Out limit 2 = 20 (negative slope)

The following applies:

Current Value Output Value -3 30 0 30 5 25 7 23 10 20 15 20

The output of the SPAN function is a single floating point number. It is unreliable if any of the inputs are unreliable.

Command Reference 77

Page 174: Docs | Documents | Johnson Controls

Process Example The following is a periodic process with a period of ten minutes as set by PERIOD 00:10:00. It executes at a priority of 4. The MIN function selects the lowest of the four zone temperatures, ZONE-1 through ZONE-4, and stores it in variable low_temp! This value is then used by the SPAN function which calculates the new setpoint setp!. The TELL command commands the heating control loop setpoint to the value of setp!.

The SPAN function will produce the following values for setp! vs. low_temp!:

low_temp! setp! 65 95 68 95 69 90 70 85 71 80 72 75 75 75

PROCESS 'AHU_9\HTG_SP' “HEATING SETPOINT CALC” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: CALCULATE THE HEATING SETPOINT USING THE LOWEST OF

REM THE FOUR ZONES

REM

REM --------------------------------------------------------------------

REM

PERIOD 00:10:00

PRIORITY 4

low_temp! = MIN('AHU_9\ZONE-1','AHU_9\ZONE-2','AHU_9\ZONE-3','AHU_9\ZONE-4')

SETP! = SPAN(LOW_TEMP!,68.0,72.0,95.0,75.0)

TELL 'AHU_9\HTG_CTRL\SETPOINT' TO “SET_PIDL” SEPT!,3

END PROCESS

AHU_9\ZONE-1 through AHU_9\ZONE-4--Analog Input objects of air handling unit 9 zone temperatures.

AHU_9\HTG_CTRL\SETPOINT--Setpoint attribute of air handling unit 9 PID heating control loop.

low_temp!--Local variable of type real.

78 Command Reference

Page 175: Docs | Documents | Johnson Controls

SQR Function

Purpose Calculates the square root of an expression.

Format SQR(<EXPRESSION>)

<expression>

Any numeric expression that evaluates to a number greater than or equal to 0.

Details The result of this function is a real number. If the expression is 0 or greater, the reliability of the result is the same as the reliability of the expression. If the expression is less than 0, the result is 0, flagged unreliable.

Process Example The following is a periodic process with a period of one minute as defined by PERIOD 00:01:00. The velocity of the discharge air is calculated by multiplying 4005 by the square root (SQR) of the velocity pressure (VEL_PRES). The TELL command writes this calculated value to AHU_3\VELOCITY so that it can be displayed by an operator.

PROCESS 'AHU_3\VEL_CALC' “AIR VELOCITY CALCULATION” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: CALCULATE & DISPLAY DISCHARGE AIR VELOCITY FOR AHU_3.

REM

REM

REM

REM --------------------------------------------------------------------

REM

PERIOD 00:01:00

velocity=4005*SQR('AHU_3\VEL_PRES')

TELL 'AHU_3\VELOCITY' TO “SET_AD” velocity,3

END PROCESS

velocity--Local variable of type real.

AHU_3\VEL_PRES--Analog Input object of duct velocity pressure.

AHU_3\VELOCITY--Analog Data object used to display duct air velocity.

Command Reference 79

Page 176: Docs | Documents | Johnson Controls

STOP Statement

Purpose Stops the current process from executing.

Format STOP

Details When this statement is encountered in a process, the execution of the process is terminated as if the entire process had completed normally. All statements after a STOP statement will never execute unless they are pointed to with a GOTO or ON GOTO statement.

A STOP statement in a function terminates the function and the process that called it. If the process is periodic, the next execution will occur when the period expires; the STOP statement only ends the current execution of the process.

Usage Example IF ERROR? THEN STOP

This statement will end the process if the value of the variable error? is True.

TAN Function

Purpose Calculates the tangent of a numeric expression.

Format TAN (<EXPRESSION>)

<expression>

Any numeric expression.

Details The expression represents an angle in radians. The result of this function is a real number, and its reliability is the same as the reliability of the expression.

As the value of the numeric expression gets larger, this function may start to lose precision. When this happens, an imprecise value is returned, flagged unreliable. When the value of the expression gets too large for the function to calculate a value, it returns 0, flagged unreliable.

80 Command Reference

Page 177: Docs | Documents | Johnson Controls

Process Example The following process needs to be triggered externally; either by weekly scheduling or another process. It calculates the times of sunrise and sunset for the current day and stores these times in shared variables sunrise@ and sunset@ respectively. The TAN function is used here to calculate a parameter for calculating sunrise and sunset times.

PROCESS 'BUILDING\SUNRISE' “SUN RISE, SUN SET CALC” '\NC1'

REM -------------------------------------------------------------------------- REM

REM PURPOSE: CALCULATE SUNRISE AND SUNSET TIMES.

REM Revised: 4/95 added Meridan, simplified Julian date, fixed

REM errors in equation, Today usage

REM REVISED: 1/96, added parenthesis in SUNRISE calculation.

REM --------------------------------------------------------------------

REM

SHARED sunrise@,sunset@

DIM MONTH_OFFSET(12)

IF TRUE THEN

FIRST PASS

MONTH_OFFSET(1)=0

MONTH_OFFSET(2)=31

MONTH_OFFSET(3)=59

MONTH_OFFSET(4)=90

MONTH_OFFSET(5)=120

MONTH_OFFSET(6)=151

MONTH_OFFSET(7)=181

MONTH_OFFSET(8)=212

MONTH_OFFSET(9)=243

MONTH_OFFSET(10)=273

MONTH_OFFSET(11)=304

MONTH_OFFSET(12)=334

END FIRST PASS

END IF

MERIDIAN=90.0

REM - MERIDIAN for EASTERN =75.0, CENTRAL =90.0, MOUNTAIN=105.0,

REM PACIFIC =120.0

RAD=57.2956

LATITUDE=43.0 :REM LOCAL LATITUDE

LONGITUDE=87.9 :REM LOCAL LONGITUDE

DAY_OF_WK%=TODAY

Command Reference 81

Page 178: Docs | Documents | Johnson Controls

IF DAY_OF_WK% > 7 THEN DAY_of_WK%=DAY_OF_WK%-7

REM -- Fix for Alternate days Holiday may still cause a problem.

IF YEAR-YEAR/4*4=0 AND MONTH>2 THEN LEAP_YEAR%=1 ELSE LEAP_YEAR%=0

JULIAN_DATE%=DAY+MONTH_OFFSET(MONTH) +LEAP_YEAR%

REM SET JULIAN DATE TO CURRENT DAY PLUS MONTH OFFSET AND LEAP YEAR.

TOTAL_DAYS%=365+LEAP_YEAR% :REM NUMBER OF DAYS IN THE YEAR

DECLINATION=23.45*SIN(2*PI*(284+JULIAN_DATE%)/TOTAL_DAYS%)

EQ_OF_TIME=-(7.75*SIN(2*PI*(JULIAN_DATE%-4)/TOTAL_DAYS%)+\

10*SIN(4*PI*(JULIAN_DATE%+10)/TOTAL_DAYS%))

ARG=-1*TAN(LATITUDE/RAD)*TAN(DECLINATION/RAD)

TEMP=(PI/2-ARG-0.16667*ARG^3-0.075*ARG^5-0.0446428*ARG^7)*RAD

HALF_DAY=0.0666667*TEMP

IF JULIAN_DATE% -DAY_OF_WK%>=90+LEAP_YEAR% AND JULIAN_DATE%-DAY_OF_WK%\

<297+LEAP_YEAR% THEN DAYLIGHT%=1 ELSE DAYLIGHT%=0

SUNSET=12+HALF_DAY+(5-EQ_OF_TIME)/60+((LONGITUDE-MERIDIAN)*4)/60+\

0.00833+DAYLIGHT%

SUNRISE=12-(HALF_DAY+(5+EQ_OF_TIME)/60-((LONGITUDE-MERIDIAN)*4)/60)\

0.00833+DAYLIGHT%

SUNSET%=SUNSET*60 :REM CONVERT REAL NUMBERS TO TIME FORMAT

SUNRISE%=SUNRISE*60

sunset@=SUNSET%

sunrise@=SUNRISE%

END PROCESS

82 Command Reference

Page 179: Docs | Documents | Johnson Controls

TELL Statement

Purpose Sends a command to an object or attribute.

Formats TELL '<SYSTEM\OBJECT>' TO “<COMMAND>“ [<P1, P2, ..., PN>]

TELL '<SYSTEM\OBJECT\ATTRIBUTE>' TO “<COMMAND>“ [<P1, P2, ..., PN>]

<system name>

Name of the system that TELL statement is addressing; eight characters maximum.

<object name>

Name of the object that TELL statement is addressing; eight characters maximum.

<attribute>

Specific attribute to be commanded. To use this format, you must specify a specific attribute; the default attribute is not optional as it is for the LET statement.

<command>

Command in ASCII format that is valid for this object or attribute; for example, START, STOP, ENABLE, DISABLE.

[<p1, p2, ..., pn>]

Parameters the command requires, each separated by commas. The data types allowed are: integer, real, logical, text, and time.

Details The following criteria must be met for this command to compile properly:

• The object or attribute named in the TELL statement must already exist in the archive data base or the NCM. The object may be existing in the NCM if verifying against the field data base.

• The command specified must be valid for this particular object or attribute.

Command Reference 83

Page 180: Docs | Documents | Johnson Controls

• The parameters specified must be valid for this command. They must match exactly the number and types of the parameters as defined by the object manager. The one exception applies to integers and real numbers, which may be exchanged.

If an object name is to be passed as a parameter, it is passed as a text string. The object manager executing the command must parse the string.

Use commas to indicate optional parameters that you don’t wish to specify. Optional parameters at the end of a list can be left out.

The special keyword DELETE can be used to delete an optional attribute. Specify DELETE in the parameter list in place of the attribute you wish to delete. For example, the following deletes the high limit attribute for the FAN object: TELL 'AHU1\FAN' TO “ALARMS” 40,DELETE,5

A TELL command can also allow for one process to trigger another. The format is: TELL '<SYSTEM\OBJECT>' TO “TRIGGER”

Usage Example with START Command

TELL 'AHU1\FAN' TO “START” 4

Commands the fan associated with system AHU1 to turn on at command Priority 4.

Usage Example with SET_AOS (Adjust) Command

TELL 'AHU3\DMPR_4' TO “SET_AOS” ADJ_VALUE,2

Commands Damper 4 of system AHU3 to adjust at the level prescribed by the ADJ_VALUE variable at Priority 2.

Usage Example with ALARMS and DELETE Commands

TELL 'X\Y' TO “ALARMS” 7.6, DELETE, DIF/2

Commands the limit attribute for the object named Y on system X to accept two new attribute values and delete the second attribute value.

Usage Example with SET_PIDL Commands

TELL 'AHU1\PIDL\OFFSET' TO “SET_PIDL” 55.0, 2

Commands the OFFSET attribute of the PIDL named `AHU1\PIDL’ to take on the value 55.0 at Priority 2.

84 Command Reference

Page 181: Docs | Documents | Johnson Controls

Process Example The following is an event triggered process which is triggered when the shared variable summer? changes. The TELL command will change the high alarm limit of RTU_1\MA_TMP to 75 degrees when summer? is True. The second TELL command will change the high alarm limit to 130 degrees if summer? is False. The low alarm limit and differential won’t be changed.

PROCESS 'RTU_1\LIMIT' “SEASON LIMIT CHANGE” '\OFFIC_NC'

REM --------------------------------------------------------------------

REM

REM PURPOSE: CHANGE MIXED AIR HIGH ALARM LIMIT BASED ON SEASON.

REM

REM --------------------------------------------------------------------

REM

SHARED summer?

IF summer? THEN

TELL 'RTU_1\MA_TMP' TO “ALARMS” ,75,

ELSE

TELL 'RTU_1\MA_TMP' TO “ALARMS” ,130,

END IF

END PROCESS

summer?--A shared variable of type Boolean.

RTU\MA_TMP--Analog Input object representing the mixed air temperature of roof top unit 1.

Command Reference 85

Page 182: Docs | Documents | Johnson Controls

Table 1 lists the commands and parameters for each object type.

Table 1: Commands per Object Type

Object Type Commands Parameters Comments Access Controller

(D600) LOC_TRIG None Disable process triggering.

UNL_TRIG None Enable process triggering. Accumulator LOC REP None Disable COS annunciation. UNL_REP None Enable COS annunciation. LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. ALARMS Low limit High limit Set/change alarm parameters. Differential WARNINGS Setpoint Set/change warning parameters. Normalband Either both setpoint and

normalband must be in the command with specified values

Feedback time or both must be absent.

Differential Analog Data LOC_REP None Disable COS annunciation. UNL_REP None Enable COS annunciation. LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. ALARMS Low limit High limit Set/change alarm parameters. Differential WARNINGS Setpoint Set/change warning parameters. Normalband Either both setpoint and

normalband must be in the command with specified values

Feedback time or both must be absent.

Differential SET_AD Value,

Priority (2 or 3) At Priority 2 override value. At Priority 3 replace value.

RELEASE None Release Priority 2 value. Continued on next page . . .

86 Command Reference

Page 183: Docs | Documents | Johnson Controls

Object Type (Cont.)

Commands Parameters Comments

Analog Input LOC REP None Disable COS annunciation. UNL_REP None Enable COS annunciation. LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. ALARMS Low limit High limit Set/change alarm parameters. Differential WARNINGS Setpoint Set/change warning parameters. Normalband Either both setpoint and

normalband must be in the command with specified values

Feedback time or both must be absent.

Differential Analog Output LOC_REP None Disable COS annunciation. Digital UNL_REP None Enable COS annunciation. LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. SET_AOD Value Override output at Priority 2. RELEASE None Release Priority 2 value. Analog Output

Setpoint LOC_REP None Disable COS annunciation.

UNL_REP None Enable COS annunciation. LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. SET_AOS Value,

Priority (2 or 3) At Priority 2 override value. At Priority 3 replace value.

RELEASE None Release Priority 2 value. RELEASE 3 None Release Priority 3 value. Binary Data LOC_REP None Disable COS annunciation. UNL_REP None Enable COS annunciation. LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering SET_BD Value,

Priority (2 or 3) At Priority 2 override value. At Priority 3 replace value.

REL_ALL None Releases Priorities 1 and 2. Moves current highest priority command to Priority 3.

RELEASE None Release Priority 2 value. UNLATCH None Reset latched condition. Continued on next page . . .

Command Reference 87

Page 184: Docs | Documents | Johnson Controls

Object Type (Cont.)

Commands Parameters Comments

Binary Input LOC_REP None Disable COS annunciation. UNL_REP None Enable COS annunciation. LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. UNLATCH None Reset latched condition. Binary Output LOC_REP None Disable COS annunciation. UNL_REP None Enable COS annunciation. LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. REL_ALL None Releases any Priorities 1-7.

Moves current highest priority command to Priority 8.

REL_PRI Priority Release at specified priority. START Priority Output state 1 at Priority. STOP Priority Output state 0 at Priority. C210A LOC_REP None Disable COS annunciation. UNL_REP None Enable COS annunciation. LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. ST210AAN* Value Override value of attribute at

Priority 2.

ST210ABN* Value Override value of attribute at Priority 2.

ST210ASP* Value, Priority (2 or 3)

At Priority 2 override value of attribute. At Priority 3 replace value of attribute.

REL_210A* Priority (2 or 3) Release at specified priority. * Must specify attribute. Continued on next page . . .

88 Command Reference

Page 185: Docs | Documents | Johnson Controls

Object Type (Cont.)

Commands Parameters Comments

C260A LOC_REP None Disable COS annunciation. UNL_REP None Enable COS annunciation. LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. ST260AAN* Value Override value of attribute at

Priority 2.

ST260ABN* Value Override value of attribute at Priority 2.

ST260ASP* Value, Priority (2 or 3)

At Priority 2 override value of attribute. At Priority 3 replace value of attribute.

REL_260A* Priority (2 or 3) Release at specified priority. * Must specify attribute. C260X LOC_REP None Disable COS annunciation. UNL_REP None Enable COS annunciation. LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. ST260XAN* Value Override value of attribute at

Priority 2.

ST260XBN* Value Override value of attribute at Priority 2.

ST260XSP* Value, Priority (2 or 3)

At Priority 2 override value of attribute. At Priority 3 replace value of attribute.

REL_260X* Priority (2 or 3) Release at specified priority. * Must Specify Attribute. C500X LOC_REP None Disable COS annunciation. UNL_REP None Enable COS annunciation. LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. ST500XAN* Value Override value of attribute at

Priority 2.

ST500XBN* Value Override value of attribute at Priority 2.

ST500XSP* Value, Priority (2 or 3)

At Priority 2 override value of attribute. At Priority 3 replace value of attribute.

REL_500X* Priority (2 or 3) Release at specified priority. * Must Specify Attribute. Continued on next page . . .

Command Reference 89

Page 186: Docs | Documents | Johnson Controls

Object Type (Cont.)

Commands Parameters Comments

Control System LOC_REP None Disable COS annunciation. UNL_REP None Enable COS annunciation. LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. STCSAN* Value,

Priority (2 or 3) At Priority 2 override value of attribute. At Priority 3 adjust value of attribute.

STCSBN* Value, Priority (2 or 3)

At Priority 2 override value of attribute. At Priority 3 adjust value of attribute.

STCSMS* Value Priority (2 or 3)

At Priority 2 override value of attribute. At Priority 3 adjust value of attribute.

REL_CS* Priority (2 or 3) At Priority 2 release override of attribute. At Priority 3 release adjust of attribute.

* Must specify attribute. Must know from the software model the CS object is based on whether the attribute is defined to be adjustable. For STCSAN, STCSBN, and STCSMS commands, must know which attributes are valid for each command.

DCDR LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. DCM LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. DCM140 LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. DSC8500 LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. DSC-1000 LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. Expansion

Module (XM) LOC_TRIG None Disable process triggering.

UNL_TRIG None Enable process triggering. FIRE LOC_REP None Disable COS annunciation. UNL_REP None Enable COS annunciation. LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. Continued on next page . . . Object Type

(Cont.) Commands Parameters Comments

FPU LOC_TRIG None Disable process triggering.

90 Command Reference

Page 187: Docs | Documents | Johnson Controls

UNL_TRIG None Enable process triggering. JC-BASIC PRC_ENA None Enable process operation. PRC_DIS None Disable process operation. TRIGGER None Force a JC-BASIC process to run. Lighting Controller LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. Lighting Control

Group LOC_REP None Disable COS annunciation.

UNL_REP None Enable COS annunciation. LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. TIMED_ON Hours

(optional) Timed override for hours or default time if hours omitted.

ON None Turn group on, will override LC schedule.

OFF None Turn group off, will override LC schedule.

RELEASE None Release JC-BASIC control. MC LOC_REP None Disable COS annunciation. UNL_REP None Enable COS annunciation. LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. RELEASE None Release Priority 2 value. SET_MC Value At Priority 2 override value. Priority (2 or 3) At Priority 3 replace value. UNLATCH None Reset latched condition. MSD LOC_REP None Disable COS annunciation. UNL_REP None Enable COS annunciation. LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. REL_ALL None Release Priorities 1 and 2. Moves

current highest priority command to Priority 3.

Continued on next page . . .

Command Reference 91

Page 188: Docs | Documents | Johnson Controls

Object Type (Cont.)

Commands Parameters Comments

MSD RELEASE None Release Priority 2 value. SET_MC Value,

Priority (2 or 3) At Priority 2 override value. At Priority 3 replace value.

UNLATCH None Reset latched condition. MSI LOC_REP None Disable COS annunciation. UNL_REP None Enable COS annunciation. LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. UNLATCH None Reset latched condition. MSO LOC_REP None Disable COS annunciation. UNL_REP None Enable COS annunciation. LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. REL_ALL None Releases any Priorities 1-7.

Moves current highest priority command to Priority 8.

REL_PRI Priority Release at specified priority. SET_MSO Value,

Priority (2 or 3) At Priority 2 override value. At Priority 3 replace value.

N2OPEN LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. PID Controller LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. PID Loop LOC_REP None Disable COS annunciation. UNL_REP None Enable COS annunciation. LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. AUX_ENA None Allow Aux input to pass through

PID loop.

AUX_DIS None Don’t allow Aux input to pass through PID loop.

SET_PIDL* Value, Priority (2 or 3)

At Priority 2 override value of attribute. At Priority 3 replace value of attribute.

REL_PIDL* None Release Priority 2 value of attribute.

* Must specify attribute : TELL '<sys\obj\attribute>' TO “<command>“ [<p1, p2,... pn>]. Valid attributes are: INP1VAL, INP2VAL, INP3VAL, INP4VAL, INP5VAL, INP6VAL, SETPOINT, OFFSET, HI_SAT_V, LO_SAT_V, AUX_IN, SEL_INP

Continued on next page . . .

92 Command Reference

Page 189: Docs | Documents | Johnson Controls

Object Type (Cont.)

Commands Parameters Comments

PID Loop STARTUP None Restart PID algorithm. READER LOC_REP None Disable COS annunciation. UNL_REP None Enable COS annunciation. LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering. Trend BEG_TRND None Start trend sampling for attribute.

Must specify attribute.

END_TRND None Stop trend sampling for attribute. Must specify attribute.

Totalization BEG_TOT None Start tot sampling for attribute. Must specify attribute.

END_TOT None Stop tot sampling for a attribute. Must specify attribute.

RES_TOT Value Reset totalized value of specified attribute. Must specify attribute.

Demand Limiting and Load Rolling

DL_MON None Monitor only--inhibits further load shedding by DL.

DL_SHED None Enables load shedding by DL. DL_TARGT Value, Level (0-3) Change demand limit target. LOC_LOAD System\object Don't allow load to be shed. LOC_REP None Disable COS annunciation. LOC_TRIG None Disable process triggering. LR_MON None Monitor only--inhibits further load

shedding by LR.

LR_SHED None Enables load shedding by LR. LR_TARGT Value, Level (0-3) Change load rolling target. RESETPER None Set current demand and

consumption to 0.

UNL_LOAD System\object Allow load to be shed. UNL_REP None Enable COS annunciation. UNL_TRIG None Enable process triggering. ZONE LOC_REP None Disable COS annunciation. UNL_REP None Enable COS annunciation. LOC_TRIG None Disable process triggering. UNL_TRIG None Enable process triggering.

Command Reference 93

Page 190: Docs | Documents | Johnson Controls

TIME Function

Purpose Retrieves the current time of day.

Format TIME

Details This function uses a 24-hour format for expressing time (00:00:00 to 23:59:59), where 00:00:00 is midnight and 12:00:00 is noon.

Process Example The following is a periodic process as defined by PERIOD 00:10:00. The IF command will compare the current time of day, via the TIME function, to the value stored in the shared variable sunrise@. If the current time is greater than sunrise@, the TELL and PERIOD commands will be executed.

PROCESS'LIGHTING\PARKING' “PARKING LOT LIGHTS OFF" '\EAST_NC'

REM --------------------------------------------------------------------

REM

REM PURPOSE: TURN OFF PARKING LOT LIGHTS AT SUNRISE.

REM

REM --------------------------------------------------------------------

REM

SHARED sunrise@

PERIOD 00:10:00

IF TIME>sunrise@ THEN

TELL 'LIGHTING\PARKING' TO “STOP” 7

PERIOD 00:00:00

END IF

END PROCESS

sunrise@-- shared variable of type time.

LIGHTING\PARKING--Binary Output object for parking lot lights.

94 Command Reference

Page 191: Docs | Documents | Johnson Controls

TIME$ Function

Purpose Places the current time into an ADVISORY (or ADVISORY USING) and PRINT (or PRINT USING) statement.

Format TIME$

Details This function sends out an eight-character string of the form HH:MM:SS (hours, minutes and seconds). You can use it only in ADVISORY, ADVISORY USING, PRINT, and PRINT USING statements.

Process Example The following is an event triggered process. When the building changes to the occupied mode, BUILDING\OCCUPIED is True, this process will start the four roof top fans, release the room temperature setpoints to their normal value, and print the following message:

The building is in OCCUPIED mode at 6:30:15 03/23/1990.

The time is inserted by the TIME$ function.

When the building changes to the unoccupied mode, BUILDING\OCCUPIED is False, this process will stop the four roof top fans, change the room setpoints to the night setback value, and print:

The building is in UNOCCUPIED mode at 18:00:05 03/23/1990.

PROCESS 'BUILDING\OCC_UNOC' “OCCUPIED/UNOCCUPIED” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: SET INITIAL CONDITIONS FOR OCC/UNOC MODES OF OPERATION.

REM THIS PROCESS WILL BE TRIGGER WHEN WEEKLY SCHEDULE COMMANDS

REM BUILDING\OCCUPIED.

REM

REM --------------------------------------------------------------------

REM

IF 'BUILDING\OCCUPIED' THEN :REM START THE FANS

TELL 'RTU_1\FAN_SST' TO “START” 7

TELL 'RTU_2\FAN_SST' TO “START” 7

TELL 'RTU_3\FAN_SST' TO “START” 7

TELL 'RTU_4\FAN_SST' TO “START” 7

Command Reference 95

Page 192: Docs | Documents | Johnson Controls

TELL 'RTU_1\ROOM_SP' TO “RE;EASE” :REM ROOM SETPOINT TO NORMAL

TELL 'RTU_2\ROOM_SP' TO “RELEASE”

TELL 'RTU_3\ROOM_SP' TO “RELEASE”

TELL 'RTU_4\ROOM_SP' TO “RELEASE”

PRINT '\PC_PTR' “THE BUILDING IS IN OCCUPIED MODE AT “,TIME$,DATE$

ELSE :REM STOP THE FANS

TELL 'RTU_1\FAN_SST' TO “STOP” 7

TELL 'RTU_2\FAN_SST' TO “STOP” 7

TELL 'RTU_3\FAN_SST' TO “STOP” 7

TELL 'RTU_4\FAN_SST' TO “STOP” 7

:REM ROOM SETPOINT TO NIGHT SET BACK

TELL 'RTU_1\ROOM_SP' TO “SET_AD” 'BUILDING\SETBACK',2

TELL 'RTU_2\ROOM_SP' TO “SET_AD” 'BUILDING\SETBACK',2

TELL 'RTU_3\ROOM_SP' TO “SET_AD” 'BUILDING\SETBACK',2

TELL 'RTU_4\ROOM_SP' TO “SET_AD” 'BUILDING\SETBACK',2

PRINT '\PC_PTR' “THE BUILDING IS IN UNOCCUPIED MODE AT “,TIME$,DATE$

END IF

END PROCESS

BUILDING\OCCUPIED--A Binary Data object, which contains the occupied/unoccupied status of the building.

RTU_1\FAN_SST through RTU_4\FAN_SST--Binary Output objects, which starts and stops roof top unit fans.

RTU_1\ROOM_SP through RTU_4\ROOM_SP--Analog Data objects, which contain room temperature setpoints for areas served by the roof top units.

96 Command Reference

Page 193: Docs | Documents | Johnson Controls

TIME_TO_INT Function

Purpose Returns a time value as an integer.

Format TIME_TO_INT (<time expression>, <UNITS>)

<time expression>

Time expression whose value will be converted to an integer. This function uses a 24-hour format for expressing time (00:00:00 to 23:59:59), where 00:00:00 is midnight and 12:00:00 is noon.

<units>

Units of time, either seconds or minutes. Entire word must be spelled out; any combination of lower and upper case letters is allowed.

Details If the time expression is within the valid range (00:00:00 to 23:59:59), the reliability of the output is determined by the reliability of the time expression. If the time expression is less than 00:00:00, the output is 0 flagged unreliable. If the time expression is greater than 23:59:59, the output is 86399 flagged unreliable if the units are seconds, and 1439 flagged unreliable if the units are minutes.

If the units are minutes and the time expression includes 30 seconds or greater, the time expression is rounded up to the next highest minute. For example, 22:30:34 would be rounded up to 22:31:00.

Usage Examples rem convert time to seconds

outreal! = time_to_int(timevalue@, SECONDS)

outint% = time_to_int(timevalue@, SECONDS)

rem convert time to minutes

outreal! = time_to_int(timevalue@, MINUTES)

outint% = time_to_int(timevalue@, MINUTES)

Command Reference 97

Page 194: Docs | Documents | Johnson Controls

TODAY Function

Purpose Retrieves the current day of the week.

Format TODAY

Details This function sends out the day as an integer from 1 to 15, where:

1 Sunday 8 Alternate Sunday

2 Monday 9 Alternate Monday

3 Tuesday 10 Alternate Tuesday

4 Wednesday 11 Alternate Wednesday

5 Thursday 12 Alternate Thursday

6 Friday 13 Alternate Friday

7 Saturday 14 Alternate Saturday

15 Holiday

The reliability of the result is based on the reliability returned from the time-of-day manager.

Usage Example #REPLACE SUNDAY# “1”

IF TODAY=SUNDAY# THEN . . .

Process Example The following is a periodic process which will run once a day. The statements under the IF-THEN will execute on regular (1) and alternate (8) Sundays. The TOTAL function will retrieve the totalized data for the system\object\attribute. The PRINT statement will output the text and totalized value to printer PC_PTR.

PROCESS 'BUILDING\TOT_DATA' “PRINT TOTALIZED DATA” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: READ AND PRINT FAN RUN TIME DATA EVERY SUNDAY.

REM

REM

REM --------------------------------------------------------------------

REM

PERIOD 23:59:59

IF TODAY=1 OR TODAY=8 THEN :REM IS IT SUNDAY?

98 Command Reference

Page 195: Docs | Documents | Johnson Controls

tot=TOTAL('AHU_1\FAN_STAT\VALUE')

PRINT '\PC_PTR' “AHU_1 FAN RUN TIME =“,tot,”HOURS”

tot=TOTAL('AHU_2\FAN_STAT\VALUE')

PRINT '\PC_PTR' “AHU_2 FAN RUN TIME =“,tot,”HOURS”

tot=TOTAL('AHU_3\FAN_STAT\VALUE')

PRINT '\PC_PTR' “AHU_3 FAN RUN TIME =“,tot,”HOURS”

tot=TOTAL('AHU_4\FAN_STAT\VALUE')

PRINT '\PC_PTR' “AHU_4 FAN RUN TIME =“,tot,”HOURS”

END IF

END PROCESS

tot--Local variable of type real.

AHU_1\FAN_STAT\VALUE through AHU_4\FAN_STAT\VALUE--Attribute of AHU_4\FAN_STAT, which is being totalized by the Totalization feature.

TOTAL Function

Purpose Retrieves the current period totalization for a non-array attribute.

Format TOTAL ('<SYSTEM NAME>\<OBJECT NAME>\<ATTRIBUTE>')

<system name>

Name of the system that has this object defined; eight characters maximum.

<object name>

Name assigned to identify this object; eight characters maximum.

<attribute>

Name of attribute that has been totalized; eight characters maximum.

Command Reference 99

Page 196: Docs | Documents | Johnson Controls

Details This function returns a real number. For runtime totalization, the number returned is the time count in minutes. If the attribute is not currently assigned to totalization, or no response is given to the data request, the value of the function will be zero and flagged unreliable.

Usage Example LET A=TOTAL ('AHU1\MTR\VALUE')

Process Example The following is a periodic process which will run once a day. The TOTAL function will retrieve the totalized data for each AHU FAN_STAT VALUE attribute. The PRINT statement will output the text and totalized value to printer PC_PTR.

PROCESS 'BUILDING\TOT_DATA' “PRINT TOTALIZED DATA” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: READ AND PRINT FAN RUN TIME DATA EVERY SUNDAY.

REM

REM

REM --------------------------------------------------------------------

REM

PERIOD 23:59:59

IF TODAY=1 OR TODAY=8 THEN :REM IS IT SUNDAY?

tot=TOTAL('AHU_1\FAN_STAT\VALUE')

PRINT '\PC_PTR' “AHU_1 FAN RUN TIME =“,tot,”HOURS”

tot=TOTAL('AHU_2\FAN_STAT\VALUE')

PRINT '\PC_PTR' “AHU_2 FAN RUN TIME =“,tot,”HOURS”

tot=TOTAL('AHU_3\FAN_STAT\VALUE')

PRINT '\PC_PTR' “AHU_3 FAN RUN TIME =“,tot,”HOURS”

tot=TOTAL('AHU_4\FAN_STAT\VALUE')

PRINT '\PC_PTR' “AHU_4 FAN RUN TIME =“,tot,”HOURS”

END IF

END PROCESS

tot--Local variable of type real.

AHU_1\FAN_STAT\VALUE through AHU_4\FAN_STAT\VALUE--Attribute of AHU_4\FAN_STAT, which is being totalized by the Totalization feature.

100 Command Reference

Page 197: Docs | Documents | Johnson Controls

UNRELIABLE Function

Purpose Returns a True value if the expression evaluates to an unreliable value; otherwise, it returns False.

Format UNRELIABLE <EXPRESSION>

<expression>

Any valid expression.

Details This function returns a True status if and only if the value of the expression is unreliable; otherwise, it returns a False status.

The logical result of this function is always reliable.

Usage Example IF UNRELIABLE (x) THEN

'AHU1\PID_L3\SETPOINT' = DEFAULT

ELSE

'AHU1\PID_L3\SETPOINT' = X

END IF

X? = UNRELIABLE (X)

Y? = UNRELIABLE (Y)

IF X? OR Y? THEN.....

WAIT Statement

Purpose Temporarily delays process execution.

Format WAIT <TIME EXPRESSION>

<time expression>

Waiting period from 00:00:01 to 23:59:59.

Details You may combine the WAIT statement with the WHILE loop to build a customized periodic algorithm, delay between interlock subordinate commands, or perform minimum on/off time delays.

A trigger that occurs while a WAIT delay is in progress will interrupt the WAIT and resume execution at the beginning of the process.

Command Reference 101

Page 198: Docs | Documents | Johnson Controls

If you specify a wait period of zero seconds, the interpreter issues a runtime error message and skips over the WAIT statement.

Usage Example WAIT 00:00:10

This example specifies a WAIT statement of ten seconds. WAIT X@ + Y@

IF X? THEN WAIT X@ + Y@

WETDP Function

Purpose Calculates the wet bulb temperature from a dry bulb temperature, dew point temperature, and barometric pressure.

Format

WETDP (<DRY BULB TEMPERATURE>, <DEW POINT TEMPERATURE>, <BAROMETRIC PRESSURE>,

<UNITS>)

<dry bulb temperature>

Current floating point value of the dry bulb sensor. Range: -147.9 to 391.9°F (-99.9 to 199.9°C)

<dew point temperature>

Current floating point value of the dew point sensor. Range: -147.9 to 391.9°F (-99.9 to 199.9°C)

<barometric pressure>

Range: 15.00 to 32.00 in. Hg

<units>

Units of measurement, either English or Metric.

102 Command Reference

Page 199: Docs | Documents | Johnson Controls

Details The sensed dry bulb temperature and dew point temperature are entered into the wet bulb equation. This equation is equivalent to the ASHRAE standard for calculating wet bulb temperature. (For details, see ASHRAE Handbook of Fundamentals, American Society of Heating, Refrigerating, and Air Conditioning Engineers, Atlanta, Chapter 6, 1985.)

The reliability of the inputs determine the reliability of the output. If any input is deemed unreliable, the output is flagged as unreliable. An input that is outside the prescribed range would make it unreliable.

Process Example The following is a periodic process which executes every 30 minutes as defined by PERIOD 00:30:00. The wet bulb temperature of the outside air is calculated by the WETDP function which uses the outside air dry bulb temperature and the outside air dew point temperature. The 29.9 specifies the barometric pressure. ENGLISH specifies the units of the inputs and result of the WETDP function. The result of the WETDP function is stored in Analog Data object BUILDING\OA_WET by the TELL command so that it can be displayed by an operator.

PROCESS 'BUILDING\WETBULB' “WET BULB TEMP CALC” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: CALCULATE THE OUTSIDE AIR WET BULB TEMPERATURE & DISPLAY AS

REM OBJECT BUILDING\OA_WET.

REM

REM --------------------------------------------------------------------

REM

PERIOD 00:30:00 :REM CALCULATE EVERY 30 MINUTES

oa_wet=WETDP('BUILDING\OA_TMP','BUILDING\OA_DP',29.9,ENGLISH)

TELL 'BUILDING\OA_WET' TO “SET_AD” oa_wet,3

END PROCESS

BUILDING\OA_TMP--Analog Input object of outside air temperature.

BUILDING\OA_DP--Analog Input object of outside air dew point temperature.

Command Reference 103

Page 200: Docs | Documents | Johnson Controls

BUILDING\OA_WET--Analog Data object of calculated outside air wet bulb temperature.

oa_wet--Local variable of type real which holds the result of the WETDP function.

WETRH Function

Purpose Calculates the wet bulb temperature from a dry bulb temperature, relative humidity, and barometric pressure.

Format WETRH (<DRY BULB TEMPERATURE>, <RELATIVE HUMIDITY>, <BAROMETRIC PRESSURE>,

<UNITS>)

<dry bulb temperature>

Current floating point value of the dry bulb sensor. Range: -47.9 to 391.9°F (-99.9 to 199.9°C).

<relative humidity>

Current floating point value of the relative humidity sensor. Range: 0 to 100% (If 0% is entered, 0.1 is used.)

<barometric pressure>

Range: 15.00 to 32.00 in. Hg

<units>

Units of measurement, either English or Metric.

Details The sensed dry bulb temperature and relative humidity are entered into the wet bulb equation. This equation is equivalent to the ASHRAE standard for calculating wet bulb temperature. (For details, see ASHRAE Handbook of Fundamentals, American Society of Heating, Refrigerating, and Air Conditioning Engineers, Atlanta, Chapter 6, 1985.)

The reliability of the inputs determines the reliability of the output. If any input is deemed unreliable, the output is flagged as unreliable. An input that is outside the prescribed range would make it unreliable.

104 Command Reference

Page 201: Docs | Documents | Johnson Controls

Process Example The following is a periodic process which executes every 30 minutes as defined by PERIOD 00:30:00. The wet bulb temperature of the outside air is calculated by the WETRH function which uses the outside air dry bulb temperature and the outside air humidity. The 29.9 specifies the barometric pressure. ENGLISH specifies the units of the inputs and result of the WETRH function. The result of the WETRH function is stored in Analog Data object BUILDING\OA_WET by the TELL command so that it can be displayed by an operator.

PROCESS 'BUILDING\WETBULB' “WET BULB TEMP CALC” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: CALCULATE THE OUTSIDE AIR WET BULB TEMPERATURE & DISPLAY AS

REM OBJECT BUILDING\OA_WET.

REM

REM --------------------------------------------------------------------

REM

PERIOD 00:30:00 :REM CALCULATE EVERY 30 MINUTES

oa_wet=WETRH('BUILDING\OA_TMP','BUILDING\OA_HUM',29.9,ENGLISH)

TELL 'BUILDING\OA_WET' TO “SET_AD” oa_wet,3

END PROCESS

BUILDING\OA_TMP--Analog Input object of outside air temperature.

BUILDING\OA_HUM--Analog Input object of outside air humidity.

BUILDING\OA_WET--Analog Data object of calculated outside air wet bulb temperature.

oa_wet--Local variable of type real that holds the result of the WETRH function.

Command Reference 105

Page 202: Docs | Documents | Johnson Controls

WHILE END-WHILE Loop

Purpose Executes a block of statements in a loop as long as a given condition is True.

Format WHILE <EXPRESSION>

<STATEMENTS>

END WHILE

<expression>

Any logical expression.

<statements>

Any valid statements.

Details If the expression in the WHILE statement is True, the loop statements are executed. The loop continues to execute until the expression becomes False, at which point control passes to the next statement that immediately follows the END WHILE statement.

The WHILE loop can be nested to any level. For each WHILE statement, you must have a corresponding END WHILE statement. The compiler returns an error if a WHILE statement is missing its matching END WHILE statement, and vice versa.

SHARED COOLING?

WHILE ‘AHU1\OUTDOOR' <70.0

END WHILE

If a process enters into an infinite loop (which happens if the WHILE condition is always True), the looping process will in effect hang and hold up all other processes as well. This doesn’t apply to a WAIT statement.

Usage Example COOLING?=FALSE

WAIT 00:15

COOLING?=TRUE

106 Command Reference

Page 203: Docs | Documents | Johnson Controls

Process Example The following is an event triggered process. It will be triggered when summer? or AHU_1\FAN_STAT change. When summer? and AHU_1\FAN_STAT are both True, the statements between the WHILE and the END WHILE will be executed. This will continue until either summer? or AHU_1\FAN_STAT is False. The WAIT statement will cause the process to stop execution. After five minutes, execution will resume. While this process is in a wait state, other processes can execute.

PROCESS 'AHU_1\COOLING' “COOLING PROCESS” '\NC1'

REM --------------------------------------------------------------------

REM

REM PURPOSE: TURN THE COOLING STAGE ON OR OFF AS REQUIRED.

REM

REM --------------------------------------------------------------------

REM

SHARED summer?

WHILE 'AHU_1\FAN_STAT'=ON AND summer?=TRUE

IF NOT('AHU_1\ROOM_TMP'>='AHU_1\ROOM_SP' DIFF 1.0) THEN

TELL 'AHU_1\CLG_STG' TO “START” 4

ELSE

TELL 'AHU_1\CLG_STG' TO “STOP” 4

END IF

WAIT 00:05:00 :REM DELAY PROCESS FOR 5 MINUTES

END WHILE

END PROCESS

summer?--Shared variable of type Boolean that represents the season state.

AHU_1\FAN_STAT--Binary Input object of AHU1 fan status.

AHU_1\CLG_STG--Binary Output object of AHU1 cooling stage start/stop.

AHU_1\ROOM_TMP--Analog Input object of room temperature served by AHU1.

AHU_1\ROOM_SP--Analog Data object of room temperature setpoint for area served by AHU1.

Command Reference 107

Page 204: Docs | Documents | Johnson Controls

YEAR Function

Purpose Retrieves the current year.

Format YEAR

Details This function returns the current year in the form YYYY (e.g., 989). The reliability of the result is based on the reliability returned from the time-of-day manager.

Usage Example REM CHECK FOR LEAP YEAR

IF (YEAR_(YEAR/4)*4)=0 THEN

LEAPYEAR?=TRUE

ELSE

LEAPYEAR?=FALSE

END IF

Process Example This process needs to be triggered externally; either by weekly scheduling or another process. It calculates the times of sunrise and sunset for the current day and stores these times in shared variables sunrise@ and sunset@ respectively. The YEAR function is used here to determine if the present year is a leap year.

PROCESS 'BUILDING\SUNRISE' “SUN RISE, SUN SET CALC” '\NC1'

REM -------------------------------------------------------------------------- REM

REM PURPOSE: CALCULATE SUNRISE AND SUNSET TIMES.

REM Revised: 4/95 added Meridan, simplified Julian date, fixed

REM errors in equation, Today usage

REM REVISED: 1/96, added parenthesis in SUNRISE calculation.

REM --------------------------------------------------------------------

REM

SHARED sunrise@,sunset@

DIM MONTH_OFFSET(12)

IF TRUE THEN

FIRST PASS

MONTH_OFFSET(1)=0

MONTH_OFFSET(2)=31

MONTH_OFFSET(3)=59

MONTH_OFFSET(4)=90

MONTH_OFFSET(5)=120

108 Command Reference

Page 205: Docs | Documents | Johnson Controls

Command Reference 109

MONTH_OFFSET(6)=151

MONTH_OFFSET(7)=181

MONTH_OFFSET(8)=212

MONTH_OFFSET(9)=243

MONTH_OFFSET(10)=273

MONTH_OFFSET(11)=304

MONTH_OFFSET(12)=334

END FIRST PASS

END IF

MERIDIAN=90.0

REM - MERIDIAN for EASTERN =75.0, CENTRAL =90.0, MOUNTAIN=105.0,

REM PACIFIC =120.0

RAD=57.2956

LATITUDE=43.0 :REM LOCAL LATITUDE

LONGITUDE=87.9 :REM LOCAL LONGITUDE

DAY_OF_WK%=TODAY

IF DAY_OF_WK% > 7 THEN DAY_of_WK%=DAY_OF_WK%-7

REM -- Fix for Alternate days Holiday may still cause a problem.

IF YEAR-YEAR/4*4=0 AND MONTH>2 THEN LEAP_YEAR%=1 ELSE LEAP_YEAR%=0

JULIAN_DATE%=DAY+MONTH_OFFSET(MONTH) +LEAP_YEAR%

REM SET JULIAN DATE TO CURRENT DAY PLUS MONTH OFFSET AND LEAP YEAR.

TOTAL_DAYS%=365+LEAP_YEAR% :REM NUMBER OF DAYS IN THE YEAR

DECLINATION=23.45*SIN(2*PI*(284+JULIAN_DATE%)/TOTAL_DAYS%)

EQ_OF_TIME=-(7.75*SIN(2*PI*(JULIAN_DATE%-4)/TOTAL_DAYS%)+\

10*SIN(4*PI*(JULIAN_DATE%+10)/TOTAL_DAYS%))

ARG=-1*TAN(LATITUDE/RAD)*TAN(DECLINATION/RAD)

TEMP=(PI/2-ARG-0.16667*ARG^3-0.075*ARG^5-0.0446428*ARG^7)*RAD

HALF_DAY=0.0666667*TEMP

IF JULIAN_DATE% -DAY_OF_WK%>=90+LEAP_YEAR% AND JULIAN_DATE%-DAY_OF_WK%\

<297+LEAP_YEAR% THEN DAYLIGHT%=1 ELSE DAYLIGHT%=0

SUNSET=12+HALF_DAY+(5-EQ_OF_TIME)/60+((LONGITUDE-MERIDIAN)*4)/60+\

0.00833+DAYLIGHT%

SUNRISE=12-(HALF_DAY+(5+EQ_OF_TIME)/60-((LONGITUDE-MERIDIAN)*4)/60)\

0.00833+DAYLIGHT%

SUNSET%=SUNSET*60 :REM CONVERT REAL NUMBERS TO TIME FORMAT

SUNRISE%=SUNRISE*60

sunset@=SUNSET%

sunrise@=SUNRISE%

END PROCESS

Page 206: Docs | Documents | Johnson Controls

JC-BASIC Programmer’s Manual

Reference

Reference Overview 3

Appendix A: Application Example 5 l Specification 5 l Source Code 6

Appendix B: Syntax Rules 9 l Syntax for Statements and Functions 11 l Syntax for Numbers 13 l Syntax Maximums 13 l Guidelines 14 l Programming Recommendations 14 l Programming Tips 14

Appendix C: Syntax In Backus-Naur Form 15 l Notation Overview 15 l Rules 16 l Lexical Considerations 22 l Compiler Directives 23 l Semantic Notes 23

Appendix D: Error Messages 25 l Compiler Error Messages 25

Appendix E: Quick Reference Tables 31 l Keywords 31 l Reserved Constants *32 l Operators 33 l Statements 33 l Functions 34 l Special Characters 35 l JC-BASIC NCM Data Attribute and Command Descriptions *36

* Indicates those sections where changes have occurred since the last printing.

© November, 1996 Johnson Controls, Inc. 1 Code No. LIT-632050

Page 207: Docs | Documents | Johnson Controls

2 Reference

Page 208: Docs | Documents | Johnson Controls

Reference Overview

This section contains five appendixes of helpful information:

Appendix A is an application example of JC-BASIC source code.

Appendix B explains the syntax rules for writing processes in JC-BASIC.

Appendix C lists the JC-BASIC syntax in Backus-Naur form.

Appendix D is a table of compiler error messages.

Appendix E contains complete lists of JC-BASIC keywords, reserved constants, operators, statements, functions, special characters, and NCM data attribute and command descriptions.

Reference 3

Page 209: Docs | Documents | Johnson Controls

4 Reference

Page 210: Docs | Documents | Johnson Controls

Appendix A:

Application Example

The following example represents a partial system that is the JC-BASIC source code to satisfy the given specification.

Economizer: The economizer will override the damper control to the minimum outdoor air position when the outdoor air enthalpy exceeds the return air enthalpy.

Specification

Supply fan start/stop control: The supply fan start/stop request will be issued based on time scheduled occupancy. If the fan alarm occurs, a stop request is issued and the fan is locked out. This alarm must be reset manually.

Return fan start/stop: When the supply fan is started, the return fan will be started.

Unoccupied cycle: During the unoccupied cycle, if the room temperature falls below the night set back heating setpoint of 60°F (15.65°C), the system will be placed in a low limit override state. The fan will be started and the controls set for full heat.

Reference 5

Page 211: Docs | Documents | Johnson Controls

Source Code The following processes show how these criteria might be programmed in JC-BASIC.

First Process

PROCESS 'AHU1\START_UP' “SFAN START_UP LOGIC” '\NCM1'

REM SUPPLY FAN AND RETURN FAN START-UP/SHUT-DOWN FROM TIME

REM SCHEDULE OR UNOCCUPIED ROOM TEMP LOW-LIMIT OVERRIDE.

REM FAN ALARM LOCKOUT WITH MANUAL RESET.

SHARED LOW_LIMIT_OVR?

IF ('AHU1\START_UP' = ON) OR LOW_LIMIT_OVR? THEN

IF 'AHU1\START_UP\JCBREL' = OFF THEN

TELL 'AHU1\SPF_STSP' TO “START” 2

END IF

ELSE

TELL 'AHU1\SPF_STSP' TO “STOP” 2

END IF

END PROCESS

Second Process

PROCESS 'AHU1\RTF_INTL' “RFAN INTRLCK” '\NCM1'

REM WHEN SUPPLY FAN IS STARTED THEN RETURN FAN IS STARTED

IF 'AHU1\SPF_STSP' = ON THEN \

TELL 'AHU1\RTF_STSP' TO “START” 2 \

ELSE \

TELL 'AHU1\RTF_STSP' TO “STOP” 2

END PROCESS

6 Reference

Page 212: Docs | Documents | Johnson Controls

Third Process

PROCESS 'AHU1\ALRM_SDN' “ALARM SHUTDOWN” '\NCM1'

REM FANS ARE SHUTDOWN ON ALARM STATUS.

REM ALARM MUST BE MANUALLY RESET.

IF 'AHU1\SPF_STSP\STATUS' = ALARM \

OR 'AHU1\RTF_STSP\STATUS' = ALARM THEN

TELL 'AHU1\FAN_ALM\VALUE' TO “SET_BD” TRUE,3

TELL 'AHU1\SPF_STSP' TO “STOP” 4

END IF

END PROCESS

Reference 7

Page 213: Docs | Documents | Johnson Controls

8 Reference

Page 214: Docs | Documents | Johnson Controls

Appendix B:

Syntax Rules

This list compiles the rules you must follow when writing processes in JC-BASIC. You may find this a good troubleshooting resource when a process does not compile error-free:

1. Don’t use the line continuation character (\) in the middle of a keyword, variable name, or string, or to continue a REMark across more than one physical line.

2. Enter a blank space before the statement separator character (a colon :) if what precedes the space is an integer or a time value of hours and minutes (no seconds). No space, however, is required after the colon.

3. Nest no more than 20 pairs of parentheses in an expression.

4. Enclose object names in single quotes. Don’t let object names cross lines. JC-BASIC processes don’t allow wildcard references (e.g., dir\*.*).

5. For text strings, use the following standard and extended ASCII characters: 032 through 126, 128 through 167, and 225. Enclose text strings in double quotes.

You can use double quotes in the text stream by specifying two double quotes in a row. The following text steam is valid: “FAN IS ”“ON”””.

Reference 9

Page 215: Docs | Documents | Johnson Controls

6. Begin variables with a letter, and end them with the proper symbol: % for integer, ! for real (optional), ? for logical, and @ for time. You cannot use keywords as variables (e.g., FOR@ is not a legal variable name).

7. Begin the function name assigned to a user-defined function with a letter and end it with the proper symbol: % for integer, ! for real (optional), ? for logical, and @ for time. The full title of a user-defined function must include FN and its name, with no embedded spaces (e.g., FNEXAMPL).

8. In all USING statements, include at least one “#” symbol to represent how to format numbers.

9. For a REM statement, you cannot use the backslash character (\) as the line continuation character. If you want to continue the remark, enter a carriage return, type REM, and continue the text on the second and subsequent lines. Similarly, the colon character (:), a statement separator, is not treated as a statement separator when embedded in a REM statement.

10. Begin compiler directives with a # symbol as the first non-blank character on a logical line. This distinguishes them from JC-BASIC statements. Don’t use spaces between the # sign and the directive keyword. Enter the directive all alone on one physical line.

10 Reference

Page 216: Docs | Documents | Johnson Controls

Syntax for Statements and Functions

1. The first statement on a logical line for a process must be the PROCESS statement and the last statement, the END PROCESS statement.

2. Only one RESTART process can be defined per NCM. This process is optional.

3. All referenced items in a process must exist somewhere in the archive data base or on the network. Except for the process name of the process being compiled, you cannot use an item that is not defined in the system. If you do, an error will occur when you compile the program.

4. Object and attribute references in a process cannot cross line boundaries; that is, the object name cannot be on the first physical line and the attribute on the next physical line.

5. Only a single array element, not a whole array, can be used as a parameter to pass data.

6. Parameters defined inside a process or function cannot be accessed by any other process or function. A parameter may have the same name as a local or shared variable, but if it does, the variable is not accessible inside that function.

7. These JC-BASIC items are not allowed in any user-defined function:

PROCESS-END PROCESS

DEF FN-END DEF

GOSUB-RETURN

8. The EXIT DEF statement can only be used in user-defined functions.

9. The GOTO and ON-GOTO statements inside user-defined functions cannot reference a label outside the function and vice versa.

10. The name of the function may not be used as an operand in an expression [e.g., FNX = N * (FNX-1) is not allowed].

11. Nested function definitions are not allowed.

Reference 11

Page 217: Docs | Documents | Johnson Controls

12. A function call must be declared (shared variable) or defined (local variable) before its name can be used in an expression.

13. Recursive function calls are not allowed. That is, a function may not call itself either directly or by a chain of function calls which eventually calls itself again.

14. No array attributes or array variables may be triggers.

15. The EXEMPT declaration must follow the SHARE declaration for SHARED variables.

16. For a simple IF statement, the entire statement must be contained on one line. In a block IF statement, the IF, ELSE, and END IF portions must be on their own separate logical lines.

17. Every block IF statement requires END IF as its last logical line.

18. The variable in the FOR-NEXT statement must be numeric.

19. Interleaved FOR loops are not legal. For example:

Correct Incorrect FOR I% = 1 TO 10

statements FOR I% = 1 TO 10

statements

FOR J% = 2 TO 20 statements

FOR J% = 2 TO 20 statements

NEXT J% NEXT I%

NEXT I% NEXT J%

20. The FOR index variable must be a single, local, or shared numeric variable. A FOR statement must have a matching NEXT statement, and vice versa.

21. Every WHILE statement requires END WHILE as its last logical line.

22. A GOTO statement may not pass execution to another process. In other words, the label referenced in a GOTO statement must be a label pointing to a statement within the same process as the GOTO statement.

12 Reference

Page 218: Docs | Documents | Johnson Controls

23. A RETURN statement must have an accompanying GOSUB statement; likewise, a GOSUB statement must have an accompanying RETURN statement.

24. The expression type in a LET statement must be the same as the destination type. Exceptions are integers and real numbers, and integers and time values, which may be mixed.

25. The actual parameters provided in the TELL parameter list must match exactly the number and types of the parameters as defined by the object manager. The one exception is that integers and reals may be exchanged.

26. Replace identifiers (name given to a replace directive) may not be keywords. Also, they may not be placed inside single or double quotes or in a remark.

27. Nested INCLUDE files are not allowed (i.e., an INCLUDE directive cannot appear in an include file). The INCLUDE directive may appear anywhere within a source file but must appear before any references are made to any included declarations.

Numeric data can be integers or real numbers. Real numbers may be expressed as number.number (e.g., 12.56) or in scientific notation (e.g., 1.25E-5). Numeric constants may have the minus sign (-) preceding it. For numbers in scientific notation, no embedded blanks are allowed (e.g., 2 x 10 -5 is invalid).

Syntax for Numbers

1. Physical lines have a maximum length of 255 characters. A logical line can contain up to 1024 characters.

Syntax Maximums

2. Each NCM may have up to 255 separate processes.

3. A given process can be no larger than 32K bytes of memory. The total memory available for JC-BASIC on a given NCM will depend on what other feature data bases are implemented at that NCM.

4. Only one priority statement can be declared per process.

Reference 13

Page 219: Docs | Documents | Johnson Controls

Guidelines 1. If the text on one logical line gets too long, you can extend it to the next physical line by using the line continuation character (\), then a carriage return.

2. In a PROCESS statement, both single and double quotes are used. Single quotes enclose a system, object, or attribute name. Double quotes enclose text strings.

1. For easier reading and better understanding, place all declarations before the process to which they apply.

Programming Recommendations

2. You should not use a GOTO statement to jump into the middle of a FOR-NEXT or WHILE loop. The results will be unpredictable.

Be careful when using single and double quotes. Make sure you pair them up, and use them in their proper places.

Programming Tips

14 Reference

Page 220: Docs | Documents | Johnson Controls

Appendix C:

Syntax in Backus-Naur Form

This appendix contains the complete JC-BASIC syntax in Backus-Naur form. It conforms to the following requirements:

• It is non-left recursive.

• It has been left factored.

• It may be implemented by a non-backtracking, top-down, predictive parser.

The following meta-language notation will be used: Notation Overview <name> non-terminal called name

a | b alternative, choice between a and b

{ } groups strings together

{ }r can be repeated 0 or more times

[ ] optional items

e empty production

All other characters will be terminals in the language.

Note: The < and > characters are both meta-language and JC-BASIC symbols.

Reference 15

Page 221: Docs | Documents | Johnson Controls

Rules The following are the rules defining a legal JC-BASIC process. The “start” non-terminal is <process>.

<process> ==> <process state> <complex state list> <process end state>

<process state> ==> [<label>] PROCESS <process name> <string constant> <network address> <EOS>

<process name> ==> <syst\object name>

<process end state> ==> [<label>] END PROCESS {<EOLL> | <EOF>}

<complex state list> ==> {[<label>] [<declaration> | <complex state> | <simple statement>] <EOS>}r

<declaration> ==> <DIM state> | <function def block> | <priority state> | <exempt state> | <SHARED state>

<DIM state> ==> DIM <array list>

<SHARED state> ==> SHARED <var list>

<var list> ==> <var decl> {, <var decl>}r

<array list> ==> <array decl> {, <array decl>}r

<var decl> ==> <single var decl> | <array decl>

<single var decl> ==> <id>

<array decl> ==> <id> ( <number>)

<function def block> ==> DEF FN<id> [ <parm list>] { = <expression> | <EOS> <complex state list> <function end state>}

<parm list> ==> ([ <id list> ])

<id list> ==> <id> {, <id>}r

<function end state> ==> [ <label> ] END DEF

<priority state> ==> PRIORITY {1 | 2 | 3 | 4 }

<exempt state> ==> EXEMPT <exempt list>

16 Reference

Page 222: Docs | Documents | Johnson Controls

<exempt list> ==> <exempt item> {, <exempt item>}r

<exempt item> ==> <syst\object name> | <attribute name> | <variable> | ALL

<complex state> ==> <for loop> | <block if> | <while loop>

<for loop> ==> <for statement> <EOS> <complex state list> <next statement>

<for statement> ==> FOR <variable> = <numeric expression> TO <numeric expression> [STEP <numeric expression>]

<next statement> ==> [<label>] NEXT [<variable list>]

<block if> ==> IF <logical expression> THEN <EOS> [<first pass block>] <complex state list> [ [<label>] ELSE <EOS> [<first pass block>] <complex state list>] [<label>] END IF

<first pass block> ==> [<label> ] FIRST PASS <EOS> <complex state list> [ <label>] END FIRST PASS <EOS>

<while loop> ==> WHILE <logical expression> <EOS> <complex state list> [ <label>] END WHILE

<simple statement> ==> <simple if state> | <let statement> | <Goto statement> | <gosub state> | <return statement> | <stop statement> | <computed Goto> | <remark state> | <advisory statement> | <print statement> | <wait statement> | <exit def statement> | <period state> | <tell statement> | <abort statement> | <empty statement> | <DIM state> | <priority state> | <exempt state> | <SHARED state>

<simple if state> ==> IF <logical expression> THEN {<label> | <simple statement>} [ELSE {<label> | <simple statement>}]

<let statement> ==> [LET] {<variable ref> | FN<id> | <attribute ref> | <syst\object name>} = expression>

Reference 17

Page 223: Docs | Documents | Johnson Controls

<Goto statement> ==> GOTO <label> | GO TO <label>

<gosub state> ==> GOSUB <label> | GO SUB <label>

<return statement> ==> RETURN

<stop statement> ==> STOP

<computed Goto> ==> ON <numeric expression> {GOTO | GO TO | GOSUB | GO SUB} <label list>

<remark state> ==> REM <text>

<exit def state> ==> EXIT DEF

<period state> ==> PERIOD <time expression>

<tell statement> ==> TELL { <object name> | <attribute ref>} TO <command> [<tell text/exp>]

<command> ==> <string constant>

<abort statement> ==> ABORT

<empty statement> ==> e

<advisory statement> ==> ADVISORY <adv type> [USING <format string>] <mixed text/expr>

<adv type> ==> CRITICAL1 | CRITICAL2 | CRITICAL3 | CRITICAL4 | FOLLOW-UP | STATUS

<mixed text/expr> ==> <mixed list element> {,<mixed list element>}r

<mixed list element> ==> “<text>“ | <expression> | DATE$ | TIME$ | <string attrib ref>

<tell text/expr> ==> <tell list element> {,<tell list element>}r

<tell list element> ==> “<test>“ | <expression> | DELETE | e

<print statement> ==> PRINT <printer> [USING <format string>] <mixed text/expr>

<printer> ==> ' \ <object name>`

<format string> ==> “<format char>{<format char>}r”

<format char> ==> # | . | -

<wait statement> ==> WAIT <time expression>

18 Reference

Page 224: Docs | Documents | Johnson Controls

<numeric function> ==> TODAY | DAY | MONTH | YEAR | ABS (<numeric expression>) | {MAX | MIN | AVG} (<numeric expression>, <numeric exp list>) | {SQR | SIN | COS | TAN | LOG} (<numeric expression>) | FILTER (<numeric expression>, <numeric expression>, <numeric expression>) | SPAN (<numeric expression>, <numeric expression>, <numeric expression>, <numeric expression>, <numeric expression> ) | RAMP (<numeric expression>, <numeric expression>, <numeric expression> ) | ENTHALPYDP (<numeric expression>, <numeric expression>, <numeric expression>, <units type> ) | ENTHALPYRH (<numeric expression>, <numeric expression>, <numeric expression>, <units type> ) | REL_HUM (<numeric expression>, <numeric expression>, <units type>) | DEWPT (<numeric expression>, <numeric expression>, <units type> ) |WETDP (<numeric expression>, <numeric expression>, <numeric expression>, <units type> ) | WETRH (<numeric expression>, <numeric expression>, <numeric expression> <units type> ) | FORCE_REL (<expression>) | FORCE_UNREL (<expression>) | N_CANC_PULSE (<logical expression>, <time expression>) | CANC_PULSE (<logical expression>, <time expression>) | PIRESET (<numeric expression>, <numeric expression>, <numeric expression>, <numeric expression>, <numeric expression>, <numeric expression>, <numeric expression>, <numeric expression>, <logical expression>) | {TOTAL | LASTTOT} (<attribute ref>) | TIME_TO_INT (<time expression>, <time resolution type>) | <user function ref>

<units type> ==> ENGLISH | METRIC

<time resolution type> ==> SECONDS | MINUTES

<time function> ==> TIME | INT_TO_TIME (<numeric expression>, <time resolution type>) | <user function ref>

<logical function> ==> UNRELIABLE (<expression>) | <user function ref>

Reference 19

Page 225: Docs | Documents | Johnson Controls

<user function ref> ==> FN<id> ([<expression list>])

<string constant> ==> “<text>“

<continuation char> ==> \

<network address> ==> ' \ <object name>'

<label list> ==> <label> {, <label>}r

<label> ==> <number>

<numeric exp list> ==> <numeric expression> {, <numeric expression>}r

<numeric expression> ==> <expression>

<time expression> ==> <expression>

<logical expression> ==> <expression>

<expression list> ==> <expression> {, <expression>}r

<expression> ==> <logical term> { {OR | XOR} <logical term>}r

<logical term> ==> <logical factor> {AND <logical factor>}r

<logical factor> ==> [NOT] <unary log factor>

<unary log factor> ==> <primary term> [<relational Oper> <primary term> [DIFF <numeric expression>]]

<relational Oper> ==> = | < > | < | > | < = | > =

<primary term> ==> <primary factor> { {+ | -} <primary factor>}r

<primary factor> ==> <unary factor> { {* | /} <unary factor>}r

<unary factor> ==> [-] <factor>

<factor> ==> <primary> {^[-]<primary>}r

<primary> ==> <constant> | <variable ref> | (<expression>) | <numeric function> | <logical function> | <time function> | <parameter ref> | <attribute ref>

<logical attrib ref> ==> <attribute ref>

20 Reference

Page 226: Docs | Documents | Johnson Controls

<string attrib ref> ==> <attribute ref>

<attribute ref> ==> {<syst\object name> | <attribute name>} [<attrib array index>]

<attrib array index> ==> (<numeric expression> )

<parameter ref> ==> <variable>

<variable ref> ==> <variable> [(<numeric expression>)]

<variable> => <id>

<variable list> ==> <variable> {,<variable>}r

<id> ==> <name> [? | ! | % | @ ]

<name> ==> <letter> {<letter> | <digit> | _ }r

<letter> ==> A | B | C | ... | Z | a | b | ... | z

<constant> ==> <numeric constant> | <logical constant> | <time constant>

<logical constant> ==> TRUE | FALSE

<syst\object name> ==> 'FMS system name\FMS object name'

<attribute name> ==> 'FMS system name\FMS object name\attribute name'

<time constant> ==> <hh:mm:ss> | <hh:mm>

<hh:mm:ss> ==> <number>:<number>:<number>

<hh:mm> ==> <number>:<number>

<numeric constant> ==> <unsigned constant> | <pre-defined const>

<unsigned constant> ==> <number> | [<number>].[<number>] [E [- | +] <number>]

<number> ==> <digit> {<digit>}r

<digit> ==> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

<pre-defined const> ==> ALARM | CLOSED | HI _ALARM | HI _WARNING | LO _ALARM | LO _WARNING | NORMAL | OFF | ON | OPEN | PI | RESET | SET | TROUBLE

Reference 21

Page 227: Docs | Documents | Johnson Controls

<text> ==> {<character>}r

<character> ==> <letter> | <digit> | [ | ] | = | < | > | ? | , | . | / | ! | $ | # | @ | % | & | * | ( | ) | - | + | { | } | : | ; | ' | \ | ^ | _ | ' | ““ | blank

<EOS> ==> : | <EOLL>

<EOLL> ==> end of physical line without continuation character

<EOF> ==> end of source file

The following rules govern the lexical properties of the language:

Lexical Considerations

• Physical input line limit is 255 characters.

• Logical line limit is 1024 characters.

• The \ character allows for multiple physical lines on one logical line.

• The : character allows for multiple statements on one logical line (blanks are required around the :).

• End-of-line is equivalent to one blank.

• Blanks may not appear in constants or identifiers. Use the underscore ( _ ) as a substitute.

• Blank lines may be used.

• Upper/lower case for alpha characters is not significant (i.e., case insensitive).

22 Reference

Page 228: Docs | Documents | Johnson Controls

Compiler Directives

Compiler directives control some features of the compiler during translation time. These directives are in the form: #directive parameters

The directives are:

#LIST -or- #NOLIST: Turns on or off the inclusion of the source lines in the compiler listing file; default: #LIST.

#REMARKS -or- #NOREMARKS: Turns on/off the inclusion of remarks in the object code; default: #NOREMARKS.

#REPLACE name “string”: Replaces a name in the source file with an associated string of characters.

#INCLUDE “DOS file name”: Insert lines of this DOS file at the point where this directive is encountered.

Directives must be all alone on one physical line.

Semantic Notes • Expression syntax is written such that all operand types could be used for all operations. Semantically, only certain operand types are valid for each operator. These are described fully in various sections of the manual. Only numeric types allow for mixing of types for a single operator.

• Only one PRIORITY statement is allowed per process.

• Unsigned reals require at least one digit in the non-exponent portion of the number.

• Time constants must be between 00:00:00 and 23:59:59.

• The DIFF operator may not be used with the <> comparison operator (“not equal to”).

• The left and right sides of assignment (LET) statements must follow this format:

LET <destination> = <expression>

Reference 23

Page 229: Docs | Documents | Johnson Controls

24 Reference

Page 230: Docs | Documents | Johnson Controls

Appendix D:

Error Messages

The following is a list of the error messages that the compiler could write to the list file.

Compiler Error Messages

Error Code Message 100 Function parameter cannot be an array

101 Attribute is not a triggerable attribute

102 Attribute is not a writable attribute

103 Too many characters in attribute name

104 Too few characters in attribute name

105 Characters after line continuation have been ignored

106 Left and/or right side of + operator is logical

107 Advisory type incorrect

108 Left and/or right side of AND operator is not logical

109 Array subscript too large

110 Illegal character found in attribute name

111 Illegal character found in object name

112 Illegal character found in string

113 Illegal character found in system name

114 Control variable not a local or shared variable

115 Control variable not an integer or real variable

116 Decimal point found without any accompanying digits

117 Non-numeric expression found to left of operator

118 Non-numeric expression found to right of operator

119 Non-numeric expression found to the right of DIFF

120 <> relational operator not allowed in DIFF expression

121 Incorrect DIM variable

122 Unknown compiler directive

123 Left and/or right side of / operator is logical or time

124 Unknown END keyword

125 EXEMPT variable must be attribute or shared variable

126 Unknown item found in expression

127 Illegal character found in format string

128 Can’t assign value to function outside its DEF

129 Unknown GO keyword

Continued on next page . . .

Reference 25

Page 231: Docs | Documents | Johnson Controls

Error Code (Cont.)

Message

130 Missing/incorrect INCLUDE filename

131 Cannot assign a logical value to an integer variable

132 Cannot assign an integer value to a logical variable

133 Cannot assign a real value to a logical variable

134 Cannot assign a time value to a logical variable

135 Bad variable name

136 Left and/or right side of * operator is logical or time

137 Missing/incorrect network address

138 Incorrect FOR variable given

139 Right side of NOT operator is not logical

140 Bad opcode found while resolving a forward label reference

141 Left and/or right side of OR operator is not logical

142 Incorrect parameter type

143 Left and/or right side of ^ operator is logical or time

144 Missing/incorrect printer name

145 Priority value must be in the range 1-4

146 Missing/incorrect process name

147 Cannot assign a logical value to a real variable

148 Cannot assign a time value to a real variable

149 Incorrect relative operator for logical expression

150 Missing/incorrect #REPLACE id

151 Instruction not allowed in a RESTART process

152 Shared variable must be of type logical

153 Incorrect SHARED variable

154 Statement not allowed in a simple IF statement

155 Subscript type is not integer or real

156 Left and/or right side of - operator is logical

157 Missing/incorrect TELL command

158 Cannot assign a logical value to a time variable

159 Cannot assign a real value to a time variable

160 Right side of unary - is logical or time

161 Right side of unary + is logical or time

162 Instruction not allowed in a user defined function

163 Need at least 1 character after FN in function name

164 Left and/or right side of XOR operator is not logical

165 Cannot create timer

Continued on next page . . . Error Code (Cont.)

Message

166 Cannot get source date and time

26 Reference

Page 232: Docs | Documents | Johnson Controls

167 Cannot kill timer

168 Control variable in FOR statement cannot be an array

169 Compiler directive must be 1st item on physical line

170 Label already defined

171 Parameter already defined

172 ELSE statement found inside a FIRST PASS statement

173 END IF statement found inside a FIRST PASS statement

174 Expected a real or integer expression

175 Expected a real, integer, time or logical parameter

176 Expected an attribute parameter

177 Expected user defined function name

178 Expected an integer constant

179 Expected a logical expression

180 Expected a logical type parameter

181 Expected a real or integer type parameter

182 Expected an object reference

183 Expected a string

184 Expected a time expression

185 Expected a time type parameter

186 Expected the keyword ENGLISH or METRIC

187 Exponent too large

188 Extra characters found at end of statement

189 Unable to open file

190 Keyword FIRST PASS not allowed here

191 Function cannot be part of an expression inside its own definition

192 Hours value is too large

193 Variable doesn’t match the nearest FOR loop

194 Incorrect number of parameters - expecting

195 Integer constant is too large

196 Label defined inside of a user defined function

197 Label defined outside of a user defined function

198 Label defined inside of another user defined function

199 Keyword not allowed in expression

200 Label too large

Continued on next page . . . Error Code (Cont.)

Message

201 Line is too large to decompile

202 Logical line exceeds 1024 characters

203 Logical and non-logical data used with operator

Reference 27

Page 233: Docs | Documents | Johnson Controls

204 Loop crosses user defined function definition

205 Minutes value is too large

206 Negative sign must be at the beginning or end of the format string

207 Missing left parenthesis on array variable

208 Missing right parenthesis on array variable

209 Missing back slash in system object name

210 Missing comma

211 Missing double quote at end of string

212 Missing END PROCESS keyword

213 Missing single quote at end of system object name

214 Missing equal sign

215 Missing exempt item

216 Missing exponent

217 Missing closing right parenthesis in expression

218 Missing format string

219 Missing left parenthesis on function parameter list

220 Missing right parenthesis on function parameter list

221 Missing GOTO/GOSUB keyword

222 Missing/incorrect label reference

223 Missing minutes field in time constant

224 Missing parameter after comma

225 Format string must have at least 1 pound sign

226 Missing PROCESS keyword

227 Missing/incorrect process descriptor string

228 Missing required parameter

229 Missing seconds field in time constant

230 Missing THEN keyword

231 Missing TO keyword

232 Missing variable reference after comma

233 Only one decimal point allowed in format string

234 Only one negative sign allowed in format string

235 Too many characters in name token

236 Multiple ELSE statements found

Continued on next page . . . Error Code (Cont.)

Message

237 Nested replacements not allowed

238 Nested user defined functions not allowed

239 Not part of a WHILE statement

240 Not part of a FIRST PASS statement

241 Not part of a user defined function definition

242 Not part of an IF statement

28 Reference

Page 234: Docs | Documents | Johnson Controls

243 Missing keyword DEF

244 Missing $ in keyword DATE$

245 Not part of a FOR statement

246 Nested INCLUDE files not allowed

247 Missing PASS keyword

248 Numeric and non-numeric data used with operator

249 Process object exceeds 32K

250 Too many characters in object name

251 Too few characters in object name

252 Cannot open include file

253 More that 1 PRIORITY statement found

254 Real constant is too large

255 Real constant is too small

256 This TELL command requires an attribute destination

257 This TELL command requires an object destination

258 Seconds value is too large

259 Source line too large

260 String attributes not allowed in TELL commands

261 Too many characters in string

262 Too many characters in system name

263 Time and non-time data used with operator

264 Too many characters in time constant

265 Too many errors found - compilation aborted

266 Too many internal labels

267 Too many internal variables

268 Too many levels of parentheses in expression

269 Two label definitions on same logical line

270 Unable to allocate memory block - system error

271 Unable to add process object to data base

272 Unable to close network. Status =

Continued on next page . . .

Reference 29

Page 235: Docs | Documents | Johnson Controls

Error Code (Cont.)

Message

273 Unable to create JC-BASIC compiler status dialog box

274 Unable to create JC-BASIC compiler status dialog box template

275 Unable to delete process object

276 Unable to get user initials

277 Unable to lock memory block - system error

278 Unable to open network. Status =

279 Unable to start compile

280 User defined function has not been defined

281 Unfinished FOR loop found

282 Unfinished IF loop found

283 Unfinished user function definition found

284 Unfinished WHILE loop found

285 Unknown/incorrect attribute found

286 Unknown/incorrect object found

287 Undefined REPLACE identifier

288 Unknown statement type found

289 Name does not begin with a letter

290 Label reference never defined

291 User-defined function has already been defined

292 Variable has already been defined

293 Manufacturing file not found

294 Incorrect NCM for system

295 Expected the keyword SECONDS or MINUTES

30 Reference

Page 236: Docs | Documents | Johnson Controls

Appendix E:

Quick Reference Tables

JC-BASIC has a set of keywords that have specific meanings. These are defined functions, so you should not declare them in a process. Also, use them only as allowed. For example, a process cannot be assigned the name “PROCESS.” All JC-BASIC commands, statements, function names, and operator names are also keywords. The keywords are:

Keywords

ABORT EXEMPT NAME STEP ABS EXIT NEXT STOP ADVISORY FALSE NORMAL SUB ALARM FILTER NOT TAN ALL FIRST OFF TELL AND FOLLOW-UP ON THEN AVG FOR OPEN TIME CANC_PULSE

FORCE_REL OR TIME$

CLOSED FORCE_UNREL PASS TIME_TO_INT COS GO PERIOD TO CRITICAL1 GOSUB PI TODAY CRITICAL2 GOTO PI_RESET TOTAL CRITICAL3 HI_ALARM PRINT TROUBLE CRITICAL4 HI_WARNING PRIORITY TRUE DATE$ IF PROCESS UNRELIABLE DAY INT_TO_TIME RAMP USING DEF LASTTOT REL_HUM WAIT DELETE LET REM WETDP DEWPT LO_ALARM RESET WETRH DIFF LO_WARNING RETURN WHILE DIM LOG SET XOR ELSE MAX SHARED YEAR END METRIC SPAN ENGLISH MIN SQR ENTHALPYDP

MONTH STATUS

ENTHALPYRH

N_CANC_PULSE

SIN

The compiler directives, also keywords, are:

#INCLUDE #REMARKS #LIST #REPLACE #NOLIST #NOREMARKS

Reference 31

Page 237: Docs | Documents | Johnson Controls

JC-BASIC has a set of reserved constants which have specific meanings and uses. These are defined, so they should not be declared in a process. The reserved constants with their types and values are:

Reserved Constants

Reserved Constant Type Value ALARM Numeric 2

CLOSED Boolean True

HI_ALARM Numeric 6

HI_WARNING Numeric 5

LO_ALARM Numeric 4

LO_WARNING Numeric 3

NORMAL Numeric 0

OFF Boolean False

ON Boolean True

OPEN Boolean False

PI Numeric 3.14159265359

RESET Boolean False

SET Boolean True

TROUBLE Numeric 1

32 Reference

Page 238: Docs | Documents | Johnson Controls

The operators used in JC-BASIC are: Operators

Operator Definition Precedence Type ^ exponential 1 arithmetic

- unary minus 2 arithmetic

+ unary plus 2 arithmetic

*,/ multiply,divide 3 arithmetic

+,- add,subtract 4 arithmetic

DIFF differential 5 arithmetic

> greater than 6 relational

< less than 6 relational

>= greater or equal to

6 relational

<= less or equal to 6 relational

= equal to 6 relational

<> not equal 6 relational

NOT negation 7 logical

AND and 8 logical

OR or 9 logical

XOR xor 9 logical

Here is a quick reference to all available JC-BASIC statements:

Statements

ABORT EXIT DEF PRINT USING ADVISORY FIRST PASS PRIORITY ADVISORY USING GOSUB PROCESS DEF - END DEF GOTO REMARK DIM IF - THEN RETURN END FIRST PASS IF - THEN - ELSE SHARED END IF LET STOP END PROCESS ON-GOSUB TELL END WHILE ON-GOTO WAIT EXEMPT PERIOD WHILE EXEMPT ALL PRINT

Reference 33

Page 239: Docs | Documents | Johnson Controls

Functions Here is a quick reference to all available JC-BASIC functions:

ABS INT_TO_TIME SQR AVG LASTTOT TAN CANC_PULSE LOG TIME COS MAX TIME$ DATE$ MIN TIME_TO_INT DAY MONTH TODAY DEWPT N_CANC_PULSE TOTAL ENTHALPYDP PI_RESET YEAR ENTHALPYRH RAMP UNRELIABLE FILTER REL_HUM WETDP FORCE_REL SIN WETRH FORCE_UNREL SPAN

34 Reference

Page 240: Docs | Documents | Johnson Controls

Special Characters

Character Usage Meaning ! after variable name real variable ? after variable name Boolean variable @ after variable name time variable % after variable name integer variable $ after date or time string : between numerics time constant : not between numerics statement separator " print, advisory, or tell parameter

list string

" TELL statement encloses command " PROCESS statement encloses 24-character process ID ' object or attribute reference encloses object or attribute names # before keywords: LIST, NOLIST,

REMARK, NOREMARK, INCLUDE, REPLACE

compiler directive

# after ID replace ID # in using string formats one digit . with numerics decimal point . in USING string formats decimal point - in USING string formats position of sign - in equation unary minus or subtraction + in equation unary plus or addition * in equation multiplication / in equation division ^ in equation exponentiation = in equation equal comparison = in LET statement assignment operator after destination

variable > in equation greater than comparison < in equation less than comparison ( in equation denotes precedence ( after variable denotes subscript or attribute reference ( after function name begins parameter list ) in equation denotes precedence ) after variable denotes subscript or attribute reference ) after function name ends parameter list \ at end of line line continuation character \ in single quotes (') separator of system, object, and

attribute names

Reference 35

Page 241: Docs | Documents | Johnson Controls

JC-BASIC NCM Data Attribute and Command Descriptions

Description Name Unique to JC-

B

Type Range Usage *

System name SYSTEM N string 8 char max R, J

JCB process name

OBJECT N string 8 char max R, J

JCB process descriptor

NAME N string 24 char max R, J

NCM node name NODENAME Y string 8 char max R, J

NCM gate address NCMGATE Y integer 1-256 R, J

NCM node address

NCMNODE Y integer 1-256 R, J

NCM port address NCMPORT Y integer 1-4 R, J

JCB process status The eight possible states are explained in detail in the following table.

STATUS N integer 1 = Not fully downloaded 2 = Error 3 = Disabled 4 = Held 5 = Ready 6 = Executing 7 = Waiting 8 = Time sliced

R, D, J

JCB process reliability

JCBREL Y Boolean 0-1 R, J

Object code size OBJSIZE Y integer 1-32765 R, J

Process period JCBPER Y time hr, min, sec R, J

Process priority PRIORITY Y integer 1-4 R, J * R=Readable, D=Default attribute, J=JC-BASIC readable Continued on next page . . .

36 Reference

Page 242: Docs | Documents | Johnson Controls

Description (Cont.)

Name Unique to JC-

B

Type Range Usage *

Password initials INITIALS Y string 4 char max R, J

Compiler Rev, Major

MAJORREV Y integer 1-15 R, J

Compiler Rev, Minor

MINORREV Y integer 1-15 R, J

Built by BUILTBY Y integer 0=JC BASIC 1=GPL 2=CAE

R, J

Last src, date/time SRC_DATM Y dattime yr, mo, day, hr, min, sec

R

Last compile, date/time

CMP_DATM Y dattime yr, mo, day, hr, min, sec

R

Execution count EXECOUNT Y real 1-millions R

Prefix PREFIX N Boolean 0=normal 1=some abnormal condition

R, J

* R = Readable, D = Default attribute, J = JC-BASIC readable

Reference 37

Page 243: Docs | Documents | Johnson Controls

Status Number

Status Name

Description

1 Not Fully Downloaded

An error occurred during process download . The process cannot be executed, no commands will work on the process, and only a full download will delete and re-add the process.

2 Error The process cannot be triggered or executed. The process is placed in the Error state when a fatal error occurs while executing the process, or when an ABORT statement is executed. The process can only be enabled by an operator command, a download of an enabled version of the process, another process, or an MCO command.

3 Disabled The process cannot be triggered or executed. The process can only be enabled by an operator command, a download of an enabled version of the process, another process, or an MCO command.

4 Held The process is being downloaded or is waiting for the RESTART process to finish execution. Once the download or RESTART finishes, the process is set to READY and queued for execution.

5 Ready The process is enabled and is waiting for a reason to execute, such as an event trigger, a period expiration, or a Trigger command.

6 Executing The process is currently executing.

7 Waiting The executing process is delayed by a WAIT statement. The process will remain delayed until the WAIT delay timer expires, or the process is triggered, or a Disable command cancels the WAIT statement.

8 Time-sliced The executing process has exceeded the maximum instructions any process is allowed to execute before exiting or implementing a WAIT statement. The process is placed in a Time-slice queue, which is the lowest priority queue. The process will remain in this state until it is executed (in priority order), or is issued a Disable command. Processes are placed in the Time-sliced state to prevent large or infinite loops from degrading the performance of other processes.

JC-BASIC Process Status

38 Reference

Page 244: Docs | Documents | Johnson Controls

Glossary

See Access Controller Object. AC

The hardware object that defines the interface between the D600 Controller and the Network Control Module (NCM).

Access Controller Object (AC)

The software representation of a binary input device that measures flow or consumption by monitoring a rate of contact or voltage change.

Accumulator Object (ACM)

See Accumulator Object. ACM

An Application Specific Controller used for Air Handling Unit operations. The AHU may be used as a standalone unit, or connected to the N2 Bus as an element in a Metasys® Network.

AHU Controller

A point object derived from an analog value that was obtained as the result of a control process, operator entry, or attribute from another object.

Analog Data Object (AD)

The software representation of a hardware device that is monitoring an analog value.

Analog Input Object (AI)

The software representation of a control output used in positioning valves, dampers, and other proportional devices. The AOD object is generally used in conjunction with the PID Loop object.

Analog Output Digital Object (AOD)

The software representation of an analog output device used in position control, or remote Setpoint adjustment.

Analog Output Setpoint Object (AOS)

Data base stored at an Operator Workstation for a particular NCM. It contains process objects, and data bases of hardware objects, point objects, and feature software.

Archive Data Base

© November, 1996 Johnson Controls, Inc. 1 Code No. LIT-632060

Page 245: Docs | Documents | Johnson Controls

A group of storage locations in memory in which data elements can be stored. JC-BASIC allows a maximum of 15878 array elements. Actual maximum depends on available NCM memory.

Array

A characteristic or property of an object (e.g., a low limit of an analog point) that describes the object status and makes it unique.

Attribute (System Reference)

A point object derived from a binary value that was obtained as the result of a control process, operator entry, or attribute from another object.

Binary Data Object (BD)

The software representation of a Binary Input device that is monitoring a 2-state (On/Off) field condition.

Binary Input Object (BI)

The software representation of a 2-state (On/Off) controlled device.

Binary Output Object (BO)

Statements that interrupt the normal top-down execution of a process by transferring execution to another area. Branching statements are GOTO and ON-GOTO, GOSUB and ON-GOSUB, RETURN, and EXIT DEF.

Branching Statements

A software object that represents one Smart Terminal Interface/Card Reader combination in an IAC-600 Access Control System.

Card Reader Object (READER)

For a point object, the act of transferring from one condition to another in realtime (e.g., a Binary Input point object changing from Normal to Alarm).

Change-of-State (COS)

Restarting the NCM so that it is operating out of EPROM (Erasable Programmable Read-Only Memory) based code. When the Network Control Module is Cold Started, both code and data need to be downloaded and stored within DRAM (Dynamic Random-Access Memory) to return to normal operations. Contrast with Warm Start.

Cold Start

2 Glossary

Page 246: Docs | Documents | Johnson Controls

A REM (remarks) statement that provides additional comments from the programmer about the execution of the process. REM statements are valuable for communicating the intended behavior of the details of a process to a different programmer who may have to modify the code sometime in the future.

Comment Statement

The program which translates a source file into one or more object files and a list file, and checks a process for errors and tags the errors.

Compiler

Special instructions to the JC-BASIC compiler. These instructions tell the compiler to do something while translating a JC-BASIC process. The compiler directives are #INCLUDE, #LIST and #NOLIST, #REMARKS and #NOREMARKS, and #REPLACE.

Compiler Directives

A statement that directs which statements should be executed based on which conditions are true. The conditional statement is IF-THEN-ELSE.

Conditional Statement

Actual values that JC-BASIC uses during process execution. The four types of constants are: real, integer, logical (Boolean), and time.

Constants

Represents a control system as a software object. The CS object attributes are selected analog, binary, and multi-state points in the controller. Used to represent AHU, LCP, UNT, and VAV controllers only.

Control System (CS)

See Change-of-State. COS

Text-oriented software program for creating global and object data bases.

Data Definition Language (DDL)

Functions that supply the date and time that an advisory or print occurred.

Date And Time Functions

See Digital Control Module. DCM

Glossary 3

Page 247: Docs | Documents | Johnson Controls

A device object mapped to an LCP application specific controller.

DCDR Object

See Data Definition Language. DDL

See Normalband. Deadband

A type of statement that gives instructions to the compiler, but has no executable code.

Declaration Statement

See Halting Statements. Delay Statements

Differential (DIFF) is a special type of relational operator that adds a deadband to a comparison. Typically used to control a setpoint.

Differential Operator

A point interface and control module that resides in either the NCU or NEU. It provides direct digital control on modulating devices for up to ten closed loops, and is equipped with ten universal inputs and ten universal outputs.

Digital Control Module (DCM)

See Compiler Directives. Directives

A command that terminates the execution of a process. The command is issued to selected object files at the Operator Workstation or to selected process names at the NCM.

Disable

Disk Operating System. DOS

Passing of a program and data bases from an Operator Workstation to an NCM.

Download

A command that resets the Disabled command and allows the process to execute. The command is issued to selected object files at the Operator Workstation or to selected process names at the NCM.

Enable

4 Glossary

Page 248: Docs | Documents | Johnson Controls

A type of statement that gives computer instructions. Executable statements are divided into the following categories: assignment and command, branching, loop, conditional, comment, halting and delay, and output statements.

Executable Statement

Any valid combination of operands, constants, variables, and operators. JC-BASIC has three different types of expressions: numeric (integer and real), logical, and relational.

Expression

A combined network system of Operator Workstations, Network Control Units, Network Expansion Units, Application Specific Controllers, Network Terminals, and points used to control and monitor a building or group of buildings.

Facility Management System (FMS)

See Facility Management System. FMS

See Process Focus. Focus

A set of routines that return a numeric result after performing some procedure on parameters passed to it. See also User-Designed Functions and Standard Functions.

Function

See Graphic Programming Language. GPL

A symbol-based language used to define control strategies and object data bases for a Metasys Network.

Graphic Programming Language (GPL)

Statements that stop or otherwise interrupt a process. Halting and delay statements are ABORT, STOP, and WAIT.

Halting Statements

Functions that control input and output rate of change. HVAC-Related Functions

The totalization functions LASTTOT and TOTAL. LASTTOT returns the last period totalized value of an attribute; TOTAL returns the current totalized value.

Input Functions

Glossary 5

Page 249: Docs | Documents | Johnson Controls

Whole numbers without decimal places. Their range is from -999999999 to 999999999.

Integer Constants

A portable version of the Operator Workstation. Laptop Computer

In a process, a backslash character (\) that extends a logical line over one or more physical lines. JC-BASIC allows a maximum of 12 consecutive levels of line continuation characters.

Line Continuation Character

A file with an .LST extension. A list file may contain the contents of the source file, plus any errors found by the compiler, plus some summary information.

List File

A variable whose existence is known only to the process in which it is defined. A local variable may be set to a value in the process using the LET statement.

Local Variables

Boolean constants whose values are True and False. Logical Constants

Expressions that perform logical (Boolean) operations on logical values, and return a True or False value.

Logical Expressions

In a process, one of two types of lines. A logical line is one or more physical lines that consists of one or more statements. It is extended over one physical line by placement of a backslash character (\) at the end of each physical line. JC-BASIC allows a maximum of 1024 characters per logical line. See also Physical Line.

Logical Line

Expressions that perform logical (Boolean) operations on logical values, and return a True or False value.

Logical Operators

A set of instructions that are executed repeatedly. Loop

Statements that run the execution of a process in a repeating loop. Loop statements are FOR-NEXT and WHILE-END WHILE statements.

Loop Statements

6 Glossary

Page 250: Docs | Documents | Johnson Controls

See Multiple Command Object. MCO

A user-defined ASCII text that can be associated with a COS report.

Message

An evolutionary distributed Facility Management System, designed by Johnson Controls, Inc.

Metasys

A software object that sends commands to other objects. Multiple Command Object (MCO)

A device object mapped to an AHU, UNT, or VAV type of application specific controller.

N2OPEN Object

See Network Control Module. NCM

See Network Control Unit. NCU

A collection of Operator Workstations, printers, NTs, NCUs, NEUs, ASCs, N1 LANs, and N2 Buses which make up an FMS system.

Network

The main processing module in the Network Control Unit. The NCM is a fully programmable module that coordinates and supervises the control activities for all points and control loops connected to the NCU, remote NEUs, and ASCs.

Network Control Module (NCM)

A standalone panel used to control a building’s (mechanical) equipment. The NCU consists of an enclosure, door, and baseframe housing electronic modules including a NCM, terminal blocks, and signal conditioners. It is highly flexible in hardware and software configuration and provides direct digital control, energy management, supervisory control, and point monitoring.

Network Control Unit (NCU)

A remote field panel containing the same configurable modules as the NCU, but without the NCU’s user-programmable main processor, the NCM.

Network Expansion Unit (NEU)

See Network Expansion Unit. NEU

Defines the width of the normal operating range for objects. Normalband

Glossary 7

Page 251: Docs | Documents | Johnson Controls

Real and integer actual values that JC-BASIC uses during process execution.

Numeric Constants

Operands separated by arithmetic operators. Numeric Expressions

The numeric functions are ABS, AVG, COS, LOG, MAX, MIN, SIN, SQR, and TAN. Each function is applied to the number or list of numbers beside it.

Numeric Functions

Symbols describing arithmetic functions to be applied to the operands in the statement.

Numeric Operators

A software data base record that corresponds to and characterizes a field device, a data point, an N2 address, or a control function.

Object

A file with an .OBJ extension that contains the executable portion of a process that can be downloaded to an NCM. JC-BASIC allows a maximum object file size of 32 Kb for one process.

Object File

The address in a computer instruction of data to be operated on.

Operand

A Personal Computer based operator interface used for sophisticated information management, data storage, and system programming.

Operator Workstation

Statements that display messages on a monitor or send messages to a printer. Output statements are ADVISORY with ADVISORY USING, and PRINT with PRINT USING.

Output Statements

The length of time after a process executes its END PROCESS statement and before it is placed on the queue for execution.

Period (Process Period)

8 Glossary

Page 252: Docs | Documents | Johnson Controls

One of two types of lines in a process. A physical line is one line across the CRT screen or page and is ended by a carriage return. JC-BASIC allows a maximum of 256 characters per physical line. See also Logical Line.

Physical Line

Used to manipulate outputs for closed loop control at a given Digital Control Module. The PID Loop object is the software that generates these outputs by using a collection of inputs and other variables to perform calculations and issue commands.

PID Loop Object (PIDL)

Software that corresponds to and characterizes field devices and data points. There are eight types of point objects: Accumulator, Analog Data, Analog Input, Analog Output Digital, Analog Output Setpoint, Binary Data, Binary Input, and Binary Output.

Point Object

All processes have an assigned priority level. Priorities range from 1 to 4, where 1 is the highest and 4 is the lowest. A higher priority process is always executed before a lower priority process. A process assigns itself a priority via its PRIORITY statement; a process without a PRIORITY statement defaults to Priority 4.

Priority (Process Priority)

A self-sufficient, modular block of computer instructions. A process consists of an input section, a logic section, and an output section. JC-BASIC allows a maximum of 255 processes per NCM. Actual maximum depends on available NCM memory.

Process

A focus window that provides general information about a process. It combines certain static information about the definition of the process with dynamic information from the NCM concerning its current status of execution.

Process Focus

A summary showing a subset of the information for all processes in a given system.

Process Summary

Functions that ask for several parameter values to use in the fixed equation to yield a value.

Psychrometric Functions

See Card Reader Object. Reader

Glossary 9

Page 253: Docs | Documents | Johnson Controls

Positive and negative numbers that may contain decimal places. They may also be numbers expressed in scientific notation.

Real Constants

Symbols describing the type of comparison to be made to values in the expression.

Relational Expressions

Expressions that compare two values and determine if it is True or False.

Relational Operators

Functions that set the reliability flag of a value or determine the reliability of a value. Reliability functions are FORCE_REL, FORCE_UNREL, and UNRELIABLE.

Reliability Functions

Symbols that provide for specific needs. JC-BASIC uses these reserved symbols:

Reserved Symbols

+ - * / ( ) = < > " ' : \ @ % ? ! # $ ^ .

You may use reserved symbols freely within remark statements. Within the process, you must use them according to their defined meanings.

Variables used when more than one process needs a particular variable.

Shared Variables

A file with a .BAS extension. The source file is the storage location for one or more JC-BASIC process that applies to one Network Control Module.

Source File

Pre-programmed functions that return a numeric, logical, or time value which can be used in expressions. Standard functions are classified under these categories: date and time, HVAC-related, numeric, psychrometric, reliability, and special input.

Standard Functions

Lines of computer instruction within a process. Every logical line in a process is a statement, or several statements separated by a colon (:). See also Declaration Statements and Executable Statements.

Statements

10 Glossary

Page 254: Docs | Documents | Johnson Controls

A block of code accessed by a GOSUB or ON GOSUB statement. A subroutine is local, which means it is used in the same process that calls it.

Subroutine

See Process Summary. Summary

A set of rules for constructing a valid JC-BASIC process. Syntax

One of the three hierarchical name levels for objects. Used at an Operator Workstation to group objects within summaries. The other hierarchical name levels for objects are Network Name and Group Name.

System Name

See Attribute. System Reference

Time-of-day values with a range from 00:00:00 to 23:59:59. Time Constants

An event that causes a process to execute. Examples of triggering events are a manual command from a user, a Binary shared variable that changes value, time programmed command, or triggerable object attribute that changes state which is an input to the process.

Trigger

Exchanges data between the NCM and Operator Workstation. This process may be automatic (in the case of an NCM request following power loss), or it may be a manual request from the user (through the Operator Workstation).

Upload/Download

The user-designed function, DEF FN, creates and names customized functions. See also Standard Functions.

User-Designed Functions

Names whose values can change during the execution of a process. JC-BASIC has four different types of variables: integer, real, logical, and time. See also Local Variables and Shared Variables.

Variables

Glossary 11

Page 255: Docs | Documents | Johnson Controls

Restarting the Network Control Module so it remains fully operational following initial diagnostics tests. When the Network Control Module is Warm Started, both code and data remain safely stored within DRAM (Dynamic Random Access Memory). All shared variables keep their value; however, all local variables are initialized. Contrast with Cold Start.

Warm Start

12 Glossary