Jump to content

Recommended Posts

Posted

HI all

I'm programming a project on a 1st gen V120 and wanted to confirm something about the relay outputs. I was attempting to write a program that could trigger a given relay output from more than one rung in the same module, but it appears that isn't allowed. For example, if a coil for output 1 is present in rung 1 and rung 2, then the coil for O1 in rung 1 is simply ignored. I can see some logic in not allowing this, but I found it strange that it doesn't trigger any error or warning if that was the intention. Could anyone confirm this for me? 

Posted
53 minutes ago, ZK0 said:

HI all

I'm programming a project on a 1st gen V120 and wanted to confirm something about the relay outputs. I was attempting to write a program that could trigger a given relay output from more than one rung in the same module, but it appears that isn't allowed. For example, if a coil for output 1 is present in rung 1 and rung 2, then the coil for O1 in rung 1 is simply ignored. I can see some logic in not allowing this, but I found it strange that it doesn't trigger any error or warning if that was the intention. Could anyone confirm this for me? 

As far as I remember on the other PLCs that I have used before that's how it works, the code will only respect one Coil.

also, why someone will do that on purpose?.

 

I guess you could technically do it on subroutines as long each sub has the logic conditions that doesn't allow both to be active at the same time.... but again, why?

  • MVP 2023
Posted
1 hour ago, ZK0 said:

For example, if a coil for output 1 is present in rung 1 and rung 2, then the coil for O1 in rung 1 is simply ignored.

This is basic to ladder logic and you need to recognize this in order to be proficient in this programming language. Understand that the coil is both activated (if off and power passes to the coil) AND deactivated (if on and power doesn't pass to the coil) by the logic in a ladder rung. If one rung turns it on and another turns it off, it can't exist in both states simultaneously. If two different logic conditions are needed activate a coil, then simply place them both in the same rung.

By the way, you can run Project Optimizer from the Build menu in VisiLogic and it will tell you all instances of duplicate coils.

Posted

I understand, thank you very much for your responses. The reasoning behind this was that I am trying to control a solenoid and two DC motors, with direction switching, using only the 6 relay outputs. Simplified to clarify, motor 1 may be controlled by outputs 0 and 1, then motor 2 may be controlled by outputs 1 and 2, so pressing one button would set Os 0 and 1 and another button would set Os 1 and 2. I have ended up just splitting the two functions into different sub routines, rather than controlling everything from one screen. 

Posted
45 minutes ago, ZK0 said:

I understand, thank you very much for your responses. The reasoning behind this was that I am trying to control a solenoid and two DC motors, with direction switching, using only the 6 relay outputs. Simplified to clarify, motor 1 may be controlled by outputs 0 and 1, then motor 2 may be controlled by outputs 1 and 2, so pressing one button would set Os 0 and 1 and another button would set Os 1 and 2. I have ended up just splitting the two functions into different sub routines, rather than controlling everything from one screen. 

Thats the use of set reset, and any way the other option is to use flags or auxiliar contacts to use one single output.... at the end ladder logic is like an rlectrical diagram, you just can not have duplicate coils, but you could have many contacts  that can set the same coil based on different conditions.

 

I don't want to be that guy, but the way you are trying to solve this problem is not correct. for now it may work, but if you keep doing your logic like this... its going to be a mess and hard to troubleshoot.

 

Trust me, I've been there ...when I was still learning. good practices and well structured code will save you a lot of time in the future.

 

  • MVP 2023
Posted

On top of what Fernando says, doing it the way you're suggesting can create issues with the potential to have conflicting instructions occurring during one scan, which can play havoc with physical devices.  If you are determined to continue along the path you've chosen, I would be placing a deliberate small time delay between each change of control, such that the "new" control does not do anything for a few scans at least, and likely longer would be better.

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.