kmc bacnet module for niagara - home - kmc controls configuration node ......

90
Reference to KMC BACnet Module for Niagara AX Includes installation instructions Revision E

Upload: dinhkien

Post on 03-May-2018

306 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Reference to KMC BACnet Module

for NiagaraAX

Includes installation instructions

Revision E

Page 2: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Important notices ©2012, KMC Controls, Inc.

WinControl, NetSensor, and the KMC logo are registered trademarks of KMCControls, Inc.

TotalControl, BACstage, and FullBAC are trademarks of KMC Controls, Inc.

ActiveX, Silverlight, Microsoft Excel, Windows, and Windows Vista areregistered trademarks of Microsoft, Inc.

Adobe Flash Player, Acrobat and Acrobat Reader are trademarks of AdobeSystems, Inc.

Tridium, JACE, Niagara Framework, NiagaraAX and Vykon are registeredtrademarks of Tridium, Inc.

Workbench, WorkPlaceAX, and AX Supervisor, are trademarks of Tridium Inc.

BACnet and ASHRAE are registered trademarks of the American Society ofHeating, Refrigerating and Air-Conditioning Engineers.

All rights reserved. No part of this publication may be reproduced,transmitted, transcribed, stored in a retrieval system, or translated into anylanguage in any form by any means without the written permission of KMCControls, Inc.

Printed in U.S.A.

Disclaimer The material in this manual is for information purposes only. The contentsand the product it describes are subject to change without notice. KMCControls, Inc. makes no representations or warranties with respect to thismanual. In no event shall KMC Controls, Inc. be liable for any damages, director incidental, arising out of or related to the use of this manual.

KMC Controls, Inc.P.O. Box 49719476 Industrial DriveNew Paris, IN 46553U.S.A.TEL: 1.574.831.5250FAX: 1.574.831.5252E-mail: [email protected]

KMC BACnet Module

2 Revision E

Page 3: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

About this manual 5

Section 1: Installing the KMC BACnet module 7Compatibility and licensing 7What you need to know 7Adding the module files 8Discovering controllers 10Add KMCBACnet configuration 10Configuring offline controllers 12

Section 2: Supported BACnet objects 15Accumulator object 16Analog input object 16Analog output object 18Analog value object 18Binary input object 18Binary output object 18Binary value object 18Calendar object 18Device object 18Event enrollment object 19Loop object 19Multi-state value object 19NetSensor object 19Notification Class object 19Program object 19Schedule object 20Trend log object 20

Section 3: The NetSensor configuration object 21NetSensor buttons and function 21Programming the NetSensor 24

Section 4: Table objects 27Thermistor tables 27Airflow sensor tables 28Input tables 28Control Basic tables 29

Section 5: About Control Basic programs 31About Control Basic scans 32Writing Control Basic statements 33Labels and line numbers 33Real numbers 35Hierarchy of operators 35

KMC BACnet Module for Niagara

Revision E 3

Page 4: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Relational operators 36Using arithmetic operators 36Using Boolean logic 37Programming format and notation 37Programming with variables 38Transferring values between BACnet controllers 39Programming with mnemonics 40

Section 6: Keywords for Control Basic 43Using example programs from help 43Syntax for commands and functions 43

Appendix A: Next Generation Control Basic 79Control Basic versions in controllers 80Deprecated keywords 81Changes to IF THEN 82File compatibility 82Keywords for new functions and statements 83Labels in Next Generation Control Basic 84Line numbers 85Local variables 85References to objects in remote devices 85Using the conversion tool 86

Index 87

KMC Controls, Inc.

4 Revision E

Page 5: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

About th is manual

This publication is an installation manual for the Niagra KMC BACnetmodule. Review this material in its entirety before installing or using anyof the KMC BACnet components.

This manual covers adding the KMC BACnet module to Niagara Workbenchand a Tridium JACE panel. Sections in this manual include the followingtopics:

w Information you need to gather before you begin installing the modulew Version and licensing requirements for NiagaraAX

w Installing the module in Workbench and JACE panelsw Adding the module to KMC BACnet controllers.

KMC BACnet Module for Niagara

Revision E 5

Page 6: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

KMC Controls, Inc. : About this manual

Revision E 6

Page 7: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

S e c t i o n 1 : Ins tal l ing the KMC BACne t module

This section is the procedures for adding the KMC BACnet module toNiagara Workbench, updating JACE panels, and discovering KMCBACnet controllers.

The KMC Controls BACnet Module for NiagaraAX adds the requiredfunctionality to the NiagaraAX framework to fully integrate KMC BACnetcontrollers into a Niagara managed controls system. Topics in this sectioninclude the following:

Adding the KMC BACnet module to the Niagara framework.Discovering KMC BACnet controllers.Adding controllers to the KMC BACnet module database.Adding the module to a JACE panel.

Compatibility andlicensing

The KMC Controls BACnet driver is compatible with NiagaraAXWorkbenchversion 3.5.25 and later.

In addition to installing the module on the correct version of Workbench, theNiagara system must be licensed for BACnet components. Details for BACnetlicensing are covered in the document Niagara AX BACnet Guide which isavailable from Tridium.

What you need toknow

This manual assumes your familiarity with the following subjects:

Your computer and the Windows operating system.The Tridium NiagaraAX framework including Workbench.The principles of the building automation systems that will be managedwith the Niagara installation.

In addition to the material presented in this user’s guide, review and haveavailable the following reference material.

The user’s guides for each device in the system.A sequence of operation for each piece of equipment in the site.Detailed plans and drawings for the building automation system.Information about the LAN including routers, switches and firewalls.

KMC BACnet Module for Niagara

Revision E 7

Page 8: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Adding the modulefiles

To install the KMC BACnet module to Workbench, use Windows Explorer toadd the following files to the modules and lib folders. The files arecompressed and supplied in a .zip file.

kmcBACnet.jardeviceKnowledgeBase.xmlCBCompile.exeNGCompile.exe

The modules and lib folders are located inside of a folder that will includethe vendor's name and a version number. This folder is represented as SystemHome in the following diagram.

Illustration 1–1 KMC Niagara module file locationss

System Home x.x (Vendor name and version.)

lib

modules

deviceKnowledgeBas.xml

NGcomile.exe

CBcomile.exe

System Home (Name is specific to vendor.)

kmcBACnet.jar

Installing on a computer platformTo install the module on a computer platform, do the following:

1. With Windows Explorer, locate the folder in vendor's System Homefolder.

2. Drag the file kmcBACnet.jar to the modules folder.3. Drag the following files to the lib folder.

l deviceKnowledgeBase.xml

l CBCompile.exe

l NGCompile.exe

This completes installation of the module on the computer platform.

Updating JACE controllersAdding or updating the KMC BACnet module file for a JACE controller is atwo part process.

KMC Controls, Inc.

8 Revision E

Page 9: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Adding the .jar file with Software Manager.Adding the .exe and .xml support files with the File Transfer Client.

Before updating a JACE controller with the KMC BACnet module files, firstadd the files to the platform on a computer and then update the JACEcontroller. See Installing on a computer platform on page 8.

To update or add the .jar file to a JACE controller, do the following:

1. Locate the JACE controller in the Nav list.2. Under the platform icon locate the Software Manager. Double-clickthe icon to start the Software Manager.

3. In the Files list, locate the line with kmc BACnet.4. Right-click kmc BACnet and then choose Install KMC Controls x.x.x.5. Click Commit.

To update the support files, do the following:

1. Locate the JACE controller in the Nav list.2. Under the platform icon locate the File Transfer Client. Double-clickthe icon to start the File Transfer Client.

3. In the Files on this computer list, press and hold CTRL while clicking eachof the following file names:

l deviceKnowledgeBase.xml

l CBCompile.exe

l NGCompile.exe

4. When all three files are selected, click the transfer button .5. Restart the station on the JACE controller to make sure the KMCBACnet module locates the new support files.

KMC BACnet Module

Revision E 9

Page 10: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Discoveringcontrollers

Before a KMC BACnet controller can be directly configured with the KMCBACnet module, the controllers must be discovered by Workbench. Theprocedure for discovering on-line controllers is described in the Tridiumdocument Niagara BACnet Guide.

After the BACnet controllers are discovered, they will be listed in the Navpane as show in the illustration BACnet devices in the Nav pane on page 10.

Illustration 1–2 BACnet devices in the Nav pane

Add KMC BACnetconfiguration

Once controllers have been discovered with Workbench, they can be addedto the KMC BACnet Module database. Once they are in the Niagara database,the objects and properties in the controllers can be directly configured withWorkbench.

To add the controllers to the database, do the following:

KMC Controls, Inc.

10 Revision E

Page 11: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

1. In the Discovered pane choose one or more KMC BACnet controllers.2. Click +Add at the bottom of the window.3. When the Add dialog opens, select KMC BACnet Device from the Typelist.

4. Click OK.

Illustration 1–3 Add dialog

To edit an object in a KMC BACnet controller, do the following:

1. Locate the device in the Nav pane.2. Click the icon to expand the list under the KMC Object configurationicon .

3. Continue to expand the list to scroll to the object.4. Double-click the object to open a configuration dialog.

Most objects and properties in KMC BACnet controllers are standard BACnetproperties. For descriptions of the unique properties, see Supported BACnetobjects on page 15.

KMC BACnet Module

Revision E 11

Page 12: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Configuring offlinecontrollers

BACnet controllers from KMC Controls can be configured without beingconnected to a BACnet network. The offline configuration is done through anoffline configuration node added to the device. In addition to offlineconfiguration and programming, a BACstage .bac file can be imported andexported through the offline configuration node.

Illustration 1–4 Nav window with configuration node

KMC configuration node

Offline configuration node

BACnet device node

Adding an offline configuration node

Before adding an offline configuration node, the device must have a KMCObject Configuration node. Adding the KMC Object Configuration Node isdiscussed in the topic Add KMC BACnet configuration on page 10

To create an offline configuration node, do the following:

1. Locate the KMC BACnet device icon in the Nav list.2. Right-click the icon and choose Actions and then Create Offline

Configuration From Device from the shortcut menu.3. Enter a name for the configuration and then click OK.4. The creation of the device offline configuration node will take severalminutes. Monitor the progress in the Jobs pallet.

New configuration nodes are added to the list under the device in the Navwindow. The offline configuration node icon follows the configuration icon.

Creating a .bac file

A .bac file can only be created from an offline configuration node. If thedevice does not have an offline configuration node, see the procedure Addingan offline configuration node.

KMC Controls, Inc.

12 Revision E

Page 13: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

To create a .bac file from an offline configuration node, do the following:

1. Locate the offline configuration icon in the Nav list.2. Right-click the icon and choose Actions and then Export To File from theshortcut menu.

3. Enter a name for the .bac file, choose a storage location, and then clickOK.

4. The creation of the .bac file will take several minutes. Monitor theprogress in the Jobs pallet.

Importing a .bac file

A .bac file is a text file that includes all of the programming andconfiguration of a KMC Controls BACnet controller. This is a file that can beimported and exported with TotalControl or BACstage programs.

Note: FlexStat controllers and BAC-A1616BC building controllers are notsupported for importing .bac files.

To import a .bac file, do the following:

1. Locate the KMC BACnet offline configuration icon in the Nav list.2. Right-click the icon and choose Actions and then Import Offline

Configuration File from the shortcut menu.3. Locate the .bac file and then click OK.4. Importing the file will take several minutes. Monitor the progress in theJobs pallet.

Reloading an offline configuration

To reload or refresh an offline configuration node with the configuration inthe controller, do the following:

1. Locate the offline configuration icon in the Nav list.2. Right-click the configuration icon, choose Actions, and then Read From

Device from the shortcut menu.3. Reloading the configuration will take serveral minutes. Monitor theprogess in the Jobs pallet.

KMC BACnet Module

Revision E 13

Page 14: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Writing an offline configuration to a device

To write to one or more devices do the following:

1. Locate the offline configuration icon in the Nav list.2. Right-click the configuration icon and then do one of the following:

l To write to only the parent device, choose Actions, and thenWrite ToDevice from the shortcut menu.

l To write to more than one device, choose Actions, and thenWrite toMultiple Devices from the shortcut menu.

3. Writing to devices will take several minutes. Monitor the progress in theJobs pallet.

Illustration 1–5 Write to Multiple Devices dialog

KMC Controls, Inc.

14 Revision E

Page 15: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

S e c t i o n 2 : Suppor ted BACne t obje c ts

The following topics are a reference to the features and characteristics ofBACnet objects and properties supported by the KMC BACnet modulefor Niagara.

