Beginner guide (986746), страница 15
Текст из файла (страница 15)
Be sure to clear CY if its previous status is not required in thecalculation, and to use the result placed in CY, if required, before it is changed by execution of anyother instruction.The augend and addend must be in BCD, if not special relay 25503 (Error Flag) is turned ON andADD is not executed.ADD is executed each time the CPU scans the program. To execute it only once.6-766.qAPPLICATION EXAMPLES OF BASIC COMMANDSSubtract – SUB(31)SUB finds the difference between the data in one channel and the data in another channel or aconstant, and then outputs the result to a third channel.Therefore, three data must be specified : an minuend, an subtrahend and a result channel.Operand Data AreasLadder SymbolsMi: Minuend channelIR, SR, AR, DM, HR, TC, LR, #SUB(31)MiSuSu: Subtrahend channelIR, SR, AR, DM, HR, TC, LR, #RR: Result channelIR, AR, DM, HR, LRExample circuitLadder diagram00000Address000000010002CLC(41)SUB(31)HR04#1234200MinuendSubtrahendResultInstructionLDCLC(41)SUB(31)Data00000HR04#12342000004END(01)In the above example, before executing SUB, the Carry Flag (special relay 25504) is turned OFF bythe Clear Carry (CLC).
The addition and subtraction instructions include CY in the calculation aswell as in the result. Be sure to clear CY if its previous status is not required in the calculation, andto use the result placed in CY, if required, before it is changed by execution of any other instruction.The minuend and subtrahend must be in BCD, if not special relay 25503 (Error Flag) is turned ONand ADD is not executed.SUB is executed each time the CPU scans the program. To execute it only once.6-776.qAPPLICATION EXAMPLES OF BASIC COMMANDSApplication #14: Measuring The Life Of A Cutting KnifeA knife is used to cut 3 products A, B and C and has to be changed after cutting 1000 pieces of A or500 pieces of B or 100 pieces of C.
but the products come at random. A buzzer is sound when thelife of the knife is up.3 sensors are assign to differentiate the 3 products. Another sensor is used to signal cuttingcompletion. A pushbutton to start the process.•I/O AssignmentInput000000000100002000030000400005DeviceCutter SensorProduct AProduct BProduct CStart pushbuttonResetOutput0100001001DeviceBuzzerCutter (Knife)Start Push-button (4)Product A, B or CKnife (1001)Reset Push-button (5)Buzzer (1000)Cutting Machine6-786.APPLICATION EXAMPLES OF BASIC COMMANDSMnemonic codesLadder Diagram : Main 1 Network 1Main 1 – Knife liftApplication : Measuring the life of a cutting lifeNetwork 1 – CutterCutter activation200.00000.00010.01StartCutsensorCutter010.01CutterAddress0000000100020003000400050006000700080009InstructionLDORAND NOTOUTLDDIFU(13)LDANDCLC(41)ADD(30)Network 2 – CutterCutter start pushbutton000.04Startpb0010001100120013DIFU(13)200.00StartLDANDCLC(41)ADD(30)Network 3 – Add 1200.00000.01StartProductACLC(41)ADD(30)HR00add2#0001HR00add 2Network 4 – Add 2200.00000.02StartProductB0014001500160017LDANDCLC(41)ADD(30)Data2000001001000000100100004200002000000001HR00#0001HR002000000002HR00#0002HR002000000003HR00#0010HR00CLC(41)ADD(30)HR00add2#0002HR00add 2Network 5 – Add 10200.00000.03StartProductCCLC(41)ADD(30)HR00add2#0010HR00add 26-796.APPLICATION EXAMPLES OF BASIC COMMANDSNetwork 6 – Compare253.13CPM(20)#1000NCAddress001500160017InstructionLDOUTCMP(20)HR00add2255.06200.01=Flag255.07200.02<FlagNetwork 7 – Buzzer010.00200.01001801900200021002200230024002500260027ANDOUTLDANDOUTLDOROUTLDMOV(21)0028END(01)Cutter200.02Data25313TR 0#1000HR002550620001TR 0255072000220001200020100000005# 0000HR00Network 8 – Reset000.05MOV(21)Reset#0000HR00add2Network 9 – EndEnd (01)6-806.qAPPLICATION EXAMPLES OF BASIC COMMANDSApplication #15: Car Park ControlThis is a simple car park control system that allows only a maximum of 100 cars parking space.Everytime a car comes in, the PLC will automatically add one through sensor S1.
Any car that goesout will automatically be subtracted by one through sensor S2. When 100 cars are registered, the carpark full sign will be lighted to inform oncoming vehicles not to enter.CAR PARKFULLCar coming in(10000)S1 (0)S2 (1)Car coming out•I/O AssignmentInput0000000001DeviceSensor S1Sensor S2Output01000DeviceCar Park Full Sign6-816.APPLICATION EXAMPLES OF BASIC COMMANDSMnemonic codesLadder Diagram : Main 1 Network 1Main 1 – Carpark controlApplication : Car Park ControlNetwork 1 – Car in000.00DIFU(13)Address00000001000200030004InstructionLDDIFU(13)LDCLC(41)ADD(30)200.00CarinS1Network 2 – Add 1200.00CLC(41)CarinADD(30)00050006000700080009LDDIFU(13)LDCLC(41)SUB(31)HR00#0001HR00001000110012Network 3 – Car out000.01LDOUTCMP(20)DIFU(13)200.01CaroutS2Network 4 – Subtract 1200.01CLC(41)S2001300140015001600170018ANDLDANDOR LDOUTEND(01)Data000002000020000HR00#0001HR00000012000120001HR00#0001HR0025313TR 0HR00#010025506TR 02550501000SUB(31)HR00#0001HR00Network 5 – Compare253.13CPM(20)HR00NC#0100255.06=Flag010.00Carparkfull255.05>FlagNetwork 6 – EndEnd (01)6-826.qAPPLICATION EXAMPLES OF BASIC COMMANDSExample: Ball Sorter MechanismHopper with 2 colour balls(black &white)Start (0)Top(1000) CylinderBall Sensor (S1)(1001) BottomCylinderStop (3)Colour Sensor (S2)Pusher (1002)Black BallsWhiteIn this application, the system is to sort out the black & white balls into 2 different container.The start button will start the operation, Ball sensor (S1) will sense the presence of the ball in thehopper.
The top solenoid will release the ball for the colour sensor (S2) to differentiate the colourbefore being release into the container.•I/O AssignmentInput00000000010000200003DeviceStart PBBall sensor (S1)Colour sensor (S2)Stop PBOutput010000100101002DeviceTop cylinderBottom cylinderPusher6-836.APPLICATION EXAMPLES OF BASIC COMMANDSLadder Diagram : Main 1 Network 1Main 1 – Ball Sorting (Conventional Method)Network 1 – Start cond000.00000.03200.01StartStopStartcond200.01StartcondNetwork 2 – Top cylinder200.01000.01StartcondS1200.03010.00Topcylinder010.00TopcylinderNetwork 3 – Timer010.00TIMTopcylinder000#0015Network 4 – DelayTIM000200.03TIM004200.03Network 5 – White&black200.03000.02ColorsenseTIM001White#0005000.02ColorsenseTIM002Black#0005Network 6 - BottomcylinderTIM001010.01WhiteBottomcylinTIM0036-846.APPLICATION EXAMPLES OF BASIC COMMANDSNetwork 7 – Delay 0.5sec010.01TIMBottomcylin004#0005Network 8 - PusherTIM002010.02BlackPusherTIM003#0010Network 9 - EndEnd(01)6-856.APPLICATION EXAMPLES OF BASIC COMMANDSLadder Diagram : Main 1 Network 1Main 1 – Balls sortingThis program separates white balls from black balls using the shift register methodNetwork 1 – Start000.00000.03200.00StartStopCond200.00CondNetwork 2 –Differentiation up200.00DIFU(13)Cond200.01Network 3 – Set bit 1 onFirst bit of HR 00 is set200.01MOV(21)#0001HR00.04HR00ShiftShift.04Network 4 – Shift register253.14SFT(10)No200.02HR00ShiftClock000.03HR00ShiftStopNetwork 5 – ProcessProcess sequencing clock input to shift register000.01200.02200.02Shift.00S1ClockClockHR00.01TIM000HR00.0Shift.01HR00.02Shift.02000.02S2TIM003HR00.03TIM001Shift.036-866.APPLICATION EXAMPLES OF BASIC COMMANDSNetwork 6 – Set bit 1 onHR00.01010.00Shift.01TopcyTIM001#0010Network 7 – Set bit 1 onHR00.03010.00Shift.03BotcyTIM001#0010Network 8 – Delay 1secHR00.02000.02Shift.02S2TIM002#0010Network 9 – PusherTIM002HR00.04010.02010.02Shift.04PusherTIMPusher003#0010Network 10 - EndEnd(01)6-877.USEFUL CIRCUITRY1 – Cycle Differentiation CircuitDescriptionCircuit Example 1Differentiation up circuit operates for only one cycle timewhen an input signal turns on (i.e., at the leading edge ofthe input signal).0000DIFU (13)0200(DIFU)02001000Signal(input signal)0000DifferentiationoutputTT: 1 cycle execution timeDifferentiation upoutputOutputDIFU (13)0200Differentiation upoutput(DIFU)0200JMP (04)Differentiation down circuit operates for only one cycletime when an input signal turns off (i.e., at the fallingedge of the input signal).Program AJMP (05)Signal(input signal)0000DifferentiationoutputDIFD (14)0200DifferentiationDown output(DIFD)T02001001Application exampleUsing the 1-cycle differentiation up circuit when anarithmetic operation is to be executed only once at theleading edge of an input signal (i.e., when the input signalturns on), when a given program (A, in the examplebelow) is to be executed only once at the leading edge ofthe input signal, etc.
To execute the arithmetic operation,the given program, etc., only once at the trailing edge ofan input signal (i.e., when the input signal turns off), usethe 1-cycle differentiation down circuit.This circuit causes program A to be executed only once atthe leading edge of input signal 0000.JMP andJMEinstructions before andWrite theafter program A, respectively.Circuit Example 2This circuit is an application exampledifferentiation circuit using an auxiliary relay.I/O AssignmentSignal (input signal)Differentiation outputOutput relayOutput relayOutput0000020010001001Signal (input signal)Differentiation outputAuxiliary relayofthe0000100010017-17.USEFUL CIRCUITRY00001000Differentiation upoutput0000DIFU (13)0200Differentiation upoutput(DIFU)000002001001JMP (04)000002011000Differentiation downoutputProgram AJMP (05)00001001This circuit causes program A to be executed only once atthe leading edge of input signal 0000.JMPJME instructions before andWrite theandafter program A, respectively.7-27.USEFUL CIRCUITRYFlicker Circuit(2) 1-sec clock pulse (Auxiliary relay 25502) is usedDescriptionThis circuit repeat outputs at specified ON/OFF intervalswhen a signal (input signal) is applied.2550200001000FlickeroutputSignal(input signal)0000Flicker outputT1T23200T1, T2: Specified ON and OFFtimesApplication examplesUse this circuit for the count input of a long-timer (usinga CNT instruction), the flickering failure indication of anannunciator, the timing generation of a relay circuit, etc.T2T1T2T1T2T1T2T1T1: 0.5 secT2: This time changes depending on theprogram position.(3) 1-cycle execution time is usedI/O AssignmentSignal (Input signal)Flicker output1-sec clock pulse100000000000relay 1000Auxiliary relay 255021000Circuit ExamplesFlickeroutput0000The circuit examples below are applicable to many PLCs.1000(1) Timers are used.T10000T2T2T2T2T2T2TIM002TIM0010000TIM001ON time1 secTIM002Off time2 sec1000FlickeroutputT1: This time changes depending on theprogram position.T2: 1-cycle execution timeTIM00100003200T1T2T1T2T1T2T1T1: 1 secT2: 2sec7-37.USEFUL CIRCUITRYSingle-shot CircuitDescriptionCircuit ExampleThis circuit is used to keep the ON time of a single (inputsignal) constant.This circuit is applicable to many PLCs.00001000Signal(input signal)1000DifferentiationoutputTTT: Single-shot time (constant)I/O AssignmentSignal (Input signal)Single-shot outputOutput relay 1000TIM00110001000TIM001Single-shottime 3 sec1001Single-shotoutputTIM0010000relay 10017-47.USEFUL CIRCUITRYLong-Time Timer CircuitDescription(2) A combination of a timer and a counterThe timers can be set to a maximum of 999.9 sec.
Usethis circuit if the time setting exceeding this maximum isrequired.0000TIM001TIM0015 secTIM001Timer ON condition2,000counts0000Timer outputTime setting(999.9 sec min)CNT0021002Timer outputI/O AssignmentWith this combination, a 10,000-sec (5sec x 2,000counts) timer circuit is configured.Timer ON condition0000Timer output: Output relay 1002Timer TIM001 is used to generate 5-sec pulses which arethen counted by counter CNT002 to 2,000 counts.Circuit ExampleThe circuit examples below are applicable to manyPLCs.(1) A combination of two timersWhen the CNT instruction is used, the present value ofthe timer is retained during a power failure.(3) A combination of a 1-sec clock (25502) and acounter (memory retentive type timer)0000TIM001500 secTIM10000TIM002800 secTIM20000100225502CNT001#5000Timer outputCNT0011002Timer outputWithout two timers, a 1,300-sec (500 + 800sec) timercircuit is configured.A timer circuit of 1999.8 sec (999.9 + 999.9sec)maximum can be configured.With this combination, a 5,000-sec timer circuit isconfigured.Special auxiliary relay 25502 generates a 1-sec clock.When the CNT instruction is used, the present value ofthe timer is retained during a power failure.7-57.USEFUL CIRCUITRYON/OFF-Delay CircuitDescriptionI/O AssignmentThis circuit is used to delay the ON/OFF time of a signal(input signal) for a given time.Signal (input signal) 0000ON/OFF-delay output : Output relay 1003Circuit ExampleSignal (input signal)The circuit examples below are applicable to CPM1ON/OFF delay output0000T1T2T1 : ON-delay timeT2 : OFF-delay timeApplication exampleWhen a data input (BCD) and a data read input arereceived simultaneously from external devices, it isnecessary to turn on the data read input after data hasbeen accepted.