Creating a PLC Program

  • Upload
    ddadara

  • View
    218

  • Download
    0

Embed Size (px)

Citation preview

  • 8/12/2019 Creating a PLC Program

    1/8

    Creating a PLC Program

    This is a simplified procedure for interface familiarisation purposes. For a PLC to function, you will

    normally create a program off line (locally on your computer) then go online and transfer it into the PLC's

    memory. Before you start this task, it is best to collect the following information:

    Determine the PLC/CPU device type and PLC memory settings required to run your program.

    Determine the type of communications connection to the PLC.

    Determine the input/output requirements for your program, and organise I/O units into racks attached to your PLC.

    PLC/Network Device Type Settings

    Select the Newoption in the Filemenu.

    A dialog box is displayed for selecting the PLC device type and connection settings. See the Change

    PLC helpfor details.

    The new project is created and the structure is shown in theproject workspace.

    Assigning I/O Points on the PLC's Racks and Units

    Select the I/O Tableof the new PLC on the project workspace.

    When a PLC is first switched on it will create a real I/O tablebased on the units which are actually

    plugged into its racks.

    You may need to create an I/O Table model on your computer which matches the registered and real IO

    table in the PLC.

    When you work online you may thentransferyour created I/O Table to the PLC's registered IO Table

    (not all PLCs allow this). The PLC stores the registered I/O Table separately from the real I/O Table, and

    will continually check that they match.

    You can compare your local I/O Table on your computer with the registered I/O Table in the selected

    PLC to check if there are differences.

    When an I/O assignment has been made, addresses which are within the I/O table show special prefixes

    on the ladder editor. An 'I' prefix shows that the address is mapped to an input unit. A 'Q' prefix showsthat the address is mapped to an output unit. The address' usage is also shown in thesymbol tables.

    Writing the Program

    If you are using the mouse, ensure that you have the Diagram and Viewstool barsdisplayed.

    The PLC is designed to respond to sensing (on or off) inputs to which the PLC is connected. These inputs

    are graphically represented in the ladder diagram as contacts, for example , allowing you place them in

    a logical sequence to control the output (a coil) from the PLC or to trigger a function such as a timer.

    Programs can be structured by using Function Blocks to handle repetitive tasks. Ladder or StructuredText can be used within Function Blocks. The main programming language (and language used to call the

    Function Blocks are Ladder or Structured Text).Seeladder programming

  • 8/12/2019 Creating a PLC Program

    2/8

  • 8/12/2019 Creating a PLC Program

    3/8

    It is necessary to insert arunginto the editor before elements (contacts, coils, or instructions) can be

    placed in it

    In some cases, it is not possible to show parts of a mnemonic program as a ladder rung. In these cases, a

    statement list box is used for the section, and other parts of the program appear as ladder. A block

    program is a special part of a program that cannot be shown in ladder form. The block program contains

    logical instructions that cannot be used in the normal ladder format.

    When on-line to a PLC and monitoring, it is possible to see power-flow executing. The parts of the

    diagram where power is present are shown with a thick line of the power-flow colour.

    CX-Programmer can show the mnemonic instructions that are produced from the ladder constructs. Themnemonics view displays these and updates the view whenever the ladder diagram is changed. It is also

    write a program in mnemonic instructions and observe the changes in the ladder view.

    Inserting Ladder Program Elements

    Creating a PLC Program

    Contact/Coil Dialogs

    Instruction Dialogs PLC Instructions

    Mnemonics View

    For details of how the Ladder Section Window has been affected by the introduction of the IEC61131-3

    support, refer to theEnhancements to Support IEC61131-3 Function Blockstopic.

    Entering a Contact/Coil (Ladder Section Window)

    The same dialog is used for entering both contacts and coils. It can however be displayed in two forms,

    either: simple dialog mode or detailed dialog mode. The default mode can be set in theTools | Optionsdialog.

    Note:The operand of a contact or coil is an address representing a bit - a BOOLdata type.

    Simple dialog mode

    An address or symbol name can be entered in this dialog. When Detail button is pressed, the dialog

    changes to Detailed dialog mode.

    If the Show with comment dialog option also ticked in theOptiondialog, then a comment dialog will

    appear after entering an address or symbol name.

    Inputting Symbols

    Input the symbol name and click the OKButton (or press the EnterKey). The New Symbol Dialog Box

    will be displayed.

  • 8/12/2019 Creating a PLC Program

    4/8

    Enter the address and comment, and then click the OKButton.

    The symbol can be registered in either the Global Symbol Table or Local Symbol Table. Select the check

    box to register the symbol in the Global Symbol Table.

    Detailed Dialog Mode

    When the Detail button is pressed, the contact/coil dialog expands to include a number of additional

    fields. Unchecking the Show in simple dialog mode box in theOptiondialog, will cause the contact/coil

    dialog to always be shown in the detailed mode.

    Name or address

    This list shows all defined symbols for the program and PLC.

    It is possible to just type an address in the operand list. If the address has been mapped to a symbol, the

    symbol is indicated in the symbol information area.

    As a name is typed, CX-Programmer attempts to complete the symbol name from those in the list. The

    details of the symbol are shown in the symbol information area of the dialog. A new symbol name can

    also be typed, if it is required to create a new symbol at the time of entering the contact/coil information.

    Also,symbols can be filteredby symbol names or comments inputted in the dialog.

  • 8/12/2019 Creating a PLC Program

    5/8

    Creating a Symbol: It is possible to create a symbol directly from within this dialog, by typing a new

    name (conforming to thesymbol naming convention) or address:

    When typing a new symbol name, an address and optional comment can also be entered. If the

    contact/coil was previously entered using an address, the address will be filled in. The address may be left

    blank, to specify that the address is to beautomatically allocated. The symbol will be created aslocal,unless the

    Global check box is set.

    A global symbol may belinked to a CX-Server file.

    If an address is entered instead of a name, only a comment may be entered in addition. This will create a

    global, unnamed symbol. If a comment is not entered, a symbol will not be created.

    Edit Symbol

    Press this button in order to edit an existing symbol - when pressed, the editing fields in the 'symbol

    information' part of the dialog are enabled. Note that it is only possible to edit a BOOLdata-type, non

    pre-defined symbolin this dialog.

    Thename, address and comment may be changed. Note that the scope of the symbol (local/global)

    cannot be changed. Alocal symbolmust have a name. Onlyglobal symbolscan belinked to a CX-Server

    file.

    When editing a symbol, the symbol information fields work in the same way as theInsert symboldialog.

    Symbol Information

    The name, address/value,data typeand comment of the chosen symbol is shown. The scope of the

    symbol is shown as eitherglobal or local.

    For CJ2H-CPU -EIP, whether the symbol is a network symbol is also shown.

    Differentiation

    It may be required for the contact to be differentiated, i.e. be active for one scan only.

    Select differentiate up, differentiate downor none.

    Note: This only applies to contacts - it is not available for coils.

    Immediate Refresh

    It may be required for the operand in an I/O unit to be read/written immediately upon execution of the

    contact/coil. Usually, the input or output is read/written to the input/output unit at the end of the execution

    cycle.

  • 8/12/2019 Creating a PLC Program

    6/8

    Instruction Dialog (Ladder Section Window)

    Instruction

    Instruction dialog is available in the ladder view to enter details of a PLC instruction. The dialog can be

    displayed in two forms, either: simple dialog modeor detailed dialog mode.The default mode can be

    set in theTools | Optionsdialog.

    Note:Some instructions are not available for use when programming in ladder language - they must be

    used directly in amnemonic list.

    Simple dialog mode

    Instruction and operand(s) can be entered in this dialog. When Detailbutton is pressed, the dialog

    changes to Detailed dialog mode.

    If the Show with comment dialogoption is also ticked in theOptiondialog, then a comment dialog (for

    each operands) will appear after entering an instruction and operand(s).

    Detailed dialog mode

    When the Detailbutton is pressed, the Instruction dialog expands to include a number of additional fields.

    Unchecking the Show in simple dialog modebox in the Options dialog, will cause the Instruction dialog

    to always be shown in the detailed mode.

    There are three ways to select an instruction:

  • 8/12/2019 Creating a PLC Program

    7/8

    1. Type its name into the Instruction edit box. CX-Programmer attempts to complete

    the function name as it is typed, and displays details of the required operands below

    the instruction edit box.

    2. Type the instruction number into the Instruction edit box. Use the correct number

    of digits for the PLC (some PLCs use 2 digits, the others use 3 digits). When an

    instruction number has been recognised, CX-Programmer fills in the instruction

    name and displays details of the required operands below the instruction edit box.

    3. Select an instruction from a list by selecting the Find Instructionbutton. When theFind Instructiondialog appears, select the instruction category in the left side of the

    displayed dialog then the required instruction in the category from the right side of

    the dialog.

    Note that it is possible to get full help on a particular instruction by typing its mnemonic into the

    Instructionfield, and pressing Instruction Help. If the instruction exists on more than one family of

    PLCs (i.e. C-series, CV-series, or CS/CJ-series), a choice of family will first be given.

    Note than certain instructions have dependencies between operands, so that the value of one operand will

    determine the valid range of another. For these instructions, it is possible to check whether the operands

    are valid by pressing the Checkbutton.

    Operands

    The number of operands available for selection will depend on the instruction selected.

    Instruction and operands should be divided with a space when entering in Simple dialog mode. To enter

    operand in detailed dialog mode, use the keyboard up/down cursor, or Tab keys to select the operand

    number to edit .

    The valid range for the selected operand is indicated below the operand box. This updates as informationis typed. Initially (when the information for the operand is empty), it shows the address ranges which are

    valid. When beginning to type the operand details, the information is updated to show the valid range for

    the address type chosen.

    It is possible to use asymbolfor the operand. The symbol name may be typed directly or the symbol can

    be selected using the find symbol dialog. To browse for a symbol, press F3 when entering the operand, or

    press the browse button to the right of the edit box.

    When a symbol name or comment is input in the operand box and the [Filter symbol] button is pressed,

    the[Filter Symbol] dialogis shown and the target symbol can be selected from the dialog to input it in the

    [Operand] box.

    Seeoperand typesfor an explanation of how to enter a correct operand.

    Symbol Information

    Whenever CX-Programmer finds asymbolassociated with the typed operand, symbol information is

    displayed in this box. The name, address/value and comment are shown, together with thedata typeof the

    symbol and its scope (global or local).

    Expansion Table

    You can use this table to define theexpansion instructions.

  • 8/12/2019 Creating a PLC Program

    8/8

    PLC Instruction Sets

    Every PLC has a set of special instructions which can be used for programming. Different types of PLC

    have different abilities and this is reflected in the instructions available. Some instructions are common

    across all PLCs.

    PLCs can be split into 3 families - the instruction sets for each are described below:

    C-Series PLC Instructions

    CV-Series PLC Instructions

    CS/CJ-Series PLC Instructions

    Mnemonic Editing

    Select the Mnemonicsoption from the View menu (or press Alt+Mkeys) to display the Mnemonics

    representation of the ladder diagram (note that asectionmust be selected for this menu option to be

    available). Use Alt+D to return to diagram view.

    The mnemonic editor behaves in a similar way to a text editor, except that you can be in 'block' or

    'editing' modes.

    When starting the mnemonic editor, it opens in block mode and whole line is shown selected at the cursor

    position. In this mode, it is possible to manipulate the lines of mnemonic using the copy / cut / paste and

    delete options. To select more than one line at a time, select the line at the top of the desired range of

    lines, hold down the shift key and click/move the cursor to the end of the range.

    It is possible to paste a mnemonic program into CX-Programmer from a text-editor - the text will be

    pasted in the position of the cursor.

    To enter 'edit' mode, press return. In this mode, a line of text is highlighted in the text highlight colour.

    The text may now be edited in a normal way. To add another line, press return. To exit 'edit' mode, press

    Esc.

    The mnemonic instructions available for each PLC type are described in thePLC Instruction Set

    references.

    Note: To synchronize the cursor in the mnemonic editor and the ladder editor, Synchronize ladder and mnemonic

    cursorsoption must be checked - seeDiagram Options.

    Note

    The Mnemonic Editor is not available in a CS/CJ-H and CJ1M PLC's project with Function Blocks being

    used.