The Niagara modules supports standard BACnet objects and propertieswithin BACnet devices. Most objects contain only standard properties whichare not described in this document. Properties unique to KMC controllers aredescribed in the following topics.

Accumulator object on page 16Analog input object on page 16Analog output object on page 18Analog value object on page 18Binary input object on page 18Binary output object on page 18Binary value object on page 18Calendar object on page 18Device object on page 18Event enrollment object on page 19Loop object on page 19Multi-state value object on page 19Program object on page 19Schedule object on page 20

In addition to the standard BACnet properties, the KMC module supportsobjects unique to KMC controllers. Configuration for the NetSensor andtables in the KMC controllers are described in the following sections.

The NetSensor configuration object on page 21Table objects on page 27

KMC BACnet Module for Niagara

Revision E 15

Page 16: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Accumulator object KMC BACnet controllers include the standard required BACnet propertiesfor accumulator objects. Accumulator objects are typically used for inputs thatrequire pulse counting such as power meters.

Analog input object KMC BACnet controllers include the standard required BACnet propertiesfor analog input objects. The analog input object also includes the followingproperties.

Filter weightOffset and multiplierCalibrationTable index

Filter weightingSets the number of samples that are averaged together to calculate thedisplayed value. A sample is taken on each scan.

Filter Weight Scans to average

0 1

1 2

2 4

3 8

4 16

5 32

6 64

7 128

Table 2–1 Filter weight values

Calibration for custom inputsThe Custom Device Calibration function converts the input voltage—such asthe voltage from a temperature transmitter—to a calculated present value.The calculation is based on an input voltage that falls between 0 and 5 volts.

Range Enter values in Desired Range text boxes when two points are knownthat correspond to 0 and 5 volts at the input.

KMC BACnet Module for Niagara

Revision E 16

Page 17: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

In Desired Range From enter the value to display in Present Value whenthe input voltage equals 0 volts.In Desired Range To enter the value to display in Present Value when theinput voltage equals 5 volts.

Offset and multiplier Enter offset and multiplier values when a calibrationfactor and offset for the input device are known. For example if a transduceroutput is calibrated for degrees Centigrade and Present Value needs todisplay in degrees Fahrenheit.

CalibrationEnter a calibration factor to adjust the input for sensor inaccuracies.

For a low reading enter a positive correction value.For a high reading enter a negative correction value.The valid range for a calibration factor is from -30 to 30.The default value is 0 (no calibration).

Table indexThe table index value selects which of the tables within the controller to usewith the input. A table performs a look-up function based on the input of anobject and then performs a linear interpolation to calculate the present valueof the object.

Table number Description

1 KMC Type II

2 KMC Type III

3 Air Flow Sensor

4 Input Table 4

5 Input Table 5

6 Control Basic Table 1

7 Control Basic Table 2

8 Control Basic Table 3

Table 2–2 Table list

See the related topic Table objects on page 27.

KMC Controls, Inc.

17 Revision E

Page 18: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Analog outputobject

KMC BACnet controllers include the standard required BACnet propertiesfor analog output objects.

When the device type is set to Custom, offset and multiplier properties areactive. A custom device automatically scales the output voltage for display asan output unit of measure. For example, if the input of a variable frequencydrive requires 0 volts for minimum speed and 10 volts represents full speed,entering 50% for present value will set the output to 5 volts.

Analog value object KMC BACnet controllers include the standard required BACnet propertiesfor analog value objects.

Binary input object KMC BACnet controllers include the standard required BACnet propertiesfor binary input objects.

Binary output object KMC BACnet controllers include the standard required BACnet propertiesfor binary output objects.

Binary value object KMC BACnet controllers include the standard required BACnet propertiesfor binary value objects.

Calendar object KMC BACnet controllers include the standard required BACnet propertiesfor calendar objects.

Device object KMC BACnet controllers include the standard required BACnet propertiesfor device objects. The object includes also a GEST property and automaticbaud detection.

GEST—Gated Event State Transitions When selected, prevents the in-alarmbit in the status flags property from indicating an alarm condition whenEvent Enable within an object is set to Disabled. This prevents some softwarefrom detecting an alarm condition when the Event Enable property is set toDisabled.

Set the GEST property to True to enable GEST and False to disable it.

Automatic baud selection KMC BACnet controllers can be set toautomatically detect the baud rate of an MS/TP network. When a controllerthat is set to automatically detect the network baud is first powered, it willstart at the selected baud and then try other rates until it matches the MS/TPtraffic. If no traffic is detected, it will return to the selected baud. Validsettings are 9600, 19,200, 38,400 and 76,800 baud. The default rate is 38400.

KMC BACnet Module

Revision E 18

Page 19: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Event enrollmentobject

KMC BACnet controllers include the standard required BACnet propertiesfor event enrollment objects.

Loop object KMC BACnet controllers include the standard required BACnet propertiesfor loop objects. Loop properties may also be manipulated with Control Basicmnemonics. See the topic Programming with mnemonics on page 40.

Multi-state valueobject

KMC BACnet controllers include the standard required BACnet propertiesfor multi-state value objects.

NetSensor object The NetSensor object represents an optional display unit that is supported byselect KMC BACnet controllers. Configuration of the NetSensor object isexplained in the section The NetSensor configuration object on page 21.

Notification Classobject

KMC BACnet controllers include the standard required BACnet propertiesfor notification class objects.

Program object KMC BACnet controllers include the standard required BACnet propertiesfor program objects. The program object also includes an AutoRun property.Details on the Control Basic programming language are described in thefollowing sections.

About Control Basic programs on page 31Keywords for Control Basic on page 43

Program object AutoRunThe AutoRun property automatically starts the Control Basic program in theprogram object after a cold start, warm start, or when power is applied to thecontroller. Set the property to True to enable AutoRun and False to disableAutorun.

The Control Basic editorEdit or modify Control Basic programs in the Edit dialog of the programobject.

Compile Click to test the program for proper syntax. Clicking Compile doesnot send the program to the controller. Errors are listed in the OutputWindow.

KMC Controls, Inc.

19 Revision E

Page 20: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

OK Tests the program for proper syntax and then, if it is correct, sends it tothe controller. After the program is sent to the controller, it is stored in thecontroller’s non-volatile memory.

Output Window The Output Window is an information window that listsprogram information and status after successfully compiling. The size of theprogram is also listed in the Output Window.

Schedule object KMC BACnet controllers include the standard required BACnet propertiesfor schedule objects.

Trend log object KMC BACnet controllers include the standard required BACnet propertiesfor trend log objects.

KMC BACnet Module

Revision E 20

Page 21: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

S e c t i o n 3 : The Ne tSenso r conf igurat ion objec t

This section covers configuring and programming examples for theNetSensor.

The NetSensor is a wall mounted display and sensor unit that connectsdirectly to selected models of KMC BACnet controllers. The unit consists ofan LCD display, a thermistor, seven buttons and optional humidity andmotion sensors.

Button functions and layout are described in the topic NetSensor buttonsand function on page 21.Typical configuration and Control Basic programming examples aredescribed in the topic Programming the NetSensor on page 24.

NetSensor buttonsand function

The properties in a NetSensor object configure the NetSensor buttons tocontrol and display the present value of the assigned object.

To configure a NetSensor object, do the following:

1. Select an object to assign to a button from the Assignment list.2. Select the display format.3. Set the Permission for each button to either Read Only or Read/Write.4. Configure AutoBlank, Calibration, and Retain Changes as required.

The functions of the NetSensor buttons are listed in the table NetSensorbutton functions on page 22.

Illustration 3–1 NetSensor models and button layouts

41

56 7

23

4

3

1

2

4

2 3

1

56 7

KMC BACnet Module for Niagara

Revision E 21

Page 22: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Button Function

Up arrow Increases displayed analog values and toggles binary values

Down arrow Decreases displayed analog values and toggles binary values

Button 1 The default display value. Only Button 1may be assigned to theinternal temperature sensor.

Button 2 Labeled as Setpoint but can be defined as an input, output or valueobject within the controller.

Buttons 3–6 Can be defined as an input, output or value object within thecontroller.

Button 7 On applicable models, assigned as the humidity sensor physicallyincluded on the NetSensor.

Button 8 Press buttons 5 and 7 together and then press the up arrow ordown arrow button to change Aux from Off to On. This alsorepresents the optional motion sensor.

Table 3–1 NetSensor button functions

Assignment Selects the object that stores the button display value. The objectcan be either an analog or binary object. Typically the assignment object is avalue object.

Current Value This numerical property indicates the current value—inengineering units—the NetSensor will display when the button is pushed.

Display Format Use Display Format to select one of the units from the drop-down list.

Units in the table NetSensor analog display formats on page 23 are activewhen the object under Assignment is an analog object.Units in the table NetSensor binary display formats on page 24 are activewhen a binary object is selected under Assignment.

Permission The permission property sets the button to be either adisplay-only button or a button that an operator can use to change a value inthe building automation system.

Read Only indicates an operator may only view the data displayed onthe NetSensor.Read/Write indicates an operator may use the arrow buttons to changethe data.

Retain Changes When selected, the present value of the object associatedwith a button is written to the flash memory in a KMC BACnet controller andretrieved from the controller after a cold start.

KMC Controls, Inc.

22 Revision E

Page 23: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

AutoBlank When this check box is selected, the NetSensor display will godark approximately 15 seconds after the last button is pushed.

Calibration (Button 1 only) Enter a value to correct the temperaturesreading as compared to a calibrated test instrument.

For a low temperature reading enter a positive correction value.For a high temperature reading enter a negative correction value.The maximum calibration is 3.2 degrees Fahrenheit above or below thedisplayed value.

DisplayFormat

Description

deg.C Displays temperature in degrees Celsius. Available only onButton 1. If deg.C is selected, Button 1 is assigned to the internaltemperature sensor andmust be associated with a value object.

deg.F Displays temperature in degrees Fahrenheit. Available only onButton 1. If deg.F is selected, Button 1 is assigned to the internaltemperature sensor andmust be associated with a value object.

0 Sets the precision of the display to nearest whole number.

0.0 Sets the precision of the display to one place to the right of thedecimal point.

0.00 Sets the precision of display to two places to the right of thedecimal point.

Time Sets the NetSensor to display a time format.

Off/Low/High The NetSensor cycles through each word as arrow buttons arepressed and released. The analog value object cycles from 0 to 2.

Off/On1/2/3 The NetSensor display cycles through each word as arrow buttonsare pressed and released. The analog value object cycles from0 to 3.

System Time Use to set time in a stand-alone controller when an operatorworkstation or other timemaster device is not available.

Day Of Week Use to set the day of week in a stand-alone controller when anoperator workstation or other timemaster device is not available.

Table 3–2 NetSensor analog display formats

KMC BACnet Module

Revision E 23

Page 24: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

DisplayFormat

Description

On/Off The NetSensor toggles between words as arrow buttons arepressed and released. The binary object toggles between 0 and 1.

Low/High The NetSensor toggles between words as arrow buttons arepressed and released. The binary object toggles between 0 and 1.

Cool/Heat The NetSensor toggles between words as arrow buttons arepressed and released.The binary object toggles between 0 and 1.

Table 3–3 NetSensor binary display formats

Programming theNetSensor

This topic covers several typical configurations and programming forNetSensor buttons.

Button 1–internal temperature sensorButton 1 and the space temperature sensor inside of the NetSensor areusually associated with analog value object AV1.

In Assignment, select an analog value object to associate with thetemperature button.Set Display Format to °F or °C.Set Permission to Read Only. Operators can then view the roomtemperature by touching Button 1 but cannot change the value.

Button 1–controller pointsTo manage or display an object value from Button 1, configure as follows:

In Assignment, select an input, output or value object to associate withthe temperature button.Set Display Format to 0, 0.0 or 0.00.Set Permission to Read Only or Read/Write.

l If set to Read Only, operators can view the value associated with theButton but cannot change it.

l Is set to Read/Write operators can change the value of the object byfirst touching Button 1 and then pressing the up or down arrowbuttons.

KMC Controls, Inc.

24 Revision E

Page 25: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

SetpointButton 2 is usually associated with analog value object AV2.

In Assignment, select an analog value object to associate with the setpointbutton.Set Display Format to 0, 0.0 or 0.00.Set Permission to Read/Write. Operators can view and change thesetpoint by first touching button 2 and then pressing an up or downarrow button.Write a Control Basic statement to start equipment based on theconditions of the setpoint.

IF AV2 < AV1 THEN START BO6

Humidity(Humidity equipped models only) Button 7—the humidity sensor— is usuallyassociated with analog value object AV7.

In Assignment, select an analog value object to associate with thehumidity button.Set Display Format to 0.Set Permission to Read/Write. Operators can view the room humidity bytouching button 7 but cannot change the value.

