ladder diagram question

Discussion in 'Homework Help' started by famguy, Jun 6, 2013.

  1. famguy

    Thread Starter New Member

    Jun 6, 2013
    3
    0
    i have a button and i want to program it in ladder diagram in such way that the first press will ON the light, and the second press will turn it off. (like the the tv power button)


    any help would appreciated.
    also if you have a good resource for learning ladder diagrams i would like to have your word

    thanks
     
  2. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    Here is one example.

    Google is your friend for a ladder logic tutorial.
     
  3. famguy

    Thread Starter New Member

    Jun 6, 2013
    3
    0
    i dont know what are these s and r
     
  4. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    S is for set (closes Y0).

    R is for reset (opens Y0).
     
  5. panic mode

    Senior Member

    Oct 10, 2011
    1,318
    304
    that code will not work, output will always be cleared. the idea is correct but needs intermediate flag as storage and input must be one-shot.

    there are many ways to do this and it is commonly used as test for rookies. many PLCs have built in instruction just for this. since you did not provide model of your plc, i can't help you with specific instruction but generic code will do just fine.

    following line gives you 16 individual toggles. they cannot be used at the same time though.

    here is a generic solution for SLC500 but because it so plain it will work on any plc as long as you substitute instructions:
    [NEQ B3:0 0]---[OSR B3:1/0]------[XOR B3:0 B3:10 B3:10]

    B3:0/0, B3:0/1 ... B3:0/15 are triggers
    B3:10/0 ... B3:10/15 are outputs
    B3:1/0 is used as one shot


    same things on Compact or ControLogix but for up to 32 toggles in one line
    [NEQ Trigger 0]---[ONSR osrFlag]------[XOR Trigger OutputFlags OutputFlags ]


    Mitsubishi has instruction for single bit (ALT or FF depending on processor family) but we can still do sledge hammer approach and get 16 toggles instead of just one:
    [<> k4M0 0]-----------[WXORP k4M0 k4M16 k4M16]

    etc.

    the point is, if you know how to manipulate bits, platform is not important.
    bulk toggles are handy when processing HMI buttons for example (keypads, toggle machine settings etc). if there is need to make the toggles work simultaneously, they need to be handled individually.

    attached image shows corrected version of earlier code sample.
    i used M0 as temporary storage to save old state of Y0.
    also note that X0 is oneshot. this is important to get single transition otherwise Y0 will keep on toggling every 10ms (or whatever your scan time is) as long as X0 is high. result is random state (either on or off) after you release button. using oneshot sorts this out....

    if you are using allen bradley PLC, then SET and RESET equivalnet instructions are OTL and OTU (latch and unlatch).
     
Loading...