CX-Programmer User Manual (986752), страница 6
Текст из файла (страница 6)
It is possible to skip this step, and use addresses directly within the program.It is better, however, to create symbolic names for the addresses so that the programs become morereadable and maintainable.Use the following procedure to create symbols.1, 2, 3…1.Click in the Diagram Window and select the View Local Symbols button from thetoolbar.2.Select the New Symbol button from the toolbar. The Insert Symbol dialogue isdisplayed.3.Enter ‘AmberLight’ in the Name field.4.Set the Address or value field to ’10.01’.5.Leave the Data type field set to ‘BOOL’ to indicate a bit (binary) value.6.Type ‘Prepare to go / stop’ in the Comment field.7.Select the OK pushbutton to proceed.Repeat this procedure for each of the other entries in the following table:AddressData TypeRedLightName10.00BOOLGreenLight10.02BOOL1NUMBERRedLightTimerGoTimer for the red light periodAmberLightTimer2NUMBERTimer for the amber light periodGreenLightTimer3NUMBERTimer for the green light period4NUMBERTimer for the amber only periodT0001BOOLAmberOnlyTimerRedTimerDoneAmberTimerDoneT0002BOOLGreenTimerDoneT0003BOOLAmberOnlyTimerDoneT0004BOOL48NUMBERTimeIntervalNote:Revision 2.0CommentStopSpeed at which the sequence works(ticks)It is important to use the standard form of addresses in CX-Programmer.
Dependingupon their defined type, addresses may have two components – a channel and a bitnumber. In the above example, the symbol ‘RedLight’ is defined as type ‘BOOL’.Entering the address ‘10’ is interpreted by CX-Programmer as ‘0.10’. If it had beenintended as bit zero at address 50, it would have been necessary to enter it as ‘5000’or (more easily) ‘50.00’.Page 23CHAPTER 2 – Quick Start GuideOMRONNote:Symbols of NUMBER type have been used to indicate the timer numbers used in thePLC.
Whilst it is possible to type numbers directly into the program ‘TIM’ instructionoperands, it is more readable to define symbols which can have a name and comment.CX-Programmer allows numbers to be defined as symbols, as well as addresses.Note:It is possible to create symbols whilst creating the PLC programs – when enteringladder contact/coil and instruction information. It is not necessary to use the symboltable to create symbols.Creating a Ladder ProgramA PLC can be programmed using either the Ladder or Mnemonic programming languages. The Ladderprogram is created in the Diagram View of the Diagram Window.Use the following procedure to create a ladder program.1, 2, 3…1.Ensure the Ladder program is displayed in the Diagram Workspace.2.Give the rung a comment by using the Properties box (move the cursor to the rungmargin and access the properties box from the context menu).Note: A rung comment placeholder can be inserted into the compiled code (if theInclude Comment Instructions property of the PLC is set), and the commentitself can then be saved to a file or file-card.
All comments are saved in the projectfile.3.Place a New Closed Contact at the start of the rung – select the New ClosedContact button from the toolbar and click in the top left cell. The New ClosedContact dialogue is displayed.4.Select ‘AmberOnlyTimerDone’ from the Name or Address list field and selectthe OK pushbutton.Note that the rung margin now shows a red mark down its side.
This is toindicate that the rung is incomplete – the marker bar shows whenever the runghas an error.5.Place an Instruction by selecting the New PLC Instruction button from the toolbarand clicking next to the Contact. The New Instruction dialogue is displayed.6.Enter the instruction ‘TIM’ and the two operands to ‘RedLightTimer’ and‘TimeInterval’, in the Operands field.Note: The value of the symbol ‘RedLightTimer’ is used for the operand – thenumber ‘1’.
In CX-Programmer, it is necessary to use a NUMBER for the firstoperand of a TIM/CNT instruction. It is not allowed to use a timer/counteraddress (i.e. T001 is not allowed).7.Page 24Select the OK pushbutton to accept the settings in the New Instruction dialogue.Note that the rung margin no longer shows a red mark down its side. There is noerror within the rung.Revision 2.0OMRONCHAPTER 2 – Quick Start Guide8.Give the instruction a comment by using the Properties box (place the cursor overthe instruction title and bring up the properties).
Enter the text ‘Red light on only’and press return.9.Place a New Contact at the start of the next rung. (Either like before, or by movingthe cursor to the start of the rung and using the Insert/Contact/Normally Openmenu command, or by pressing the shortcut key displayed for that menu command– usually ‘C’). The New Contact dialogue is displayed.10. Select ‘RedTimerDone’ from the Name or Address field and select the OKpushbutton.12. Place an instruction next to the Contact and display the New Instruction dialogue.(Either like before, or by using the Insert/Instruction menu command, or bypressing the shortcut key for that command – usually ‘I’). Enter the instruction‘TIM’ in the Instruction edit box. Enter the two operands ‘AmberLightTimer’ and‘TimeInterval’ in the Operands field.13.
Select the OK pushbutton to accept the settings in the New Instruction dialogue.14. Give the instruction a comment of ‘Red and amber lights on together’.15. Place a New Contact at the start of the next rung to display the New Contactdialogue.16. Select ‘AmberTimerDone’ from the Name or value field and select the OKpushbutton.17. Place an instruction next to the Contact and display the New Instruction dialogue.Enter the instruction ‘TIM’ and the two operands ‘GreenLightTimer’ and‘TimeInterval’ in the Operands field.18. Select the OK pushbutton to accept the settings in the New Instruction dialogue.19. Give the instruction the comment ‘Green light on only’.20.
Place a New Contact at the start of the next rung to display the New Contactdialogue.21. Select ‘GreenTimerDone’ from the Name or value field and select the OKpushbutton.22. Place an instruction next to the Contact and display the New Instruction dialogue.Enter the instruction ’TIM’ and the two operands ‘AmberOnlyTimer’ and‘TimeInterval’ in the Operands field.23. Select the OK pushbutton to accept the settings in the New Instruction dialogue.24.
Give the instruction a comment of ‘Amber light on only’.The Ladder Program should resemble that illustrated (depending upon the display options chosen).Revision 2.0Page 25CHAPTER 2 – Quick Start GuideOMRONUse the following procedure to place an output for each of the traffic lights into the program.1, 2, 3…Page 261.Ensure the Ladder program is displayed in the Diagram Workspace.2.Place a New Contact at the start of the next rung and assign it to symbol‘RedTimerDone’ (select the symbol name in the ‘Name or address’ list of the NewContact dialogue.3.Place a New Closed Contact to the right of the Red and Amber Timer and assignit to symbol ‘GreenTimerDone’.4.Place a Coil by selecting the New Coil button from the toolbar next to the GreenLight Timer. Select ‘RedLight’ from the Name and Address field and select theOK pushbutton.5.On the next rung below, place a contact to the left.
Assign it to use‘AmberTimerDone’.Revision 2.0OMRONCHAPTER 2 – Quick Start Guide6.To the right of the contact, place a closed contact, and assign it to‘GreenTimerDone’.7.To the right of the second contact, place a coil and assign it to ‘RedLight’.8.On the next rung, place a contact on the left, and assign it to ‘AmberTimerDone’.9.To the right of the contact, place a closed contact and assign it to‘GreenTimerDone’.10. To the right of the second contact, place a coil and assign it to ‘AmberLight’.11.
Press return when the selected cell is on the right of the rung. This will create a newline.12. Below the left ‘AmberTimerDone’ contact (but on the same rung), place a NewClosed Contact and assign it to the symbol ‘RedTimerDone’.13. Place a new Vertical by selecting the New Vertical button from the toolbarbetween the ‘GreenTimerDone’ Contact and the ‘AmberLight’ Coil. Connect thisto the ‘RedTimerDone’ by placing New Horizontal connections to join to theVertical by selecting the New Horizontal button from the toolbar.14. Place a New Contact at the start of the next rung and assign it to symbol‘GreenTimerDone’ via the New Contact dialogue.9.Place a Coil next to the contact and assign it to symbol ‘GreenLight’.10.
Place an Instruction on the next rung of type ‘END’ via the New Instructiondialogue.The output rungs of the Ladder program should resemble those shown below.Revision 2.0Page 27CHAPTER 2 – Quick Start GuideOMRONUse the following procedure to examine the ladder program.1, 2, 3…1.Ensure the Ladder program is displayed in the Diagram Workspace.2.Switch to symbol table by selecting the View Local Symbols button from thetoolbar.