05.05.2014 Views

csmstr - Omega Engineering

csmstr - Omega Engineering

csmstr - Omega Engineering

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

PROGRAMMING TIPS<br />

CRIMSON USER MANUAL - MODULAR CONTROLLER<br />

The sample shown below sets several variables, and then changes the display page…<br />

Motor1 := 0;<br />

Motor2 := 1;<br />

Motor3 := 0;<br />

GotoPage(Page1);<br />

The actions will be executed in order, and the program will then return to the caller.<br />

IF STATEMENTS<br />

This type of statement is used within a program to make a decision. The construct consists of<br />

an if statement with a condition in parentheses, followed by an action (or actions) to be<br />

executed if the condition is true. If more than one action is specified, each should be placed<br />

on a separate line, and curly-brackets should be used to group the statements together. An<br />

optional else clause can be used to provide for code to be run if the condition is false.<br />

The architecture of the if statement is as follow…<br />

if( condition ){<br />

action1;<br />

}<br />

else{<br />

action2;<br />

}<br />

The example below shows an if statement with a single action…<br />

if( TankFull )<br />

StartPump := 1;<br />

The example below shows an if statement with two actions…<br />

if( TankEmpty ) {<br />

StartPump := 0;<br />

OpenValue := 1;<br />

}<br />

The example below shows an if statement with an else clause…<br />

if( MotorHot )<br />

StartFan := 1;<br />

else<br />

StartFan := 0;<br />

Note that it is very important to remember to place the curly-brackets around groups of<br />

actions to be executed in the if or else portion of the statement. If you omit the brackets,<br />

PAGE 230<br />

http://www.redlion.net/controller

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!