Jump to content

Recommended Posts

Hi all,

I'm working on a project, where we use Vision V570 and V200-E1B. I wrote some codes in order to automize the switching of 3 tanks regarding their level. I wrote something like below. Here is the logic;

When operator resets the situation of the tank, tank status turns to full, when tanks pressure goes below a certain level, its status goes to "empty" and PLC switches to the other full tanks. The problem is, if I reset first tank's status when second or third tank is working, it switches directly to the first tank, before waiting that active tank to be empty. So this causes some tanks stays unused.

How can we fix this? PLC should wait the active tank to be empty and after that it should switch to the other one.

 

Thanks in advance for your help.

aaaa.png

Link to comment
Share on other sites

  • MVP 2023

It would help to see the rest of your code, but clearly as soon as MB 3 turns off, O 2 will turn on. You will need logic that is a bit more complex to handle your objective. I would set up something akin to a State Machine where you have bits that are Set and Reset according to which tank is the active tank with logic that switches them according to your needs.

Additional comments:

1) You should use a Positive Transition of MB 1 to Reset MB 10, MB 11, & MB 12 and place that in a separate rung from the rest of the O 2 coil logic.

2) Do NOT place separate logic threads in the same ladder rung. The thread with SB 1 - MB 16 - TD 2 should be in a separate rung (and you do not need SB 1 there).

3) You do not need the inverted contact of MB 1 after MB 10 - they are already mutually exclusive.

4) Need more details of how you switch between Automatic and Manual modes. As shown above, it is impossible for logic to switch out of automatic mode (see #1 above).

Link to comment
Share on other sites

19 minutes ago, Flex727 said:

It would help to see the rest of your code, but clearly as soon as MB 3 turns off, O 2 will turn on. You will need logic that is a bit more complex to handle your objective. I would set up something akin to a State Machine where you have bits that are Set and Reset according to which tank is the active tank with logic that switches them according to your needs.

Additional comments:

1) You should use a Positive Transition of MB 1 to Reset MB 10, MB 11, & MB 12 and place that in a separate rung from the rest of the O 2 coil logic.

2) Do NOT place separate logic threads in the same ladder rung. The thread with SB 1 - MB 16 - TD 2 should be in a separate rung (and you do not need SB 1 there).

3) You do not need the inverted contact of MB 1 after MB 10 - they are already mutually exclusive.

4) Need more details of how you switch between Automatic and Manual modes. As shown above, it is impossible for logic to switch out of automatic mode (see #1 above).

Hi Flex727,

Please see my answers below.

1) I want anybody to use ManualMode when AutomaticMode is active. If I use a positive transition, somebody can open Manual Mode when Automatic Mode is active.

2) That thread is a part of another logic, I didn't see a problem on placing it in a ladder, but if you say that will cause issues, I can move it to another ladder.

3) This is the same as #1. These inverted contacts restricts switching between automatic/manual mode.

4) If Automatic Mode is active, you cannot use Manual mode.

 

There are also some other threads in different ladders for the other 2 tanks.

 

111.png

112.png

Link to comment
Share on other sites

  • 2 weeks later...
2 hours ago, Joe Tauser said:

You've built a bit-banger to make a conditional sequencer.  There is a better way.

It's also much clearer to put the outputs in their own subroutine and handle automatic and manual control separately.

Can you post your actual PLC program?  I could hack on it for you.

Joe T.

Hi Joe,

 

I have uploaded the file to "WeTransfer" folder. Please find it attached.

 

https://we.tl/dspvOgEbT0

 

Thanks in advance.

Link to comment
Share on other sites

  • MVP 2023

First of all, only put one logical operation per network.  When you put several separate rungs in one network, it may not compile the way you think it will.  Creating a new network guarantees separation of operations.

It is also very helpful in troubleshooting to keep your functionality together.  For example, the timers controlling the fan were spread across several networks.  I grouped them together and wrote simpler timer pair logic in the Outputs subroutine.

