+ All Categories
Home > Documents > Ladder Diagram

Ladder Diagram

Date post: 30-Sep-2015
Category:
Upload: anastasia-pesterean
View: 24 times
Download: 2 times
Share this document with a friend
Description:
an interesting book
Popular Tags:
45
1 PLCs Ladder diagram (LD) programming language
Transcript
  • 1

    PLCs

    Ladder diagram (LD)

    programming language

  • CPU

    Origins of Ladder Diagram

    The Ladder Diagram (LD) programming

    language originated from the graphical

    representation used to design an electrical

    control system

    Control decisions were made using relays

    After a while Relays were replaced by logic

    circuits

    Logic gates used to make control decisions

    Finally CPUs were added to take over the

    function of the logic circuits

    I/O Devices wired to buffer transistors

    Control decisions accomplished through

    programming

    OR AND

  • The origins of LD

    Ladder Diagram (LD) was developed from the graphical representation used

    for the electrical wiring diagrams

    LD language has been developed to

    facilitate the creation and maintenance

    of programs in an easy way

    LD uses computer graphic

    representation that are similar with

    electric diagrams which are easy to

    understand

    this reduces the costs of learning the

    language and technical support

  • What is a Rung?

    A rung of ladder diagram code can contain both input and

    output instructions

    Input instructions perform a comparison or test and set the rung

    state based on the outcome

    Normally left justified on the rung

    Output instructions examine the rung state and execute some

    operation or function

    In some cases output instructions can set the rung state

    Normally right justified on the rung

    Input Instruction Output Instruction

  • Series Vs Parallel Operations

    Ladder Diagram input instructions perform logical AND and OR

    operations in and easy to understand format

    If all Input Instructions in series must all be true for outputs to execute

    (AND)

    If any input instruction in parallel is true, the outputs will execute (OR)

    Paralleling outputs allows multiple operations to occur based on the

    same input criteria

    OR

    AND

    A

    B

    C D

    IF ((A OR B) AND (NOT C) AND D) THEN E=1; F=1 END_IF

    E

    F

    Branches

  • Writing program in LD

    Writing a program involves drawing a diagram (LD diagram) similar with electrical diagram.

    LD diagram components model the operation of electrical diagrams based on contact elements.

    Interpretation of operation is similar to the interpretation of electrical diagrams.

    The basic elements used for writing a program in LD language are: contacts,

    coils,

    timers,

    counters and

    functional blocks (functions).

  • Contacts

    Contacts are programming elements that

    model the electrical contacts of switching

    devices.

    As in the case of real contact, these can be

    normaly open NO- (a) or normaly closed NC (b).

    a) b)

    IN001 IN002 IN003

  • Contacts

    In a LD program, contacts may be associated with PLC inputs, PLC outputs or internal variables.

    At the input we can connect two state devices such as:

    auxiliary contacts of the contactor and relay,

    NC contacts or NO contacts of the control buttons,

    NC contacts or NO contacts of the limit switches,

    NC contacts or NO contacts of detectors of physical quantities,

    NC contacts or NO contacts of protection elements,

    digital outputs of measuring, protection or control devices,

    digital outputs of PLC of other control systems etc.

  • Contacts

    In addition to regular contacts, some manufacturers

    make available to programmers other programming

    elements corresponding to PLC inputs encountered,

    especially in digital circuits, such as:

    latched inputs

    inputs active on the the rising edge

    inputs active on the falling edge.

  • Coils

    The coils are programming elements that model the

    operation of the coils of contactors and

    electromagnetic relays.

    As with real coils, the coils of LD programs can have

    two states: powered or unpowered.

    Coils can be associated with PLC outputs and

    internal variables modeling auxiliary contacts of

    relays.

    a) b)

    OUT 001 OUT 002 OUT 003

  • Coils

    Each output is uniquely identified, in a different way from one manufacturer to another.

    Each output is associated with a single coil and one or more contacts that can be used similarly to auxiliary contacts of contactors and relays.

    At these outputs can be connected devices that have two operation states such as:

    coils of contactors or relays,

    signaling and light elements,

    small power loads,

    digital inputs of some meters, protection and control devices,

    digital inputs of other PLCs or control systems etc.

  • Timers

    Timers are programming elements that model the operation of timer relays and timer contacts.

    They are used to perform actions delayed or lasting a certain interval of time.

    TON IN

    T#200ms

    Pump_Tmr

    PT ET 178

    Q

  • Timers

    PLC manufacturers provide both basic and complex timing functions.

    Timers used in LD programs have more flexibility and functionality than individual timers.

    Simple timers allow an action to be delayed by a certain time that can be programmed.

    Complex timers can offer a variable timing based on certain conditions occurring at a time.

  • Timers

    Each timer in the diagram is uniquely identified, this identification being different from one manufacturer to another.

    If the time base is the same for all the timers, specified in the PLC programming manual, the time based is omitted.

    The default value can be expressed in units of time (s).

    Timers have at least one initialization input, its activation starts timing, and an output.

    In some implementations, the timers have a an enable input and one output which is the negated of the first output.

  • Counters

    Counters are programming elements that can receive a series of pulses that are analyzed in the LD program to detect the number of occurrences of events such as:

    number of steps performed by a stepper motor,

    number of connection-disconnection of an appliance.

    number of bottles that have been filled in a filling station, etc.

    CTU

    200

    Load_Cnt

    PV CV 178

    Q

    IN ENO

    Load_Cnt_DN R

  • Counters

    The number of events can be compared to certain default values and the outcome of these comparisons can result in certain appropriate given decisions and orders.

    There are several types of counters among the most common being:

    unidirectional counters up counter

    down counter

    bidirectional counters which can count up and down.

    Each counter in the diagram is uniquely identified, how is this done differes from one manufacturer to another.

  • Counters

    For each counter one must specifies the default value, this being the maximum number counted by the counter before the ouput is activated.

    The counter has at least two inputs, one for counting and one for the initialization (following the initialization, the counter starts to count incoming pulses to the counting input) and an output.

    Other options can also be provided such as a count enable input and output which is the negated of the first output.

  • Functional blocks

    For materialization of complex functions needed to

    facilitate writing programs in LD language functional

    blocks (FB) are used.

    FBs model various categories of the most used

    functions such as:

    Load functions of numerical constants,

    arithmetic functions,

    logic functions of 8 or 16 bits,

    conversion functions of the various formats of information

    (binary, BCD, Gray, etc.),

    interrupt handling functions

  • Function blocks

    edge detecting,

    functions implementing complex controllers and

    sequencers,

    functions handling high-speed counters.

    The design and operation of function blocks differ

    from a PLC to another and is specific to each

    manufacturer if not compying to IEC 61131 standard.

  • Restrictions in writing LD programs

    When writing a LD program for a specific

    PLC one must take into account the

    limitations of the software package which

    comes with the PLC:

    limitations regarding the size of LD diagram

    limitations on LD diagram execution

  • Limitations concerning the size of LD diagram

    Limitations related to:

    intrinsic properties of language;

    Specific implementations of various commercial

    software packages

    Are due to technical solutions adopted by

    producers to implement various elements of

    the language.

  • Limitations concerning the size of LD diagram

    Some of these limitations are as follows:

    a coil must always be fed through a contact;

    coil must always be introduced at the right end of a rung;

    all contacts have to be in the horizontal direction;

    number of contacts on a rung is limited by the software;

  • Limitations concerning the size of LD diagram

    a contact group can feed a single coil;

    the achievement of loops can be carried out in one way or

    may not be permitted;

    the direction of flow through the circuit is from left to the

    right of the diagram.

    Usually the PLC programming manuals contain all

    information necessary for the user to write the

    program in the format accepted by the PLC.

  • Limitations on how the program is executed

    PLC operation is based on the repeated execution of the program that it stores into memory. Each cycle of execution of the program includes three separate stages:

    read entries

    execution of program instructions

    updating outputs

    The duration of such a cycle depends on the speed of the processor that comes with PLC and the length of the user program.

  • Limitations on how the program is executed

    Reading of input stage: inputs states are and stored in memory in the input table.

    Execution of program instructions stage: input values are used for instruction execution, the result of which is wirtten in the output table.

    Updating the output stage: information from the output table is used to activate/deactivate PLC outputs.

    The three steps mentioned above are executed separately. PLC input changes during second stage have no effect on input values used for the instruction execution. They will be used only after they have will be read in the input read stage of the next execution cycle.

  • Limitations on how the program is executed

    If the second stage, after the execution of one or more instructions the value of an ouput is modified, this change will not actually appear in the corresponding output terminal, but only on the third stage when the outputs are updated based on the output table.

    In writing an LD program one should consider also the way the PLC executes the written program.

  • Interpretation of LD diagrams

    There are two ways of interpreting LD

    diagram:

    line evaluation - contacts are read along the line,

    from left to right, line by line, from the first line and

    ending with the last;

    column evaluation - read contacts in column one,

    from top to bottom, column by column from the

    first column on the left and ending with the last on

    the right.

  • Interpretation of LD diagrams

    In both cases one must consider the difference from the operation of electric diagrams:

    Relays: A change in the status of a contact in the power supply circuit of the coil of a contactor can lead to immediate change of its state whether or not there are other elements connected in series or parallel with the contact.

    LD Program: Coil state will not be changed until it will be read the status of all elements by which it is fed.

    Due to the high speed of execution of the processor, this does not generally pose a problem. It should be considered in cases of critical applications where it might appear a different operation from the desired one.

  • Interpretation LD diagram - Reading on line

  • Interpretation LD diagram - Reading column

  • LD languagein IEC 61131-3

    By introducing this language in IEC 61131-3

    it was aimed to standardize a whole set of

    languages that were declared to be of Ladder Diagram type.

  • Program execution

    Ladder rungs are

    evaluated from left to

    right and from top to

    bottom

    Branches within a line

    are evaluated from top

    left to bottom right

    P S

    R

    The

    B

    D E

    F G H

    I J K

    Phase

    Branch

    Null

    Line program

  • Non Retentive Coils

    The referenced bit is reset when processor power is cycled

    Coil -( )-

    Sets a bit when the rung is true(1) and resets the bit when the rung is false (0)

    PLC5 calls this an OTE Output Enable

    Negative coil -( / )-

    Sets a bit when the rung is false(0) and resets the bit when the rung is True(1)

    Not commonly supported because of potential for confusion

    Set (Latch) coil -(S)-

    Sets a bit (1) when the rung is true and does nothing when the rung is false

    Reset (Unlatch) Coil -(R)-

    Resets a bit (0) when the rung is true and does nothing when the rung is false

  • Contacts

    Normally Open Contact -| |-

    Enables the rung to the right of the instruction if the rung to the left

    is enabled and underlining bit is set (1)

    Normally Closed Contact -|/|-

    Enables the rung to the right of the instruction if the rung to the left

    is enabled and underlining bit is reset (0)

    Positive transition contact -|P|-

    Enables the right side of the rung for one scan when the rung on

    left side of the instruction is true

    Negative transition contact -|N|-

    Enables the right side of the rung for one scan when the rung on

    left side of the instruction is false

  • Retentive Vs Non-retentive Operation

    Definitions

    Retentive values or instructions maintain their last state

    during a power cycle

    Non-retentive values or instructions are reset to some

    default state (usually 0) after a power cycle

    IEC1131 permits values to be defined as retentive

    A contradiction to this is ladder diagram where 3

    instructions are classified as retentive

    In most PLCs only timer and coil instructions operate as

    non-retentive

  • Retentive Coils

    The referenced bit is unchanged when processor

    power is cycled

    Retentive coil -(M)-

    Sets a bit when the rung is true(1) and resets the bit when the

    rung is false (0)

    Set Retentive (Latch) coil -(SM)-

    Sets a bit (1) when the rung is true and does nothing when the

    rung is false

    Reset Retentive (Unlatch) Coil -(RM)-

    Resets a bit (0) when the rung is true and does nothing when

    the rung is false

  • Transition Sensing Coils

    Positive transition-sensing coil -(P)-

    Sets the bit bit (1) when rung to the left of the

    instruction transitions from off(0) to on(1)

    The bit is left in this state

    Negative transition-sensing coil -(N)-

    Resets the bit (0) when rung to the left of the

    instruction transitions from on(1) to off(0)

    The bit is left in this state

  • Timers in Ladder Diagram

    There three timer instructions in

    IEC1131

    TP - Pulse timer

    TON - Timer On Delay

    TOF - Timer Off Delay

    Time values

    Time base is 1msec (1/1000 of a sec)

    Values entered using duration literal

    format

    Two possible visualizations Depending

    on use of EN/ENO

    1st method requires extra programming

    if timer done status needs to be

    referenced on other rungs

    2nd method sets a bit with Q which can

    be referenced by other logic, ENO=EN

    TON IN

    T#200ms

    Pump_Tmr

    PT ET 178

    Q

    TON

    T#200ms

    Pump_Tmr

    PT ET 178

    Q

    IN ENO

    Pump_Tmr_DN

  • Timer Operation IN

    Q

    ET PT

    |

    0

    Pulse (TP) Timing

    IN

    Q

    ET PT

    |

    0

    On-Delay (TON) Timing

    IN

    Q

    ET PT

    |

    0

    Off-Delay (TOF) Timing

    IN = Rung input condition

    Q = Comparison output

    results

    Varies with timer types

    PT = Preset Time

    ET = Elapse Time

  • Counters in Ladder Diagram

    There three counter instructions in

    IEC1131

    CTU - Count Up Counter

    CTD - Count Down Counter

    CTUD - Count Up/Down Counter

    All three count rung transitions

    Two possible visualizations

    Depending on use of EN/ENO

    1st method requires extra

    programming if timer done status

    needs to be referenced on other

    rungs

    2nd method sets a bit with Q which

    can be referenced by other logic,

    ENO=EN

    CTU

    200

    Load_Cnt

    PV CV 178

    Q

    IN ENO

    Load_Cnt_DN R

    CTU

    200

    Load_Cnt

    PV CV 178

    Q IN

    R

  • Counter Operation Parameters

    CU/CD = Count up/Down

    Q/QU/QD = Comparison Output

    R = Reset to Zero

    LD = Load CV with PV

    PV = Preset Value

    CV = Count Value

    ...

    ...

    CV PV

    |

    0

    CU

    QU

    CD

    QD

    LD

    R

    Count Up/Down (CTUD) Counter

    ... IN

    Q

    CV PV

    |

    0

    LD

    ... Count Down (CTD) Counter

    ... IN

    Q

    CV PV

    |

    0

    R

    Count Up (CTU) Counter

    ...

  • CAL

    RET RET

    CAL

    Execution Control Elements

    Jump / Label Instructions

    Jump to a label skips a block of

    code without it being scanned

    LBL - Named target for a jump

    operation

    JMP - Performs a jump when

    the rung conditions are true

    CALL / RETURN Instructions

    Used to encapsulate logic and call

    it as a subroutine

    Causes execution to change

    between functions or subroutines

    CAL - Passes control to another

    named function

    PLC5 uses JSR

    RET - Exits a function and returns

    control back to the calling routine

    | Skip_Calc | |-| |-------------(JMP)--| | ... | | Skip_Calc | |---[LBL]---...

  • The look and feel of IEC 1131-3 is somewhat different from the

    1Million+ PLCs that Allen Bradley has running in factories throughout the world

    IEC places the input parameters on the outside of the instruction block

    vs the PLC5 where they are presented inside of the block

    TON

    Timer

    Preset

    Pump_Tmr

    200.000

    Accum 178.251

    (EN)

    (DN)

    ADD

    Source A

    Source B

    Tank1_In

    Offsetr

    Destination Tank_Level

    178.251

    78.251

    100.000

    + EN

    100.000 178.251

    ENO

    78.251 Offsetr

    Tank1_In Tank_Level

    Different Instruction Presentations

    TON

    T#200ms

    Pump_Tmr

    PT ET 178

    Q

    IN ENO

    Pump_Tmr_DN

  • Extending the IEC1131-3 Instruction Set

    IEC1131-3 Provides a very basic set of instructions to do simple operations (81 Ladder Diagram Instructions)

    Data Type Conversion - Trunc, Int_to_Sint, Dint_to_Real, Bcd_To_Int

    Boolean Operations - Bit Test, Bit Set, One Shot, Semaphores

    Timers / Counters - Ton, Tp, Ctu, Ctd, Ctud

    Simple Math - Add, Sub, Mul, Div, Mod, Move, Expt

    Misc. Math - Abs, Sqrt, Ln, Log, Exp, Sin, Cos, Tan, Asin, Acos, Atan

    Bit Shift - Shl, Shr, Ror, Rol

    Logic - And, Or, Xor, Not

    Selection - Sel, Max, Min, Limit, Mux

    Compare - GT, GE, EQ, LE, LT, NE

    String - Len, Left, Right, Mid, Concat, Insert, Delete, Replace, Find

    Control - JMP, LBL, JSR, RET

    All complex operations are left to the user or vendor to define

    File Operations, PID, Diagnostic, For/Nxt Loop, Search, Sort are not in IEC1131-3

    Extensions to the instruction set are permitted so that vendors can add instructions that their customers need

    All vendors have defined their own set of extensions

  • Bibliography

    Ron Bliss, Introduction to IEC1131-3 Ladder

    Diagram, Allen-Bradley

    SR EN 61131-3, PLC. Part 3. Programming

    Languages

    CGHaba, Sisteme de comanda a masinilor

    electrice, Ed. Gh.Asachi, Iai


Recommended