Page 257 - Programmable Logic Controllers, Fifth Edition - Mobile version
P. 257

operation of the logic rung can be summarized as follows:
                   L1  Input      SW   Ladder logic program          SUB instruction used with the SLC 500 controllers. The
                                        SUB
                           SW           SUBTRACT                       •  When input switch SW is closed the rung will be true.
                                        Source A       N7:10           •  The value stored at the source B address, N7:05
                                                          520
                                        Source B       N7:05              (322), is subtracted from the value stored at the
                                                         322              source A address, N7:10 (520).
                                        Destination    N7:20           •  The answer (198) is stored at the destination ad-
                                                         198
                                                                          dress, N7:20.
               Figure 11-7  SLC 500 SUB (subtract) instruction.        •  Source A and source B can be either values or ad-
                                                                          dresses that contain values, but A and B cannot both

                  Sign Bit (S)—Address S2:0/3, is set to 1 when the       be constants.
                  result is a negative number.                          The program of Figure 11-8 shows how the SUB func-
                                                                     tion can be used to indicate a vessel overfill condition.
               11.3  Subtraction Instruction                         This application requires an alarm to sound when a supply
                                                                     system leaks 5 lb or more of raw material into the ves-
               The SUB (subtract) instruction is an output instruction that
               subtracts one value from another and stores the result in   sel after a preset weight of 500 lb has been reached. The
               the destination address. When rung conditions are true, the   operation of the program can be summarized as follows:
               subtract instruction subtracts source B from source A and   •  When the start button is pressed, the fill solenoid
               stores the result in the destination. Figure 11-7 shows the   (rung 1) and filling indicating light (rung 2) are



                              Inputs                       Ladder logic program                    Outputs
                                                                                 Fill
                     L1                         Stop      Start        Full    solenoid                         L2
                                        1
                                                                                                    Fill
                                Start                      Fill                                   solenoid
                                                         solenoid
                          Start
                          Stop                  Fill
                                              solenoid     Full                 Filling
                                        2
                               Stop
                                               GEQ                              Full
                                        3      GREATER THAN OR EQUAL                                Filling
                                               Source A              I:012
                                               Source B              500
                               I:012                                                                  Full
                         Weight  (All 16 bits)
                       transducer               Full                  SUB
                                        4                             SUBTRACT                      Alarm
                                                                      Source A        I:012
                                                                      Source B        500
                                                                      Destination     N7:1



                                                                                Alarm
                                               GEQ
                                        5      GREATER THAN OR EQUAL
                                               Source A              N7:1
                                               Source B                5
                      Figure 11-8  Vessel overfill alarm program.



               238        Chapter 11  Math Instructions







          pet73842_ch11_234-251.indd   238                                                                              03/11/15   4:07 PM
   252   253   254   255   256   257   258   259   260   261   262