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

Hello

third option

 

nw1

            Probe            Coiltemp

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

 

nw2

Coil               Coiltemp      Coil

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

                                                |

Coil               Coiltemp   |

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

 

Not so nicely. drawn but I think you understand

 

kind regards

Henny

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 
---[P]------(X)

2. Use toggle logic:


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

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:

 Test
-(R)

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

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...