Timers reset themselves when power is removed.  You don't need separate logic to reset them.

I put together a state machine that steps through the tanks in order in automatic mode.  I also moved the scaling and the alarms to their own subroutine.

You'll notice that the Main routine is now very small.  I put all the functions of the system into their own subroutine.  I hate the phrase "best practices", but this way really does make it easier to understand what's going on.

Let me know if it works the way you want it to.  "Likes" are always appreciated.

Joe T. 

 

 

Edited by Joe Tauser
File deleted by request
  • Like 1
  • Upvote 1
Link to comment
Share on other sites

3 hours ago, Joe Tauser said:

First of all, only put one logical operation per network.  When you put several separate rungs in one network, it may not compile the way you think it will.  Creating a new network guarantees separation of operations.

It is also very helpful in troubleshooting to keep your functionality together.  For example, the timers controlling the fan were spread across several networks.  I grouped them together and wrote simpler timer pair logic in the Outputs subroutine.

Timers reset themselves when power is removed.  You don't need separate logic to reset them.

I put together a state machine that steps through the tanks in order in automatic mode.  I also moved the scaling and the alarms to their own subroutine.

You'll notice that the Main routine is now very small.  I put all the functions of the system into their own subroutine.  I hate the phrase "best practices", but this way really does make it easier to understand what's going on.

Let me know if it works the way you want it to.  "Likes" are always appreciated.

Joe T. 

Hi Joe,

Thanks for your effort. However, when I turn on Automatic Mode, it opens all outputs. Tanks empty/full situations are not applicable.

 

Thanks for your effort. However,  

Link to comment
Share on other sites

  • MVP 2023

There is no way all the outputs could come on in Automatic mode unless all the tanks are low, in which case it will continually cycle through them.  I did not put in a pause state as this program was written to show another way of doing things.  I didn't have a system to test it on, so it's most probable that something was overlooked.  My code almost always has a mistake the first time I load it.

Did you troubleshoot what I did?

Joe T.

Link to comment
Share on other sites

I will load Joe's program into a V430,  use online mode to force AI memory integer values,  and then actually live test it on the OPLC.  I'm not real good at evaluating program flow by looking at the ladder screens. Live test may reveal something. Will post results late tonight. What  language is HMI screens in? 

If scan goes from left to right within a rung, I am getting impression all three outputs could end up on in auto mode when all three tanks are below critcal setpoint (which Joe stated, cyclically). Will find out when running live on V430. 

  • Upvote 1
Link to comment
Share on other sites

UPDATE: downloaded (converted) N Switcher program into a V430 i had in the shop. hardware AI's were paired to arbritrary MI's, forced MI 1,2,3,4 with D#4000, switched to AUTO mode and observed (in online mode) all three outputs on.  left to tend to another matter and came back, decided to pull power supply and move setup into my living room. didn't observe HMI prior to removing power. plugged back in and HMI flickered white and then black. online mode worked. downloaded original program back in, No HMI. :( boot screens with black and red backgrounds show up fine. new download status lines listed something about "HMI display on PLC does not exist on Current Project".  trying system upgrade now. all black and red boot screens display fine on hmi. HMI Has worked fine from day out of the box until I unplugged AC supply (which is no big deal). happens when power fails or troubleshooting.  OS update finished, still black HMI with no backlighting. Oh boy. Trying a download and burn now. weird. 10 sec screen press brings HMI to life (info mode). Commanded INIT from info mode and HMI came back in regular program. WHAT A WILD RIDE!

  • Upvote 1
Link to comment
Share on other sites

@thecarb

Possible solution found. Try the mildly edited code attached. I duplicated your issue (not sure if you were testing with sensors live and connected, I was not). Here's what I believed caused the "all outputs on condition" I observed on a fresh run of JoeT's program: Powered up, MI2,3,4 at ZERO. Scaling SR runs before values can be forced into MI's (pre scaled values) and thus SETS MB3,4,5 putting outputs into cyclical ON states. I put a vector load on power up that loads D#4000 into MI3,4,5 then I hold off ScalingandAlarm subroutine with an on delay timer for 10 seconds. This allows time for pressure transducers (if powered on at same time of PLC) to initialize and output current. Perhaps OPLC was grabbing zero values on transducers at system power up and MB3,4,5 are latching then must be USER reset. All happens before you can wink. Could be filtering on AI's or speed of successive approximation capture. Don't know those specs of the top off my head.  Good luck Carb. -dB\

