Jump to content

Set and Reset coil based on a condition (noob ladder question)

Recommended Posts

I have a COIL and a PROBE.

When PROBE contact is raised (positive transitional) then energize COIL (this works):

  Probe     Coil 
---[P]---+--( )---
   Coil  |
---[ ]---+

Now, how do I do the following:

When PROBE contact is raised again (positive transitional) and COIL is already energized, then de-energize the COIL.


Any help would be greatful as I already spent half a day trying to solve this..

I'm using VisiLogic ladder. SM43-J-T20. 


Thank you!

Link to comment
Share on other sites


third option



            Probe            Coiltemp

-------[P]----------(. )



Coil               Coiltemp      Coil

----[./ ]------[    ]--------------(.    )


Coil               Coiltemp   |

---[     ]------[/ ] ---------|


Not so nicely. drawn but I think you understand


kind regards


Link to comment
Share on other sites

On ‎12‎/‎12‎/‎2016 at 11:09 AM, adambg said:


I finally found two solutions that seems to work.

1. Use toggle coil:

  Probe     Coil 

2. Use toggle logic:

      Probe     Coil     Coil
-------[P]---+---[ ]------(R)
             |  Coil     Coil

Thank you all!

Be careful using a conditional to set and reset the same coil on the same rung of logic.  When the program is compiled to down to code it may not compile how you think and can give weird logic bugs.  You can get conditions in the final code where the coil changes states between evaluations and you set and reset the coil on the same pass.


I highly recommend separating the logic out into multiple rungs.

Link to comment
Share on other sites

  • 2 weeks later...

Hi, the second design is definitely wrong. Even if you break it into two rungs, you will get this:

  1. If Probe is set and Coil is set, the Coil will be reset.
  2. In the next rung, the positive transition of Probe is still active and Coil is in reset state. So it will be set again; i.e. these two rungs will make the Coil set not regarding its initial state.

If you really like this design, you will need third bit variable, let's say Test. Test will be reset before the first rung, and it will be set in the case if Coil is reset. The setting rung should be called only if Test is still in reset state:


 Probe           Coil    Coil    Test
-[P]-------------| |-----(R)-----(S)

 Probe   Test    Coil    Coil

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.