Home
1756-PM003H-EN-E, SFC and ST Programming Languages
Contents
1. xX SBR Subroutine The operands are the same as those for the relay ladder SBR instruction Publication 1756 PM003H EN E excerpt from 1756 RMO003H EN P August 2005 RET Operands RET Return Return par RET Return ET ReturnPar us Description Program Control Instructions JSR RET SBR 10 5 Relay Ladder Operand Type Format Description Return BOOL immediate data from this routine that you want to copy parameter SINT tag to the corresponding return parameter in the INT array tag JSR instruction DINT REAL structure Structured Text The operands are the same as those for the relay ladder RET instruction Function Block Parameters w iN RET Return The operands are the same as those for the relay ladder RET instruction The JSR instruction initiates the execution of the specified routine which is referred to as a subroutine e The subroutine executes one time e After the subroutine executes logic execution returns to the routine that contains the JSR instruction To program a jump to a subroutine follow these guidelines IMPORTANT Do not use a JSR instruction to call execute the main routine e You can put a JSR instruction in the main routine or any other routine e If you use a JSR instruction to call the main routine and then put a RET instruction in the main routine a major fault occurs type 4 code 31 Publication 1756 PIM00
2. Automatic reset Don t scan C Programmatic reset This table compares the different options for handling the last scan of a step During the last scan of a step this option does execution actions Don t scan Only P and PO actions execute They execute according to their logic Programmatic reset All actions execute according to their logic Automatic reset e P and PO actions execute according to their logic e All other actions execute in postscan mode e On the next scan of the routine the P and PO actions execute in postscan mode retention of data values All data keeps its current values All data keeps its current values e Data reverts to its values for postscan e Tags to the left of assignments clear to zero method for clearing data Use P and PO actions Use either e status bits of the step or action to condition logic e P and PO actions Use either e assignment non retentive assignment e instructions that clear their data during postscan reset of a nested SFC A nested SFCs remains at its current step A nested SFCs remains at its current step Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 For the Restart Position property if you choose the Restart at initial step option then e Anested SFC resets to its initial step e The X bit of a stop element in a nested SFC clears
3. ELS optional J l ELSE optional J F bool _ expressionZ THEN lt statement gt lt q Statements to execute when bool_expression2 is true lt statement gt lt q Statements to execute when both expressions are false END F To use ELSIF or ELSE follow these guidelines 1 Toselectfromseveral possible groups ofstatements addone ormore ELSIF statements e Each ELSIF represents an alternative path e Specify as many ELSIF paths as you need e The controller executes the first true IF or ELSIF and skips the rest of the ELSIFs and the ELSE 2 Todosomething when all of the IF or ELSIF conditions are false add an ELSE statement Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 6 14 Program Structured Text This table summarizes combinations of IF THEN ELSIF and ELSE If you want to And Then use this construct do something if or when conditions do nothing if conditions are false IF THEN are true do something else if conditions are false IF THEN ESLE choose from alternative statements do nothing if conditions are false IF THEN ELSIF ATR based on Sasign default statements if al IF THEN ELSIF ELSE p conditions are false Arithmetic Status Flags not affected Fault Conditions none Example 1 IF THEN If you want this Enter this structured text IF rejects gt 3 then IF rejects gt 3 THEN conveyor off 0 c
4. Disabled Forces of this type are inactive If the project contains any forces of this type they are not overriding your logic Installed At least one force of this type exists in the project None Installed Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 No forces of this type exist in the project Force Logic Elements 13 5 FORCE LED If your controller has a FORCE LED use the LED to determine the status of any I O forces IMPORTANT The FORCE LED shows only the status of I O forces It does not show that status of SFC forces If the FORCE LED is Then off e No tags contain force values e 0 forces are inactive disabled flashing e Atleast one tag contains a force value e 0 forces are inactive disabled solid e 0 forces are active enabled e Force values may or may not exist GSV Instruction IMPORTANT The ForceStatus attribute shows only the status of I O forces It does not show the status of SFC forces This example shows how to use a GSV instruction to get the status of forces GSV Get System Value Class Name MODULE Instance Name Attribute Name ForceStatus Dest Force_Status o where Force_Status is a DINT tag To determine if Examine this bit For this value forces are installed 0 1 no forces are installed 0 0 forces are enabled 1 1 forces are disabled 1 0 Publication 1756 PM003H EN E excerpt from 1756 PM001H EN
5. 1 construct and then determines if the conditions are true before SEBERT executing the statements again T This differs from the WHILE DO loop because the WHILE DO DOS SS pos t 2 The WHILE DO loop evaluates its conditions first If the UNTIL pos 101 OR conditions are true the controller then executes the structarray pos value targetvalue statements within the loop The statements in a REPEAT UNTIL loop are always executed at least once The statements in a WHILE DO loop might never be executed end repeat Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Example 2 If you want this Move ASCII characters from a SINT array into a string tag In a SINT array each element holds one character Stop when you reach the carriage return 1 Initialize Element_number to 0 2 Count the number of elements in SINT_array array that contains the ASCII characters and store the result in SINT_array_size DINT tag 3 Set String_tag element_number the character at SINT_array element_number 4 Add 1 to element_number This lets the controller check the next character in SINT_array 5 Set the Length member of String_tag element_number This records the number of characters in String_tag so far 6 If element_number SINT_array_size then stop You are at the end of the array and it does not contain a carriage return 7 If the character at SINT_array element_number
6. L EXAMPLE o oo package_done on 1 and carton_size 8 a Package the product When the product is in the package the package_done bit turns on b Pack the product either 8 per carton or 16 per carton Solution Pac age carton 8 _ Pack_8 Pack_16 carton_16 5 package_done on 1 and carton_size 16 To override the state of a transition see Force Logic Elements on page 13 1 Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 4 24 Design a Sequential Function Chart Transition Tag Each transition uses a BOOL tag to represent the true or false state of the transition If the transition is The value is And true 1 The SFC goes to the next step false 0 The SFC continues to execute the current step How Do You Want to Program the Transition To program the transition you have these options If you want to Then enter the conditions as an expression in Use a BOOL Expression structured text enter the conditions as instructions in Call a Subroutine another routine use the same logic for multiple transitions Use a BOOL Expression The simplest way to program the transition is to enter the conditions as a BOOL expression in structured text A BOOL expression uses bool tags relational operators and logical operators to compare values or check if conditions are
7. Allen Bradley SFC and ST Programming Languages Excerpts from Logix5000 Controllers Common Procedures 1756 PM001H EN P Logix5000 Controllers General Instructions Reference Manual 1756 RM003H EN P Programming Manual Rockwell Automation Important User Information Solid state equipment has operational characteristics differing from those of electromechanical equipment Safety Guidelines for the Application Installation and Maintenance of Solid State Controls Publication SGI 1 1 available from your local Rockwell Automation sales office or online at http www ab com manuals gi describes some important differences between solid state equipment and hard wired electromechanical devices Because of this difference and also because of the wide variety of uses for solid state equipment all persons responsible for applying this equipment must satisfy themselves that each 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 use or application of this equipment The examples and diagrams in this manual are included solely for illustrative purposes Because of the many variables and requirements associated with any particular installation Rockwell Automation Inc cannot assume responsibility or liability for actual use based on the examples and diagrams No patent liability is assumed by Rockwe
8. green dot Hide a Wire If a wire gets in the way of other parts of your SFC hide the wire to make the SFC easier to read To hide a wire right click the wire and select Hide Wire location to which the wire goes To see the SFC element to which the wire goes click the grid location on the wire Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Program a Sequential Function Chart 5 9 Configure a Step Assign the Preset Time for a Step O m a step_name UJ 1 Click the button of the step Preset I n 4 ms 1 Use Expression Define 2 On the General tab type the time for the step in milliseconds 3 Click When the step is active for the preset time Timer Preset the DN bit of the step turns on To calculate the preset time for a step at runtime see Use an Expression to Calculate a Time on page 5 9 Configure Alarms for a Step To turn on an alarm if a step executes too long or not long enough 1 Click the button of the step O E step_name E 2 Check the AlarmEnable check box Alarming O AlarmHigh V AlarmEnable AlarmLow LimitHigh ms Use Expression Defne LimitLow 4 ms Use Expression Define Type the time for the high alarm and low alarm in milliseconds 3 Click To calculate the time for an alarm at runtime see Use an Expression to Calculate a Time on page 5 9 Publication 1756 PM00
9. Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Chapter 6 Program Structured Text When to Use This Chapter Use this chapter to write and enter structured text for a e structured text routine e action of a sequential function chart SFC e transition of sequential function chart SFC Structured Text Syntax Structured text is a textual programming language that uses statements to Term assignment see page 6 2 define what to execute e Structured text is not case sensitive e Usetabsandcarriage returns separate lines tomake yourstructured text easier to read They have no effect on the execution of the structured text Structured text can contain these components Definition Examples Use an assignment statement to assign values to tags tag expression The operator is the assignment operator ayn Terminate the assignment with a semi colon expression see page 6 4 An expression is part of a complete assignment or construct statement An expression evaluates to a number numerical expression or to a true or false state BOOL expression An expression contains tags A named area of the memory where data is stored valuel BOOL SINT INT DINT REAL string immediates A constant value 4 operators A symbol or mnemonic that specifies an operation tagl tag2 within an expression tagl gt valuel functions When executed a function yields one value Use f
10. numeric_expression selector2 lt statement gt lt q statements to execute when numeric_expression selector3 lt statement gt j j __ statements to execute when numeric_expression any selector See the table on the next page for valid selector values Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Arithmetic Status Flags Fault Conditions Program Structured Text 6 17 The syntax for entering the selector values is When selector is Enter one value value statement multiple distinct values value value2 valueN lt statement gt Use a comma to separate each value a range of values value1 valueN lt statement gt Use two periods to identify the range distinct values plus a range valuea valueb value1 valueN lt statement gt of values The CASE construct is similar to a switch statement in the C or C programming languages However withthe CASE constructthe controller executes only the statements that are associated with the first matching selector value Execution always breaksafterthe statements of thatselector and goes to the END_CASE statement not affected none Publication 1756 PIM003H EN E excerpt from 1756 PM001H EN P August 2005 6 18 Program Structured Text Example If you want this Enter this structured text If recipe number 1 then CASE recipe number OF Ingredient A outlet 1 open 1 al
11. 1 on page 4 20 2 In the step that turns off the device use a Reset action Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Design a Sequential Function Chart 4 37 This figure shows the use of a stored action Action Name action that you want to execute for more than one step step that starts the action more steps Action Name same name as the stored action Step_014 step that stops the action When the SFC leaves the step that stores the action RSLogix 5000 software continues to show the stored action as active By default a green border displays around the action This lets you know that the SFC is executing the logic of that action To use a stored action follow these guidelines e The Reset action only turns off the stored action It does not automatically turn off the devices of the action To turn off the device follow the Reset action with another action that turns off the device Or use the Automatic reset option described on page 4 33 e Before the SFC reaches a stop element reset any stored actions that you do not want to execute at the stop An active stored action remains active even if the SFC reaches a stop e Use caution when you jump in between a step that stores an action and a step that resets the action Once you reset an action it only starts when you execute the step that stores the action Publication 1756 PM003H EN E ex
12. P August 2005 13 6 Force Logic Elements What to Force You can force these elements of a project If you want to Then override an input value output value produced tag or consumed tag Add an 0 Force override the conditions of a transition one time to go from an active step to the next step Step Through a Transition or a Force of a Path override one time the force of a simultaneous path and execute the steps of the path override the conditions of a transition in a sequential function chart Add an SFC Force execute some but not all the paths of a simultaneous branch of a sequential function chart When to Use an l 0 Force Use an I O force to e override an input value from another controller G e a consumed tag e override an input value from an input device e override your logic and specify an output value for another controller G e a produced tag e override your logic and specify the state of an output device IMPORTANT Ma orcing increases logic execution time The more values you force the longer it takes to execute the logic IMPORTANT I O forces are held by the controller and not by the programming workstation Forces remain even if the programming workstation is disconnected When you force an I O value e You can force all I O data except for configuration data e If the tag is an array or structure such as an I O tag force a BOOL SINT INT DINT or REAL element or member e If t
13. PM001H EN P August 2005 4 2 Design a Sequential Function Chart Whatisa Sequential A Selene function eer SFC similar toa flowchart It oie 9 steps and transitions to perform specific operations or actions This Function Chart example shows the elements of an SFC Figure 4 1 SFC Example A step represents a major function of your process It contains the actions that occur at a particular time phase or station No devices_in_program_mode An action is one of the functions that a step performs conweyor_program_control l fan_program_control l _ fan_on fan_state l initialize_done __ A transition is the true or false condition that tells the SFC initialise DN fan Devicelitate when to go to the next step A qualifier determines when an action starts and stops conveyor_start Conveyor _state l PO conveyor_stop conveyor state 0 A simultaneous branch executes more than 1 step at the same time part_sensor_photorye N Action_003 o 0 palletize J Show or hide an action all_stations_done JSR Assembly_Done 0 JSR instruction calls a subroutine continued on next page Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Design a Sequential Function Chart 4 3 Figure 4 2 SFC Example continued from previous page pallet_check m E p
14. POSTAGE NECESSARY IF MAILED IN THE UNITED STATES PLEASE REMOVE ASCII Character Codes Character Dec Hex Character Dec Hex Character Dec Hex Character Dec Hex ctrl NUL 0 00 SPACE 32 20 64 40 96 60 ctrl A SOH 1 01 l 33 21 A 65 41 a 97 61 ctrl B STX 2 02 34 22 B 66 42 b 98 62 ctrl C ETX 3 03 35 23 C 67 43 c 99 63 ctrl D EOT 4 04 36 24 D 68 44 d 100 64 ctrl E ENQ 5 05 37 25 E 69 45 e 101 65 ctrl F ACK 6 06 amp 38 26 F 70 46 102 66 ctrl G BEL 7 07 39 27 G 71 47 g 103 67 ctrl H BS 8 08 40 28 H 72 48 h 104 68 ctrl I HT 9 09 41 29 l 73 49 i 105 69 ctrl J LF 10 I 0A r 42 2A J 74 4A j 106 6A ctrl K VT 11 0B 43 2B K 75 4B k 107 6B ctrl L FF 12 0C 44 2C L 76 4C l 108 6C ctrl M CR 13 r 0D 45 2D M 77 4D m 109 6D ctrl N SO 14 0E 46 2E N 78 4E n 110 6E ctrl O SI 15 OF 47 2F 0 79 4F 0 111 6F ctrl P DLE 16 10 0 48 30 P 80 50 p 112 70 ctrl Q DC1 17 11 1 49 31 Q 81 51 q 113 71 ctrl R DC2 18 12 2 50 32 R 82 52 r 114 72 ctrl S DC3 19 13 3 51 33 S 83 53 S 115 73 ctrl T DC4 20 14 4 52 34 T 84 54 t 116 74 ctrl U NAK 21 15 5 53 35 U 85 55 u 117 75 ctrl V SYN 22 16 6 54 36 V 86 56 V 118 76 ctrl W ETB 23 17 7 55 37 W 87 57 Ww 119
15. Rockwell Automation representative for any States technical support issues New Product Satisfaction Return Rockwell tests all of our products to ensure that they are fully operational when shipped from the manufacturing facility However if your product is not functioning and needs to be returned United States Contact your distributor You must provide a Customer Support case number see phone number above to obtain one to your distributor in order to complete the return process Outside United Please contact your local Rockwell Automation representative for States return procedure ControlNet is a trademark of ControlNet International Ltd DeviceNet is a trademark of the Open DeviceNet Vendor Association www rockwellautomation com Corporate Headquarters Rockwell Automation 777 East Wisconsin Avenue Suite 1400 Milwaukee WI 53202 5302 USA Tel 1 414 212 5200 Fax 1 414 212 5201 Headquarters for Allen Bradley Products Rockwell Software Products and Global Manufacturing Solutions Americas Rockwell Automation 1201 South Second Street Milwaukee WI 53204 2496 USA Tel 1 414 382 2000 Fax 1 414 382 4444 Europe Rockwell Automation SA NV Vorstlaan Boulevard du Souverain 36 BP 3A B 1170 Brussels Belgium Tel 32 2 663 0600 Fax 32 2 663 0640 Asia Pacific Rockwell Automation 27 F Citicorp Centre 18 Whitfield Road Causeway Bay Hong Kong Tel 852 2887 4788 Fax 852 2508 1846 Headquarters for
16. a bit in its tag SFC_ACTION structure To do the action other logic must monitor the bit and execute when the bit is on With boolean actions you have to manually reset the assignments and instructions that are associated with the action Since there is no link between the action and the logic that performs the action the automatic reset option does not effect boolean actions Publication 1756 PIM003H EN E excerpt from 1756 PM001H EN P August 2005 4 18 Design a Sequential Function Chart For example B N S_Open_Outlet S_Complete_the_Batch When the S_Complete_the_Batch step is active the S_Open_Outlet action executes When the action is active its Q bit turns on S_Open_Outlet Q JSR Jump To Subroutine Routine Name Open_Outlet A ladder logic routine monitors the Q bit S_Open_Outlet Q When the Q bit is on the JSR instruction executes and opens the outlet valve You can reuse a boolean action multiple times within the same SFC SFC_ACTION Structure Each action non boolean and boolean uses a tag to provide information about the action Access this information via either the Action Properties dialog or the Monitor Tags tab of the Tags window If you want to Then check or set Datatype Details this member determine when the action is 0 BOOL The status of the O bit depends on whether the action is a boolean active action or non boolean action If the action is Then the Q b
17. a station either drills or polishes Selection Branch Drill Polish To simplify my programming want to separate communications Simultaneous Branch and block transfers from other control logic All occur at the same etl time Control Comms BTs In a heat treating area the temperature ramps up at a specific Sequence rate maintains that temperature for a specific duration and then cools at a specific rate Ramp Maintain Cool At station 12 the machine drills taps and bolts a part The steps Sequence occur one after the other Drill Tap Bolt Step 12 inspects a process for the correct mix of chemicals Wire N start of SFC e f OK then continue with the remaining steps Step 12 e f not OK go to the top of the SFC and purge the system Not 0 OK Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 each path has its own transition do this Y Design a Sequential Function Chart 4 13 Sequence A sequence is a group of steps that execute one after the other do this THEN this THEN this Selection Branch A selection branch represents a choice between one path step or group of steps or another path i e an OR structure e Only one path executes e By default the SFC checks the transitions from left to right The SFC takes the first true path RSLogix 5000 software lets you change the order in which the SFC
18. a step or stop Reset SFR instruction that the instruction specifies e The Reset bit indicates to which step or stop the SFC will go to begin executing again e Once the SFC executes the Reset bit clears determine the maximum time TMax DINT Use this for diagnostic purposes The controller clears this value that a step has been active only when you select the Restart Position of Restart at initial step during any of its executions and the controller changes modes or experiences a power cycle determine if the Timer T value OV BOOL Use this for diagnostic purposes rolls over to a negative value Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 4 10 Design a Sequential Function Chart If you want to Thencheckorset Data type this member Details determine how many times a Count DINT This is not a count of scans of the step step has become active e The count increments each time the step becomes active e t increments again only after the step goes inactive and then active again e The count resets only if you configure the SFC to restart at the initial step With that configuration it resets when the controller changes from program mode to run mode use one tag for the various Status DINT For this member Use this bit status bits of this step Raset 77 AlarmHigh 23 AlarmLow 24 AlarmEn 25 OV 26 DN 27 LS 28 SA 29 FS 30 X 31 1 The FS and LS bits are only active dur
19. area e EnablingI Oforcescausesinput output produced orconsumedvalues to change e Ifforces are enabled and you installa force the new force immediately takes effect 1 What is the state of the I O Forces indicator If Then note off No 1 0 forces currently exist flashing No I O forces are active But at least one force already exists in your project When you enable 1 0 forces a existing 1 0 forces will also take effect solid 1 0 forces are enabled active When you install add a force it immediately takes effect 2 Open the routine that contains the tag that you want to force Publication 1756 PIM003H EN E excerpt from 1756 PM001H EN P August 2005 13 8 Force Logic Elements When to Use Step Through Step Through a Transition or a Force of a Path 3 Right click the tag and choose Monitor If necessary expand the tag to show the value that you want to force e g BOOL value of a DINT tag 4 Install the force value To force a Do this BOOL value Right click the tag and choose Force ON or Force OFF non BOOL value In the Force Mask column for the tag type the value to which you want to force the tag Then press the Enter key 5 Are I O forces enabled See step 1 If Then no From the Logic menu choose 1 0 Forcing gt Enable All 1 0 Forces Then choose Yes to confirm yes Stop To override a false transition one time and go from an active step to the next ste
20. at SINT_array element_number 5 Add 1 to element_number This lets the controller check the next character in SINT_array 6 Set the Length member of String_tag element_number This records the number of characters in String_tag so far 7 If element_number SINT_array_size then stop You are at the end of the array and it does not contain a carriage return 8 Go to 3 Enter this structured text element number 0 SIZE SINT array 0 SINT array size While SINT array element_ number lt gt 13 do String tag DATA element number SINT array element_ number element _number element number 1 String tag LEN element number If element number SINT array size then exit end_if end while Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Program Structured Text 6 25 REPEAT UNTIL Use the REPEAT UNTIL loop to keep doing something until conditions are true Operands Structured Text REPEAT lt statement gt Do i a UNTIL bool expression bool_ l BOOL tag BOOL tag or expression that evaluates to D BEP AT expression expression a BOOL value BOOL expression IMPORTANT Makesurethatyoudonotiteratewithinthelooptoomanytimesinasingle scan e Thecontrollerdoesnotexecuteanyotherstatementsintheroutineuntil it completes the loop e If the time that it takes to complete the loop is greater than the watchdog timer for the task a major fa
21. checks the transitions see chapter 5 single horizontal q line OR this OR this This path skips the structure does nothing single horizontal lt q line Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 4 14 Design a Sequential Function Chart Simultaneous Branch A simultaneous branch represents paths steps or group of steps that occur at the same time G e an AND structure e All paths execute e All paths must finish before continuing with the SFC e The SFC checks the transition after the last step of each path has executed at least once one transition for all paths gt g double horizontal do this AND this AND this line Y Y Y double horizontal line Wire to a Previous Step In addition to connecting steps in sequences simultaneous branches and selection branches you can connect a step to a previous point in your SFC This lets you e loop back and repeat steps e return to the beginning of the SFC and start over Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Design a Sequential Function Chart 4 15 For example y gt go to this step If this condition is true simpl
22. from 1756 PM001H EN P August 2005 13 2 Force Logic Elements Precautions When you use forces take these precautions Forcingcancauseunexpectedmachinemotionthatcouldinjure personnel ATTENTION l Beforeyouuseaforce determine howtheforcewilleffectyour machine or process and keep personnel away from the machine area e EnablingI Oforcescausesinput output produced orconsumedvalues to change e Enabling SFC forces causes your machine or processto gotoa different state or phase e Removing forces may still leave forces in the enabled state e Ifforces are enabled and you installa force the new force immediately takes effect Enable Forces For a force to take effect you enable forces You can only enable and disable forces at the controller level e You can enable I O forces and SFC forces separately or at the same time e You cannot enable or disable forces for a specific module tag collection or tag element IMPORTANT If you download a project that has forces enabled the programming software prompts youto enableordisable forces after the download completes When forces are in effect enabled a gt appears next to the forced element Step_001 Oo Tran_010 bool tag 1 Local 5 Data 13 Local 5 0 Data 6 MOV Move Source Flow_Valve_1 Re Dest Local 3 0 ChiData La Ke b gt TRUE forces are in effect enabled state to which the element is forced Publication 1756 PM
23. in the simultaneous branch as long as the force is active Gnstalled and enabled e To leave a simultaneous branch the last step of each path must execute at least one time and the transition below the branch must be true e Forcing a transition false prevents the SFC from reaching the last step of a path e When you remove or disable the force the SFC can execute the rest of the steps in the path Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 13 10 Force Logic Elements For example to exit this branch the SFC must be able to e execute Step_011 at least once e get past Tran_011 and execute Step_012 at least once e determine that Tran_012 is true E Tao bool_tag_3 Force a Simultaneous Path To prevent the execution of a path of a simultaneous branch force the path false When the SFC reaches the branch it executes only the un forced paths This path executes This path does not execute If you force a path of a simultaneous branch to be false the SFC stays in the simultaneous branch as long as the force is active installed and enabled Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Force Logic Elements 13 11 e To leave a simultaneous branch the last step of each path must execute at least one time and the transition below the branch must be true e Forcing a path false prevents the SFC from entering a path and executing it
24. of the path that is to the left of where you want to add the new path Click green dot 3 To wire the selection branch to the preceding step click the bottom pin of the step A and then click the horizontal line of the branch B A green dot shows a valid connection point Publication 1756 PIM003H EN E excerpt from 1756 PIM001H EN P August 2005 5 6 Program a Sequential Function Chart End a Selection Branch 1 Select the last transition of each path in the branch To select the transitions you can either e Click and drag the pointer around the transitions that you want to select e Click the first transition Then press and hold Shift and click the rest of the transitions that you want to select 0 0 Tran_004 Tran_005 Tran_006 2 E 2 On the SFC toolbar click 3 Add the step that follows the selection branch green dot 4 To wire the selection branch to the step click the top pin of the step A and then click the horizontal line of the branch B A green dot shows a valid connection point Set the Priorities of a By default the SFC checks the transitions that start a selection branch from left to right If you want to check a different transition first Selection Branch assign a priority to each path of the selection branch For example it is a good practice to check for error conditions first Then check for normal conditions To assign priorities to a selection branch
25. on Timer clears and then begins to increment AlarmLow stays on You have to manually turn it off 5 Timer reaches the LimitHigh value of the step AlarmHigh bit turns on Timer continues to increment 6 Step becomes inactive X bit turns off Timer retains its value AlarmHigh stays on You have to manually turn it off Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 4 28 Design a Sequential Function Chart Here is an example of the use of the Preset time of a step EXAMPLE Functional specification says a Cook the ingredients in the tank for 20 seconds b Empty the tank Solution Cook PRE 20000 ms Cook DN on 1 Here is an example of the use of the high alarm of a step EXAMPLE Functional specification says a Home 8 devices b Ifall8devicesarenothome within 20 seconds then shutdown the system Solution Init LimitHigh 20000 ms Init_OK _ __ Init_Not_OK jnit AlarmHigh Step_1 Shutdown Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Design a Sequential Function Chart 4 29 Turn Off a Device atthe End When the SFC leaves a step you have several options on how to turn off devices that the step turned on of a Step Programmatic Reset Automatic Reset use logic to clear let the controll
26. option enter a numeric expression that calculates the time at runtime DN BOOL When the Timer T reaches the Preset PRE value the Done DN bit turns on and stays on until the step becomes active again flag if a step did not execute LimitLow DINT Enter the time in the LimitLow member milliseconds long enough e If the step goes inactive before the Timer T reaches the LimitLow value the AlarmLow bit turns on e The AlarmLow bit stays on until you reset it e To use this alarm function turn on check the AlarmEnable AlarmEn bit As an option enter a numeric expression that calculates the time at runtime AlarmEn BOOL To use the alarm bits turn on check the AlarmEnable AlarmEn AlarmLow BOOL bit If the step goes inactive before the Timer T reaches the LimitLow value the AlarmLow bit turns on e The bit stays on until you reset it e To use this alarm function turn on check the AlarmEnable AlarmEn bit Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Design a Sequential Function Chart 4 9 If you want to Thencheckorset Datatype Details this member flag if a step is executing too LimitHigh DINT Enter the time in the LimitHigh member milliseconds long e Ifthe Timer T reaches the LimitHigh value the AlarmHigh bit turns on e The AlarmHigh bit stays on until you reset it e To use this alarm function turn on check the AlarmEnable AlarmEn bit As an o
27. program mode to run mode use one tag for the various Status DINT For this member Use this bit status bits of this action 0 30 A 31 Describe Each Action in To organize the logic for an action first describe the action in Pseudocode pseudocode If you are unfamiliar with pseudocode e Use a series of short statements that describe what should happen e Use terms or symbols such as if then otherwise until and or ee e Sequence the statements in the order that they should execute e If necessary name the conditions to check first when Ist and then the action to take second what 2nd Enter the pseudocode into the body of the action After you enter the pseudocode you can e Refine the pseudocode so it executes as structured text e Use the pseudocode to design your logic and leave the pseudocode as comments Since all structured text comments download to the controller your pseudocode is always available as documentation for the action Publication 1756 PIM003H EN E excerpt from 1756 PM001H EN P August 2005 4 20 Design a Sequential Function Chart Choose a Qualifier for an Action Table 4 1 Choose a Qualifier for an Action To convert the pseudocode to structured text comments add these comment symbols For a comment on a single line comment Use one of these formats that spans more than one line comment start of comment start of comment comment end of en
28. such as new part that is in position a temperature that is reached a preset time that is reached or a recipe selection that occurs The step is the actions that take place before that change Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 4 8 Design a Sequential Function Chart If you want to e Stop when your steps are in meaningful increments For example This organization of steps Is produce_solution probably too large set_mode close_outlet set_temperature probably too small open_inlet_a close_inlet_a set_timer reset_temperature open_outlet reset_mode preset_tank add_ingredient_a cook drain probably about right SFC_STEP Structure Each step uses a tag to provide information about the step Access this information via either the Step Properties dialog box or the Monitor Tags tab of the Tags window Thencheckorset Data type this member Details determine how long a step has T DINT When a step becomes active the Timer T value resets and then been active milliseconds starts to count up in milliseconds The timer continues to count up until the step goes inactive regardless of the Preset PRE value flag when the step has been PRE DINT Enter the time in the Preset PRE member When the Timer T active for a specific length of reaches the Preset value the Done DN bit turns on and stays on time milliseconds until the step becomes active again As an
29. the button of the element 2 Click the Tag tab and type the description for the element General Action Order Tag Name Description z z 3 Click 4 Drag the description box to the desired location on the SFC Add a Text Box A text box lets you add notes that clarify the function of an SFC element step transition stop etc Text boxes are only stored in the offline ACD project file Text boxes are not downloaded into controller memory Or use a text box to capture information that you will use later on For example urn on the fan transfer J fala E 1 Click TSF SFC A text box appears J 2 Drag the text box to a location near the element to which it applies 3 Double click the text box and type the note Then press Ctrl Enter Publication 1756 PIM003H EN E excerpt from 1756 PM001H EN P August 2005 Program a Sequential Function Chart 5 19 4 As you move the element on the SFC what do you want the text box to do If you the text box to Then stay in the same spot Stop You are done move with the element to which it Go to step 5 applies a 7 Step_002 i A green dot 5 Click the pin symbol in the text box and then click the SFC element to which you want to attach the text box A green dot shows a valid connection point Show or Hide Text Boxes or Tag Descriptions You have the option of showing or hiding both text boxes and tag descript
30. the step is not on its last scan conveyor_fwd LS 0 this statement turns on conveyor_state When conveyor_state turns on the conveyor turns on On the last scan of the step conveyor_fwd LS 1 this statement turns off conveyor_state When conveyor_state turns off the conveyor turns off Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Design a Sequential Function Chart 4 33 For an action that uses one of the stored qualifiers use the Q bit of the action to condition your logic See SFC_ACTION Structure on page 418 EXAMPLE Use the Programmatic Reset Option and the Q Bit When the action is not on its last scan conveyor_start Q 1 this statement turns on conveyor_state When conveyor_state turns on the conveyor turns on On the last scan of the action conveyor_start Q 0 this statement turns off conveyor_state When conveyor_state turns off the conveyor turns off You can also use a PO Pulse Falling Edge action to clear data This example uses an action to turn on a conveyor at the start of a step A different action turns off the conveyor at the end of the step EXAMPLE Use the Programmatic Reset Option and a PO Action m N f conveyor_start PrE conveyor_state 1 PO __ conveyor_stop conveyor state 0 This action turns on the conveyor When conveyor_state turns on the conveyor turns on Sal conveyor_fwd Before the
31. true or false For example tag1 gt 65 Here are some examples of BOOL expressions bool tag a bool tag a amp dint _tag a gt 8 bool _tag_b Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Design a Sequential Function Chart 4 25 Call a Subroutine To use a subroutine to control a transition include an End Of Transition EOT instruction in the subroutine The EOT instruction returns the state of the conditions to the transition as shown below condition_1 condition_2 s condition_3 BOOL_tag a a A BOOL_tag 0 o JSR o or 2 If condition 1 amp condition 2 amp condition 3 then BOOL tag 1 Else BOOL tag 0 End if G EOT BOOL tag 1 Call a subroutine 2 Check for the required conditions When those conditions are true turn on a BOOL tag 3 Use an EOT instruction to set the state of the transition equal to the value of the BOOL tag When the BOOL tag is on true the transition is true Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 4 26 Design a Sequential Function Chart Transition After a Specified Time step_name X step_name T step_name DN Each step of the SFC includes a millisecond timer that runs whenever the step is active Use the timer to e signal when the step has run for the requ
32. 003H EN E excerpt from 1756 PM001H EN P August 2005 ATTENTION Force Logic Elements 13 3 Disable or Remove a Force To stop the effect of a force and let your project execute as programmed disable or remove the force e You can disable or remove I O and SFC forces at the same time or separately e Removing a force on an alias tag also removes the force on the base tag Changes to forces can cause unexpected machine motion that could injure personnel Before you disable or remove forces determine howthe changewilleffectyourmachineorprocessandkeeppersonnelawayfromthe machine area Check Force Status Before you use a force determine the status of forces for the controller You can check force status To determine the status of Use any of the following 1 0 forces e online toolbar e FORCE LED e GSV instruction SFC forces Online Toolbar The Online toolbar shows the status of forces It shows the status of I O forces and SFC forces separately Rem Run HE T 10 Forces Enabled Forces tab gt Forces De instaled No Edits amp T SFC Forces Disabled Redundancy fll None Installed P i Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 13 4 Force Logic Elements This Enabled Means e f the project contains any forces of this type they are overriding your logic e f you add a force of this type the new force immediately takes effect
33. 07 Call a Subroutine Use a Jump to Subroutine JSR instruction to execute a subroutine when the action is active 1 In the SFC right click the text entry area of the action and select Set JSR Routine lt none gt X Input Parameters Return Parameters EES aa a 2 Choose the routine that you want to call 3 To pass a parameter to the routine click an empty Input Parameters text box Then use the down arrow to select the tag that contains the parameter 4 To receive a parameter from the routine click an empty Return Parameters text box Then use the down arrow to select the tag in which to store the parameter from the routine 5 Click N action_name SR routine name Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 5 16 Program a Sequential Function Chart Assign the Execution Order Actions execute in the order in which they appear of Actions Document an SFC Step_003 N _ Action_000 N f Action_0014 N f Action_002 When Step_003 is active its actions execute in this order 1 Action _000 2 Action_001 3 Action_002 To change the order in which an action executes drag the action to the desired location in the sequence A green bar shows a valid placement location To document an SFC you can N Action_000 N Action_001 To document this And you want to Do this gene
34. 1 true return to OS JSR step_2 D false step_1 n false return to OS JSR step_ 2 lt Da true step_1 return to OS JSR step_2 lt tran 2 false Tetum to OS JSR true step_2 step_1 false return to OS JSR last scan last scan Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 4 50 Design a Sequential Function Chart Notes Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Chapter 5 Program a Sequential Function Chart When to Use This Chapter Use this chapter to enter a sequential function chart SFC into RSLogix 5000 software Enter the SFC as you design it Or first design the SFC and then enter it To design the SFC see Design a Sequential Function Chart on page 4 1 To program a sequential function chart routine For this information See page Add an SFC Element 5 1 Create a Simultaneous Branch 5 3 Create a Selection Branch 5 5 Set the Priorities of a Selection Branch 5 6 Return to a Previous Step 5 7 Configure a Step 5 8 Program a Transition 5 10 Add an Action 5 12 Configure an Action 5 12 Program an Action 5 14 Assign the Execution Order of Actions 5 16 Document an SFC 5 16 Configure the Execution of the SFC 5 20
35. 1 Right click the horizontal line that starts the branch and select Set Sequence Priorities Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Program a Sequential Function Chart 5 7 2 Clear uncheck the Use default priorities check box and select a transition Set Sequence Priorities xj Use default priorities left to right on routine Description 1 Tran 001 2 Tran_002 3 Tran_003 Move 4 Use the Move buttons to raise or lower the priority of the transition 3 When all the transitions have the desired priority click When you clear uncheck the Use default priorities check box numbers show the priority of each transition a Return to a Previous Step Connect a Wire to the Step 1 Click the lower pin of the transition that signals the jump Then click the top pin of the step to which you want to go A green dot shows a valid connection point Typically the resulting connection orients itself along the center of the flowchart and is hard to see 2 To make the jump easier to read drag its horizontal bar above the step to which the jump goes You may also have to reposition some of the SFC elements Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 5 8 Program a Sequential Function Chart For example to go to Step_001 from Tran_003 Drag the horizontal bar here 1 Then click here Click here 4
36. 13 decimal value of the carriage return then stop Otherwise go to 3 Program Structured Text 6 27 Enter this structured text element number 0 SIZE SINT array 0 SINT array size Repeat String tag DATA element number SINT array element_ number element _number element number 1 String tag LEN element number If element number SINT array size then exit end_if Until SINT array element_number 13 end repeat Publication 1756 PIM003H EN E excerpt from 1756 PM001H EN P August 2005 6 28 Program Structured Text Comments To make your structured text easier to interpret add comments to it e Commentsletyouuse plainlanguagetodescribehow yourstructured text works e Comments do not affect the execution of the structured text Structuredtext comments are downloaded into controller memory andare available for upload To add comments to your structured text To add a comment Use one of these formats ona single line comment at the end of a line of structured comment text comment within a line of structured text comment comment that spans more than one line start of comment end of comment start of comment end of comment For example Format Example comment At the beginning of a line Check conveyor belt direction IF conveyor direction THEN At the end of a line ELSE If conv
37. 3H EN E excerpt from 1756 PM001H EN P August 2005 5 10 Program a Sequential Function Chart Use an Expression to Calculate a Time To calculate a time based on tags in your project enter the time as a numeric expression You can use an expression to calculate e Preset e LimitHigh e LimitLlow To enter a time as an expression 1 Click the button of the step 2 Check the Use Expression check box Preset fo ms M Use Expression Define 3 Click the Define button and enter an expression browse for a tag choose a function ale choose an operator e es 2 oft Cancel create a tag i Zi Type a numeric expression that defines the time e Use the buttons alongside the dialog box to help you complete the expression e For information on numeric expressions see Expressions on page 6 4 4 Click 5 To close the Step Properties dialog box click Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Program a Sequential Function Chart 5 11 Program a Transition Enter a BOOL Expression The simplest way to program the transition is to enter the conditions as a BOOL expression in structured text For information on BOOL expressions see Expressions on page 6 4 transition_name q 1 Double click the text area of the transition 2 Type the BOOL expression that determines when the transition is true or false 3 T
38. 3H EN E excerpt from 1756 RMO003H EN P August 2005 10 6 Program Control Instructions JSR RET SBR JSR 1 If you want to copy data to a tag in the subroutine enter an input parameter 2 If you want to copy a result of the subroutine to a tag in this routine enter a return parameter 3 Enter as many input and return parameters as you need The following diagram illustrates how the instructions operate Calling Routine JSR Subroutine SBR RET 1 If the JSR instruction has a return parameter enter an RET instruction SBR 42974 1 If the JSR instruction has an input parameter enter an SBR instruction 2 Place the SBR instruction as the first instruction in the routine 3 For each input parameter in the JSR instruction enter the tag into which you want to copy the data 2 Place the RET instruction as the last instruction in the routine 3 For each return parameter in the JSR instruction enter a return parameter to send to the JSR instruction 4 In a ladder routine place additional RET instructions to exit the subroutine based on different input conditions if required Function block routines only permit one RET instruction There are no restrictions other than controller memory on the number of nested routines you can have or the number of parameters you pass or return level 1 subrouti
39. 6 PM001H EN P August 2005 13 12 Force Logic Elements Remove or Disable Forces ATTENTION Changes to forces can cause unexpected machine motion that could injure personnel Beforeyoudisableorremoveforces determinehowthechange willeffectyourmachineorprocessandkeeppersonnelawayfromthemachinearea If you want to stop an individual force And leave other forces enabled and in effect The Rem ove an Individual Force stop all 1 0 forces but leave all SFC forces active leave the I O forces in the project Disable All 1 0 Forces remove the 1 0 forces from the project Rem ove All 1 0 Forces stop all SFC forces but leave all 1 0 forces active ATTENTION leave the SFC forces in the project Disable All SFC Forces remove the SFC forces from the project Remove an Individual Force Rem ove All SFC Forces Ifyouremoveanindividual force forcesremainintheenabledstate andany new force immediately takes effect Beforeyouremoveaforce determinehowthechangewilleffectyourmachine or process and keep personnel away from the machine area 1 Open the routine that contains the force that you want to remove 2 What is the language of the routine If Then SFC Go to step 4 ladder logic Go to step 4 function block Go to step 3 structured text Go to step 3 3 Right click the tag that has the force and choose Monitor If necessary expand the tag to show the value th
40. 6 PM003H EN E excerpt from 1756 PM001H EN P August 2005 4 48 Design a Sequential Function Chart This step_1 tran_1 tran_2 step_2 step_3 tran_3 t tran_4 Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Figure 4 8 When parameters enter and exit an SFC input paramete T eturn parameters Figure 4 7 Execution of a Selection Branch executes like this step_1 lt true n gt faise return to OS JSR step_1 return to OS JSR OS JSR return to step_2 nput parameters 3 step_1 return to i faise OS JSR tran_1 true return parameters return to OS JSR input parameters step_1 9 return to ana OS JSR true return to OS JSR step_1 last scan step_3 e z return to false Da ase OS JSR true return to OS JSR step_3 last scan last scan Design a Sequential Function Chart 4 49 Figure 4 9 Options for Execution Control This step_1 tran_1 step_2 tran_2 executes like this Execute current active steps only Execute until FALSE transition true return to step_
41. 77 ctrl X CAN 24 18 8 56 38 X 88 58 X 120 78 ctrl Y EM 25 19 9 57 39 Y 89 59 y 121 79 ctrl Z SUB 26 1A 58 3A Z 90 5A Z 122 7A ctrl ESC 27 1B 59 3B 91 5B 123 78 ctrl FS 28 1C lt 60 3C 92 5C 124 7C ctrl GS 29 1D 61 3D 93 5D 125 7D ctrl RS 30 1E gt 62 3E i 94 5E 126 7E ctrl_ US 31 1F 63 3F 95 5F DEL 127 STF Rockwell Automation Rockwell Automation provides technical information on the web to assist you in using our products At http support rockwellautomation com you can Support find technical manuals a knowledge base of FAQs technical and application notes sample code and links to software service packs and a MySupport feature that you can customize to make the best use of these tools For an additional level of technical phone support for installation configuration and troubleshooting we offer TechConnect Support programs For more information contact your local distributor or Rockwell Automation representative or visit http support rockwellautomation com Installation Assistance If you experience a problem with a hardware module within the first 24 hours of installation please review the information that s contained in this manual You can also contact a special Customer Support number for initial help in getting your module up and running United States 1 440 646 3223 Monday Friday 8am 5pm EST Outside United Please contact your local
42. Defined Right click on the item that is named see on your screen or in an example User Defined bold an entry in the Glossary Type a name If you want additional information refer to name in the Glossary If you are viewing the PDF file of the manual click name to jump to the glossary entry courier information that you must supply Right click You must identify the specific program in based on your application a name of program your application Typically it is a name or variable variable that you have defined enclosed in brackets a keyboard key Publication 1756 PMO03H EN E August 2005 Press Enter Press the Enter key Design a Sequential Function Chart Program a Sequential Function Chart Table of Contents Chapter 4 When to Use This Chapter oaaao eas eae cee ete 4 1 What is a Sequential Function Chart 4 2 Define th PASksil son 4 4 ae was wb co atte nA AD 4 5 Choose How to Execute the SEC ay naana aaua anaa 4 6 Define the Steps of the Process n on anaana 4 6 Oroanize the Steps ic r Sea ad Sticks E EE EKE E E 4 11 Add Actions for Each Step n anaa aaaea 4 15 Describe Each Action in Pseudocode 4 19 Choose a Qualifier for an Action 0 00 4 19 Define the Transition Conditions 0 4 20 Transition After a Specified Time 2s eae exe oe 4 25 Turn Off a Device at the End of a Step 4 04h uae wesc 4 28 Keep Something O
43. Dodge and Reliance Electric Products Americas Rockwell Automation 6040 Ponders Court Greenville SC 29615 4617 USA Tel 1 864 297 4800 Fax 1 864 281 2433 Europe Rockwell Automation Br hlstraRe 22 D 74834 Elztal Dallau Germany Tel 49 6261 9410 Fax 49 6261 17741 Asia Pacific Rockwell Automation 55 Newton Road 11 01 02 Revenue House Singapore 307987 Tel 65 351 6723 Fax 65 355 1733 Publication 1756 PIM003H EN E excerpts from 1756 PM001H EN P and 1756 RMO003H EN P August 2005 PN 957974 51 Supersedes Publication 1756 PM003G EN E March 2004 Copyright 2005 Rockwell Automation Inc All rights reserved Printed in the U S A AB Allen Bra dley SFC and ST Programming Languages Programming Manual
44. FC Once at the stop element you have several options to restart the SFC And the Last Scan of Active Then Steps option is At the end of the step that calls the nested SFC the nested SFC automatically resets Automatic reset e The nested SFC resets to the initial step e The X bit of the stop element in the nested SFC clears to zero Programmatic reset 1 Use an SFC Reset SFR instruction to restart the SFC Dic cea at the required step 2 Use logic to clear the X bit of the stop element 1 Use an SFC Reset SFR instruction to restart the SFC at the required step 2 Use logic to clear the X bit of the stop element This example shows the use of the SFC Reset SFR instruction to restart the SFC and clear the X bit of the stop element Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Design a Sequential Function Chart 4 41 EXAMPLE Restart Reset the SFC If SFC_a_stop X on SFC_a is at the stop and SFC_a_reset on time to reset the SFC then for one scan ons 0 on Reset SFC_a to SFC_a_Step_1 SFC_a_stop X 0 SFR SFC_a_stop SFC_a_reset ons 0 SFC_a_stop Et ONS SFC Reset SFC Routine Name SFC_a Step Name SFC_a_step_1 Publication 1756 PIM003H EN E excerpt from 1756 PM001H EN P August 2005 4 42 Design a Sequential Function Chart SFC_STOP Structure Each stop uses a tag to provide information about the stop e
45. INT array tag a result of the subroutine INT e Return parameters are optional DINT e Enter multiple return parameters if REAL needed structure JSR operands continued on next page Program Control Instructions JSR RET SBR 10 3 JSR Operands continued Function Block Input Parameters Return Parameters Jump to Subroutine Routine P x JSR RA Jump to Subroutine Routine The operands are the same as those for the relay ladder JSR instruction For each parameter in a SBR or RET instruction use ATTENTION the same data type including any array dimensions as the corresponding parameter in the JSR instruction Using different data types may produce unexpected results Publication 1756 PM003H EN E excerpt from 1756 RMO003H EN P August 2005 10 4 Program Control Instructions JSR RET SBR SBR Operands The SBR instruction must be the first instruction in a relay ladder or structured text routine Relay Ladder SBR Subroutine Acarand Gano Ennaat Neesnntas nput par 9 Operand Type Format Description Input BOOL tag tag in this routine into which you want to parameter SINT array tag copy the corresponding input parameter from INT the JSR instruction DINT REAL structure SBR InputPar Structured Text The operands are the same as those for the relay ladder SBR instruction Function Block Parameters Subroutine
46. Once an SFC completes its last step it does not automatically restart at the first step You must tell the SFC what to do when it finishes the last step Do this Wire the last transition to the top of the step to which you want to go See Wire to a Previous Step on page 4 14 stop and wait for a command to restart last_tranistion process_done stop Use a Stop Element See Use a Stop Element on page 4 38 Use a Stop Element The stop element lets you stop the execution of an entire SFC or a path of a simultaneous branch and wait to restart When an SFC reaches a stop element e The X bit of the stop element turns on This signals that the SFC is at the stop element e Stored actions remain active e Execution stops for part or all of the SFC If the stop element is at the end of a Then sequence entire SFC stops selection branch path within a simultaneous branch only that path stops while the rest of the SFC continues to execute Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 If the SFC is nested i e another SFC calls this SFC as a subroutine NOT nested i e no SFC calls this SFC as a subroutine Design a Sequential Function Chart EXAMPLE Use a Stop Element last_step m last_tranistion When the SFC reaches last_step and process_done is true the execution of the SFC stops process_done Restart Reset the S
47. SFC leaves the step the PO action turns off the conveyor On the last scan of the step conveyor_state turns off This turns off the conveyor Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 4 34 Design a Sequential Function Chart Use the Automatic Reset Option To automatically turn off clear devices at the end of a step 1 In the Last Scan of Active Steps property select the Automatic reset option 2 To turn off a device at the end of the step control the state of the device with an assignment or instruction such as e assignment non retentive assignment e Output Energize OTE instruction in a subroutine During the last scan of each step the Automatic reset option e executes P and PO actions according to their logic conditions e clears tags to the left of assignments e executes a postscan of embedded structured text e executes a postscan of any subroutine that an action calls via a Jump to Subroutine JSR instruction e resets any nested SFC SFC that an action calls as a subroutine IMPORTANT Thepostscan ofanactionactually occurs whentheaction goesfromactivetoinactive Dependingonthequalifierof theaction the postscancouldoccurbefore orafterthelast scan of the step As a general rule the postscan executes instructions as if all conditions are false For example the Output Energize OTE instruction clears its data during postscan Some instructions do not f
48. ST logic The term Logix5000 controller refers to any controller that is based on the Logix5000 operating system such as e CompactLogix controllers e ControlLogix controllers e FlexLogix controllers e PowerFlex 700S with DriveLogix controllers e SoftLogix5800 controllers Who Should Use this This manual is intended for those individuals who program Manual applications that use Logix5000 controllers such as e software engineers e control engineers e application engineers e instrumentation technicians When to Use this Manual Use this manual when you perform these actions e develop the basic code for your application e modify an existing application e perform isolated tests of your application As you integrate your application with the I 0 devices controllers and networks in your system e Refer to the user manual for your specific type of controller e Use this manual as a reference when needed Publication 1756 PMO03H EN E August 2005 Preface 2 How to Use this Manual This manual is divided into the basic tasks that you perform while programming a Logix5000 controller e Each chapter covers a task e The tasks are organized in the sequence that you will typically perform them As you use this manual you will see some terms that are formatted differently from the rest of the text Text that is Identifies For example Means Italic the actual name of an item that you Right click User
49. Verify the Routine 5 21 Add an SFC Element To add SFC elements use the SFC toolbar start of simultaneous start of selection branch step and transition branch stop step subroutine return jii ii path ia box 4 2lal lel s s 25 a xl HIFI src Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 5 2 Program a Sequential Function Chart Add and Manually Connect Elements 1 On the SFC toolbar click the button for the item that you want to add 2 Drag the element to the required location on the SFC green dot 3 To wire connect two elements together click a pin on one of the elements A and then click the pin on the other element B A green dot shows a valid connection point Add and Automatically Connect Elements 1 Select click the element to which you want to connect a new element 2 With the element still selected click the toolbar button for the next element Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Program a Sequential Function Chart 5 3 Drag and Drop Elements From the SFC toolbar drag the button for the required element to the desired connection point on the SFC A green dot shows a valid connection point 4d Slol t a5 oo 5a BF gt HIFA SFC green dot Create a Simultaneous Start a Simultaneous Branch Branch 1 On the SFC toolbar click the button Drag the new branch to the desired locati
50. ags done is a BOOL tag and your specification says If count is greater than or equal to length you are done counting How Strings Are Evaluated done count gt length Thehexadecimalvaluesofthe ASCII characters determineifonestringisless than or greater than another string e Whenthetwostringsaresortedasinatelephonedirectory theorderof the strings determines which one is greater ASCII Characters Hex Codes Jab 31 61 62 LA a Tb 31962 H r A 41 S g s a AB 41 42 AB lt B e t ene i 3 B 42 r a 61 a gt B Y ab 61 62 e Strings are equal if their characters match e Charactersarecasesensitive Uppercase A 41 isnotequaltolower case a 61 Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Use this format Use logical operators Program Structured Text 6 9 Logical operators let you check if multiple conditions are true or false The result of a logical operation is a BOOL value lf the comparison is true false Use these logical operators The result is For Use this operator Data Type logical AND amp AND BOOL logical OR OR BOOL logical exclusive OR XOR BOOL logical complement NOT BOOL For example Example For this situation You d write BOOLtag If photoeye is a BOOL tag and your specification IF photoeye THEN says If photoeye_1 is on then NOT BOOL
51. allet_not_full E pallet_full P1 pallet_move_reset SFR Pallet_Move pallet_move_Step_001 pallet_move_stop X 0 pallet_mowe_stop X Determination of whether to continue or g N L ffan_off fan state 0 N f devices_in_operator_mode onveyor_program_comtrol 0 fan _program_control 0 conveyor step on Figure 4 1 on the previous page N pallet_move_procedure JSR Pallet_Move 0 A selection branch chooses between different execution paths A text box lets you add descriptive text or notes to your SFC O stop Astop lets you stop and wait for a command to restart A wire connects one element to another element anywhere on the chart This wire takes you to the Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 4 4 Design a Sequential Function Chart To design a sequential function chart For this information See page Define the Tasks 4 5 Choose How to Execute the SFC 4 6 Define the Steps of the Process 4 6 Organize the Steps 4 11 Add Actions for Each Step 4 15 Describe Each Action in Pseudocode 4 19 Choose a Qualifier for an Action 4 19 Define the Transition Conditions 4 20 Transition After a Specified Time 4 25 Turn Off a Device at the End of a Step 4 28 Keep Something On From Step to Step 4 34 End the SFC 4 38 Nest an SFC 4 41 Configure When to Return to the OS JSR 4 42 Pause or Re
52. am A Program Tags A SFC off motors and open or close valves The SFC in MainTask commands the state for each device The function block diagrams set and maintain that state This task periodic uses function block diagrams to configure and regulate temperature loops The SFC in MainTask commands the temperatures The function block diagrams set and maintain those temperatures This task continuous executes the sequential function chart SFC The SFC commands the specific state or temperature for each device or temperature loop Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 4 6 Design a Sequential Function Chart Choose How to Execute the To execute an SFC either configure it as the main routine for a SFC program or call it as a subroutine If Then The SFC is the only routine in the program Configure the SFC as the main routine for the program The SFC calls a the other routines of the program The program requires other routines to execute 1 Configure another routine as the main routine for independent of the SFC the program The SFC uses boolean actions 2 Use the main routine to call the SFC as a subroutine If the SFC uses boolean actions then other logic must run independent of the SFC and monitor status bits of the SFC Define the Steps of the A step represents a major function of your process It contains the Process actions that occur at a parti
53. at is forced e g BOOL value of a DINT tag 4 Right click the tag or element that has the force and choose Remove Force Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Force Logic Elements 13 13 Disable All 1 0 Forces From the Logic menu choose I O Forcing gt Disable All I O Forces Then choose Yes to confirm Remove All 1 0 Forces From the Logic menu choose I O Forcing gt Remove All I O Forces Then choose Yes to confirm Disable All SFC Forces From the Logic menu choose SFC Forcing gt Disable All SFC Forces Then choose Yes to confirm Remove All SFC Forces From the Logic menu choose SFC Forcing gt Remove All SFC Forces Then choose Yes to confirm Publication 1756 PIM003H EN E excerpt from 1756 PM001H EN P August 2005 13 14 Force Logic Elements Notes Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Chapter 10 Program Control Instructions JSR RET SBR Introduction Use the program control instructions to change the flow of logic If you want to Use this instruction Available in these languages See page Jump to a separate routine pass data to the JSR relay ladder 10 2 routine execute the routine and return results SBR RET function block structured text Publication 1756 PM003H EN E excerpt from 1756 RM003H EN P August 2005 10 2 Program Control Instructions JSR RET SBR Jump to Subroutine JSR Subrou
54. cerpt from 1756 PM001H EN P August 2005 4 38 Design a Sequential Function Chart In this example steps 1 4 require a fan to be on At the end of step_4 the fan is reset turned off When the SFC jumps back to step_3 the fan remains off fa turn on the fan step_ stored step_2 step_3 turn off the fan step_4 reset To turn the fan back on the SFC has to jump back to step_1 Use One Large Step If you use one large step for multiple functions then use additional logic to sequence the functions One option is to nest an SFC within the large step In this example a step turns on a fan and then calls another SFC The nested SFC sequences the remaining functions of the step The fan stays on throughout the steps of the nested SFC EXAMPLE Use a Large Step N E fanon fan ProgProgReq 1 fan ProgCommand This action turns on a fan q e fan ProgProgReg lets the SFC command the state of the fan e fan ProgCommand turns on the fan Step_003 N Laf Nested_SFC JSR SFC_2 0 This action calls another SFC The SFC sequences the remaining functions of the step Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 End the SFC To automatically loop back to an earlier step Design a Sequential Function Chart 4 39 For additional information on how to nest an SFC see Nest an SFC on page 4 41
55. cular time phase or station Step Actions A step executes continuously until a Do this transition tells the SFC to go to the a MIX next step and do this Transition 4 ti J e f true go to the next step A transition ends a step The transition defines the physical conditions that must occur or change in order to go to the next step Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Design a Sequential Function Chart 4 7 Step Guidelines As you define the steps of your process follow these guidelines e Start with large steps and refine the steps in several passes first pass second pass third pass Paint Transfer_In Transfer_In Paint Paint_Flow Air_Flow Elec_Charg Clean Clean Transfr_Out Transfr_Out e When you first open an SFC routine it contains an initial step and transition Use this step to initialize your process initial step initial transition The controller executes the initial step after a project download when the controller goes into Run mode if the SFC is configured to when the controller transitions to Run mode and on power up when the routine containing the chart is modified online and the controller transitions to or from Test mode e To identify a step look for a physical change in your system
56. d of Each action non boolean and boolean uses a qualifier to determine when it starts and stops The default qualifier is Non Stored The action starts when the step is activated and stops when the step is deactivated To change when an action starts or stops assign a different qualifier If you want the action to And Thenassignthis Which qualifier means start when the step is activated stop when the step is deactivated N Non Stored execute only once P1 Pulse Rising Edge stop before the step is deactivated or when the L Time Limited step is deactivated stay active until a Reset action turns off this action 5 Stored stay active until a Reset action turns off this action SL Stored and Time Limited or a specific time expires even if the step is deactivated start a specific time after the step is activated stop when the step is deactivated D Time Delayed Ara E STEPIE stl ae stay active until a Reset action turns off this action DS Delayed and Stored start a specific time after the step is activated stay active until a Reset action turns off this action SD Stored and even if the step is deactivated before this time Time Delayed Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Table 4 1 Choose a Qualifier for an Action Design a Sequential Function Chart 4 21 If you want the action to And Thenassignthis Which qualifier means execute once when the step is activated execut
57. e Ingredient A Outlet_1 1 Ingredient B outlet 4 open 1 Ingredient B Outlet 4 1 If recipe number 2 or 3 then 27 35 Ingredient A Outlet 4 1 Ingredient A outlet 4 open 1 Ingredient B Outlet 2 1 Ingredient B outlet 2 open 1 If recipe number 4 5 6 or 7 then Moots Ingredient A Outlet 4 1 Ingredient A outlet 4 open 1 Ingredient B Outlet 2 1 Ingredient B outlet 2 open 1 If recipe number 8 11 12 or 13 then 8 11 13 Ingredient A Outlet_1 1 Ingredient A outlet 1 open 1 Ingredient B Outlet 4 1 Ingredient B outlet 4 open 1 Otherwise all outlets closed 0 ELSE Ingredient 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 the controller e enters the RUN mode e leaves the step ofan SFC if you configure the SFC for Automatic reset Thisappliesonlyifyouembedtheassignmentintheactionofthestep oruse the action to calla structured text routine via a JSR instruction Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Program Structured Text 6 19 FOR DO Use the FOR DO loop to do something a specific number of times before doing anything else Operands Structured Text FOR count initial value TO final value BY increment DO Operand Type Format Description lt statement g
58. e This Chapter onnaa aaa eyo ened 6 1 Structured Text Syntax cee cg oaaao a 1 dad aes aS bead one as 6 1 ASSIONII SIMS oo ie Gi wrt fea ON Copel ete Gand wee ne he ek 6 2 Expressi ns rekia ols sch goucd bh ai be bah wee Ree a hos 6 4 MSTHUICHONS S 4 8 Sohe a a eh 7h Bia SEES ee SORTER SS 6 11 CONSU aes SA hte a Seacrest eaten eh aT amp Detects e 6 12 TEASE HIEN onana Siw dtu ah oeare od a tate Date Sb ea ee a Be 6 13 CASE BOR 2 peun Saleen Pee al OG Se N Beal ee 6 16 FOR DIO ge esha hana we engin aires Se pen ea Bek a ALG a ae Raat A 6 19 WELLE B 3 1 Oct Bde BP oe oh eee te ile tn BO EE Pet ude Be a et 6 22 REPEAT UNTI Dasa vacate Ait oot etn Se nee ents 6 25 COMMER cna dpb erations Ste eure ten a Sic Se eves 6 28 Chapter 13 When to Use This Chapter nanao oe be Edd 8 Gaede 13 1 PLrECAUION Ss es er a aai Rodos leche sb a E AA 13 2 Check Force Stat sSro r a rea e Era AD E Pe BR EEDA EEA 13 3 WAI CO Forces srine die gusts heeds Rete awe EA EER Bi 13 5 When to Use an I O Force 4 ih tA Ee eee ead 13 5 Add an I O Force a a gas tn Bh accu eh A wt 13 6 When to Use Step Through nananana aaaea 13 7 Step Through a Transition or a Force of a Path 13 7 When to Use an SFC Force ouaaa a ea a he RES 13 7 Addai SEG FOLE nats oes ad E E Ee ee Bek 13 9 Remove or Disable Forces 2 0 2 0 000 000000 eee 13 10 Chapter 10 TM EOCUMICHONE 41 Svcs 4c Gece with PAS tds eh Fed dow eats Shee 10 1 Jump to Subroutine JSR Subrouti
59. e action executes For more information see Use a Boolean Action on page 4 17 1 Click the button of the action a G A enera Action Order Tag step_name i 0 Qualifier 7 Non Stored J Boolean 2 Check the Boolean check box woa Program an Action To program an action you can e Enter Structured Text e Call a Subroutine Enter Structured Text The easiest way to program an action is to write the logic as structured text within the body of the action When the action turns on the controller executes the structured text l step_name i 1 Double click the text area of the action 2 Type the required structured text 3 To close the text entry window press Ctrl Enter Ej z action_name step_name comment LJ statement Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Program a Sequential Function Chart 5 15 For information on structured text For this structured text information See general information about assignments operators Program Structured Text on page 6 1 functions instructions or comments information about a specific instruction e Logix5000 Controllers General Instructions Reference Manual publication 1756 RM003 e Logix5000 Controllers Process and Drives Instructions Reference Manual publication 1756 RMO006 e Logix5000 Controllers Motion Instruction Set Reference Manual publication 1756 RM0
60. e loop that repeats the path of a selection branch that returns to a entire SFC previous step Add Actions for Each Step Use actions to divide a step into the different functions that the step performs such as commanding a motor setting the state of a valve or placing a group of devices in a specific mode Step Actions Do this MIX and do this How Do You Want to Use the Action There are two types of actions If you want to Then execute structured text directly in the SFC Use a Non Boolean Action call a subroutine use the automatic reset option to reset data upon leaving a step only set a bit and program other logic to monitor the bit to Use a Boolean Action determine when to execute Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 4 16 Design a Sequential Function Chart Use a Non Boolean Action A non boolean action contains the logic for the action It uses structured text to execute assignments and instructions or call a subroutine With non boolean actions you also have the option to postscan automatically reset the assignments and instructions before leaving a step e During postscan the controller executes the assignments and instructions as if all conditions are false e The controller postscans both embedded structured text and any subroutine that the action calls To automatically reset assignments and instructions
61. e once when the step is deactivated P Pulse start when the step is deactivated execute only once PO Pulse Falling Edge turn off reset a stored action p R Reset e S Stored e SL Stored and Time Limited e DS Delayed and Stored e SD Stored and Time Delayed Define the Transition Conditions The transition is the physical conditions that must occur or change in order to go to the next step The transition tells the SFC when to go to the next step transition If true go to the next step Publication 1756 PIM003H EN E excerpt from 1756 PM001H EN P August 2005 4 22 Design a Sequential Function Chart Transitions occur in the For this structure Make sure that sequence A transition is between each step steps Te transitions selection branch Transitions are inside the horizontal lines transitions ba E eee l simultaneous branch Transitions are outside the horizontal lines E transitions Eo ee eee See a Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Design a Sequential Function Chart 4 23 Here are two examples of transitions EXAMPLE oo a Turnon2compressors Whenacompressorison the Device1State bit is on b Whenbothcompressorsareon gotothenextstep Solution Init Init_Done compressor_1 Device1State on 1 and
62. e step that turns off the device Later define a Stored and Reset Action pair to control the device Paint Clean Transfr Out turn off the fan Use One Large Step Paint transfer paint clean Use one large step that contains all the actions that occur while the device is on L transfer control the fan Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 4 36 Design a Sequential Function Chart Use a Simultaneous Branch A simple way to control a device or devices during one or more steps is to create a separate step for the devices Then use a simultaneous branch to execute the step during the rest of the process EXAMPLE A paint operation 1 Transfers the product into the paint shop 2 Paints the product using 3 separate paint guns 3 Cleans the guns 4 Transfers the product to the paint ovens During the entire process the system must control the shop fans Solution Transfer_In Paint_Flow Air_Flow Elec_Charg Fan Clean Transfr_Out Store and Reset an Action Typically an action turns off stops executing when the SFC goes to the next step To keep a device on from step to step without a bump store the action that controls the device 1 In the step that turns on the device assign a stored qualifier to the action that controls the device For a list of stored qualifiers see Table 4
63. earch the array for a specific product use its bar code and determine the quantity that is in stock 1 Get the size number of items of the Inventory array and store the result in Inventory_Items DINT tag 2 Initialize the position tag to 0 3 If Barcode matches the ID of an item in the array then a Set the Quantity tag Inventory position Qty This produces the quantity in stock of the item b Stop Barcode is a string tag that stores the bar code of the item for which you are searching For example when position 5 compare Barcode to Inventory 5 D 4 Add 1 to position 5 If position is to Inventory_Items 1 repeat 3 and 4 Since element numbers start at 0 the last element is 1 less than the number of elements in the array Otherwise stop SIZE Inventory 0 Inventory Items For position 0 to Inventory Items 1 do If Barcode Inventory position ID then Quantity Inventory position OQty Exit End if End for Publication 1756 PIM003H EN E excerpt from 1756 PM001H EN P August 2005 6 22 Program Structured Text WHILE DO Use the WHILE DO loop to keep doing something as long as certain conditions are true Operands Structured Text WHILE bool_expression DO Operand Type Format Enter lt statement gt END WHILE bool_ l BOOL tag BOOL tag or expression that evaluates to expression expression a BOOL value IMPORTANT Makesurethatyoudonotit
64. er ee data _ automatically clear data Each option requires you to make these choices 1 Choose a last scan option 2 Based on the last scan option develop your logic so that the last scan returns data to the desired values Choose a Last Scan Option On the last scan of each step you have these options The option that you choose applies to all steps in all SFCs of this controller If you want to And on the last scan of a step Then See control which data to clear Execute only P and PO actions and use them to Use the Don t Scan Option page 4 30 clear the required data Execute all actions and use either of these Use the Programmatic Reset Option page 4 31 options to clear the required data e status bits of the step or action to condition logic e Pand PO actions let the controller clear data gt Use the Automatic Reset Option page 4 33 Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 4 30 Design a Sequential Function Chart Controller Properties Controller_Name ioj xi User Protocol Major Faults Serial Port System Protocol SFC Execution File Date Time Advanced General Minor Faults Execution Control Execute current active steps only Execute until FALSE transition Restart Position C Restart at most recently executed step Restart at initial step Last Scan of Active Steps Characteristic
65. eratewithinthelooptoomanytimesinasingle scan e Thecontrollerdoesnotexecuteanyotherstatementsintheroutineuntil it completes the loop e If the time that it takes to complete the loop is greater than the watchdog timer for the task a major fault occurs e Consider using a different construct such as IF THEN Description The syntax is WHILE bool _expressionl DO lt statement gt lt q Statements to execute while bool_expression is true IF bool_expression2 THEN EXET If there are conditions when you want to optional exit the loop early use other statements END_IF such as an IF THEN construct to condition an EXIT statement Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Program Structured Text 6 23 These diagrams show how a WHILE DO loop executes and how an EXIT statement leaves the loop early lad BOOL expression tals true statement 1 statement 2 statement 3 statement 4 v rest of the routine While the bool_expression is true the controller executes only the statements within the WHILE DO loop Arithmetic Status Flags not affected Fault Conditions A major fault will occur if false ae BOOL expression true statement 1 statement 2 statement 3 statement 4 e yes Exit _ _ ___ CA m v rest of the routine To stop the loop be
66. erent organizations of steps or different selections of execution options For a diagram of the See page Execution of a Sequence 4 44 Execution of a Simultaneous Branch 4 45 Execution of a Selection Branch 4 46 When parameters enter and exit an SFC 4 46 Options for Execution Control 4 47 Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 4 46 Design a Sequential Function Chart Figure 4 5 Execution of a Sequence This executes like this step_1 step_1 ee tran_1 J return to step_2 false 4 OS JSR tran_2 true return to OS JSR step_1 last scan step_2 alse true return to OS JSR return to OS JSR step_2 last scan Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Design a Sequential Function Chart 4 47 Figure 4 6 Execution of a Simultaneous Branch This executes like this e tran_1 false Tetum to step_2 step_3 OS JSR true TT franz return to OS JSR step_1 step_2 step_3 A return to faise tan 2 gt taise Ti true step_2 step_3 tran_2 true return to OS JSR step_2 step_3 false 4 last scan return to OS JSR last scan Publication 175
67. eyor isn t moving set alarm light light 1 END IF comment Sugar Inlet 1 open the inlet IF Sugar Low low level LS amp Sugar High high level LS THEN Controls the speed of the recirculation pump The speed depends on the temperature in the tank IF tank temp gt 200 THEN comment Sugar Inlet 0 close the inlet IF bar _code 65 A THEN Gets the number of elements in the Inventory array and stores the value in the Inventory Items tag SIZE Inventory 0 Inventory Items Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Chapter 13 When to Use This Chapter Force Logic Elements Use a force to override data that your logic either uses or produces For example use forces in the following situations e test and debug your logic e check wiring to an output device e temporarily keep your process functioning when an input device has failed Use forces only as a temporary measure They are not intended to be a permanent part of your application For this information See page Precautions 13 2 Check Force Status 13 3 What to Force 13 6 When to Use an 1 0 Force 13 6 Add an 0 Force 13 7 When to Use Step Through 13 8 Step Through a Transition or a Force of a Path 13 8 When to Use an SFC Force 13 9 Add an SFC Force 13 11 Remove or Disable Forces 13 12 Publication 1756 PM003H EN E excerpt
68. fore the conditions are true use an EXIT statement Fault type Fault code the construct loops too long 6 1 Example 1 If you want this The WHILE DO loop evaluates its conditions first If the conditions are true the controller then executes the statements within the loop This differs from the REPEAT UNTIL loop because the REPEAT UNTIL loop executes the statements in the construct and then determines if the conditions are true before executing the statements again The statements in a REPEAT UNTIL loop are always executed at least once The statements in a WHILE DO loop might never be executed Enter this structured text 0 While pos lt 100 lt gt targetvalue do pos amp structarray pos value pos pos 2 String tag DATA pos SINT array pos end _ while Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 6 24 Program Structured Text Example 2 If you want this Move ASCII characters from a SINT array into a string tag In a SINT array each element holds one character Stop when you reach the carriage return 1 Initialize Element_number to 0 2 Count the number of elements in SINT_array array that contains the ASCII characters and store the result in SINT_array_size DINT tag 3 If the character at SINT_array element_number 13 decimal value of the carriage return then stop 4 Set String_taglelement_number the character
69. gger execution osri_1 InputBit tag _xic OSRI osri_1 IF osri_1 OutputBit THEN ABL 0 serial_ control END IF Constructs Constructs can be programmed singly or nested within other constructs If you want to Use this construct Available in these languages See page do something if or when specific IF THEN structured text 6 13 conditions occur select what to do based on a numerical value CASE OF structured text 6 16 do something a specific number of times before FOR DO structured text 6 19 doing anything else keep doing something as long as certain WHILE DO structured text 6 22 conditions are true keep doing something until a condition is true REPEAT UNTIL structured text 6 25 Some key words are reserved for future use These constructs are not available e GOTO e REPEAT RSLogix 5000 software will not let you use them Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Program Structured Text 6 13 IF THEN Use IF THEN to do something if or when specific conditions occur Operands Structured Text IF bool_expression THEN Operand Type Format Enter lt statement gt END IF bool_ BOOL tag BOOL tag or expression that evaluates to E expression expression a BOOL value BOOL expression Description The syntax is IF bool expressionl THI mi zZ lt statement gt Statements to execute when bool_expression is true
70. he data value is a SINT INT or DINT you can force the entire value or you can force individual bits within the value Individual bits can have a force status of no force force on force off e You can also force an alias to an I O structure member produced tag or consumed tag An alias tag shares the same data value as its base tag so forcing an alias tag also forces the associated base tag Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Add an 1 0 Force ATTENTION a y 1 0 Forces ot d Redundancy fj Force Logic Elements 13 7 Removing a force from an alias tag removes the force from the associated base tag Force an Input Value Forcing an input or consumed tag e overrides the value regardless of the value of the physical device or produced tag e does not affect the value received by other controllers monitoring that input or produced tag Force an Output Value Forcing an output or produced tag overrides the logic for the physical device or other controller s Other controllers monitoring that output module in a listen only capacity will also see the forced value To override an input value output value produced tag or consumed tag use an I O force Forcingcancauseunexpectedmachinemotionthatcouldinjure personnel Before youusea force determine how the force will effect your machine or process and keep personnel away from the machine
71. he transitions that start each path It takes the first true path If no transitions are true the SFC repeats the previous step RSLogix 5000 software lets you change the order in which the SFC checks the transitions Execute 2 or more steps at the same time All paths must finish before continuing the SFC Simultaneous Branch A single transition ends the branch The SFC checks the ending transition after the last step in each path has executed at least once If the transition is false the SFC repeats the previous step Loop back to a previous step Wire to a Previous Step m yl Connect the wire to the step or simultaneous branch to which you want to go Do not wire into out of or between a simultaneous branch Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 4 12 Design a Sequential Function Chart Here are some examples of SFC structures for different situations Example situation Station 45 and 46 of an assembly line work on parts simultaneously When both stations are done the parts move down 1 station Example solution Simultaneous Branch 45 46 Depending on the build code
72. hmeticoperators arithmeticfunctions and bitwise operators For example tag1 5 e Often you nest a numeric expression within a bool expression For example tag1 5 gt 65 Use the following table to choose operators for your expressions If you want to Then Calculate an arithmetic value Use arithmetic operators and functions on page 6 6 Compare two values or strings Use relational operators on page 6 7 Check if conditions are true or false Use logical operators on page 6 9 Compare the bits within values Use bitwise operators on page 6 10 Publication 1756 PIM003H EN E excerpt from 1756 PM001H EN P August 2005 6 6 Program Structured Text Use arithmetic operators and functions Youcancombinemultipleoperatorsandfunctionsinarithmeticexpressions Arithmetic operators calculate new values To _Usethis operator Optimal data type add DINT REAL subtract negate DINT REAL multiply DINT REAL exponent x to the power of y DINT REAL divide DINT REAL modulo divide MOD DINT REAL Arithmetic functions perform math operations Specify a constant a non boolean tag or an expression for the function For _Usethisfunction Optimal data type absolute value ABS numeric expression DINT REAL arc cosine ACOS numeric expression REAL arc sine ASIN numeric expression REAL arc tangent ATAN numeric expression REAL cosine COS numeric e
73. ier for the action E step_name J General Action Order Tag Qualifier anes ied T Boolean Preset fo ms Use Expression Define If you chose a timed qualifier type the time limit or delay for the action in milliseconds Timed qualifiers include e L Time Limited e SL Stored and Time Limited e D Time Delayed e DS Delayed and Stored Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Program a Sequential Function Chart 5 13 e SD Stored and Time Delayed 3 Click Calculate a Preset Time at Runtime To calculate a preset value based on tags in your project enter the value as a numeric expression 1 Click the button of the action r 2 Check the Use Expression check box Preset jo ms M Use Expression E Z step_name J 3 Click the Define button browse for a tag choose a function Dele choose an operator Pde Cancel Wi create a tag iE Type a numeric expression that defines the preset time e Use the buttons alongside the dialog box to help you complete the expression e For information on numeric expressions see Expressions on page 6 4 4 Click 5 To close the Action Properties dialog box click Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 5 14 Program a Sequential Function Chart Mark an Action as a Boolean Action Use a boolean action to only set a bit when th
74. ing a step s execution Once a step finishes executing the code within its actions the FS and or LS bits are reset If you reference either of these bits in code outside of the SFC routine in a different part of the project the bits are always cleared 0 This diagram shows the relationship of the X FS SA and LS bits step_name X step_name FS step_name SA step_name LS i Ess first scan Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 last scan ae Dig Organize the Steps To Execute 1 or more steps in sequence e One executes repeatedly e Then the next executes repeatedly e Choose between alternative steps or groups of steps depending on logic conditions e Execute a step or steps or skip the step or steps depending on logic conditions Design a Sequential Function Chart 4 11 Once you define the steps of your process organize them into sequences simultaneous branches selection branches or loops Use this structure Sequence Selection Branch With these considerations The SFC checks the transition at the end of the If true the SFC goes to the next step If false the SFC repeats the step It is OK for a path to have no steps and only a transition This lets the SFC skip the selection branch By default the SFC checks from left to right t
75. ions If you select to show descriptions the SFC window only shows the descriptions for steps transitions and stops not actions 1 From the Tools menu select Options 2 Under SFC Editor select the Display category E Application Font Color FC Editor FBD Editor E Structured Text Editor i Font Color Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 5 20 Program a Sequential Function Chart Hide an Individual Tag Description To hide the description of a specific element while showing other descriptions 1 Click the button of the element whose description you want to hide 2 Check the Never display description in routine check box M 3 Click 0K Configure the Execution of The SFC Execution tab of the controller properties lets you configure the SFC e what to do when a transition is true e where to start after a transition to the Run mode or recovery from a power loss e what to do on the last scan of a step 1 On the Online toolbar click the controller properties button Publication 1756 PMO003H EN E excerpt from 1756 PM001H EN P August 2005 Program a Sequential Function Chart 5 21 3 Choose e whether or not to return to the OS JSR if a transition is true e where to restart the SFC The restart position applies when the controller loses power or leaves the Run or Remote Run mode Select If you want to restart at the Select Last step
76. ired time and the SFC should go to the next step e signal when the step has run too long and the SFC should go to an error step Figure 4 3 Action of a timer and associated bits of a step step_name PRE Description 1 Step becomes active X bit turns on Timer T begins to increment 2 Timer reaches the Preset PRE value of the step DN bit turns on Timer continues to increment 3 Step becomes inactive X bit turns off Timer retains its value DN remains on 4 Step becomes active X bit turns on Timer clears and then begins to increment DN bit turns off Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Design a Sequential Function Chart 4 27 Figure 4 4 Action of the low and high alarms for a step step_name AlarmEn _ l I T step_name X step_name LimitHigh l I step_name LimitLow l l step_name T step_name AlarmHigh m l step_name AlarmLow m E 00O 00 Description 1 AlarmEn is on To use the low and high alarms turn this bit on Turn the bit on via the properties dialog box or the tag for the step 2 Step becomes active X bit turns on Timer T begins to increment 3 Step becomes inactive X bit turns off Timer retains its value Since Timer is less than LimitLow AlarmLow bit turns on 4 Step becomes active X bit turns
77. is situation You d write valuel operator value2 If input1 input2 and result are DINT tags and your resultl inputl AND specification says Calculate the bitwise result of input2 input1 and input2 Store the result in result1 Determine the order of execution The operations you write into an expression are performed ina prescribed order not necessarily from left to right e Operations of equal order are performed from left to right e Ifan expression contains multiple operators or functions group the conditions in parenthesis This ensures the correct order of execution and makes it easier to read the expression Order Operation 1 function negate NOT MOD subtract lt lt gt gt lt gt S wl col ao ao s wl nN amp AND XOR OR Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Program Structured Text 6 11 Instructions tag_xic Structured text statements can also be instructions See the Locator Table at thebeginningofthismanualforalistoftheinstructionsavailableinstructured text A structured text instruction executes each time it is scanned A structured text instruction within a construct executes every time the conditions of the construct are true If the conditions of the construct are false the statements within the construct are not scanned There is no
78. it is boolean on 1 the entire time the action is active including the last scan of the action non boolean on 1 while the action is active but off 0 at the last scan of the action To use a bit to determine when an action is active use the Q bit A BOOL The A bit is on the entire time the action is active determine how long an action T DINT When an action becomes active the Timer T value resets and has been active milliseconds then starts to count up in milliseconds The timer continues to count up until the action goes inactive regardless of the Preset PRE value Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Design a Sequential Function Chart 4 19 If you want to Then check or set Datatype Details this member use one of these time based PRE DINT Enter the time limit or delay in the Preset PRE member The qualifiers L SL D DS SD action starts or stops when the Timer T reaches the Preset value As an option enter a numeric expression that calculates the time at runtime determine how many times an Count DINT This is nota count of scans of the action action has become active e The count increments each time the action becomes active e t increments again only after the action goes inactive and then active again e The count resets only if you configure the SFC to restart at the initial step With that configuration it resets when the controller changes from
79. lement If you want to Thencheck orset Datatype Details this member determine when the SFC is at X BOOL e When the SFC reaches the stop the X bit turns on the stop e The X bit clears if you configure the SFCs to restart at the initial step and the controller changes from program to run mode e In a nested SFC the X bit also clears if you configure the SFCs for automatic reset and the SFC leaves the step that calls the nested SFC determine the target of an SFC Reset BOOL An SFC Reset SFR instruction resets the SFC to a step or stop Reset SFR instruction that the instruction specifies e The Reset bit indicates to which step or stop the SFC will go to begin executing again e Once the SFC executes the Reset bit clears determine how many times a Count DINT This is not a count of scans of the stop stop has become active e The count increments each time the stop becomes active e t increments again only after the stop goes inactive and then active again e The count resets only if you configure the SFC to restart at the initial step With that configuration it resets when the controller changes from program mode to run mode use one tag for the various Status DINT For this member Use this bit status bits of this stop Reset 22 X 31 Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Design a Sequential Function Chart 4 43 Nest an SFC One method for organizing your projec
80. ll Automation Inc with respect to use of information circuits equipment or software described in this manual Throughout this manual we use notes to make you aware of safety considerations Identifies 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 IMPORTANT Identifies information that is critical for successful application and understanding of the product ATTENTION Identifies information about practices or circumstances that can lead to personal injury or death property damage or economic loss Attentions help you e identify a hazard e avoid a hazard e recognize the consequence TAATAAN Labels may be located on or inside the drive to alert people that dangerous voltage may be present BURN HAZARD Labels may be located on or inside the drive to alert people that surfaces may be dangerous temperatures Preface Purpose of this Manual This manual contains excerpts from Logix5000 Controllers Common Procedures publication 1756 PM001H EN P and Logix5000 Controllers General Instructions Reference Manual publication 1756 RM003H EN P This manual provides information on e Sequential Function Chart SFC programming language e Structured Text ST programming language e Jump to Subroutine GSR Subroutine SBR and Return RET instructions needed to access SFC and
81. m Main routine JSR routine 1 2 value_1 value 2 float_ value 1 Subroutine SBR value_a value_b lt statements gt RET float_a Publication 1756 PM003H EN E excerpt from 1756 RMO003H EN P August 2005 10 10 Program Control Instructions JSR RET SBR Example 2 Relay Ladder MainRoutine When abc is on subroutine_1 executes calculates the number of cookies and places a value in cookies_1 JSR Jump to Subroutine Routine name subroutine_1 Return par cookies_1 abc Adds the value in cookies_1 to cookies_2 and stores the result in total_cookies DD Add Source cookies_2 g Source B cookies_1 g Dest total_cookies p Subroutine_1 When def is on the RET instruction returns value_1 to the JSR cookies_1 parameter and the rest of the subroutine is not scanned def RET Return Return par value_1 When defis off previous rung and ghiis on the RET instruction returns va ue_2to the JSR cookies_ parameter and the rest of the subroutine is not scanned hi RET Return Return par yalue_2 When both defand ghiare off previous rungs the RET instruction returns va ue_3 to the JSR cookies_7 parameter RET Return Return par yvalue_3 Publication 1756 PM003H EN E excerpt from 1756 RMO003H EN P August 2005 Program Control Instructions JSR RET SBR 10 11 Example 3 Function Block JSR instruction in Routine_A JSR E J
82. ment and store the result in position Use relational operators Relational operators compare twovalues orstrings to provideatrue orfalse result The result of a relational operation is a BOOL value lf the comparison is The result is true 1 false 0 Use these relational operators For this comparison Use this operator Optimal Data Type equal 5 DINT REAL string less than lt DINT REAL string less than or equal lt DINT REAL string greater than gt DINT REAL string greater than or equal gt DINT REAL string not equal lt gt DINT REAL string Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 6 8 Program Structured Text Use this format valuel operator value2 For example Example For this situation If temp is a DINT tag and your specification says If temp is less than 100x then You d write IF temp lt 100 THEN stringtagl operator stringtag2 If bar_code and dest are string tags and your specification says If bar_code equals dest then IF bar_code dest THEN charl operator char2 To enter an ASCII character directly into the expression enter the decimal value of the character If bar_code is a string tag and your specification says If bar_code DATA 0 equals A then IF bar_code DATA 0 65 THEN bool tag bool expressions If count and length are DINT t
83. n From Step to Step 4 34 End tHE SEG ace rA E a OA E E N ee ee 4 38 NSS Ai SEC ania oa ain e aa a ee aha a othe D an 4 41 Configure When to Return to the OS JSR 4 42 Pause or Reset an SFC sooo ied hae aes VEER GY 4 43 Execution Diagrams eis oie avd ts eek oe SACS OS Oty eR 4 43 Chapter 5 When to Use This Chapter ens S pias a esargw aad ae fe ha wea 5 1 Add an SFC Element ede eng dnd ae ate da bale Dap aud Saad act 5 1 Create a Simultaneous Braneh s5 4 44an x acess et oie ke 5 3 Create a Selection Branch 4 0 a bat aaa 5 5 Set the Priorities of a Selection Branchts 44 4 eens to ads 5 6 Return to a Previous Step sasaaa aaaea 5 7 Configure ASSO sre 65 ap E etek Med E E E A 5 8 Program a Transition oie 2 85 aaa al ele a 8 e 6 5 10 Add an ACION e yea Gada ys e Lacks gh oh te AaB by ces ade GAL 5 12 Confic re AM ACION cance o tE i ee eee 5 12 Program an POI ooa gee doin ge SK BOS Belen hae PG do 5 14 Assign the Execution Order of Actions 5 16 Document an SFC oie beta ee de Bt 5 16 Configure the Execution Of the SFC rsa 164 aaan SS 5 20 Verify the ROMS Bits amp naaa pad de hb A hoe RGR RCE BT oe 5 21 Editan SEC Online seg so Tasuku a a a eed ad 5 22 Publication 1756 PM003H EN E August 2005 Table of Contents 2 Program Structured Text Force Logic Elements Program Control Instructions JSR RET SBR Publication 1756 PMO03H EN E August 2005 Chapter 6 When to Us
84. ne SBR Return RET 10 2 Chapter 4 When to Use This Chapter Design a Sequential Function Chart Use this chapter to design a sequential function chart SFC for your process or system An SFC is similar to a flowchart of your process It defines the steps or states through which your system progresses Use an SFC to e organize the functional specification for your system e program and control your system as a series of steps and transitions By using an SFC to specify your process you gain these advantages e Since an SFC is a graphical representation of your process it is easier to organize and read than a textual version In addition RSLogix 5000 software lets you add notes that clarify steps or capture important information for use later on print the SFC to share the information with other individuals e Since Logix5000 controllers support SFCs you do not have to enter the specification a second time You are programming your system as you specify it By using an SFC to program your process you gain these advantages e graphical division of processes into its major logic pieces steps e faster repeated execution of individual pieces of your logic e simpler screen display e reduced time to design and debug your program e faster and easier troubleshooting e direct access to the point in the logic where a machine faulted e easy updates and enhancements Publication 1756 PM003H EN E excerpt from 1756
85. ne action_1 level 2 subroutine action_2 level 3 subroutine action_3 main routine ne a SBR C SBR C SBR C JSR action_2 action_3 JSR JSR RET RET RET Publication 1756 PM003H EN E excerpt from 1756 RMO003H EN P August 2005 Program Control Instructions JSR RET SBR 10 7 Arithmetic Status Flags Arithmetic status flags are affected Fault Conditions A major fault will occur if Fault type Fault code JSR instruction has fewer input parameters than SBR instruction 4 31 JSR instruction jumps to a fault routine 4 or user supplied 0 or user supplied RET instruction has fewer return parameters than JSR instruction 4 31 main routine contains a RET instruction 4 31 Execution Relay Ladder and Structured Text Condition Relay Ladder Action Structured Text Action prescan The controller executes all subroutines regardless of rung condition To ensure that all rungs in the subroutine are prescanned the controller ignores RET instructions l e RET instructions do not exit the subroutine e Release 6 x and earlier input and return parameters are passed e Release 7 x and later input and return parameters are not passed If recursive calls exist to the same subroutine the subroutine is prescanned only the first time If multiple calls exist non recursive to the same subroutine the subro
86. o close the text entry window press Ctrl Enter transition_name BOOL_expression This example shows three transitions that use a BOOL expression EXAMPLE Enter a BOOL Expression E Step_002 Ei E Step_001 Step_003 tag name of the transition E Tran_oo3 dint tag a gt 8 Tran_0014 J Tran_o02 bool tag_a amp ppbool tag _b bool tag_a BOOL expression that controls when the transition is true or false Call a Subroutine transition_name gt lt q L Right click the transition and select Set JSR 2 Select the routine that contains the logic for the transition JSR Properties Routine Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 5 12 Program a Sequential Function Chart Add an Action step_name UJ transition_name Configure an Action 3 Click step_name g transition_name JSR routine name To add an action to a step right click the step in which the action executes and select Add Action i l step_name j D Change the Qualifier of an Action A qualifier determines when an action starts and stops The default qualifier is N Non Stored The action starts when the step is activated and stops when the step is deactivated For more information see Choose a Qualifier for an Action on page 4 19 1 Click the button of the action n 2 On the General tab select the qualif
87. of the structured text start of comment e Comments can appear anywhere in structured text end of comment Assignments start of comment end of comment Useanassignmenttochangethevaluestoredwithinatag Anassignmenthas this syntax tag expression where Component tag Description represents the tag that is getting the new value the tag must be a BOOL SINT INT DINT or REAL is the assignment symbol expression represents the new value to assign to the tag If tag is this data type Use this type of expression BOOL BOOL expression SINT numeric expression INT DINT REAL ends the assignment Thefagretainstheassignedvalueuntilanotherassignmentchangesthevalue Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 TIP Program Structured Text 6 3 The expression can be simple such as an immediate value or another tag name ortheexpressioncanbecomplexandincludeseveraloperatorsand or functions See the next section Expressions on page 6 4 for details I Omodule dataupdatesasynchronouslytothe execution oflogic Ifyou referenceaninputmultipletimesinyourlogic theinputcouldchangestate between separate references Ifyouneedthe inputto have the same state foreachreference buffertheinputvalueandreferencethatbuffertag For more information on buffering data see page1 8 Specify a non retentive assignment The non retentive assignment is different from the reg
88. oller Properties Controller _Name p Ioj x General Serial Port System Protocol User Protocol Major Faults Minor Faults Date Time Advanced SFC Execution File Execution Control defaut p Execute current active steps only C Execute until FALSE transition You have the option of letting the SFC execute until it reaches a false transition If several transitions are true at the same time this option reduces the time to get to the desired step Use the Execute until FALSE transition option only when 1 You don t have to update JSR parameters before each step Parameters update only when the SFC returns to the JSR See Pass Parameters on page 4 42 2 A false transition occurs within the watchdog timer for the task If the time that it takes to return to a JSR and complete the rest of the task is greater than the watchdog timer a major fault occurs Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Pause or Reset an SFC Execution Diagrams Design a Sequential Function Chart 4 45 Two optional instructions are available that give you further control over the execution of your SFC If you want to Then use this instruction pause an SFC Pause SFC SFP reset an SFC to a specific step or stop Reset SFC SFR Both instructions are available in the ladder logic and structured text programming languages The following diagrams show the execution of an SFC with diff
89. ollow the general rule during postscan For a description of how a specific instruction executes during postscan see e Logix5000 Controllers General Instructions Reference Manual publication 1756 RM003 e Logix5000 Controllers Process and Drives Instructions Reference Manual publication 1756 RM006 e Logix5000 Controllers Motion Instruction Set Reference Manual publication 1756 RM007 Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Design a Sequential Function Chart 4 35 Here is an example that uses a non retentive assignment to control a conveyor It turns on a conveyor at the start of a step and automatically turns off the conveyor when the step is done EXAMPLE Automatically Clear Data This action turns on the conveyor When conveyor_state turns on the conveyor turns on N f conveyor_start conveyor state 1 conveyor_fwed F cdo When the SFC leaves the step conveyor_state turns off This turns off the conveyor Keep Something On From How Do You Want to Control the Device Step to Step To provide bumpless control of a device during more than one time or phase step do one of the following Option Example Use a Simultaneous Branch Make a separate step that controls the device Transfer_in Paint Fan Clean Transfr_Out Store and Reset an Action Transfer In turn on the fan Note the step that turns on the device and th
90. on Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 5 4 Program a Sequential Function Chart 2 To add a path to the branch select click the first step of the path that is to the left of where you want to add the new path Click green dot 3 To wire the simultaneous branch to the preceding transition click the bottom pin of the transition A and then click the horizontal line of the branch B A green dot shows a valid connection point End a Simultaneous Branch 1 Select the last step of each path in the branch To select the steps you can either e Click and drag the pointer around the steps that you want to select e Click the first step Then press and hold Shift and click the rest of the steps that you want to select C 0 Step_00S Step_006 J O 2 On the SFC toolbar click Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Program a Sequential Function Chart 5 5 3 Add the transition that follows the simultaneous branch green dot 4 To wire the simultaneous branch to the transition click the top pin of the transition A and then click the horizontal line of the branch B A green dot shows a valid connection point Create a Selection Branch Start a Selection Branch 1 On the SFC toolbar click the button Then drag the new branch to the desired location 2 To add a path to the branch select click the first transition
91. onveyor 0 alarm on 1 alarm 1 END_IF Example 2 IF THEN ELSE If you want this Enter this structured text If conveyor direction contact forward 1 then IF conveyor direction THEN light off light 0 Otherwise light on ELSE light 1 END IF The tells the controller to clear light whenever the controller e enters the RUN mode e leaves the step of an SFC if you configure the SFC for Automatic reset Thisappliesonlyifyouembedtheassignmentintheactionofthestep oruse the action to calla structured text routine via a JSR instruction Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Program Structured Text 6 15 Example 3 IF THEN ELSIF If you want this Enter this structured text If sugar low limit switch low on and sugar high limit IF Sugar Low amp Sugar High THEN switch not high on then inlet valve open on Sugar Inlet 1 Until sugar high limit switch high off ELSIF NOT Sugar High THEN Sugar Inlet 0 END_IF The tells the controller to clear Sugar Inlet whenever the controller e enters the RUN mode e leaves the step of an SFC if you configure the SFC for Automatic reset Thisappliesonlyifyouembedtheassignmentintheactionofthestep oruse the action to calla structured text routine via a JSR instruction Example 4 IF THEN ELSIF ELSE If y
92. or On the last scan of the step conveyor_state turns off This turns off the conveyor Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 4 32 Design a Sequential Function Chart Use the Programmatic Reset Option An optional method to programmatically turn off clear devices at the end of a step is to execute all actions on the last scan of the step This lets you execute your normal logic as well as turn off clear devices at the end of a step 1 In the Last Scan of Active Steps property select the Programmatic reset option 2 Clear the required data using any of these methods e To your normal logic add logic that clears the required data Use the LS bit of the step or the Q bit of the action to condition the execution of the logic e Use a PO Pulse Falling Edge action to clear the required data Make sure that the PO action or actions are last in the order of actions for the step During the last scan of the step the Programmatic reset option executes all assignments and instructions according to logic conditions e The controller does not postscan the assignments or instructions e When the SFC leaves the step all data keeps its current value This example uses a single action to turn on and off a conveyor The LS bit of the step conditions the execution of the logic See SFC_STEP Structure on page 4 8 EXAMPLE Use the Programmatic Reset Option and the LS Bit When
93. ou want this Enter this structured text If tank temperature gt 100 IF tank temp gt 200 THEN then pump slow pump fast 1 pump slow 0 pump off 0 If tank temperature gt 200 ELSIF tank temp gt 100 THEN then pump fast pump fast 0 pump slow 1 pump off 0 otherwise pump off ELSE pump fast 0 pump slow 0 pump off 1 END IF Publication 1756 PIM003H EN E excerpt from 1756 PM001H EN P August 2005 6 16 Program Structured Text CASE OF Use CASE to select what to do based on a numerical value Operands Structured Text CASE numeric_expression OF Operand Type Format Enter selectorl statement Pe ee Pere numeric_ SINT tag tag or expression that evaluates to a B expression INT expression number numeric expression ELSE DINT statement REAL END CASE selector SINT immediate same type as numeric expression INT DINT REAL IMPORTANT If you use REAL values use a range of values for a selector because a REAL value is more likely to be within a range of values than an exact match of one specific value Description The syntax is CASE numeric expression OF selectorl selector2 specify as many alternative selector values paths as you need selectors3 ELS h optional END CASE lt statement gt lt q Statements to execute when numeric_expression selector1 lt statement gt lt q statements to execute when
94. p use the Step Through option With the Step Through option e You do not have to add enable disable or remove forces e The next time the SFC reaches the transition it executes according to the conditions of the transition This option also lets you override one time the false force of a simultaneous path When you step through the force the SFC executes the steps of the path To step through the transition of an active step or a force of a simultaneous path 1 Open the SFC routine 2 Right click the transition or the path that is forced and choose Step Through Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Force Logic Elements 13 9 When to Use an SFC Force To override the logic of an SFC you have these options If you want to Then override the conditions of a transition each Force a Transition time the SFC reaches the transition prevent the execution of one or more paths Force a Simultaneous Path of a simultaneous branch Force a Transition To override the conditions of a transition through repeated executions of an SFC force the transition The force remains until you remove it or disable forces If you want to Then prevent the SFC from going to the next step force the transition false cause the SFC go to the next step regardless of transition force the transition true conditions If you force a transition within a simultaneous branch to be false the SFC stays
95. ption enter a numeric expression that calculates the time at runtime AlarmEn BOOL To use the alarm bits turn on check the AlarmEnable AlarmEn bit AlarmHigh BOOL If the Timer T reaches the LimitHigh value the AlarmHigh bit turns on e The bit stays on until you reset it e To use this alarm function turn on check the AlarmEnable AlarmEn bit do something while the step is X BOOL The X bit is on the entire time the step is active executing active including first and last scan Typically we recommend that you use an action with a N Non Stored qualifier to accomplish this do something one time when the Ft BOOL The FS bit is on during the first scan of the step step becomes active Typically we recommend that you use an action with a P1 Pulse Rising Edge qualifier to accomplish this do something while the step is SA BOOL The SA bit is on when the step is active except during the first and active except on the first and last scan of the step last scan do something one time on the isl BOOL The LS bit is on during the last scan of the step last scan of the step Use this bit only if you do the following On the Controller Properties dialog box SFC Execution tab set the Last Scan of Active Step to Don t Scan or Programmatic reset Typically we recommend that you use an action with a PO Pulse Falling Edge qualifier to accomplish this determine the target of an SFC Reset BOOL An SFC Reset SFR instruction resets the SFC to
96. ral information about the SFC pe Add a Text Box step p Adda Text Box or Add a Tag Description transition download the documentation to the controller Add Structured Text Comments have the option of showing or hiding the Add a Text Box documentation position the documentation anywhere in the zors SFC Add a Tag Description action download the documentation to the controller Add Structured Text Comments stop p Adda Text Box other element e g selection branch o Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Add a Tag Description Program a Sequential Function Chart 5 17 Add Structured Text Comments Comments embedded in the ST section of an action are downloaded into controller memory and are available for upload To enter comments 1 Double click the text area of the action 2 Type the comments To add a comment Use one of these formats ona single line comment at the end of a line of structured comment text comment within a line of structured text comment comment that spans more than one line start of comment end of comment start of comment end of comment 3 To close the text entry window press Ctrl Enter action_name comment statement Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 5 18 Program a Sequential Function Chart Add a Tag Description 1 Click
97. rs to the end of a string CONCAT insert characters into a string INSERT Expressions Anexpressionisatagname equation orcomparison Towriteanexpression use any of these elements e tag name that stores the value variable e numberthatyouenterdirectlyintotheexpression immediate value e functions such as ABS TRUNC e operators such as lt gt And Or As you write expressions follow these general rules e Useanycombinationofupper caseandlower caseletter Forexample these three variations of AND are acceptable AND And and e Formorecomplexrequirements useparenthesestogroupexpressions within expressions This makes the whole expression easier to read and ensures that the expression executes in the desired sequence See Determine the order of execution on page 6 10 Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Program Structured Text 6 5 In structured text you use two types of expressions BOOLexpression Anexpressionthat produceseitherthe BOOLvalueof1 true or 0 false e A bool expression uses bool tags relational operators and logical operators to compare values or check if conditions are true or false For example tag1 gt 65 e A simple bool expression can be a single BOOL tag e Typically youuseboolexpressionstoconditiontheexecutionofother logic Numeric expression An expression that calculates an integer or floating point value e Anumericexpressionusesarit
98. rung condition or state transition that triggers execution This differs from function block instructions that use EnablelIn to trigger execution Structured text instructions execute as ifEnableIn is always set Thisalso differs from relay ladder instructions thatuse rung condition into trigger execution Some relay ladder instructions only execute when rung condition intogglesfromfalsetotrue Thesearetransitionalrelayladder instructions In structured text instructions will execute each time they are scanned unless you pre condition the execution of the structured text instruction Forexample theABLinstructionisatransitionalinstructioninrelayladder In this example the ABL instruction only executes on a scan when tag_xic transitions from cleared to set The ABL instruction does not execute when tag_xic stays set or when tag_xic is cleared ABL ASCII Test For Buffer Line JE Channel SerialPort Control serial_control Character Count 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_xicis set notjustwhen tag_xic transitions from cleared to set Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 6 12 Program Structured Text IfyouwanttheABLinstructiontoexecuteonlywhentag_xictransitionsfrom clearedtoset youhavetoconditionthestructuredtextinstruction Useaone shot to tri
99. s steps e When you remove or disable the force the SFC can execute the steps in the path Add an SFC Force To override the logic of an SFC use an SFC force Forcingcancauseunexpectedmachinemotionthatcouldinjure personnel ATTENTION f Beforeyouuseaforce determine how the force will effectyour machine or process and keep personnel away from the machine area e Enabling SFC forces causes your machine or process to go toa different state or phase e Ifforces are enabled and you installa force the new force immediately takes effect 1 What is the state of the SFC Forces indicator Rem Run a T 1 0 Forces Enabled Forces A PF If Then note No Edits a m See off No SFC forces currently exist isable E Redundancy E T None Installed pa flashing No SFC forces are active But at least one force already exists in your project When you enable SFC forces all existing SFC forces will also take effect solid SFC forces are enabled active When you install add a force it immediately takes effect 2 Open the SFC routine 3 Right click the transition or start of a simultaneous path that you want to force and choose either Force TRUE only for a transition or Force FALSE 4 Are SFC forces enabled See step 1 If Then no From the Logic menu choose SFC Forcing gt Enable All SFC Forces Then choose Yes to confirm yes Stop Publication 1756 PIM003H EN E excerpt from 175
100. satisfactory and 3 outstanding Overall Usefulness 1 2 3 How can we make this publication more useful for you c 1 2 3 Can we add more information to help you ompleteness all necessary information procedure step illustration feature is provided nit th example guideline other explanation definition Technical Accuracy 1 2 3 Can we be more accurate all provided information l l is correct text illustration Clarity 1 2 3 How can we make things clearer all provided information is easy to understand Other Comments You can add additional comments on the back of this form Your Name Location Phone Your Title Function Would you like us to contact you regarding your comments ___No there is no need to contact me Yes please call me Yes please email me at Yes please contact me via Return this form to Allen Bradley Marketing Communications 1 Allen Bradley Dr Mayfield Hts OH 44124 9705 Phone 440 646 3176 Fax 440 646 3525 Email RADocumentComments ra rockwell com Publication 1cca 5 21 January 2001 PN 95510782 Other Comments PLEASE FASTEN HERE DO NOT STAPLE PLEASE FOLD HERE BUSINESS REPLY MAIL FIRST CLASS MAIL PERMIT NO 18235 CLEVELAND OH POSTAGE WILL BE PAID BY THE ADDRESSEE Allen Bradley BELIANCE JS ELECTRIC iine DOGE Rockwell Automation 1 ALLEN BRADLEY DR MAYFIELD HEIGHTS OH 44124 9705 NO
101. see Turn Off a Device at the End of a Step on page 4 28 Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 If you want to execute your logic without additional routines use structured text assignments constructs and instructions Design a Sequential Function Chart 4 17 To program a non boolean action you have these options Then Embed structured text For example N S_Open_Outlet S_Complete_the Batch Outlet ProgCommand 1 When the S_Complete_the_Batch step is active the S_Open_Outlet action executes The action sets the Outlet ProgCommand tag equal to 1 which opens the outlet valve re use logic in multiple steps use another language to program the action such as ladder logic nest an SFC Call a subroutine For example N S_Open_Outlet JSR Open Outlet S_Complete_the_Batch When the S_Complete_the_Batch step is active the S_Open_Outlet action executes The action calls the Open_Outlet routine Open_Outlet Routine Outlet ProgCommand When the Open_Outlet routine executes the OTE instruction sets the Outlet ProgCommand tag equal to 1 which opens the outlet valve You cannot reuse a non boolean action within the same SFC except to reset a stored action Only one instance of a specific non boolean action is permitted per SFC Use a Boolean Action A boolean action contains no logic for the action It simply sets
102. set an SFC 4 43 Execution Diagrams 4 43 Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Design a Sequential Function Chart 4 5 Define the Tasks The first step in the development of an SFC is to separate the configuration and regulation of devices from the commands to those devices Logix5000 controllers let you divide your project into one continuous task and multiple periodic tasks and event tasks 1 Organize your project These functions Go here configure and regulate devices periodic task command a device to a specific state SFC in the continuous task sequence the execution of your process 2 For those functions that go in a periodic task group the functions according to similar update rates Create a periodic task for each update rate For example 2 state devices may require faster updates than PID loops Use separate periodic tasks for each In this example a project uses two periodic tasks to regulate motors valves and temperature loops An SFC to control the process EXAMPLE Define the Tasks H E Controller Controller_Name This task periodic uses function block diagrams to turn on or Tasks Devices_Task 3 Motors_Program A Program Tags 2A Motors E ac Yalves_Program A Program Tags Ea valves Temperatures_Task E Temperatures_Program Ej Program Tags E E 2 Temperatures B 88 _MainTask MainProgr
103. struction the controller first executes the SBR instruction 2 The controller latches all data values in IREFs 3 The controller executes the other function blocks in the order that is determined by their wiring This includes other JSR instructions 4 The controller writes outputs in OREFs 5 If the routine contains an RET instruction the controller executes the RET instruction last The subroutine is called If the routine is an SFC routine the routine in initialized the same as it is during prescan Publication 1756 PM003H EN E excerpt from 1756 RMO003H EN P August 2005 Program Control Instructions JSR RET SBR 10 9 Example 1 The JSR instruction passes value_1 and value_2 to routine_1 The SBR instruction receives value_1 and value_2 from the JSR instruction and copies those values to value_a and value_b respectively Logic execution continues in this routine The RET instruction sends float_a to the JSR instruction The JSR instruction receives float_a and copies the value to float_value_1 Logic execution continues with the next instruction following the JSR instruction Relay Ladder Routine Program Main routine JSR Jump to Subroutine Routine name routine_1 Input par value_1 Input par value_2 Return par float_value_1 Subroutine SBR Subroutine Input par walue_a Input par value_b other rungs of code RET Return Return par float_a Structured Text Routine Progra
104. t count SINT tag tag to store count position as the END FOR INT FOR DO executes DINT initial_ SINT tag must evaluate to a number value INT expression specifies initial value for count DINT immediate final_ SINT tag specifies final value for count which value INT expression determines when to exit the loop DINT immediate increment SINT tag optional amount to increment count INT expression each time through the loop DINT immediate If you don t specify an increment the count increments by 1 IMPORTANT Makesurethatyou donotiteratewithinthe looptoomanytimesinasingle scan e Thecontrollerdoesnotexecuteanyotherstatementsintheroutineuntil it completes the loop e If the time that it takes to complete the loop is greater than the watchdog timer for the task a major fault occurs e Consider using a different construct such as IF THEN Description The syntax is FOR count initial value TO final value optional BY increment If you don t specify an increment the loop increments by 1 DO lt statement gt IF bool_expression THEN EXIT lt q If there are conditions when you want to optional exit the loop early use other statements END_IP such as an IF THEN construct to condition an EXIT statement END FOR Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 6 20 Program Structured Text These diagrams show how a FOR DO loop execu
105. t is to create one SFC that provides a high level view of your process Each step of that SFC calls another SFC that performs the detailed procedures of the step nested SFC This figure shows one way to nest an SFC In this method the last scan option of the SFC is configured for either Programmatic reset or Don t scan If you configure the SFC for Automatic reset then step 1 is unnecessary SFC_a i P1 Action_ooo sfr SFC_b SFC_b Step 1 SFC_a_step_x SFC_b stop x 0 SFC _b stop x 4 SFC_b stp G 1 Reset the nested SFC e The SFR instruction restarts SFC_b at SFC_b_Step_1 Each time SFC_a leaves this step and then returns you have to reset SFC_b e The action also clears the X bit of the stop element 2 Call SFC_b 3 Stop SFC_b This sets the X bit of the stop element 4 Use the X bit of the stop element to signal that SFC_b is done and it is time to go to the next step Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 4 44 Design a Sequential Function Chart Pass Parameters To pass parameters to or from an SFC place a Subroutine Return element in the SFC Input Parameters Return Parameters M w S F C_b lm SBR Subroutine Configure When to Return By default an SFC executes a step or group of simultaneous steps and to the OS f JSR then returns to the operating system OS or the calling routine JSR f Contr
106. tag If photoeye is a BOOL tag and your specification IF NOT photoeye THEN says If photoeye is off then expressionl amp expression2 If photoeye is a BOOL tag temp is a DINT tag and your specification says If photoeye is on and temp is less than 100x then expressionl OR expression2 If photoeye is a BOOL tag temp is a DINT tag and your specification says If photoeye is on or temp is less than 100x then IF photoeye amp temp lt 100 THEN IF photoeye OR temp lt 100 THEN expressionl XOR expression2 If photoeye1 and photoeye2 are BOOL tags and your specification says If e photoeyel is on while photoeye2 is off or e photoeyel is off while photoeye2 is on then IF photoeyel XOR photoeye2 THEN BOOLtag expression2 expressionl amp If photoeye1 and photoeye2 are BOOL tags open is a BOOL tag and your specification says If photoeye1 and photoeye2 are both on set open to true open photoeyel amp photoeye2 Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 6 10 Program Structured Text Use bitwise operators Bitwise operators manipulate the bits within a value based ontwo values For Use this operator Optimal Data Type bitwise AND amp AND DINT bitwise OR OR DINT bitwise exclusive OR XOR DINT bitwise complement NOT DINT For example Use this format Example For th
107. tes and how an EXIT statement leaves the loop early Done xnumber yes Done Xnumber yes ae of times ad of times no no statement 1 statement 1 statement 2 statement 2 statement 3 statement 3 statement 4 statement 4 thes ed yes P M Exit p rest of the routine Te no v rest of the routine The FOR DO loop executes a specific To stop the loop before the count reaches the last number of times value use an EXIT statement Arithmetic Status Flags not affected Fault Conditions A major fault will occur if Fault type Fault code the construct loops too long 6 1 Example 1 If you want this Enter this structured text Clear bits 0 31 in an array of BOOLs For subscript 0 to 31 by 1 do 1 Initialize the subscript tag to 0 E E 2 Clear array subscript For example when array lsubsariptl 0 subscript 5 clear array 5 End for 3 Add 1 to subscript 4 If subscript is to 31 repeat 2 and 3 Otherwise stop Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Example 2 Program Structured Text 6 21 Enter this structured text If you want this A user defined data type structure stores this information about an item in your inventory e Barcode ID of the item string data type e Quantity in stock of the item DINT data type An array of the above structure contains an element for each different item in your inventory You want to s
108. that was running Restart at most recently executed step Initial step Select Restart at initial step The restart position isn t for major faults After you clear a major fault the SFC always restarts at the initial step e what to do on the last scan of a step 4 Click Verify the Routine As you program your routine periodically verify your work 1 In the top most toolbar of the RSLogix 5000 window click 2 If any errors are listed at the bottom of the window a To go to the first error or warning press F4 b Correct the error according to the description in the Results window c Go to step 1 3 To close the Results window press Alt 1 To check your SFC you can e force transitions e step through the SFC For more information on these debug options see chapter 13 Force Logic Elements Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 5 22 Program a Sequential Function Chart Edit an SFC Online Firmware revision 13 added support for editing SFCs online When you transition the controller to test or un test edits the controller resets the SFC and starts execution at the initial step If you edit an SFC online e Time when you test or untest edits to coincide with the SFC executing the initial step e Place structured text logic in subroutines to minimize the impact of online edits e Use an SFR instruction to programmatically shift SFC execution to the desired step
109. tine SBR Return RET JSR Operands JSR Jump to Subroutine Routine name Input par Return par JSR RoutineName InputCount InputPar ReturnPar Publication 1756 PM003H EN E excerpt from 1756 RMO003H EN P August 2005 The JSR instruction jumps execution to a different routine The SBR and RET instructions are optional instructions that exchange data with the JSR instruction Relay Ladder Operand Type Format Description Routine ROUTINE name routine to execute i e subroutine name Input BOOL immediate data from this routine that you want to copy parameter SINT tag to a tag in the subroutine INT array tag e Input parameters are optional DINT e Enter multiple input parameters if REAL needed structure Return BOOL tag tag in this routine to which you want to copy parameter SINT array tag a result of the subroutine INT e Return parameters are optional DINT e Enter multiple return parameters if REAL needed structure Structured Text Operand Type Format Description Routine ROUTINE name routine to execute i e subroutine name Input count SINT immediate number of input parameters INT DINT REAL Input BOOL immediate data from this routine that you want to copy parameter SINT tag to a tag in the subroutine INT array tag e Input parameters are optional DINT e Enter multiple input parameters if REAL needed structure Return BOOL tag tag in this routine to which you want to copy parameter S
110. to zero Design a Sequential Function Chart 4 31 Use the Don t Scan Option The default option for handling the last scan of a step is Don t scan With this option all data keeps its current values when the SFC leaves a step This requires you to use additional assignments or instructions to clear any data that you want to turn off at the end of a step To turn off a device at the end of a step 1 Make sure that the Last Scan of Active Steps property is set to the Don t scan option default 2 Use a PO Pulse Falling Edge action to clear the required data Make sure that the PO action or actions are last in the order of actions for the step During the last scan of the step the Don t scan option executes only P and PO actions The assignments and instructions of the actions execute according to their logic conditions e The controller does not execute a postscan of assignments or instructions e When the SFC leaves the step all data keeps its current values This example uses an action to turn on a conveyor at the start of a step A different action turns off the conveyor at the end of the step EXAMPLE Use the Don t Scan Option Zal conveyor_fwd This action turns on the conveyor When conveyor_state turns N L conveyor_start on the conveyor turns on conveyor state 1 PO L conveyor_stop Before the SFC leaves the step the PO action turns off the conveyor state 0 convey
111. ular assignment described above in thatthe tag inanon retentive assignmentis reset to zero each time the controller e enters the RUN mode e leaves the step of an SFC if you configure the SFC for Automatic reset Thisappliesonlyifyouembedtheassignmentintheactionofthestep oruse the action to calla structured text routine via a JSR instruction A non retentive assignment has this syntax tag expression where Component Description tag represents the tag that is getting the new value the tag must be a BOOL SINT INT DINT or REAL is the non retentive assignment symbol expression represents the new value to assign to the tag If tag is this data type Use this type of expression BOOL BOOL expression SINT numeric expression INT DINT REAL ends the assignment Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 6 4 Program Structured Text Assign an ASCII character to a string Usetheassignmentoperatortoassignan ASCH charactertoanelementofthe DATA member ofa string tag To assign a character specify the value of the character or specify the tag name DATA member and element of the character For example This is OK This is not OK stringl DATA 0 65 stringl DATA 0 A stringl DATA 0 string2 DATA 0 stringl string2 Toaddorinserta string of characters toa string tag use either of these ASCII string instructions To Use this instruction add characte
112. ult occurs e Consider using a different construct such as IF THEN Description The syntax is REPEAT lt statement gt lt q Statements to execute while bool_expression1 is false eal Z IF bool_expression2 THI aDeILIES lt q If there are conditions when you want to exit the loop early use other statements END IF such as an IF THEN construct to condition an EXIT statement optional UNTIL bool _expressionl END REPEAT Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 6 26 Program Structured Text These diagrams show how a REPEAT UNTIL loop executes and how an EXIT statement leaves the loop early statement 1 statement 2 statement 3 statement 4 true rest of the routine BOOL expression false While the bool_expression is false the controller executes only the statements within the REPEAT UNTIL loop Arithmetic Status Flags not affected Fault Conditions ement 1 ement 2 ement 3 ement 4 sta sta sta sta ad Exit no v BOOL expression tug ey false rest of the routine To stop the loop before the conditions are false use an EXIT statement A major fault will occur if Fault type Fault code the construct loops too long 6 1 Example 1 If you want this Enter this structured text The REPEAT UNTIL loop executes the statements in the pos
113. ump to Subroutine Routine Add_Three_Inputs Add_Input_1 Add_Three_Result D Add_Input_2 Output_1 The values in Add_Input_1 Add_Input_2 and Add_Input_3 are copied to Input_A Input_B and Input_C respectively 3 The value of Sum_A_B_Cis copied to Add_Three_Result Function blocks of the Add_Three_ nputs routine ADD_O2 Ea RET E Subroutine Return O Sources Q Sources Q SourceB C SourceB 2 The ADD instructions add nput_A Input_B and Input_C and place the result in Sum_A_B_C Publication 1756 PM003H EN E excerpt from 1756 RM003H EN P August 2005 10 12 Program Control Instructions JSR RET SBR Notes Publication 1756 PM003H EN E excerpt from 1756 RMO003H EN P August 2005 How Are We Doing PANE Your comments on our technical publications will help us serve you better in the future Thank you for taking the time to provide us feedback wy You can complete this form and mail it back to us visit us online at www ab com manuals or email us at RADocumentComments ra rockwell com vr Pub Title Type SFC and ST Programming Languages Programming Manual Cat No 1756 ControlLogix Pub No 1756 PM003H EN E Pub Date August 2005 PartNo 957974 51 1769 CompactLogix ESS 1789 SoftLogix 1794 FlexLogix PowerFlex 700S with DriveLogix Please complete the sections below Where applicable rank the feature 1 needs improvement 2
114. unction tagl1 parentheses to contain the operand of a function Even though their syntax is similar functions differ from instructions in that functions can only be used in expressions Instructions cannot be used in expressions Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 6 2 Program Struct ured Text Term instruction see page 6 11 Definition An instruction is a standalone statement Examples instruction An instruction uses parenthesis to contain its operands Depending on the instruction there can be zero one or multiple instruction operand operands When executed an instruction yields one or more values that are partof instruction operandl a data structure Terminate the instruction with a semi colon operand2 operand3 Even though their syntax is similar instructions differ from functions in that instructions cannot be used in expressions Functions can only be used in expressions construct A conditional statement used to trigger structured text code i e other IF THEN see page 6 12 statements CASE Terminate the construct with a semi colon FOR DO WHILE DO REPEAT UNTIL EXIT comment Text that explains or clarifies what a section of structured text does comment see page 6 28 e Use comments to make it easier to interpret the structured text e Comments do not affect the execution
115. utine is prescanned each time The rung condition out is set to false relay ladder only rung condition in is false to The subroutine does not execute na the JSR instruction Outputs in the subroutine remain in their last state The rung condition out is set to false rung condition in is true The instruction executes na The rung condition out is set to true Enableln is set na Enableln is always set The instruction executes Publication 1756 PM003H EN E excerpt from 1756 RMO003H EN P August 2005 10 8 Program Control Instructions JSR RET SBR Condition instruction execution Relay Ladder Action Structured Text Action JSR copies input parameters to input parameters appropriate SBR tags logic execution begins in routine identified by JSR yes yes RET copies return parameters to gt return parameters appropriate JSR tags no no yes end of subroutine r y rung condition out is set to true rung condition out is set to false logic execution returns to JSR continue executing routine postscan Same action as prescan described above Same action as prescan described above Function Block Condition Action prescan No action taken instruction first scan No action taken instruction first run No action taken normal execution postscan 1 If the routine contains an SBR in
116. xpression REAL radians to degrees DEG numeric expression DINT REAL natural log LN numeric expression REAL log base 10 LOG numeric expression REAL degrees to radians RAD numeric expression DINT REAL sine SIN numeric expression REAL square root SQRT numeric expression DINT REAL tangent TAN numeric expression REAL truncate TRUNC numeric expression DINT REAL Publication 1756 PM003H EN E excerpt from 1756 PM001H EN P August 2005 Use this format valuel operator value2 operator valuel For example Example Program Structured Text 6 7 For this situation If gain_4 and gain_4_adj are DINT tags and your specification says Add 15 to gain_4 and store the result in gain_4_adj If alarm and high_alarm are DINT tags and your specification says Negate high_alarm and store the result in alarm You d write gain 4 adj gain 4 15 alarm high_ alarm function numeric expression If overtravel and overtravel_POS are DINT tags and your specification says Calculate the absolute value of overtravel and store the result in overtravel_POS overtravel POS ABS overtravel valuel operator function value2 value3 2 If adjustment and position are DINT tags and sensor1 and sensor2 are REAL tags and your specification says Find the absolute value of the average of sensor1 and sensor2 add the position adjustment ABS sensorl sensor2 2 adjust
Download Pdf Manuals
Related Search
Related Contents
View ERI Results Philips Stick 929689874401 HSM MultiShred one-4-all KD80 - テスコム Kit RC4 TAC3 FULL Manuel d`installation - AERIA Philips Screeneo Smart LED Projector HDP1590 bedienungsanleitung 2010 - KTM-Versand, Ersatzteile, Zubehör Basic CMYK - Kitchen Craft Caractéristiques techniques ダウンロード2 - 鳥取県西部広域行政管理組合 Copyright © All rights reserved.
Failed to retrieve file