*FILE REMOVED*

 

  • Upvote 1
Link to comment
Share on other sites

  • MVP 2023

Thanks for loading and checking it on a live system, Dustin.  Your settling timer on the scaling routine is a good solution.

15 hours ago, Joe Tauser said:

I did not put in a pause state

This would have also helped to indicate to the operator that the real problem was ALL the tanks were empty.

The point of my code was to demonstrate a method.  

Joe T.

 

 

  • Upvote 1
Link to comment
Share on other sites

Thank you very much for your help, Joe Tauser  and your great effort "hotwires".

It works great in "Automatic Mode", except when all the tanks are empty. If they all are empty, it opens all tank outputs but they should be closed at that situation. I tried to add an inverted contact but didn't help. I'm trying to find a solution for it.

Link to comment
Share on other sites

This depends, IF for any reason the PLC resets (power failure and program downloads that require reset) will it have current (4 to 20mA) at the analog inputs on the first program scan, at least one channel above the critical low set points? The purpose of the vector fill is to load imaginary raw tank pressure values (THIS HAPPENS ONLY ON THE FIRST SCAN because of SB2 contact) that will prevent all three tanks from latching into low pressure lockout states (user must reset). You won't get real pressure data into the PLC until the timer ahead of "scalingandalarm" subroutine call has expired and it's contact goes TRUE. You could put an SB0 contact ahead of vector fill and and SB1 contact branched around (logical OR) TD8's contact. Then you can load program and observe behavior. IF you are getting all outputs on due to ALL TANKS critical low pressure THEN you can take out SB0 ahead of vector fill and remove SB1 around TD8 contact and adjust TD8's time value low enough to let your transducers stabilize at power up. I would also recommend a physical Emergency Stop mushroom head NC switch coupled to PLC input that would UNCONDITIONALLY CLOSE all valves IF activated by user. You could construct logic that would sample (delta) differential in system pressure over (defined) segments of time to detect a massive leak or open in the gas piping THEN trigger an ALL STOP on valves. I haven't done much change of value versus change in time logic, but the potential is there! A very sudden drop in tank or system pressure (downstream) could be interpreted as a rupture or massive leak. Obviously your tank pressure transducers are on the tank side of the solenoid valves.  

My best advice is to always LIVE TEST every possible (and even impossible) scenarios of Input conditions the PLC could encounter and take note of the results. I try to use as many logical FAILSAFE's in the code as possible. Then address falsing issues and adjust or remove as the live machine testing goes forward.

I don't really have time to sit down and construct logic from scratch to show you how I would have coded your application. Joe T's index/pointer example is a great approach. I probably would have used several compare FB's and S/R bits, a bit banger as Joe put it.

The community here is always happy to help others help themselves. Happy coding. You've chosen the right hardware, software, and support network for your project. Very happy with the price, performance, and support that I have always received from Unitronics.

 

  • Upvote 1
Link to comment
Share on other sites

IF the inverted contacts you added to valve control outputs handles the outputs logic in all possible conditions THEN it would be redundant to also keep vector fill and on delay for "scalingandalarms" subroutine ladder call. That was a solution for testing with no live inputs, just force loaded bits/registers via online mode. 

I try to think of things sequentially as they happen in the first scan and then in all subsequent scans. It could be that all outputs energize for a single scan then inverted contacts set them off in all subsequent scans (until pressure restored and user resets). This could all happen so fast that your solenoid valves never make a complete physical opening. 

Sounds like you have everything doing what you want it to, just be sure it happens in the sequence(s) you want. 

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...