Logix5000 Controllers Structured Text Programming Manual

2y ago
44 Views
2 Downloads
1.53 MB
38 Pages
Last View : Today
Last Download : 3m ago
Upload by : Louie Bolen
Transcription

Logix5000 Controllers Structured TextCatalog Numbers 1756 ControlLogix, 1769 CompactLogix, 1789SoftLogix, 1794 FlexLogix, PowerFlex 700S with DriveLogixProgramming Manual

Important User InformationSolid state equipment has operational characteristics differing from those of electromechanical equipment. Safety Guidelinesfor the Application, Installation and Maintenance of Solid State Controls (publication SGI-1.1 available from your local RockwellAutomation sales office or online at http://www.rockwellautomation.com/literature/) describes some important differencesbetween solid state equipment and hard-wired electromechanical devices. Because of this difference, and also because of thewide variety of uses for solid state equipment, all persons responsible for applying this equipment must satisfy themselves thateach intended application of this equipment is acceptable.In no event will Rockwell Automation, Inc. be responsible or liable for indirect or consequential damages resulting from the useor application of this equipment.The examples and diagrams in this manual are included solely for illustrative purposes. Because of the many variables andrequirements associated with any particular installation, Rockwell Automation, Inc. cannot assume responsibility or liability foractual use based on the examples and diagrams.No patent liability is assumed by Rockwell Automation, Inc. with respect to use of information, circuits, equipment, or softwaredescribed in this manual.Reproduction of the contents of this manual, in whole or in part, without written permission of Rockwell Automation, Inc., isprohibited.Throughout this manual, when necessary, we use notes to make you aware of safety considerations.WARNINGIdentifies information about practices or circumstances that can cause an explosion in a hazardous environment,which may lead to personal injury or death, property damage, or economic loss.IMPORTANTIdentifies information that is critical for successful application and understanding of the product.ATTENTIONIdentifies information about practices or circumstances that can lead to personal injury or death, property damage,or economic loss. Attentions help you identify a hazard, avoid a hazard, and recognize the consequenceSHOCK HAZARDLabels may be on or inside the equipment, for example, a drive or motor, to alert people that dangerous voltage maybe present.BURN HAZARDLabels may be on or inside the equipment, for example, a drive or motor, to alert people that surfaces may reachdangerous temperatures.Allen-Bradley, Rockwell Automation, and TechConnect are trademarks of Rockwell Automation, Inc.Trademarks not belonging to Rockwell Automation are property of their respective companies.

Table of ContentsTable of ContentsPrefacePurpose of this Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5How to Use this Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5Chapter 1Program Structured Text3Publication 1756-PM007C-EN-P - October 2009Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9Specify a Non-retentive Assignment. . . . . . . . . . . . . . . . . . . . . . . . 10Assign an ASCII Character to a String . . . . . . . . . . . . . . . . . . . . . . 11Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Use Arithmetic Operators and Functions . . . . . . . . . . . . . . . . . . . 13Use Relational Operators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14Use Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16Use Bitwise Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17Determine the Order of Execution . . . . . . . . . . . . . . . . . . . . . . . . 17Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18Constructs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19Some Key Words Are Reserved for Future Use . . . . . . . . . . . . . . 19IF.THEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20CASE.OF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23FOR DO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26WHILE DO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29REPEAT UNTIL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353

Table of Contents4Publication 1756-PM007C-EN-P - October 2009

PrefacePurpose of this ManualThis manual shows how to program Logix5000 controllers with the structuredtext programming language. This manual is one of a set of related manuals thatshow common procedures for programming and operating Logix5000controllers. For a complete list of common procedures manuals, see the Logix5000 Controllers Common Procedures Programming Manual, publication1756-PM001.The term Logix5000 controller refers to any controller that is based on theLogix5000 operating system, such as: CompactLogix controllers ControlLogix controllers DriveLogix controllers FlexLogix controllers SoftLogix5800 controllersHow to Use this ManualSome text is formatted differently from the rest of the text.Text that isIdentifiesItalicthe actual name of an item that you Right-click User-Defined see on your screen or in an exampleRight-click the item that is namedUser-Defined.courierinformation that you must supplybased on your application (avariable)Right-clickname of program You must identify the specific program inyour application. Typically, it is a name orvariable that you have defined.Press [Enter].Press the Enter key.enclosed in brackets a keyboard key5Publication 1756-PM007C-EN-P - October 2009For exampleMeans5

PrefaceNotes:6Publication 1756-PM007C-EN-P - October 2009

Chapter1Program Structured TextStructured text is a textual programming language that uses statements todefine what to execute. Structured text is not case sensitive. Use tabs and carriage returns (separate lines) to make your structuredtext easier to read. They have no effect on the execution of thestructured text.Structured text is not case sensitive. Structured text can contain AssignmentUse an assignment statement to assign values to tags.tag : expression;(see page 9)The : operator is the assignment operator.Terminate the assignment with a semi colon “;”.Expression(see page 11)An expression is part of a complete assignment or construct statement.An expression evaluates to a number (numerical expression) or to a trueor false state (BOOL expression).An expression contains:TagsA named area of the memory where data is stored(BOOL, SINT,INT,DINT, REAL, string).value1ImmediatesA constant value.4OperatorsA symbol or mnemonic that specifies an operationwithin an expression.tag1 tag2tag1 value1FunctionsWhen executed, a function yields one value. Useparentheses to contain the operand of a function.function(tag1)Even though their syntax is similar, functions differfrom instructions in that functions can only be usedin expressions. Instructions cannot be used inexpressions.Publication 1756-PM007C-EN-P - October 20097

Program Structured TextTermDefinitionExamplesInstructionAn instruction is a standalone statement.instruction();(see page 18)An instruction uses parenthesis to contain its operands.Depending on the instruction, there can be zero, one, or multipleoperands.When executed, an instruction yields one or more values that are part ofa data structure.Chapter 1instruction(operand);instruction(operand1, operand2,operand3);Terminate the instruction with a semi colon “;”.Even though their syntax is similar, instructions differ from functions inthat instructions cannot be used in expressions. Functions can only beused in expressions.ConstructA conditional statement used to trigger structured text code (i.e, otherstatements).IF.THENCASE(see page 19)Terminate the construct with a semi colon “;”.FOR.DOWHILE.DOREPEAT.UNTILEXITCommentText that explains or clarifies what a section of structured text does.(see pagepage 35) Use comments to make it easier to interpret the structured text. Comments do not affect the execution of the structured text. Comments can appear anywhere in structured text.//comment(*start of comment . . . end of comment*)/*start of comment . . . end of comment*/IMPORTANT8Use caution when copying and pasting components betweendifferent versions of RSLogix 5000 programming software.RSLogix 5000 software only supports pasting to the sameversion or newer version of RSLogix 5000. Pasting to a priorversion of RSLogix 5000 software is not supported. Whenpasting to a prior version, the paste action may succeed but theresults may not be as intended.Publication 1756-PM007C-EN-P - October 2009

Chapter 1Program Structured TextAssignmentsUse an assignment to change the value stored within a tag. An assignment hasthis syntax:tag : expression ;where:ComponentDescriptiontagRepresents the tag that is getting the new value.The tag must be a BOOL, SINT, INT, DINT, or REAL.: Is the assignment symbol.expressionRepresents the new value to assign to the tag.If tag is this data typeUse this type of expressionBOOLBOOL expressionSINTNumeric expressionINTDINTREAL;Ends the assignment.The tag retains the assigned value until another assignment changes the value.The expression can be simple, such as an immediate value or another tagname, or the expression can be complex and include several operators and/orfunctions.TIPPublication 1756-PM007C-EN-P - October 2009I/O module data updates asynchronously to the execution oflogic. If you reference an input multiple times in your logic,the input could change state between separate references. Ifyou need the input to have the same state for each reference,buffer the input value and reference that buffer tag.9

Program Structured TextChapter 1Specify a Non-retentive AssignmentThe non-retentive assignment is different from the regular assignmentdescribed above in that the tag in a non-retentive assignment is reset to zeroeach time the controller: enters the Run mode. leaves the step of an SFC if you configure the SFC for Automatic reset.(This applies only if you embed the assignment in the action of the stepor use the action to call a structured text routine via a JSR instruction.)A non-retentive assignment has this syntax:tag [: ] expression ;where:ComponentDescriptiontagRepresents the tag that is getting the new value.The tag must be a BOOL, SINT, INT, DINT, or REAL.[: ]Is the non-retentive assignment symbolexpressionRepresents the new value to assign to the tag.If tag is this data typeUse this type of expressionBOOLBOOL expressionSINTNumeric expressionINTDINTREAL;10Ends the assignment.Publication 1756-PM007C-EN-P - October 2009

Chapter 1Program Structured TextAssign an ASCII Character to a StringUse the assignment operator to assign an ASCII character to an element of theDATA member of a string tag. To assign a character, specify the value of thecharacter or specify the tag name, DATA member, and element of thecharacter.This is OKThis is not OKstring1.DATA[0]: 65;string1.DATA[0] : A;string1.DATA[0]: string2.DATA[0];string1 : string2;To add or insert a string of characters to a string tag, use either of these ASCIIstring instructions.ExpressionsToUse this instructionAdd characters to the end of a stringCONCATinsert characters into a stringINSERTAn expression is a tag name, equation, or comparison. To write an expression,use any of these elements. Tag name that stores the value (variable) Number that you enter directly into the expression (immediate value) Functions, such as: ABS, TRUNC Operators, such as: , -, , , And, OrAs you write expressions, follow these general rules. Use any combination of upper-case and lower-case letter. For example,these three variations of “AND” are acceptable: AND, And, and. For more complex requirements, use parentheses to group expressionswithin expressions. This makes the whole expression easier to read andensures that the expression executes in the desired sequence.IMPORTANTPublication 1756-PM007C-EN-P - October 2009You may add user comments inline. Therefore, local languageswitching does not apply to your programming language.11

Program Structured TextChapter 1In structured text, you use two types of expressions:BOOL expression: An expression that produces either the BOOL value of1 (true) or 0 (false). A bool expression uses bool tags, relational operators, and logicaloperators to compare values or check if conditions are true or false.For example, tag1 65. A simple bool expression can be a single BOOL tag. Typically, you use bool expressions to condition the execution of otherlogic.Numeric expression: An expression that calculates an integer orfloating-point value. A numeric expression uses arithmetic operators, arithmetic functions,and bitwise operators. For example, tag1 5. Often, you nest a numeric expression within a bool expression. Forexample, (tag1 5) 65.Use the following table to choose operators for your expressions:12If you want toThenCalculate an arithmetic valueUse Arithmetic Operators and Functions on page 13.Compare two values or stringsUse Relational Operators on page 14.Check if conditions are true or falseUse Logical Operators on page 16.Compare the bits within valuesUse Bitwise Operators on page 17.Publication 1756-PM007C-EN-P - October 2009

Chapter 1Program Structured TextUse Arithmetic Operators and FunctionsYou can combine multiple operators and functions in arithmetic expressions.Arithmetic operators calculate new values.ToUse this operatorOptimal data typeAdd DINT, REALSubtract/negate-DINT, REALMultiply*DINT, REALExponent (x to the power of y)**DINT, REALDivide/DINT, REALModulo-divideMODDINT, REALArithmetic functions perform math operations. Specify a constant, anon-boolean tag, or an expression for the function.Publication 1756-PM007C-EN-P - October 2009ForUse this functionOptimal data typeAbsolute valueABS (numeric expression)DINT, REALArc cosineACOS (numeric expression)REALArc sineASIN (numeric expression)REALArc tangentATAN (numeric expression)REALCosineCOS (numeric expression)REALRadians to degreesDEG (numeric expression)DINT, REALNatural logLN (numeric expression)REALLog base 10LOG (numeric expression)REALDegrees to radiansRAD (numeric expression)DINT, REALSineSIN (numeric expression)REALSquare rootSQRT (numeric expression)DINT, REALTangentTAN (numeric expression)REALTruncateTRUNC (numeric expression)DINT, REAL13

Program Structured TextChapter 1For example:Use this formatExampleFor this situationYou’d writevalue1 operator value2If gain 4 and gain 4 adj are DINT tags and yourspecification says: "Add 15 to gain 4 and store theresult in gain 4 adj."gain 4 adj : gain 4 15;operator value1If alarm and high alarm are DINT tags and yourspecification says: “Negate high alarm and storethe result in alarm.”alarm: -high alarm;function(numeric expression)If overtravel and overtravel POS are DINT tags andyour specification says: “Calculate the absolutevalue of overtravel and store the result inovertravel POS.”overtravel POS : ABS(overtravel);value1 operator (function((value2 value3)/2)If adjustment and position are DINT tags andsensor1 and sensor2 are REAL tags and yourspecification says: “Find the absolute value of theaverage of sensor1 and sensor2, add theadjustment, and store the result in position.”position : adjustment ABS((sensor1 sensor2)/2);Use Relational OperatorsRelational operators compare two values or strings to provide a true or falseresult. The result of a relational operation is a BOOL value.If the comparison isThe result isTrue1False0Use these relational operators.14For this comparison:Use this operator:Optimal Data Type:Equal DINT, REAL, stringLess than DINT, REAL, stringLess than or equal DINT, REAL, stringGreater than DINT, REAL, stringGreater than or equal DINT, REAL, stringNot equal DINT, REAL, stringPublication 1756-PM007C-EN-P - October 2009

Chapter 1Program Structured TextFor example:Use this formatExampleFor this situationYou’d writevalue1 operator value2If temp is a DINT tag and your specificationsays: “If temp is less than 100 then ”IF temp 100 THEN.stringtag1 operator stringtag2If bar code and dest are string tags and yourspecification says: “If bar code equals destthen ”IF bar code dest THEN.char1 operator char2If bar code is a string tag and yourspecification says: “If bar code.DATA[0] equals’A’ then ”IF bar code.DATA[0] 65 THEN.If count and length are DINT tags, done is aBOOL tag, and your specification says ”If countis greater than or equal to length, you are donecounting.”done : (count length);To enter an ASCII character directly intothe expression, enter the decimal value ofthe character.bool tag : bool expressionsHow Strings Are EvaluatedThe hexadecimal values of the ASCII characters determine if one string is lessthan or greater than another string. When the two strings are sorted as in a telephone directory, the order ofthe strings determines which one is greater.lessergreaterASCII CharactersHex Codes1ab 31 61 621b 31 62A 41AB 41 42B 42a 61ab 61 62AB Ba B Strings are equal if their characters match. Characters are case sensitive. Upper case “A” ( 41) is not equal to lowercase “a” ( 61).Publication 1756-PM007C-EN-P - October 200915

Program Structured TextChapter 1Use Logical OperatorsLogical operators let you check if multiple conditions are true or false. Theresult of a logical operation is a BOOL value:If the comparison isThe result isTrue1False0Use these logical operators:ForUse this operatorData TypeLogical AND&, ANDBOOLLogical ORORBOOLLogical exclusive ORXORBOOLLogical complementNOTBOOLFor example:Use this formatExampleFor this situationYou’d writeBOOLtagIf photoeye is a BOOL tag and your specification IF photoeye THEN.says: “If photoeye 1 is on then ”NOT BOOLtagIf photoeye is a BOOL tag and your specification IF NOT photoeye THEN.says: “If photoeye is off then ”expression1 & expression2If photoeye is a BOOL tag, temp is a DINT tag,and your specification says: “If photoeye is onand temp is less than 100 then ”.IF photoeye & (temp 100) THEN.expression1 OR expression2If photoeye is a BOOL tag, temp is a DINT tag,and your specification says: “If photoeye is onor temp is less than 100 then ”.IF photoeye OR (temp 100) THEN.expression1 XOR expression2If photoeye1 and photoeye2 are BOOL tags andyour specification says: “If:IF photoeye1 XOR photoeye2 THEN. photoeye1 is on while photoeye2 is off or photoeye1 is off while photoeye2 is onthen "BOOLtag : expression1 & expression216open : photoeye1 & photoeye2;If photoeye1 and photoeye2 are BOOL tags,open is a BOOL tag, and your specification says:“If photoeye1 and photoeye2 are both on, setopen to true”.Publication 1756-PM007C-EN-P - October 2009

Chapter 1Program Structured TextUse Bitwise OperatorsBitwise operators manipulate the bits within a value based on two values.ForUse this operatorOptimal Data TypeBitwise AND&, ANDDINTBitwise ORORDINTBitwise exclusive ORXORDINTBitwise complementNOTDINTFor example:Use this formatvalue1 operator value2ExampleFor this situationYou’d writeIf input1, input2, and result1 are DINT tags and yourspecification says: “Calculate the bitwise result ofinput1 and input2. Store the result in result1.”result1 : input1 AND input2;Determine the Order of ExecutionThe operations you write into an expression are performed in a prescribedorder, not necessarily from left to right. Operations of equal order are performed from left to right. If an expression contains multiple operators or functions, group theconditions in parenthesis “( )”. This ensures the correct order ofexecution and makes it easier to read the expression.Publication 1756-PM007C-EN-P - October 2009OrderOperation1.()2.function ( )3.**4.- (negate)5.NOT6.*, /, MOD7. , - (subtract)8. , , , 9. , 10.&, AND11.XOR12.OR17

Program Structured TextInstructionsChapter 1Structured text statements can also be instructions. A structured textinstruction executes each time it is scanned. A structured text instructionwithin a construct executes every time the conditions of the construct are true.If the conditions of the construct are false, the statements within the constructare not scanned. There is no rung-condition or state transition that triggersexecution.This differs from function block instructions that use EnableIn to triggerexecution. Structured text instructions execute as if EnableIn is always set.This also differs from relay ladder instructions that use rung-condition-in totrigger execution. Some relay ladder instructions only execute whenrung-condition-in toggles from false to true. These are transitional relay ladderinstructions. In structured text, instructions will execute each time they arescanned unless you pre-condition the execution of the structured textinstruction.For example, the ABL instruction is a transitional instruction in relay ladder. Inthis example, the ABL instruction only executes on a scan when tag xictransitions from cleared to set. The ABL instruction does not execute whentag xic stays set or when tag xic is cleared.In structured text, if you write this example as:IF tag xic THEN ABL(0,serial control);END IF;the ABL instruction will execute every scan that tag xic is set, not just whentag xic transitions from cleared to set.If you want the ABL instruction to execute only when tag xic transitions fromcleared to set, you have to condition the structured text instruction. Use a oneshot to trigger execution.osri 1.InputBit : tag xic;OSRI(osri 1);IF (osri 1.OutputBit) THENABL(0,serial control);END IF;18Publication 1756-PM007C-EN-P - October 2009

Chapter 1Program Structured TextConstructsConstructs can be programmed singly or nested within other constructs.If you want toUse this constructDo something if or when specific conditions occurIF.THENSelect what to do based on a numerical valueCASE.OFDo something a specific number of times before doinganything elseFOR.DOKeep doing something as long as certain conditions aretrueWHILE.DOKeep doing something until a condition is trueREPEAT.UNTILSome Key Words Are Reserved for Future UseThese constructs are not available: GOTO REPEATRSLogix 5000 software will not let you use them.Publication 1756-PM007C-EN-P - October 200919

Program Structured TextChapter 1Use IF THEN to do something if or when specific conditions occur.IF.THENOperands:Structured TextIF bool expression THEN statement ;END IF;OperandTypeFormatEnterboolexpressionBOOLTagBOOL tag or expression that evaluates toa BOOL value (BOOL expression)ExpressionDescription: The syntax is:IF bool expression1 THEN statement ;Statements to execute whenbool expression1 is true.OptionalELSIF bool expression2 THEN statement ;Statements to execute whenbool expression2 is true.OptionalELSE statement ;Statements to execute whenboth expressions are false.END IF;To use ELSIF or ELSE, follow these guidelines.1. To select from several possible groups of statements, add one or moreELSIF statements. Each ELSIF represents an alternative path. Specify as many ELSIF paths as you need. The controller executes the first true IF or ELSIF and skips the restof the ELSIFs and the ELSE.2. To do something when all of the IF or ELSIF conditions are false, addan ELSE statement.20Publication 1756-PM007C-EN-P - October 2009

Chapter 1Program Structured TextThis table summarizes combinations of IF, THEN, ELSIF, and ELSE.If you want toAndThen use this constructDo something if or when conditionsare trueDo nothing if conditions are falseIF THENChoose from alternative statements(or groups of statements) based oninput conditionsDo nothing if conditions are falseIF THEN ELSIFAssign default statements if allconditions are falseIF THEN ELSIF ELSEDo something else if conditions are false IF THEN ESLEArithmetic Status Flags: Not affectedFault Conditions: NoneExample 1: IF THENIf you want thisEnter this structured textIF rejects 3 thenIF rejects 3 THENconveyor off (0)conveyor : 0;alarm on (1)alarm : 1;END IF;Example 2: IF THEN ELSEIf you want thisEnter this structured textIf conveyor direction contact forward (1) thenIF conveyor direction THENlight offOtherwise light onlight : 0;ELSElight [: ] 1;END IF;The [: ] tells the controller to clear light whenever the controller: enters the Run mode. leaves the step of an SFC if you configure the SFC for Automatic reset.(This applies only if you embed the assignment in the action of the stepor use the action to call a structured text routine via a JSR instruction.)Publication 1756-PM007C-EN-P - October 200921

Program Structured TextChapter 1Example 3: IF THEN ELSIFIf you want thisEnter this structured textIf sugar low limit switch low (on) and sugar high limitswitch not high (on) thenIF Sugar.Low & Sugar.High THENinlet valve open (on)Sugar.Inlet [: ] 1;Until sugar high limit switch high (off)ELSIF NOT(Sugar.High) THENSugar.Inlet : 0;END IF;The [: ] tells the controller to clear Sugar.Inlet whenever the controller: enters the Run mode. leaves the step of an SFC if you configure the SFC for Automatic reset.(This applies only if you embed the assignment in the action of the stepor use the action to call a structured text routine via a JSR instruction.)Example 4: IF THEN ELSIF ELSEIf you want thisEnter this structured textIf tank temperature 100IF tank.temp 200 THENthen pump slowIf tank temperature 200pump.fast : 1; pump.slow : 0; pump.off : 0;ELSIF tank.temp 100 THENthen pump fastotherwise pump offpump.fast : 0; pump.slow : 1; pump.off : 0;ELSEpump.fast : 0; pump.slow : 0; pump.off : 1;END IF;22Publication 1756-PM007C-EN-P - October 2009

Chapter 1Program Structured TextUse CASE to select what to do based on a numerical value.CASE.OFOperands:Structured TextCASE numeric expression OFselector1: statement;selectorN: expressionTag or expression that evaluates to anumber (numeric expression)INTExpressionstatement;DINTEND CASE;REALselectorImmediateSINTSame type as numeric expressionINTDINTREALIMPORTANTIf you use REAL values, use a range of values for a selectorbecause a REAL value is more likely to be within a range ofvalues than an exact match of one, specific value.Description: The syntax is:CASE numeric expression OFSpecify as manyalternative selectorvalues (paths) as youneedselector1 : statement ;.Statements to execute whennumeric expression selector1selector2 : statement ;Statements to execute whennumeric expression selector2.selector3 : statement ;.Publication 1756-PM007C-EN-P - October 2009Statements to execute whennumeric expression selector323

Program Structured TextChapter 1ELSE statement ;optionalStatements to execute whennumeric expression ¼ anyselector.END CASE;The syntax for entering the selector values is:When selector isEnterOne valuevalue: statementMultiple, distinct valuesvalue1, value2, valueN : statement Use a comma (,) to separate each value.A range of valuesvalue1.valueN : statement Use two periods (.) to identify the range.Distinct values plus a range valuea, valueb, value1.valueN : statement of valuesThe CASE construct is similar to a switch statement in the C or C programming languages. However, with the CASE construct the controllerexecutes only the statements that are associated with the first matchingselector value. Execution always breaks after the statements of that selectorand goes to the END CASE statement.Arithmetic Status Flags: Not affectedFault Conditions: NoneExample24Publication 1756-PM007C-EN-P - October 2009

Chapter 1Program Structured TextExampleIf you want thisEnter this structured textIf recipe number 1 thenCASE recipe number OF1:Ingredient A outlet 1 open (1)Ingredient B outlet 4 open (1)Ingredient A.Outlet 1 : 1;Ingredient B.Outlet 4 : 1;If recipe number 2 or 3 then2,3:Ingredient A outlet 4 open (1)Ingredient A.Outlet 4 : 1;Ingredient B.Outlet 2 : 1;Ingredient B outlet 2 open (1)If recipe number 4, 5, 6, or 7 then4.7:Ingredient A outlet 4 open (1)Ingredient A.Outlet 4 : 1;Ingredient B.Outlet 2 : 1;Ingredient B outlet 2 open (1)If recipe number 8, 11, 12, or 13 then8,11.13Ingredient A outlet 1 open (1)Ingredient A.Outlet 1 : 1;Ingredient B.Outlet 4 : 1;Ingredient B outlet 4 open (1)Otherwise all outlets closed (0)ELSEIngredient A.Outlet 1 [: ]0;Ingredient A.Outlet 4 [: ]0;Ingredient B.Outlet 2 [: ]0;Ingredient B.Outlet 4 [: ]0;END CASE;The [: ] tells the controller to also clear the outlet tags whenever thecontroller: enters the Run mode. leaves the step of an SFC if you configure the SFC for Automatic reset.(This applies only if you embed the assignment in the action of the stepor use the action to call a structured text routine via a JSR instruction.)Publication 1756-PM007C-EN-P - October 200925

Program Structured TextChapter 1Use the FOR DO loop to do something a specific number of times beforedoing anything else.FOR DOOperands:Structured TextFOR count: initial value TO final value BYincrement DO statement ;OperandTypeFormatDescriptioncountSINTTagTag to store count position as theFOR DO executesSINTTagMust evaluate to a numberINTExpressionSpecifies initial value for eSINTTagINTExpressionDINTImmediateEND FOR;INTDINTinitial valuefinal valueincrementSpecifi

Comments can appear anywhere in structured text. //comment (*start of comment . . . end of comment*) /*start of comment . . . end of comment*/ Term Definition Examples IMPORTANT Use caution when copying and pasting components between different versions of RSLogix 5000 programming software. RSLogix 5000 software only supports pasting to the sameFile Size: 1MB

Related Documents:

Logix5000 Controllers Common Procedures Programming Manual, publication 1756-PM001. The term Logix5000 controller refers to any controller that is based on the Logix5000 operating system, such as: CompactLogix and Compact GuardLogix controllers ControlLogix and GuardLogix controllers DriveLogix controllers. FlexLogix controllers.

Text text text Text text text Text text text Text text text Text text text Text text text Text text text Text text text Text text text Text text text Text text text

Common Procedures Programming Manual, publication 1756-PM001. The term Logix5000 controller refers to any controller that is based on the Logix5000 operating system, such as: CompactLogix controllers ControlLogix controllers DriveLogix controllers FlexLogix controllers SoftLogix5800 controllers

Procedures Programming Manual, publication 1756-PM001. The term Logix5000 controller refers to any controller that is based on the Logix5000 operating system, such as: CompactLogix controllers ControlLogix controllers DriveLogix controllers FlexLogix controllers SoftLogix5800 controllers

This manual also provides system information you need to make system design choices. Logix5000 Controllers Common Procedures Manual, publication 1756-PM001 Guides the development of projects for Logix5000 controllers. It provides links to individual guides. Logix5000 Controllers General Instruction Set

Logix5000 Controllers Motion Instructions Reference Manual, publication 1756-RM007 Program the controller to use equipment phases PhaseManager User Manual, publication LOGIX-UM001 Import a text file or tags into a project Logix5000 Controllers Import/Export Reference Manual, publication 1756-RM084

1 Publication 1756-PM001G-EN-P - March 2004 Preface Purpose of this Manual This manual guides the development of projects for Logix5000 controllers. It provides step-by-step procedures on how to perform the following tasks, which are common to all Logix5000 controllers:

1756-Lx ControlLogix Selection Guide 1756-SG001 1756-Lx ControlLogix System User Manual 1756-UM001 1756-Lx, 1769-Lx, 1789-Lx, 1794-Lx, PowerFlex 700S Logix5000 Controllers Quick Reference 1756-QR107 1756-Lx, 1769-Lx, 1789-Lx, 1794-Lx, PowerFlex 700S Logix5000 Controllers Common Procedures Programming Manual 1756-PM001 1756-Lx, 1769-Lx, 1789-Lx .