TimeTypically Button 5 is assigned to display system time and is associated withanalog value object AV5.

Set Display Format to Time which will automatically format the displaywith a colon (:).In Assignment, select an analog value object to associate with the timebutton.Add a Control Basic line as follows:

AV5 = TIME

Verifying a functioning NetSensorTo check if a functioning NetSensor is present, use the Control Basic functionNETSENSORSTATUS on page 62.

IF NOT NETSENSORSTATUS THEN STOP BV1

KMC BACnet Module

Revision E 25

Page 26: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Motion sensing(Motion sensing models only) Detects movement in the room and changes thevalue of Button 8.

Under Assignment, select an analog value object to associate with themotion sensor. Typically this is analog value object AV8.Set Display Format to 0.Set Permission to Read/Write.Use Control Basic to evaluate the state of the object assigned to Button 8.

l A value of -1 indicates motion.

l A value of -2 indicates no motion.

l A value of 0 or 1 indicates the auxiliary function is active.

The following Control Basic program detects motion and changes the state ofvariable BV9.

IF+ AV8 = -1 THEN START BV9 , STOP A

IF AV8 = -2 < 1 THEN START A

IF TIMEON( A ) > 0:02:00 THEN STOP BV9

KMC Controls, Inc.

26 Revision E

Page 27: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

S e c t i o n 4 : Table obje c ts

KMC controllers include table objects that simplify the conversion ofinput voltages to values that are expressed in units of measure. Thissection describes the four types of table objects and how to configurethem.

Tables are objects that perform look-up functions based on data entered inthe table and an input value from an analog input. The table and input objectmust be contained in the same controller. There are four types of table objectsin KMC BACnet controllers.

KMC thermistor table objects are specifically constructed to convert theinput voltage from a KMC sensor to a temperature. See "Thermistortables" on page 27.Airflow table objects convert the input from an airflow sensor in a VAVcontroller. The output of the table is associated with the analog valueobject in the controller that represents the airflow sensor. See "Airflowsensor tables" on page 28.Input table objects are 128-point look-up tables that can be used with anyanalog input object. See "Input tables" on page 28.Control Basic tables are 32-point look-up tables that are accessible byControl Basic in the program object. See "Control Basic tables" on page29.

Thermistor tables Thermistor table objects convert the input voltage that represents the changein resistance of a thermistor to a temperature. The built-in thermistor tablesinclude values for the two types of thermistors in KMC Controls sensors.

KMC 10K Type II KMC Type II thermistorsKMC 10K Type III KMC Type III thermistors

Thermistor tables are used only with analog input objects when the a KMDthermistor is selected by the property Device Type.

Load Defaults Click to restore the default values for the table. For the twothermistor devices, the default values are the manufacturer’s specifications forthe devices.

Refresh Click Refresh to discard changes and reload the table from thecontroller.

KMC BACnet Module for Niagara

Revision E 27

Page 28: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Save When finished, click Save to update the table object in the controllerand close the dialog.

Related topicsAnalog input object on page 16Table objects on page 27Airflow sensor tables on page 28Input tables on page 28Control Basic tables on page 29

Airflow sensortables

Airflow sensor table objects are specialized device tables that calibrate theinternal airflow sensors in KMC VAV controllers. Use only the default valuesfor the airflow tables. The airflow input sensor is set by the design of thecontroller to be the fourth analog input.

Related topicsAnalog input object on page 16Table objects on page 27Thermistor tables on page 27Input tables on page 28Control Basic tables on page 29

Input tables To configure a custom input table, calculate a set of conversion factors basedon 128 sample points spread over a 0-5 volt range. Use either the data from adevice manufacturer’s specifications or data from measuring a device at aknown voltage. Enter the output value that corresponds to the input voltagein the Index column.

Refresh Click Refresh to discard changes and reload the table from thecontroller.

Save When finished, click Save to update the table object in the controllerand close the dialog.

Related topicsAnalog input object on page 16Table objects on page 27Thermistor tables on page 27Airflow sensor tables on page 28Control Basic tables on page 29

KMC Controls, Inc.

28 Revision E

Page 29: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Control Basic tables A Control Basic table performs a look-up function based on the input of anobject and 32 pairs of data. The table uses the input of the object to perform alinear interpolation between data pairs to calculate a value that is returned bythe Control Basic TBL function. Control Basic tables are useful for any of thefollowing reasons:

A custom input range is required for a sensor that is not listed as adevice type property for an input or value object.To create functions within Control Basic.The value of an expression is nonlinear or requires a complicatedcalculation.

Each of the three Control Basic tables consists of up to 32 data pairs stored intwo columns. Values in the X column correspond to the input value and mustbe entered in ascending order.

Refresh Click Refresh to discard changes and reload the table from thecontroller.

Save When finished, click Save to update the table object in the controllerand close the dialog.

Related topicsAnalog input object on page 16TBL on page 74Table objects on page 27Thermistor tables on page 27Airflow sensor tables on page 28Input tables on page 28

KMC BACnet Module

Revision E 29

Page 30: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

KMC Controls, Inc. : Section 4: Table objects

Revision E 30

Page 31: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

S e c t i o n 5 : About Contro l Bas ic prog rams

Control Basic is the process that creates the automation in KMCcontrollers. Topics in this section cover the rules for writing Control Basicprograms.

Every KMC controller includes space for Control Basic programs. Within eachcontroller a program continuously evaluates input data from the buildingautomation system. Then, based upon the instructions in the program, thecontroller takes action to keep one or more pieces of equipment operatingwithin required parameters.

The instructions within the program object are written in Control Basic, aprogramming language that is similar to BASIC (Beginner's All-purposeSymbolic Instruction Code). In addition to standard BASIC programmingfunctions, it includes specialized functions specific for the building automationcontrols industry.

Each of the following topics cover a key aspect of Control Basic.

About Control Basic scans on page 32Programming format and notation on page 37Labels and line numbers on page 33Real numbers on page 35Hierarchy of operators on page 35Relational operators on page 36Using arithmetic operators on page 36Using Boolean logic on page 37Programming with variables on page 38Transferring values between BACnet controllers on page 39Programming with mnemonics on page 40

KMC Controls, Inc.

31 Revision E

Page 32: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

About Control Basicscans

Control Basic is the process that creates the automation in a KMC controller.Each controller has several program objects for storing and executing ControlBasic instructions. When running Control Basic programs, the microprocessorin the controller does the following:

1. Evaluates the state of each object.2. Executes the Control Basic programs.3. Changes the state of all outputs when all programs have been executed.

This process—referred to as a scan—is normally performed several times asecond. See the illustration The scan process on page 32 for an example of thescanning process.

Illustration 5–1 The scan process

Start scan

End scan

Evaluate objects andrun program 1

Evaluate objects andrun program 2

Evaluate objects andrun last program.

Change outputs

The processor evaluates all program areas before making changes. Forexample, if programs 1, 3 and the last program includes instructions for LightsON, and programs 2 and 4 had instructions Lights OFF, the lights will notflash, they will only be set to ON at the end of the scan.

Tip: Program the most important events in the highest numbered program area.This prevents programs with less importance from overriding critical actions.

KMC BACnet Module

Revision E 32

Page 33: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Writing ControlBasic statements

Edit a Control Basic program by opening a program object. See the topicProgram object on page 19 for additional details.

Multiple statementsMultiple statements can be used on the same program line, but must beseparated by a colon.

10 A=B:F=C+D

FunctionsA function is a keyword that—when evaluated by Control Basic—returns avalue. This returned value is the result computed by the function. Functionssave time for complex calculations such as calculating square roots. They mayalso be used to retrieve common system data such as time.

ExpressionsA Control Basic expression describes a symbol or combination of symbolswhich represent a numeric value. Expressions may take the form of a simpleequality such as A=7 or a comparison between symbols such as X < Y.Expressions can be derived also from a function such as TIME, a controllerpoint such as AI2 (analog input 2), or by the result of a series of calculationssuch as A * B - AI2 - 2 / 9.

An expression must evaluate to a real number.

Expression Example

Functions Time, DOW, DOY, etc.

Local Variables A through Z

BACnet objects AI1, BI1, AO2, BO4, etc.

KMD Controller Points OUT1, IN3, VAR16, etc.

Table 5–1 Examples of expressions

Labels and linenumbers

Depending on the model of the controller, Control Basic programs will useeither line numbers or labels.

Standard Control BasicBAC-7000 series controllersBAC-5800 series controllers

KMC Controls, Inc.

33 Revision E

Page 34: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Next Generation Control BasicBAC-A1616 Building ControllerBAC-10000 FlexStat Controllers

Line numbers–Standard Control Basic onlyWhen writing programs for controllers that support Standard Control Basic,enter a line number at the beginning of each line. Each Control Basic programline must include a line number and at least one function or statement.

10 A = B

20 P = PI

Programs written for controllers with Next Generation Control Basic do notuse program lines.

Labels in Next Generation Control BasicLabels are used instead of line numbers with Next Generation Control Basic.Use labels when redirecting program flow with the following statements:

GOSUB on page 53GOTO on page 53ONERROR on page 64ON GOSUB on page 63ON GOTO on page 63

Declare a label by typing a name followed immediately by a colon (:).

A label can be any combination of letters (A-Z or a-z), numbers (0-9) orthe underscore (_).Labels are not case sensitive.Labels are unique to the program in which they are declared.A label cannot duplicate a keyword, constant, local variable or alias.

In the following program example, CoolMode and HeatMode are programlabels.

IF T > 55 THEN GOTO CoolMode

IF T <= 55 THEN GOTO HeatMode

END

CoolMode:

REM Cooling sequence runs here

END

HeatMode:

KMC BACnet Module

Revision E 34

Page 35: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

REM Heating sequence runs here

END

Real numbers Real numbers are any logical number between -3.4 * 1038 and 3.4 * 1038.Notation of the number is recognized in any of the following formats:

Whole numbers (100)Decimal format (.0000123)Engineering notation (7.879 E-12)

Hierarchy ofoperators

Control Basic arithmetic operators have an order of precedence. When severaloperation take place in the same program statement, some operations areperformed before others. Control Basic uses the operator-precedence shownin the illustration Order of operator precedence on page 35 when performingoperations on an expression. Operations at the same level of precedence areevaluated from left to right.

Illustration 5–2 Order of operator precedence

Operator Type Precedence

( ) Expression in parenthesis Highest (performed first)

NOT Logical NOT

^ Exponentiation

*, / Multiplication and division

\ Integer division

MOD Modulus (remainder)

+, -

<, >, <=, >= Relational

=, <>

AND Logical

OR

XOR Lowest (performed last)

Related topics

Using arithmetic operators on page 36Relational operators on page 36Using Boolean logic on page 37

KMC Controls, Inc.

35 Revision E

Page 36: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Relational operators Relational operators are used to compare two values. The result is true if thecomparison is true; otherwise, the result equals false. This result can then beused to make a decision regarding program flow. All relational operatorshave the same level of precedence.

Operator Relation Tested Example Result

= Equality 5 = 2 False

<> Inequality 5 <> 2 True

< Less than 5 < 2 False

> Greater than 5 > 2 True

<= Less than or equal to 5 <= 2 False

>= Greater than or equal to 5 >= 2 True

Table 5–2 Relational operators

Related topics

Using arithmetic operators on page 36Using Boolean logic on page 37Hierarchy of operators on page 35

Using arithmeticoperators

Operators are listed in their order of priority. The formats for usingoperators are listed in the table Arithmetic order of precedence on page 36.

Symbol Operation Example

* Multiplication 2*4=8

/ Division 10/4 =2.5

\ The integer portion of a division 13\5= 2

MOD The remainder of a division 13MOD 5=3

+ Addition 2+2=4

- Subtraction 4-3=1

^ ExponentiationRaises a value to a power

A = AI1 ^ AV1

Table 5–3 Arithmetic order of precedence

KMC BACnet Module

Revision E 36

Page 37: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Related topics

Relational operators on page 36Using Boolean logic on page 37Hierarchy of operators on page 35

Using Boolean logic Control Basic recognizes four logical operators. The operators are listed intheir order of precedence.

NOT NOT is a Boolean operator that performs a logical NOT operation onan expression. If the expression is 0, the result is 1. If the expression is non-zero, the result is 0.

For additional details on this operator, see the keyword NOT on page 62.

AND AND performs the logical AND of the two expressions. The result istrue if both expressions are non-zero; otherwise, the result is false .

For additional details on this operator, see the keyword AND on page 45.

OR OR performs the logical OR of the two expressions. The result is true ifeither expression is true. The result is false if both expressions are false.

For additional details on this operator, see the keyword OR on page 65.

XOR XOR performs the logical exclusive or of the two expressions. The resultis true if the two expressions are different; otherwise, the result is false .

For additional details on this operator, see the keyword XOR on page 77.

Related topics

Using arithmetic operators on page 36Relational operators on page 36Hierarchy of operators on page 35

Programmingformat and notation

Control Basic programs consist of a series of numbered lines. On each linethere are one or more statements.

Throughout these instructions the following notations are used to describeformats:

CAPS Words in capital letters are key words andmust be entered asshown.

lowercase Items in lowercase letters represent information such asexpressions that you supply.

Table 5–4 Typographic conventions

KMC Controls, Inc.

37 Revision E

Page 38: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

... An ellipsis (...) indicates that an itemmay be repeated as manytimes as necessary.

spaces (_) Required spaces in syntax are illustrated with an underline (_).

: A colon (:) separates statements on the same line.

[ ] Optional items are shown in brackets [ ].

All other punctuation, including commas, are part of the syntax andmust be included as shown in each example.

Typographic conventions (continued)

Programming withvariables

Variables are place holders for information such as setpoints, time delays, andoperating modes. Control Basic uses two types of variables, value objects andlocal variables.

BACnet value objects as variablesAnalog and binary value objects are used as program variables in BACnetcontrollers.

Local variablesLocal variables can only be used within the Control Basic program that refersto them. The values they represent cannot be directly transferred to otherControl Basic programs. Local variables are useful for counters or to store theresults of local calculations.

Standard Control Basic local variables Within each Control Basic programthere are 26 local variables. These variables are assigned the letters of thealphabet (A-Z).

Next Generation Control Basic Local variables in controllers that use NextGeneration Control Basic can be either a single-letter variable (A-Z) or adeclared local variable. Use the command LOCALS to declare local variableswithin each Control Basic program. All single letter local varaiables areautomatically declared unless LOCALS declares any variable. If LOCALSdeclares any local variable then any single letter variable must also bedeclared. For details on using and declaring local variables, see the keywordLOCALS on page 60.

KMC BACnet Module

Revision E 38

Page 39: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Transferring valuesbetween BACnetcontrollers

BACnet controllers from KMC Controls can read from and write to thepresent values in objects in other controllers on the internetwork.

Reading properties from other BACnet devicesWith Control Basic, a KMC BACnet controller can request the present valuefrom any other controller on the BACnet internetwork. However, thefollowing limitations must be observed.

Each controller can request a present value from no more than 32 otherdevices.Each controller can request up to a total of 64 present values from the 32devices.

For example, controller 50 can request two values each from controllers 1-32,four values each from controllers 1-16 or eight values from panels 1,5,6,8 andthirty-two values from panel 9.

To read a value from another panel, you must know the panel’s deviceinstance. The instance is separated from the value by a period (.).

Caution

In the following example, theWAIT statement is required. Donot delete it or the programwill not run correctly.

Syntax: device instance.object

10 REM * POINTS TRANSFERRED FROM DEVICE 1213

20 REM * OUTSIDE AIR TEMPERATURE *

30 AV24 = 1213.AI7

40 WAIT 0:05:00

50 END

Writing values to other controllersTo change the value in another BACnet device, you must know the devicesinstance number. The instance is separated from the value by a period(.).

Syntax: device instance.object

201.AO1 = AV1

KMC Controls, Inc.

39 Revision E

Page 40: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Programming withmnemonics

Mnemonics are a short, easy to remember abbreviations to use when writingControl Basic programs to refer to various parts of a controller. For example,a physical input is entered as AI1 or BI1 in BACnet controllers instead oftyping Input1.

Control Basic mnemonics for BACnet objects are listed in the table ControlBasic mnemonics for BACnet objects on page 40. The following line of ControlBasic is an example of using mnemonics to refer to an analog input object anda binary output object.

If AI08 > 10 Then Start BO2

Mnemonics listed as Read Only can read a value— such as its value orstatus— from that object.Mnemonics listed as Read and Write describes a property—such as itsvalue or status—that may be changed through programming or by directaccess.

Caution

If a Control Basic program uses amnemonic to refer to aninvalid local object or property within an object, the programwillcompile but it will halt execution. The reason for the halt is listedin the Description of Halt column of the ProgramObjects dialog.

Object type Mnemonic Property Action

Accumulator ACC# Present Value ReadOnly

Accumulator ACC#-PR Pulse Rate ReadOnly

Analog Input AI# Present value Read andWrite

Analog Input AI#-LL Low Limit Read andWrite

Analog Input AI#-HL High Limit Read andWrite

Analog Output AO# Present value Read andWrite

Analog Output AO#-LL Low Limit Read andWrite

Analog Output AO#-HL High Limit Read andWrite

Analog Value AV# Present value Read andWrite

Analog Value AV#-LL Low Limit Read andWrite

Analog Value AV#-HL High Limit Read andWrite

Binary Input BI# Present value Read andWrite

Table 5–5 Control Basic mnemonics for BACnet objects

KMC BACnet Module

Revision E 40

Page 41: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Object type Mnemonic Property Action

Binary Output BO# Present value Read andWrite

Binary Value BV# Present value Read andWrite

Loop LOOP# Present value ReadOnly

Loop LOOP#-B Bias value Read andWrite

Loop LOOP#-D Derivative constant Read andWrite

Loop LOOP#-P Proportional constant Read andWrite

Loop LOOP#-I Integral constant Read andWrite

Loop LOOP#-SP Setpoint Read andWrite

Multi-State Input MSI# Present value Read andWrite

Multi-State Output MSO# Present value Read andWrite

Multi-State Value MSV# Present value Read andWrite

Schedule SCHED# Present value ReadOnly

Trend TL#-EN Log enable Read andWrite

Control Basic mnemonics for BACnet objects (continued)

KMC Controls, Inc.

41 Revision E

Page 42: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

KMC Controls, Inc. : Section 5: About Control Basic programs

Revision E 42

Page 43: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

S e c t i o n 6 : Keywords fo r Contro l Bas ic

This section covers the keywords for the Control Basic programminglanguage.

The Control Basic keywords for operators, commands and functions arereserved for Control Basic. They may not be used for descriptors, labels ornames of objects, variables, or procedures.

Using exampleprograms from help

You can use example programs from the help system. Highlight the exampleand then copy the example and paste it into a Control Basic program.

Syntax forcommands andfunctions

Required spaces are shown with underscore marks ( _ ) and indicate that aspace must be included for proper syntax. Optional items are shown inbrackets [ ].

ABS This function returns the absolute value of the expression. The expression canbe a single number or the result of a calculation.

Syntax: ABS(_expression_)

Standard Control Basic example

Returns 2.3, the absolute value of -2.3.

10 A = ABS( -2.3 )

Returns the absolute value from the result of the calculation.

10 C = ABS( AV1 - AI1 )

Next Generation Control Basic example

Returns 2.3, the absolute value of -2.3.

A=ABS(-2.3)

Returns the absolute value from the result of the calculation.

C=ABS(AV1 - AI1)

KMC BACnet Module for Niagara

Revision E 43

Page 44: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

ALIAS Declares a local variable and dynamically binds the value of a property to thevariable. It also sets two intervals at which Control Basic will read from orwrite to the property bound to the variable.

Syntax: ALIAS(device, object, property, local, read interval, write interval)

Note: Next generation Control Basic only.

The same point may be bound to an ALIAS in more than one program.However, the lowest read or write interval of all ALIAS statements withinthe device is used in all programs.

See the related topic FLUSH on page 52.

Parameter Description Comments

device The device instance number Enclose the name of adevice with quotationmarks(“). Names are casesensitive.

object A valid mnemonic SeeProgramming withmnemonics on page 40.

property The property and priority forwriting.

Priority is ignored for readonly objects such as inputs.

local The local name to use withinthe program.

Use as a local variablewithin the Control Basicprogram in which the aliasis declared.

read interval The interval at which ControlBasic will read the property.

To never read from theobject, useNONE. Thedefault value is 60 seconds.

write interval The interval at which ControlBasic will write to the property.

To never write to the object,useNONE. The defaultvalue is NONE.

Table 6–1 ALIAS parameters

In the following example Control Basic binds the present value of binaryoutput BO1 in device 1212 to the local name Lights. Control Basic reads thevalue of output BO1 once an hour and writes the value every 60 seconds.

ALIAS(1212, BO1, PV@4, Lights, 1:00:00, 60)

KMC Controls, Inc.

44 Revision E

Page 45: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

The last example binds the value of the input object AI2 to the local variableOutsideAirTemp. When the device argument is omitted, Control Basic bindsthe local variable to the device with the lowest device instance that containsan input object AI2.

ALIAS("", AI2, PV, OutsideAirTemp, 100, NONE)

AND AND is a Boolean operator that performs the logical AND of two expressions.The result is true if both expressions are non-zero; otherwise, the result isfalse.

Syntax: result = expression1 AND expression2

In the following example, local variable C will always equal 1 as long as bothlocal variables A and B = 1

10 A = 1 : B = 1 : C = A AND B

See the related topic Using Boolean logic on page 37.

ARCCOS Returns the arccosine of the specified angle. Angle is expressed in radians.

Syntax: ARCCOS( angle )

10 A = ARCCOS( AV1 )

See the related topic COS on page 48.

ARCSIN Returns the arcsine of the specified angle. Angle is expressed in radians.

Syntax: ARCSIN( angle )

10 A = ARCSIN( AI8 )

See the related topic SIN on page 72.

ARCTAN Returns the arctangent of the specified angle. Angle is expressed in radians.

Syntax: ARCTAN( angle )

10 A = ARCTAN( AV12 )

See the related topic TAN on page 74.

KMC BACnet Module

Revision E 45

Page 46: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

AVG This statement returns the average value of the items enclosed in parenthesis.In the following example, local variable D equals the average of analog inputs1, 3 and 6.

Syntax: AVG(_expression_,_expression_...)

Standard BACnet Control Basic example

10 D = AVG( AI1 , AI3 , AI6 )

Next Generation Control Basic example

D=AVG(AI1, AI3, AI6)

BIND Binds a BACnet device instance to a physical network address. This istypically used to bind an MS/TP slave device to a master device.

Syntax: BIND (device, network, mac, option)

Note: For Next generation Control Basic only.

Parameter Description Comments

device The instance number of thedevice.

network The number of the BACnetnetwork on which the deviceresides

May be expressed as decimal orhexadecimal notation. Use zero(0) as the local network.

mac TheMAC address of thedevice.

Table 6–2 BIND parameters

Option Description

Hint Sets the default address but uses whatever can be foundby the controller. This is the default state.

Locked Forces the default address back to this every time it ischanges.

Table 6–3 BIND options

Examples:BIND (550013,1,13)

BIND(123456, 678, 0x24 )

BIND(123456, 0x44, 09:88:77:55:44:55 )

BIND(123456, 0x4, 10.1.2.3:678 )

KMC Controls, Inc.

46 Revision E

Page 47: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Bind(123456, 0x4, 10.1.2.3:678 , LOCKED)

BIND(123456, 0, 10.1.2.3:678 , HINT )

CLEAR Resets the value of all local variables—variables labeled A-Z and declaredvariables—to zero.

10 CLEAR

CLOSE Sets the value of a named point, binary output or value object to off.

Syntax: CLOSE_point

Standard BACnet Control Basic example

10 CLOSE BO2

20 CLOSE A

Next Generation Control Basic example

CLOSE BO2

CLOSE A

Related topics

OPEN on page 65START on page 73STOP on page 73

CONST Use to declare a variable and assign to it a fixed value. Do not use withvariables that change with subsequent steps in the program.

Syntax: CONST, variable, variable, ...

Note: For Next generation Control Basic only.

Constants must be declared before they are used in a program. Aconstant may be declared anywhere in the program but typically it is atthe beginning of the program.Must start with a letter A-Z, a-z, or an underscore (_). Constants are notcase sensitive.Can be any combination of letters (A-Z or a-z), numbers (0-9) or theunderscore (_).A constant may be used only within the program in which it is declared.A constant cannot duplicate a keyword, local variable, label or alias.

CONST Freeze = 32

KMC BACnet Module

Revision E 47

Page 48: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

CONST Boiling = 212

To declare local variables, see the keyword LOCALS on page 60.

COS Returns the cosine value of a specified angle. Angle is expressed in radians.

Syntax: COS(_angle_)

BACnet examples

Standard BACnet Control Basic example10 A = COS( AV1 )

Next Generation Control Basic exampleA = COS(AV1)

DEC Decrements the value of point by the value of step. If step is omitted, the stepvalue is 1.

Syntax: DEC(_point_,_step_) DEC(_point_)

See the related topic INC on page 56.

Standard BACnet Control Basic example

10 DEC( AV1 , A + B )

20 DEC( AV2 )

Next Generation Control Basic example

DEC( AV1 , A + B )

DEC( AV2 )

DEWPOINT Returns the dew point in degrees Fahrenheit based on Outside Air Humidity(OAH) and Outside Air Temperature (OAT). OAT is in degrees Fahrenheit.

Syntax: DEWPOINT(_OAH_,_OAT_)

See the related topic DEWPOINTSI on page 49 to express temperature indegrees Celsius.

Standard Control Basic example

10 D = DEWPOINT( AI1 , AI2 )

Next Generation Control Basic example

D=DEWPOINT(AI1, AI2)

KMC Controls, Inc.

48 Revision E

Page 49: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

DEWPOINTSI Returns the dew point in degrees Celsius based on Outside Air Humidity(OAH) and Temperature (OAT). OAT is in degrees Celsius.

Syntax: DEWPOINTSI( OAH , OAT )

See the related topic DEWPOINT on page 48 to express temperature indegrees Fahrenheit.

10 D=DEWPOINT(AI1, AI2)

DISABLE DISABLE sets the value of a point, which can be the present value of an input,output or value object, to off.

Syntax: DISABLE_point

Standard BACnet Control Basic example

10 DISABLE AO1

20 DISABLE A

Next Generation Control Basic example

DISABLE AO1

DISABLE A

Related topics

ENABLE on page 50START on page 73STOP on page 73

DOM Returns the current day of the month.

Standard BACnet Control Basic example

10 IF+ DOM = 15 THEN 20 ELSE END

20 REM Continue program execution

Next Generation Control Basic example

IF+ DOM=15 THEN GOTO Continue ELSE END

Continue:

REM Continue program execution

KMC BACnet Module

Revision E 49

Page 50: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

DOW Returns a numerical value for the day of the week.

BACnet example

In BACnet controllers the days of the week are numbered 1-7.

w Monday is day 1.w Sunday is day 7.w The day can also be identified by the first three letters (SUN, MON, etc.).

10 IF DOW = MON THEN START BO1

DOY Returns the day of the year.

w The year always begins on January 1.w December 31st is day 366.w February is always counted as having 29 days which means March 1 isalways day 61.

w On non-leap years, February 29 (day 60) is skipped.

The day of the year may be expressed as either a number or the first threeletters of the month and the day of the month.

Standard BACnet Control Basic example

10 IF DOY = 92 THEN START BO1

Next Generation Control Basic example

IF DOY=92 THEN START BO1

ENABLE ENABLE sets the value of an object, which can be the present value of aninput, output or value object to 1 or on.

Syntax: ENABLE_point

BACnet example

10 ENABLE AO1

20 ENABLE A

Related topics

DISABLE on page 49START on page 73

KMC Controls, Inc.

50 Revision E

Page 51: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

STOP on page 73

END Terminates the execution of a program. When the END statement isencountered, the program stops reading lines and exits the program. Allprograms lines that follow an encountered END statement are not executed.

In the following example, the last line is ignored and the analog output willalways equal 10.

BACnet example

10 AO1 = 10

20 END

30 AO1 = 7

KMD example

10 OUT1 = 10

20 END

30 OUT1 = 7

ENTHALPY Calculates enthalpy based on Outside Air Temperature (OAT) and OutsideAir Humidity (OAH). The value returned is expressed as BTUs per pound ofair. OAT is in degrees Fahrenheit.

Syntax: ENTHALPY(_OAH_,_OAT_)

See the topic ENTHALPYSI on page 51 to enter OAT in degrees Celsius.

BACnet example

10 E = ENTHALPY( AI1 , AI2 )

ENTHALPYSI Calculates enthalpy based on Outside Air Temperature (OAT) and OutsideAir Humidity (OAH). The value returned is expressed as joules per kilogramof air. OAT is in degrees Celsius.

Syntax: ENTHALPYSI(_OAH_,_OAT_)

See the topic ENTHALPY on page 51 to enter OAT in degrees Fahrenheit.

Standard Control Basic example

10 E = ENTHALPY-SI( AI1 , AI2 )

Next Generation Control Basic example

E=ENTHALPYSI(AI1, AI2)

KMC BACnet Module

Revision E 51

Page 52: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

FLUSH When a FLUSH statement runs, Control Basic immediately reads from orwrites to the property bound to the local variable declared by ALIAS.

Syntax: Flush (LocalAlias1)

Note: Next generation Control Basic only.

ALIAS(1212, BO1, PV@4, Lights, 1:00:00, 60)

FLUSH(Lights)

See the related topic ALIAS on page 44.

FOR TO NEXT The FOR TO NEXT loop repeats a set of instructions a specific number oftimes.

Syntax: FOR_ConrtrolVariable_=_StartValue_to_EndValue(_Step_Increment_)

ControlVariable is the variable that FOR increments each time the looprepeats. It controls whether or not Control Basic repeats the loop.ControlVariable must be local to the controller in which the Control Basicprogram is running.StartValue is the initial value that Control Basic assigns toControlVariable.EndValue is the value that the ControlVariable must equal before the loopends.Increment is the amount that Control Basic adds to ControlVariable witheach iteration of the loop. Increment can be a positive or negative value.If STEP and Increment are omitted, the default value is 1.NEXT ends FOR TO statements. It directs Control Basic to incrementControlVariable and to test whether it is greater than EndValue. If it isnot, the loop continues at the first statement within the loop; if not, theprogram continues at the first statement following NEXT.

In the following examples, the value of A increases from 0 to the value of AV2in 0.1 increments, pausing 10 seconds between steps.

Standard Control Basic example

10 FOR A = 0 TO AV2 STEP .1

20 AO1 = A

30 WAIT 0:00:10

40 NEXT A

50 END

KMC Controls, Inc.

52 Revision E

Page 53: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Next Generation Control Basic example

FOR A = 0 TO AV2 STEP .1

AO1 = A

WAIT 0:00:10

NEXT A

END

GOSUB GOSUB is the preferred way of branching to a subroutine in a program andthen returning to the original point and continuing execution. When ControlBasic encounters a GOSUB statement, the program jumps to the locationspecified and continues reading program lines until a RETURN statement isencountered. At that point the program returns to the line following theGOSUB statement.

Syntax: GOSUB_line#

In the following examples, the program reads the first line, jumps to the thirdline and then to the fourth line. The RETURN statement on the fourth linesends the program back to the second line and the program ends.

See the related topics GOTO on page 53 and RETURN on page 68.

BACnet example

10 GOSUB 30

20 END

30 REM

40 RETURN

Next generation Control Basic

GOSUB DoSubRoutine

END

DoSubRoutine:

RETURN

GOTO This function redirects the program to a new location in the program. In thefollowing examples, the program does not run the second line and output 1 isnever changed.

See the related topic GOSUB on page 53.

Syntax: GOTO_line#

KMC BACnet Module

Revision E 53

Page 54: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

BACnet example

10 GOTO 30

20 START BO1

30 REM Program continues here

40 END

Next generation Control Basic

GOTO JumpToEnd

START BO1

JumpToEnd:

END

HALT Stops the program from running and sets the Program State property toHalted. The string Message is displayed in the property Description of Halt.

Syntax: HALT “Message”

Note: For Next generation Control Basic only.

Once stopped the program cannot be restarted from Control Basic. It can berestarted only by doing one of the following:

Performing a warm start or cold startCycling controller powerChanging the Program Change property on the program object to Run.

HALT "Shutting down the program"

HSEL Selects the highest (second highest, etc.) value of the expressions listed. Thevalue for N defines whether it selects the highest (1) or the second highest (2)etc. The expressions can be variables, inputs, outputs, calculations, etc.

Syntax: HSEL(_N_,_expression_,_expression...)

This example returns the local variable A equal to the second highest value ofthe items listed.

Standard BACnet Control Basic example

10 A = HSEL( 2 , AI1 , AI2 , AI3 , AV1 )

Next Generation Control Basic example

A=HSEL(2, AI1, AI2, AI3, AV1)

KMC Controls, Inc.

54 Revision E

Page 55: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

IF THEN IF THEN is a decision making statement. The expression parameter can be anyexpression capable of being true or false (high or low, on or off, etc.) Ifexpression is true the THEN statement will be executed. If the expression isfalse (not true) the ELSE statement will be executed. The ELSE statement andassociated clause are optional. If they are not included the program reads andexecutes the next program line.

Syntax: IF_expression_THEN_clause(_ELSE_clause)

Standard BACnet Control Basic example

In this example, the program stops analog output #5 if analog input #1 is lessthan analog input #2. If analog input #1 is not less than analog input #2, analogoutput #5 will be turned on (started). If the ELSE START AO5 statement wasnot included, the program will stop analog output AO5 if analog input AI1 isless than input AI2. Otherwise, it will do nothing and end the program.

IF AI1 < AI2 THEN STOP AO5 ELSE START AO5

END

Note: Use commas to separate multiple commands in an IF statement.

IF T > S THEN START BO1 , STOP BO2

IF T > S THEN START BO1, STOP BO2 ELSE STOP BO1

Next generation Control Basic

By using ENDIF, Next Generation Basic supports block and nested IF THENstatements.

IF TIME > 7:00 THEN

a=b

ENDIF

IF TIME > 7:00 THEN

IF TIME < 9:00 THEN

B=C

ENDIF

ENDIF

KMC BACnet Module

Revision E 55

Page 56: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

IF+ THEN IF+ is similar to IF THEN, except that it detects the first time a conditionchanges from false to true. If the expression is true and on the previous scan itwas not true, the THEN clause will be executed.

Syntax: IF+_expression_THEN_clause(_ELSE_clause)

The ELSE statement and associated clause are optional. If they are notincluded the program reads and executes the next program line.

When a button closes the circuit in the sensor analog input 1 to which it isconnected, the program will branch down to line 30, which increases thesetpoint (AV13 or VAR13) by one degree. This will happen only once for eachtime the button is pressed and released. Even if the button is held for severalminutes it will only increment the setpoint by one degree.

See the related topic IF THEN on page 55 and IF- THEN on page 56.

BACnet example

10 IF+ SENSOR-ON( AI1 ) THEN GOSUB 30

20 END

30 AV13 = AV13 + 1 : REM Line 30 starts here

40 RETURN

Next generation Control Basic

IF+ SENSORON( AI1 ) THEN GOSUB 30

END

30: : AV13 = AV13 + 1

RETURN

IF- THEN IF- is similar to IF THEN except that it detects the first time a conditionchanges from true to false. In this case the THEN clause would only beexecuted if the expression is false and on the previous scan it was true.

Syntax: IF-_expression_THEN_clause(_ELSE_clause)

Note: The ELSE and associated clause is optional.

See the related topic IF THEN on page 55 and IF+ THEN on page 56.

INC Increments the value of the argument point by the value of the argument step.If step is omitted, the step value is 1. Point may be the present value of anyanalog object.

Syntax: INC(_point_, step_) INC(_point_)

KMC Controls, Inc.

56 Revision E

Page 57: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

See the related topic DEC on page 48.

Standard BACnet Control Basic example

10 INC( AV1 , A + B )

20 INC( AV2 )

Next Generation Control Basic example

INC( AV1 , A + B )

Inc( AV2 )

INT INT returns the integer portion of the numeric value expression. The valuereturned is the greatest integer that is less than or equal to the value ofexpression.

Syntax: INT(_expression_)

The following examples calculate the hour of the day (0-23) without minutesor seconds. The result is stored in analog value object AV1.

Standard BACnet Control Basic example

10 AV1 = INT( TIME / 100 )

Next Generation Control Basic example

AV1=INT(TIME/100)

INTERVAL The INTERVAL command performs an operation at a regular time interval.The statement is true at each expression time; otherwise it is false. The timeformat is in hh:mm:ss format.

Syntax: INTERVAL(_expression_)

The program sequence in this example increases the setpoint temperature—stored in value object AV1—by 0.1° every 45 seconds.

Standard BACnet Control Basic example

10 IF INTERVAL( 00:00:45 ) THEN AV1 = AV1 + .1

20 END

Next Generation Control Basic example

IF INTERVAL(00:00:45) THEN AV1 = AV1 + .1

END

KMC BACnet Module

Revision E 57

Page 58: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

INVLN The function INVLN returns the inverse natural logarithm of the numericexpression.

Note: Next generation Control Basic only.

Syntax: INVLN(_expression_)

Standard BACnet Control Basic example

10 B = INVLN( AI4 * 125 )

Next Generation Control Basic example

10 B = INVLN( AI4 * 125 )

See the related topics LN on page 59.

KMC Controls, Inc.

58 Revision E

Page 59: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

ISNAN ISNAN tests the value of expression to determine if it is a valid number. If thevalue of expression is equal to NAN (Not A Number), then ISNAN returnstrue.

Syntax: ISNAN( _expression_ )

Note: Next generation Control Basic only.

A typical use of ISNAN is to test the present value property of an object in aremote device.

Note: If the remote device goes offline, the last good value is held until thecontroller is reset with a cold start, warm start, or power cycle. After thereset, the value in the remote property becomes NAN until it is read byanother controller.

In the following example the program tests the present value of analog input4 in device instance 4410 once every minute. If the value is a usable numberthen the remote value is stored in value object AV503. If the remote value isnot valid, the value object is set equal to 55, the default value.

IF INTERVAL ( 00:01:00 ) THEN

REM Verify that the value is good

IF ISNAN( 4410.AI4 ) THEN

REM Set a default value

AV503 = 55

ELSE

REM Use the received value

AV503 = 4410.AI4

ENDIF

ENDIF

LN The function LN( ) returns the natural logarithm of the numeric expression.

Syntax: LN(_expression_)

Standard BACnet Control Basic example10 B = INVLN( AI4 * 125 )

Next Generation Control Basic exampleB = INVLN( AI4 * 125 )

KMC BACnet Module

Revision E 59

Page 60: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

LOCALS Use to declare local variables. A local variable may be used only within theprogram in which it is declared.

Note: Next generation Control Basic only.

Syntax: LOCALS variable[, variable, ...]

Locals ChilledWaterSetpoint, a, b

Local variables must be declared before they are used in a program.LOCALS may declare variables anywhere in the program but typicallyvariables are declared at the beginning of the program.Must start with a letter A-Z, a-z, or an underscore (_). They are not casesensitive.Can be any combination of letters (A-Z or a-z), numbers (0-9) or theunderscore (_).Variables A-Z are automatically declared unless LOCALS declaresanother variable.A local variable cannot duplicate a keyword, constant, label or alias.

See the related topic CONST on page 47.

LSEL LSEL returns the lowest, second lowest, etc. value of the expression listed.The value N defines whether it selects the lowest (1) or second lowest (2) etc.Expressions can be variables, inputs, outputs, calculations, etc.

Syntax: LSEL(_N_,_expression_,_expression_...)

In the examples local variable A will be set equal the second lowest value ofthe items listed.

Standard BACnet Control Basic example

10 A = LSEL( 2 , BI1 , BI2 , BI3 , BV1 )

Next Generation Control Basic example

A=LSEL(2, BI1, BI2, BI3, BV1)

MAX MAX returns the maximum value of the expression listed. Expressions can bethe present value of an input, output, or value object or the result of acalculation.

Syntax: MAX(_expression_,_expression_...)

KMC Controls, Inc.

60 Revision E

Page 61: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Standard BACnet Control Basic example

10 A = MAX( AI1 , AI2 , AI3 , AV1 )

Next Generation Control Basic example

A=MAX(AI1, AI2, AI3, AV1)

MIN MIN returns the minimum value of those expression listed. Expressions canbe the present value of an input, output, or value object or the result of acalculation.

Syntax: MIN(_expression_,_expression_...)

Standard BACnet Control Basic example

10 B = MIN( BI1 , BI2 , BI3 , BV1 )

Next Generation Control Basic example

B=MIN(BI1, BI2, BI3, BV1)

MOD MOD is an arithmetic operator that returns true if the division operationreturns a remainder equal to remainderin the expression; returns false if theremainder of the division is not equal to remainder in the expression.

Syntax: Dividend MOD Divisor_=_remainder

Standard BACnet Control Basic example

10 IF AV1 MOD 5 = 0 THEN START BO2 ELSE STOP BO2

Next Generation Control Basic example

IF AV1 MOD 5=0 THEN START BO2 ELSE STOP BO2

The following example uses MOD to calculate leap year. If the year in thecontrollers’s internal clock is a leap year, local variable L is set to true. Forother years the variable L is set to false.

10 IF YEAR MOD 4 = 0 AND YEAR MOD 100 <> 0 OR YEAR MOD 400 =

0 THEN L = 1 ELSE L = 0

See the related topic Using arithmetic operators on page 36.

MODELNUMBER Returns the numerical portion of the model number of the controller.

Syntax: MODELNUMBER

10 AV1=MODELNUMBER

KMC BACnet Module

Revision E 61

Page 62: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

MONTH Returns the current month of the year.

Standard BACnet Control Basic example

10 M = MONTH

Next Generation Control Basic example

M=MONTH

NAN Use NAN to set a variable or property to a Not A Number constant or to testif the variable or property is equal to Not A Number.

Note: Next generation Control Basic only.

IF A <> NAN THEN GOTO CONTINUE

B = 55

CONTINUE:

B = A

See the related topic ISNAN on page 59.

NETSENSORSTATUS Returns the connection status of a NetSensor with which the program cantake appropriate action. The function returns true if a functional NetSensor isconnected to the controller and false if the controller does not detect aNetSensor.

Standard Control Basic example

10 IF NOT NETSENSORSTATUS THEN STOP BV1

Next Generation Control Basic example

IF NOT NETSENSORSTATUS THEN STOP BV1

NOT NOT is a Boolean operator that performs a logical negation operation on anexpression. If the expression is 0, the result is 1. If the expression is non-zero,the result is 0.

Syntax: result = NOT expression

IF NOT BV1 THEN STOP BO2

See the related topic Using Boolean logic on page 37.

KMC Controls, Inc.

62 Revision E

Page 63: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

ON GOSUB ON GOSUB is a control statement. The program branches to the location fromthe list passed by the statement. The value of expression determines thelocation in the list to which Control Basic will continue. Expression is roundedto an integer. For example, if expression = 3 the program will branch to thelocation in the list. If the value of expression is greater than the number oflocations listed or if expression is less than 1, no branch will occur.

Syntax: ON_expression_GOSUB_location1[_location2_location3_...]

See the related topic RETURN on page 68.

Standard BACnet Control Basic example

In this example Value Object AV1 is equal to 3 which will cause the programto branch to Line 80. If AV1 were equal to 2, the program would branch toLine 60, etc.

10 AV1 = 3

20 ON AV1 GOSUB 40 , 60 , 80

30 END

40 RETURN

50 RETURN

60 RETURN

Next generation Control Basic

In this example Value Object AV1 is equal to 3 which will cause the programto branch to label 80. If AV1 equals 2, the program will branch to label 60, etc.

AV1 = 3

ON AV1 GOSUB 40 , 60 , 80

END

40:

RETURN

60:

RETURN

80:

RETURN

ON GOTO ON GOTO is a control statement. The program branches to the locations fromthe list passed by the statement. The value of expression determines thelocation in the list to which the program will branch. Expression is rounded toan integer. For example, if expression = 3 the program will branch to the third

KMC BACnet Module

Revision E 63

Page 64: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

location in the list. If the value of expression is greater than the number oflocations listed or if expression is less than 1, no branch will occur.

Syntax: ON_expression_GOTO_location1[_location2_location3_...]

Standard BACnet Control Basic example

In this example Value Object AV1 is equal to 3 which will cause the programto branch to Line 60. If AV1 were equal to 2, the program would branch toLine 60, etc.

10 AV1 = 3

20 ON AV1 GOTO 40 , 50 , 60

30 END

40 REM Program continues here

50 REM Program continues here

60 REM Program continues here

Next generation Control Basic

In this example Value Object AV1 is equal to 3 which will cause the programto branch to label 60. If AV1 equals 2, the program will branch to label 50, etc.

AV1 = 3

ON AV1 GOTO Forty, Fifty, Sixty

END

Forty:

Fifty:

Sixty:

ONERROR When an error is detected on the line previous to the line containingONERROR, the program continues at the line specified by location. In thefollowing examples, the program attempts to read an off-panel object and ifthe object is not found it substitutes the value 70.

Syntax: ONERROR location

Standard BACnet Control Basic example

10 AV16 = 101-AV1

20 ONERROR 40

30 GOTO 60 : REM Jump around error recovery

40 REM Error recovery

50 AV16 = 70

KMC Controls, Inc.

64 Revision E

Page 65: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

60 REM Continue program

Next generation Control Basic

AV16 = 101.AV1

ONERROR 40

GOTO 60 : REM Jump around error recovery

40:

REM Error recovery

AV16 = 70

60:

REM Continue program

OPEN Use OPEN to set the present value of an object to on or true.

Syntax: OPEN_point

Standard BACnet Control Basic example

10 OPEN V

20 OPEN A

30 OPEN BO1

Next Generation Control Basic example

OPEN V

OPEN A

OPEN BO1

Related topics

CLOSE on page 47START on page 73STOP on page 73

OR OR is a Boolean operator that performs the logical OR of the two expressions.The result is true if either expression is true. The result is false if bothexpressions are false.

Syntax: result = expression1 OR expression2

In the following example, local variable C will equal 1 if either of the variablesA and B are equal to 1.

10 A = 1 : B = 0 : C = A OR B

KMC BACnet Module

Revision E 65

Page 66: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

See the related topic Using Boolean logic on page 37.

OUTPUTOVERRIDE Returns the switch position of an optional HPO-6700 series output boardinstalled in the controller in which Control Basic is running.

Syntax: OUTPUTOVERRIDE( output )

The argument output is returned false if the switch is in AUTO and true if theswitch is set to either the OFF or HAND position. Output can be expressed aseither of the following:

The instance number of the output.A local variable whose value represents the number of an output object.

Standard BACnet Control Basic example 

10 BV20 = OUTPUTOVERRIDE( 2 )

Next Generation Control Basic example

BV20=OUTPUTOVERRIDE(2)

PANELADDRESS Returns the device instance number of the controller on which the ControlBasic program is running.

Standard Control Basic example

10 P = PANELADDRESS

Next Generation Control Basic example

P=PANELADDRESS

PI Inserts the value of pi. The following examples convert angle D from degreesto radians.

Standard Control Basic example

10 A = PI * ( D / 180 )

Next Generation Control Basic example

A=PI*(D/180)

KMC Controls, Inc.

66 Revision E

Page 67: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

POWERLOSS Use POWERLOSS to detect loss of power to the controller. It will also detectany other condition that causes the controller to run its restart sequence. Thisfunction returns true on the first scan of all Control Basic programs afterpower is restored. After the first scan, it returns as false .

The following examples are useful for monitoring intermittent power failuresat a controller. The value object AV32 increments by 1 each time power isrestored.

Standard Control Basic example

10 IF POWERLOSS THEN AV32 = AV32 + 1

20 END

Next Generation Control Basic example

IF POWERLOSS THEN AV32 = AV32+1

END

REM Place a REM statement at the beginning of a program line to insertexplanatory comments or remarks. REM is a method to document the use of asubroutine or to explain a formula used in a calculation.

Syntax: REM_string

Standard BACnet Control Basic example

70 REM ** Step temperature every minute by 1 degree **

80 IF INTERVAL( 0:01:00 ) THEN AV1 = AV1 + 1

90 REM **calculation for velocity (FPM)**

100 AV1 = 4004.4 * SQR( AI1 )

110 END

Next Generation Control Basic example

REM ** Step temperature every minute by 1 degree **

IF INTERVAL(0:01:00) THEN AV1=AV1+1

REM **calculation for velocity (FPM)**

AV1=4004.4*SQR(AI1)

END

KMC BACnet Module

Revision E 67

Page 68: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

RETURN This command returns control from a subroutine to a calling procedure.RETURN is always used in conjunction with GOSUB or ONGOSUBstatements to RETURN from a subroutine.

See the related topics GOSUB on page 53 and ON GOSUB on page 63.

RLQ Relinquishes the priority level of a BACnet output or value object.

Syntax: RLQ_object@priority

Standard Control Basic example

10 RLQ AO1@7

Next Generation Control Basic example

RLQ AO1@7

SCANS SCANS returns the rate a controller is processing all Control Basic programs.The value returned is expressed in scans per second. As the complexity orlength of a program increases it takes longer to process and the number ofscans per second decreases.

A useful application for SCANS is to create a time-based counter similar tothose used for time-proportioning relays. If you use the INTERVAL or WAITstatements you are limited to a time division no smaller than one second. Byprogramming a counter based on SCANS, the smallest time increment canrange between 1/5 of a second to 1/50 of a second depending on how busy thecontroller is.

If a time proportioning relay sequence is based on a 5 second cycle forexample, having time increments in only 1 second divisions would likely notbe sufficient.

See the related topic About Control Basic scans on page 32.

Standard BACnet Control Basic example

10 A = 1 / SCANS

20 B = A + B : REM B Will increment by 1 every second (based

on scan rate)

30 IF B > 10 THEN B = 0 : REM B counts 0-10 in 10 seconds

40 END

Next Generation Control Basic example

A=1/SCANS

KMC Controls, Inc.

68 Revision E

Page 69: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

B=A+B:REM B Will increment by 1 every second (based on scan

rate)

IF B>10 THEN B=0: REM B counts 0-10 in 10 seconds

END

SCHEDOFF Use this function to determine the time of day that a schedule object will setits reference object to Inactive or a value of zero (0).

Syntax: SCHEDOFF(_schedule object #_,_time_)

The returned value is the difference—in seconds—from the timespecified to the time that the schedule's present value will be Inactive (orzero).The schedule object must be within the same device.Both schedule object # and time may be expressed as either a localvariable (a), value (12:00, 6) or value object (AV1).The parameter time is entered in 24-hour format.The value returned is based on the current day of the week.A returned value of 0 indicates that the schedule is already set to off.A return of 86,400 indicates that there are no more scheduled Off timesfor the current day.

Note: KMC Controls recommends that, because it is computationally intensive,Control Basic does not continuously run the SCHEDOFF function.

See SCHEDON on page 69 for calculating the time when a schedule becomesactive.

SCHEDON Use this function to determine the time of day that a schedule object will setits reference object to Active or a non-zero value.

Syntax: SCHEDON(_schedule object #_,_time_)

KMC BACnet Module

Revision E 69

Page 70: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

The returned value is the difference—in seconds—from the timespecified to the time that the schedule's present value will become Active(or non-zero).The schedule object must be within the same device.Both schedule object # and time may be expressed as either a localvariable (A), value (12:00, 6) or value object (AV1).The parameter time is entered in 24-hour format.The value returned is based on the current day of the week.A returned value of 0 indicates that the schedule is already on.A return of 86,400 indicates that there are no more scheduled On timesfor the current day.

Note: KMC Controls recommends that, because it is computationally intensive,Control Basic does not continuously run the SCHEDON function.

In the following example, line 10 calculates a value once every five minutes.The time parameter of 0:00:00 indicates when time the schedule will be on. Ifthe schedule is set to change to On at 5:00 AM, when line 10 executes, valueobject AV1 will return a value of 18,000 seconds.

See SCHEDOFF on page 69 for calculating the time when a schedule becomesinactive.

Standard Control Basic example

10 IF INTERVAL( 0:05:00 ) THEN AV1 = SCHEDON( 1 , 0:00:00 )

Next Generation Control Basic example

IF INTERVAL(0:05:0) THEN AV1=SCHEDON(1,0:00:00)

SENSOROFF Use SENSOROFF to detect an open-circuit condition on an input that isconfigured as an analog input. A typical application is to detect momentaryconditions such as a pressed button. If the opened contact condition lastslonger than two minutes the function will be disabled. After three minutes,the object will change Out Of Service to true but the commands will stillexecute.

Syntax: SENSOROFF(_IN#_)

When used with SENSORON on page 71 and IF THEN on page 55, IF+ THENon page 56, or IF- THEN on page 56 you can determine three separateconditions from one input:

KMC Controls, Inc.

70 Revision E

Page 71: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

A temperature or other analog reading.A sensor with open contacts (SENSOROFF).A sensor with closed contacts (SENSORON).

SENSOROFF can also be used with inputs using a table if the minimum valuein the table is set to a value greater than zero and its maximum value is lessthan 5.00 volts.

Input Voltage Detected condition

0 Closed circuit

0.4 Temperature-55 degrees

4.9 Temperature-95 degrees

5.0 or greater Open circuit

Table 6–4 Example table for SENSOROFF in BACnet controllers

In the table Example table for SENSOROFF in BACnet controllers on page 71,the input voltage under normal temperature conditions will never fall below0.4 volts. When a sensor is shorted to ground, the input voltage will fall tozero, which is a condition SENSORON can detect. Similarly, if the circuit isopened, the controller will read the open circuit voltage, which is higher thanthe maximum 4.9 volts in the table which will be detected by SENSOROFF.

Standard Control Basic example

10 IF- SENSOROFF( AI1 ) THEN AV11 = 02:00:00

Next Generation Control Basic example

IF- SENSOROFF(AI) THEN AV11=02:00:0

SENSORON Use SENSORON to detect 0 volts (closed-circuit) condition on an input that isconfigured as an analog input. A typical application is to detect momentaryconditions such as a pressed button. If the opened contact condition lastslonger than two minutes the function will be disabled. After three minutes,the object will change Out Of Service to true but the commands will stillexecute.

Syntax: SENSORON(_IN#_)

When used with SENSOROFF on page 70 and IF THEN on page 55,IF+ THEN on page 56, or IF- THEN on page 56 you can determine threeseparate conditions from one input:

A temperature or other analog reading.A sensor with open contacts (SENSOROFF).A sensor with closed contacts (SENSORON).

KMC BACnet Module

Revision E 71

Page 72: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

SENSORON can also be used with analog inputs using a table if the minimumvalue in the table is set to a value greater than zero and its maximum value isless than 5.00 volts.

Input Voltage Detected condition

0 Closed circuit

0.4 Temperature-55 degrees

4.9 Temperature-95 degrees

5.0 or greater Open circuit

Table 6–5 Input conditions for SENSORON for BACnetcontrollers

In the table Input conditions for SENSORON for BACnet controllers on page72, the input voltage under normal temperature conditions would never fallbelow 0.4 volts. When a sensor is shorted to ground, the input voltage willfall to zero, which is a condition SENSORON can detect. Similarly, if thecircuit is opened, the controller will read 5.00 volts, which is higher than themaximum 4.9 volts in the table which will be detected by SENSOROFF.

Standard Control Basic example

10 IF+ SENSORON( AI1 ) THEN AV11 = 02:00:00

Next Generation Control Basic example

IF+ SENSORON(AI1) THEN AV1=02:00:00

SIN Returns the sine of the specified angle. Angle is expressed in radians.

Syntax: SIN(_angle_)

Standard Control Basic example

10 A = SIN( AI1 )

Next Generation Control Basic example

A=SIN(AI1)

SQR The SQR function returns a value equal to the square-root of the valueexpression.

Syntax: SQR(_expression_)

Standard BACnet Control Basic example

10 A = SQR( AI1 )

KMC Controls, Inc.

72 Revision E

Page 73: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Next Generation Control Basic example

A=SQR(AI1)

START START sets the value of a point to on.

Syntax: START_point

Standard BACnet Control Basic example

10 START AO1

20 START F

30 START A

Next Generation Control Basic example

START AO1

START F

START A

Related topics

STOP on page 73DISABLE on page 49ENABLE on page 50

STOP STOP sets the value of a point to Off.

Syntax: STOP_point

Standard BACnet Control Basic example

10 STOP AO1

20 STOP F

Next Generation Control Basic example

STOP AO1

STOP F

Related topics

START on page 73DISABLE on page 49

KMC BACnet Module

Revision E 73

Page 74: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

ENABLE on page 50

TAN A function that returns the tangent of the specified angle. The value angle isexpressed in radians.

Syntax: TAN(_angle_)

Standard Control Basic example

10 A = TAN( AV10 )

Next Generation Control Basic example

A=TAN(AV10)

TBL Use TBL to look up the value of an expression such as a variable in a customcreated table. Use look-up tables when the value of the expression isnonlinear or requires a complicated calculation to arrive at the proper value.Use ON-ERROR after TBL to recover from problems within the table.

Syntax: TBL(_expression_,_table#_)

When referencing a table within Control Basic, use the form TBL (x , N)where “N” is the table number and “x” is the value within the table. Thefunction returns the interpolated y coordinate-ordinate of the table. N mustbe a whole number, x can be an integer.

Standard Control Basic example

10 AV1 = TBL( AI3 , 2 )

20 ON-ERROR 40

30 GOTO 60 : REM Jump around error recovery

40 REM Start error recovery

50 REM End error recovery

60 REM Continue program

Next generation Control Basic

AV1 = TBL( AI3 , 2 )

ONERROR 40

GOTO 70 : REM Jump around error recovery

40:

REM Start error recovery

REM End error recovery

70:

REM Continue program

KMC Controls, Inc.

74 Revision E

Page 75: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

TIME A function that returns a value based on the time as maintained in thecontroller running Control Basic.

BACnet example

KMC BACnet controllers return a value for system time as the number ofseconds after midnight.

10 T=TIME

The following program returns hours, minutes and seconds in local variablesH, M, and S.

10 H = INT( TIME / 60 / 60 ) : REM Hours

20 M = INT( ( TIME - H * 60 * 60 ) / 60 ) : REM Minutes

30 S = TIME - 60 * M - 60 * 60 * H : REM Seconds

TIMEOFF Use this statements to determine if the present value of object has been in theoff state for a specific period of time. If point is a value object, it must beconfigured as a unit of time.

Syntax: TIMEOFF(_point_)

Standard Control Basic example

10 IF TIMEON(AO1)>0:10 THEN START AO2

20 REM AO2 will turn on if AO1 has been on for longer than

10 minutes

Next Generation Control Basic example

IF TIMEON(AO1)>0:10 THEN START AO2

REM AO2 will turn on if AO1 has been on for longer than 10

minutes

See the related keyword topic TIMEON on page 75.

TIMEON Use this statements to determine if the present value of object has been in theon state for a specific period of time.

Syntax: TIMEOFF(_point_)

KMC BACnet Module

Revision E 75

Page 76: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Caution

TIMEON responds to the time a property is set toOn asmaintained by the controller running the program. This timemaynot be the same as the actual time if the object containing theproperty is in a different controller.

In the following example, analog output AO2 will be set to On if output AO1has been set to On for more than 10 minutes.

10 IF TIMEON( AO1 ) > 0:10 THEN START AO2

See the related keyword topic TIMEOFF on page 75.

WAIT Use WAIT to control timed events. The program waits for the time periodspecified before reading the next program line. Other programs in thecontroller will not be affected as WAIT applies only to the program in whichit is listed.

Syntax: WAIT_period

Tip: The value for period can be expressed in 24-hour format (14:15) or convertedto decimal format (1425). See the related topic TIME on page 75.

Note: Plan carefully when using WAIT before a conditional branch such as withIF-THEN. Conditions within a controller may change the value of points orproperties during the waiting period.

Standard BACnet Control Basic example

10 START AO2

20 WAIT 0:10

30 REM * * Waits 10 Minutes at line 20 * *

40 WAIT 00:00:10

50 REM * * Waits 10 seconds at line 40 * *

60 END

Next Generation Control Basic example

START AO2

WAIT 0:10 : Rem Line 20

REM Line 30 * * Waits 10 Minutes at line 20 * *

WAIT 00:00:10 : REM Line 40

REM * * Waits 10 seconds at line 40 * *

KMC Controls, Inc.

76 Revision E

Page 77: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

END

XOR XOR performs a logical exclusion on two Boolean expressions. The result istrue if the two expressions are different; otherwise, the result is false.

Syntax: result_=_expression1_XOR_expression2

In the following example, local variable C will equal 1 as long as variables Aand B are not equal to each other.

10 A = 1 : B = 0 : C = A XOR B

See the related topic Using Boolean logic on page 37.

YEAR Returns the four-place value of the current year.

10 Y = YEAR

KMC BACnet Module

Revision E 77

Page 78: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

KMC Controls, Inc. : Section 6: Keywords for Control Basic

Revision E 78

Page 79: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Ap p end i x A : Nex t Gene rat ion Contro l Bas ic

Next Generation Control Basic is an advanced version of Control Basicthat is supported in new BACnet controllers. This section explains thedetails of Next Generation Control Basic and the differences betweenstandard and Next Generation Control Basic.

With the release of BACstage 2.3 and TotalControl Design Studio 1.5, KMCControls introduced several changes to Control Basic.

Controllers with Standard Control Basic are programmed with littlechange. However, when existing programs are loaded from a controlleryou will see some changes to the keywords and references to remotepoints. See the topic Control Basic versions in controllers on page 80 for alisting of controllers that support Standard Control Basic.Controllers with Next Generation Control Basic have several newkeywords available. In addition there are other changes to the language.

Review the following topics to become familiar with the new features ofControl Basic:

Control Basic versions in controllers on page 80Changes to IF THEN on page 82Deprecated keywords on page 81File compatibility on page 82Keywords for new functions and statements on page 83Labels in Next Generation Control Basic on page 84Line numbers on page 85Local variables on page 85References to objects in remote devices on page 85Using the conversion tool on page 86

KMC BACnet Module for Niagara

Revision E 79

Page 80: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Control Basicversions incontrollers

The following table lists the versions of Control Basic that are supported inthe BACnet controllers from KMC Controls.

Model number Control Basic version Control Basic file format

BAC-A1616 Next Generation NG

BAC-5801BAC-5802

Standard BAS

BAC-5831 Standard BAS

BAC-5841BAC-5842

Standard BAS

BAC-7001BAC-7051

Standard BAS

BAC-7003BAC-7053

Standard BAS

BAC-7301BAC-7301C

Standard BAS

BAC-7302BAC-7302C

Standard BAS

BAC-7303BAC-7303C

Standard BAS

BAC-7401BAC-7401C

Standard BAS

FlexStatBAC-10000BAC-11000BAC-12000BAC-13000BAC-14000

Next Generation NG

Table A–1 Versions of Control Basic

KMC Controls, Inc.

80 Revision E

Page 81: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Deprecatedkeywords

The use of the keywords in the table “Control Basic deprecated keywords”on page 1 change in BACstage version 2.3. Only the keywords are changed;the functions and statements they represent remain the same.

When writing programs for controllers with Standard Control Basic (seeControl Basic versions in controllers on page 80), BACstage will acceptand compile either the deprecated keywords or the replacement versionsof the keywords. For example either DEW-POINT or DEWPOINT maybe used when writing a program.When BACstage or TotalControl retrieves a Control Basic program froma controller and decompiles it, the deprecated keywords are replacedwith the new keywords. For example DEW-POINT becomesDEWPOINT and TIME-ON becomes TIMEON.For controllers with Next Generation Control Basic, BACstage orTotalControl will not accept or compile the deprecated keywords in thefollowing table.

Deprecated keyword Replacement keyword

COS-1 ARCCOS

DEW-POINT DEWPOINT

DEW-POINT-SI DEWPOINTSI

ENTHALPY-SI ENTHALPYSI

LN-1 INVLN

MODEL-NUMBER MODELNUMBER

NETSENSOR-STATUS NETSENSORSTATUS

ON-ERROR ONERROR

OUTPUT-OVERRIDE OUTPUTOVERRIDE

PANEL-ADDRESS PANELADDRESS

SCHED-ON SCHEDON

SCHED-OFF SCHEDOFF

SENSOR-OFF SENSOROFF

SENSOR-ON SENSORON

SIN-1 ARCSIN

TAN-1 ARCTAN

TIME-ON TIMEON

TIME-OFF TIMEOFF

Table A–2 Control Basic deprecated keywords

KMC BACnet Module

Revision E 81

Page 82: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Changes to IF THEN Next Generation Basic now supports block and nested IF THEN statements.

Locals ChilledWaterSetpoint

AV24 = ChilledWaterSetpoint

IF BV258 THEN

ChilledWaterSetpoint = 52

ELSE

Chilledwatersetpoint = 48

ENDIF

IF TIME > 7:00 THEN

IF TIME < 9:00 THEN

START BO1

ENDIF

ENDIF

File compatibility When saving and opening files with versions of BACstage other thanBACstage 2.3, be aware of the following compatibility issues.

Programs sent to a controller with BACstage 2.3 can be loaded from acontroller with earlier versions of BACstage. BACstage 2.2 and earlierwill list the programs using the deprecated keywords and originalsyntax for remote points.If a .BAS file includes any of the new or deprecated keywords,BACstage versions earlier than 2.3 will open but not compile theprogram. The new keywords and syntax must be changed to the originalformat.When transferring a .BAS file to a controller with Next Generation basic,the .BAS files can be converted to Next Generation format (.NGextension) with the conversion tool. See Using the conversion tool onpage 86. Controllers that support Next Generation Control basic arelisted in the topic Control Basic versions in controllers on page 80.Files created with the Backup Device (.BAC files) in BACstage 2.3 arebackwards compatible with BACstage 2.2 and earlier.

KMC Controls, Inc.

82 Revision E

Page 83: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Keywords for newfunctions andstatements

The following keywords are added to Control Basic:

ALIASBINDCONSTFLUSHHALTISNANLOCALSNAN

A brief description of each of the new keywords follow. Unless notedotherwise, the new keywords can only be used when writing programs forcontrollers with Next Generation Control Basic.

ALIASDeclares a local variable and dynamically binds the value of a property to thevariable. It also sets two intervals at which Control Basic will read from orwrite to the property bound to the variable.

Syntax: ALIAS(device, object, property, local, read interval, write interval)

See ALIAS on page 44 for a more detailed description.

BINDBinds a device instance to a physical network address. This is typically usedto bind an MS/TP slave to a master device. BIND is required in only oneprogram within the device.

Syntax: BIND (device, network, mac, option)

See the keyword BIND on page 46 for a more detail descrition.

CONSTUse to declare one or more variables and assign to them a fixed value. Do notuse with variables that change with subsequent steps in the program.

Syntax: CONST, variable, variable, ...

See CONST on page 47 for a more detailed description.

FLUSHWhen a FLUSH statement runs, Control Basic immediately reads from orwrites to the property bound to the local variable declared by ALIAS.

Syntax: Flush (LocalAlias)

KMC BACnet Module

Revision E 83

Page 84: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

See the topics FLUSH on page 52 and ALIAS on page 44 for more detaileddescriptions.

HALTStops the program from running and sets the Program State property in theprogram object to Halted. The string Message is displayed in the propertyDescription of Halt. The program can be restarted by doing any of thefollowing:

Syntax: HALT “Message”

See the keyword HALT on page 54 for a more detailed description.

ISNANISNAN tests the value of expression to determine if it is a valid number. If thevalue of expression is equal to NAN (Not A Number), then ISNAN returnstrue. A typical use of ISNAN is to test the present value property of an objectin a remote device.

Syntax: ISNAN( _expression_ )

See ISNAN on page 59 for a more detailed description.

LOCALSUse to declare local variables. A local variable may be used only within theprogram in which it is declared.

Syntax: LOCALS variable[, variable, ...]

See the keyword LOCALS on page 60 for a more detailed description.

NANUse NAN to set a variable or property to a Not A Number constant or to testif the variable or property is equal to Not A Number. NAN can be used inboth Standard and Next Generation Control Basic.

See NAN on page 62 for a more detailed description.

Labels in NextGeneration ControlBasic

In Next Generation Control Basic, labels are used instead of line numberswhen program flow is redirected with any of the following statements.

GOSUBGOTOONERRORON GOSUBON GOTO

KMC Controls, Inc.

84 Revision E

Page 85: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

In the following program example, CoolMode and HeatMode destinations of aprogram redirection.

IF T > 55 THEN GOTO CoolMode

IF T <= 55 THEN GOTO HeatMode

END

CoolMode:

REM Cooling sequence runs here

END

HeatMode:

REM Heating sequence runs here

END

Declare labels by typing a name followed immediately by a colon (:).

A label can be any combination of letters (A-Z or a-z), numbers (0-9) orthe underscore (_).Labels are not case sensitive.Labels are unique to the program in which they are declared.Labels cannot be a Control Basic keyword.

Line numbers Line numbers are not used in Next Generation Control Basic programs.However, a line number is displayed in the Control Basic editors for bothBACstage and TotalControl Design Studio. The line numbers displayed areonly for identification of problems when the program is compiled.

Line numbers continue to be used in controllers with Standard Control Basic.

Local variables The single-letter local variables a-z and A-Z may still be used withoutprogram modification. In addition to single letters, more descriptive variablesmay be used by declaring a variable with the statement LOCALS. However,once a variable is declared, all single letter variables used in the programmust also be declared. For details on declaring local variables, see thekeyword LOCALS on page 60.

References toobjects in remotedevices

When referring to an object in a remote device, the device name or instance isnow separated from the object reference by a period(.). In previous versions,the instance and name were separated with a dash (-).

10 A = 1214.AI1

KMC BACnet Module

Revision E 85

Page 86: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

In BACstage the name of the device or object can be used in place of aninstance number.

20 A = MechanicalRoom.TempMechRoom

30 A = 1214.TempMechRoom

40 A = MechanicalRoom.AI1

Using theconversion tool

A conversion tool is available on the KMC Controls web site thatconverts .BAS files to .NG files. Open an existing .BAS file and then convert itto the Next Generation format. Once converted you can do either of thefollowing:

Save the file to disk.Copy all or part of the text and then paste it into a Control Basic editor.

Illustration A–1 Control Basic converter tool

KMC Controls, Inc.

86 Revision E

Page 87: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

Index

AaboutControl Basic 31

ABS 43accumulator object 16airflow tables 28ALIAS 44analoginput object 16ouput object 18value object 18

AND 45ARCCOS 45ARCSIN 45ARCTAN 45arithmetic operators 36automaticbaud selection 18NetSensor display blanking 23

autorun 19average input values 16AVG 46

Bbinaryinput objects 18output object 18value objects 18

BIND 46boolean logic 37buttons for NetSensor 21

Ccalendar object 18calibrationanalog input 17NetSensor 23

CLEAR 47CLOSE 47comparison operators 36compatibility 7compile 19

CONST 47constants in Control Basic 47Control Basic 31, 37, 60expressions 33keywords 43mnemonics 40Next Generation 79scans 32variables 38

Control Basic tables 29COS 48

Ddayof month 49of week 50of year 50

DEC 48declaringconstants with CONST 47variables with LOCALS 60

device object 18DEWPOINT 48DEWPOINTSI 49DISABLE 49DOM 49DOW 50DOY 50

Eedit Control Basic 19ELSE 55ENABLE 50END 51ENDIF 55ENTHALPY 51ENTHALPYSI 51event enrollement object 19example programs 43exporting .bac file 12expressions 33

Ffilter weight 16FLUSH 52

KMC BACnet Module for Niagara

Revision E 87

Page 88: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

FOR TO NEXT 52functions 33

GGEST 18GOSUB 53GOTO 53

HHALT 54help examples 43hierarchy of operators 35HSEL 54humidity programing in NetSensor 25

IIF- THEN 56IF THEN 55IF THEN ELSE 56IF+ THEN 56importing .bac file 12INC 56input objectsaccumulator 16analog 16binary 18

input tables 28INT 57INTERVAL 57INVLN 58ISNAN 59

Kkeywords 43

Lleap year 61line numbers 33LN 59local variables 38LOCALS 60LSEL 60

MMAX 60

MIN 61mnemonics 40MOD 61MODELNUMBER 61MONTH 62motion sensing 26multi-state value objects 19

NNAN 62NETSENORSTATUS 62NetSensorbuttons 21calibration 23display blanking 23humidity 25motion sensing 26object 21programming 24setpoint 25temperature 24time 25verifying status 25

NOT 62notification class objects 19

Oobjects 19accumulator 16airflow table 28analog input 16analog output 18analog value 18binary input 18binary outpupt 18binary value 18calendar 18Control Basic tables 29device 18input table 28NetSensor 21notification class 19program 19schedule 20thermistor tables 27

Index KMC Controls, Inc.

88 Revision E

Page 89: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

trend log 20off-panel pointsreading 39writing 39

offline configuration 12ON GOSUB 63ON GOTO 63ONERROR 64OPEN 65operatorsarithmetic 36boolean 37comparison 36precedence 35relational 36

OR 65output objectsanalog 18binary 18

OUTPUTOVERRIDE 66

PPANELADDRESS 66PI 66POWERLOSS 67precedence of operators 35programming examplesNetSensor 24

programming notation 37pulse counting 16

Rradians 66reading properties from other devices 39relational operators 36REM 67RETURN 68RLQ 68

Sscans 32SCANS 68SCHEDOFF 69SCHEDON 69schedule objects 20

schedulesSCHEDON 69

SENSOROFF 70SENSORON 71setpoint programming in NetSensor 25SIN 72SQR 72START 73STOP 73

Ttables 27airflow 28Control Basic 29input 28TBL in Control Basic 74thermistor 27

TAN 74TBL 74temperature programming in NetSensor 24thermistor tables 27TIME 75time programming in NetSensor 25TIMEOFF 75TIMEON 75trend log objects 20

Vvalue objectsanalog 18as variables 38binary 18multi-state 19

variables 38declaring with LOCALS 60

version 7

WWAIT 76writingprograms 33properties to other devices 39

XXOR 77

KMC BACnet Module Index

Revision E 89

Page 90: KMC BACnet Module for Niagara - Home - KMC Controls configuration node ... GEST—GatedEventStateTransitionsWhenselected,preventsthein-alarm ... traffic.Ifnotrafficisdetected,itwillreturntotheselectedbaud.Valid

YYEAR 77

Index KMC Controls, Inc.

90 Revision E