Jump to content

Recommended Posts

Hello every one, I'm programming on Visilogic and when I build my project i have 1 warning on all my Nets : "Whenever the application uses a block delay or a loop - it may cause the PLC watchdog" and i don't know how to resolve it.

Hope you can help me.

Thanks, Baptiste.

programme_automate_grenailleuse_V3.vlp

Share this post


Link to post
Share on other sites

Ladder logic is not like other programming languages you may be familiar with. You rarely need to use "GoTo" loops. In over 10 years of ladder programming, I've never used that command once. Just write your logic working left to right and top to bottom. Use subroutines, as needed, to break your logic up into manageable pieces. Remember that PLCs are already looping continuously and there is a watchdog timer that is looking for the entire PLC scan to complete within a short period of time. Looping within the scan risks triggering the watchdog.

I don't have time right now to go over your program in detail, but a few items were immediately clear:

 - Never call an HMI on every PLC scan. HMI calls need to be gated by a transition contact (i.e. only called once).

- Never place more than one line of code in a single ladder rung.

- Placing timer coils and contacts in the same rung, in the way that you're doing, may not work the way you expect.

- Conditional calls of subroutines can be dangerous and I recommend avoiding them whenever possible. In your case the subroutines are mostly Reset coils, so the danger is alleviated, but it leads me to believe you're not understanding the purpose of Set and Reset coils and the difference between them and Direct coils.

- I find that code in the same rung following an HMI call sometimes does not get executed. It's good practice to separate HMI calls from the other logic. Don't try to stuff too much logic into a single rung - there's no need to conserve ladder rungs.

Here's an example of many of the above problems in a single rung:

image.png.69aa4c94e34545e9d70c02317821ff75.png

Frankly, I have no idea how this will execute (without pulling up the STL), but I'm certain it will NOT do what you're expecting it to. Break your logic up into the smallest possible pieces and place the pieces into separate rungs.

You're welcome to ask additional questions. Best of luck to you.

Share this post


Link to post
Share on other sites

Thank you. As you can see I'm a beginner and i have a lot of things to learn.  I will test what you say tomorrow.

Share this post


Link to post
Share on other sites

We were all beginners once. Unitronics has some excellent YouTube videos for training that can help you along more quickly. Also, take a look at some of the example projects that came with your VisiLogic installation to see some recommended logical formulations.

Share this post


Link to post
Share on other sites

If i don't need to use "GoTo" jumps, how can i do the return  when "niveau bas = 0" at the step 6 and the jump if "niveau haut = 1" at the step 4 ?

I give you my main Grafcet to see what i mean.  

grafcet_principal.PNG

Share this post


Link to post
Share on other sites

In fact, the sandblasting=("Fonctionnement sablage 1 et 2") need to continue while the level of sand isn't below the "low level" or if the stop press button isn't pressed.

If the level of sand is below the "low level" you need to return at the  filling step=("remplissage") and after, continue the sandblasting.

But at the beginning, if there is enough sand you need to jumps the filling step.

If the stop press button is pressed, you need to go at the next step ("Arrêt installation").

And that's what I don't know how to do without "GoTo" jumps. So if you know, that will help me a lot !

 

ps : Sorry I'm french so my grafcet is in french but i hope that you can understand with my description above.

 

programme_automate_grenailleuse_V5.vlp

Share this post


Link to post
Share on other sites

It's impossible to do this properly without knowing the details of what your hardware is (Normally Open, Normally Closed, Momentary contact, etc). There are many ways to approach the logic, but here is generally the way I would handle something like this:

image.png.46065aaeb80d101cd4e09bca2465b60a.png

"Machine Ready" is the summation of any checks you might need to do before the machine is ready to operate. "Start" assumes a N.O. momentary contact switch. "Stop" assumes a N.O. momentary contact switch (they are usually N.C., but I used N.O. here for simplicity). "Low Level Sensor" assumes a N.O. sensor to detect the level is low and may or may not be latched in some way. "Done Filling Sensor" is whatever means you have of detecting when to stop filling.

What happens with this logic is the following:
1) Start button is pressed to start sandblasting.

2) Sandblasting will proceed as long as sand level is not low.

3) If sand level goes low, begin filling while sandblasting is paused.

4) When sand level is full, resume sandblasting.

5) Stop button or alarm stops the sandblasting operation.

This is just the basic logic that would need to be fleshed out extensively with other operational details.

No jumps or GoTos required. The issue here is that you have to wrap your mind around PLC Ladder Logic. It's fundamentally different from regular computer programming and the techniques can be a bit difficult to grasp until you get into the right mindset.

I usually work my way backward from Outputs to Inputs. I examine each Output and determine ALL of the conditions that would turn on the Output, then code that for each one. For instance, with your Sandblasting Output (O 0 above), it will be on when the start button is pressed, but the fill level is okay and there are no alarms and the stop button hasn't been pressed. Just code that and you don't have to worry about other stuff in the program. Usually, you don't even need to worry about order of events, but here rung 2 follows rung 1 purposely to prevent MB 1 from being ON at any point when there is an alarm present (it might get turned on in rung 1, but it will turn back off in rung 2, thus never activating O 0).

Share this post


Link to post
Share on other sites

Ok thanks and by the way, do you know if a free simulator exist for the V130 of Unitronics because I do not have the automaton yet and i would like to test my program ?

Share this post


Link to post
Share on other sites

And I have to do 3 grafcets of security : 

1 = the emergency stop : stop all the program, power on the "emergency stop" led and initialize the program at the beginning.

2 = the presence defect : if there is a failing in the engines = stop all the program, power on the "presence defect" led and initialize the program at the beginning.

3 = open door :  stop the sandblasting, power on the "open door" led, if all the doors are closed = initialize just the sandblasting and power off the led.

 

All of these grafcets need to execute all the time and at the same time of the rest of the main grafcet.

For the moment they are just at the end of my program like this : 

image.png.2613fe105cf4a751074979393ab7f80a.png

i just wait to find a solution to put them correctly.

 

Gestion AU = the emergency stop

Gestion défaut =  the presence defect

Gestion Porte Ouverte = open door

The "marche installation" jump return to the initialization part and the "Fonc. sablage" jump return to the sandblasting part.

Share this post


Link to post
Share on other sites

I found the SB300 that can reset the plc so it works for 2 of my security grafcet and i can delete the jumps but do you know a bit or a function to reset just 1 subroutine ?

If i can reset or initialize just the sandblasting subroutine, that will be perfect.

Share this post


Link to post
Share on other sites

Correctly set up emergency stops should not just stop the plc, they should stop all machine operations through actual voltage cutoffs to everything that makes the machine dangerous.

cheers,

Aus

Share this post


Link to post
Share on other sites

I've written hundreds of programs for chemical systems that use dangerous chemicals. There are many safety systems in place including, as Ausman says above, cutting power to all the subsystems when certain alarm conditions are present, but I have never seen a situation that requires the PLC to be powered down or reset by an alarm condition. Further, a reset of the PLC does NOTHING except return operands to the "Power-Up" assignment (and execute code linked to SB 2), all of which can be easily done in ladder, if needed, without resetting the PLC itself.

As I said, examine Outputs to determine ALL of the conditions for them to be on. Some of those conditions will be the absence of alarms. Write that into your ladder code and you won't need specific reset subroutines.

I'm going to repeat this, you do NOT need any GoTos or jumps for your application. Get rid of them.

Normal computer programs execute sequentially from top to bottom, but you should not think of PLC ladder logic in that way. In PLCs, even though the ladder is executed left-to-right, top-to-bottom, you should think of it as executing all at once. Why is this? Because of the fundamental PLC cycle, which is (in abbreviated form):

1) Read all physical inputs.

2) Execute all ladder logic.

3) Write all physical outputs.

4) Repeat endlessly.

Nothing happens to the outside world until ALL of the program has executed.

Share this post


Link to post
Share on other sites

Ausman - I know but i'm a trainee and i don't have to empowerment to do wiring. My job is just to do the program and the emergency stop need to be programmed like i said above.

But my problems are the following :

1) How can i reset just 1 sub-routine ?

2) How can i do to execute the "security sub-routines" in the same time that the rest of my program ? I mean, because the security sub-routines must be able to be executed at any time and any step of the rest of  the program.

 

Share this post


Link to post
Share on other sites

Flex 727 - So I just need to put the security conditions (normally closed) at the beginning of the program (or before the sandblasting for the open doors) ? 

And if one of these conditions become true, all the program will stop while the condition don't return closed ?

And for the steps if the emergency stop (for exemple) is pressed,  i put them with an OR just under the normally closed "emergency stop" condition ?

Share this post


Link to post
Share on other sites
14 minutes ago, BaToO said:

1) How can i reset just 1 sub-routine ?

What do you mean by this?

 

15 minutes ago, BaToO said:

2) How can i do to execute the "security sub-routines" in the same time that the rest of my program ? I mean, because the security sub-routines must be able to be executed at any time and any step of the rest of  the program.

Please re-read the last part of my previous post.

 

5 minutes ago, BaToO said:

So I just need to put the security conditions (normally closed) at the beginning of the program (or before the sandblasting for the open doors) ?

In the ladder logic I posted above, you have two means of stopping operation of the sandblasting, depending on the situation. MB 3 (or another contact placed in series with MB 3) allows you to pause operations temporarily while some other task is performed (such as the refilling operation). MB 4 (or another contact placed in parallel with MB 4) will stop the sandblasting operation and require pressing the start button again to get it going again - and will not allow operation to re-start until the alarm is cleared.

Share this post


Link to post
Share on other sites

1) I mean, if a door is opened while the man is sandblasting, the part of the program in charge of sandblasting must be stopped ans reinitialized.

And i have done a sub-routine just for this part so i need to stop and reinitialize this sub-routine. (It's to avoid the GoTo jump to the beginning of the sandblasting part)

2) Oh ok sorry i did not understand 

Share this post


Link to post
Share on other sites
5 minutes ago, BaToO said:

I mean, if a door is opened while the man is sandblasting, the part of the program in charge of sandblasting must be stopped ans reinitialized.

Put a contact in parallel with MB 4 in rung 2 of my ladder above that turns on when a door is opened. Or better, place all the alarm conditions that you want to stop the machine (including "Door Open") in parallel and use them to activate MB 4.

You're hung up on something you're calling "reinitialize". Just make sure the coils that should be on are on and the coils that should be off are off. It's really fairly simple.

13 minutes ago, BaToO said:

the part of the program in charge of sandblasting must be stopped ans reinitialized.

That's exactly what this does: image.png.d649c4063249b1ca26ca6feeb1643834.png

Share this post


Link to post
Share on other sites

Hi Baptiste, you have your block diagram to guide you in your thoughts.

I strongly suggest that you make yourself an excel spreadsheet that lets you elaborate on the block diagram, with how you are actually going to do  the block diagram actions in the plc program.  The beauty of using excel is that you can easily move cells around all over the place.  A sort of overview that can even use all the correct element names.  Such a thing is also very helpful when coming back to a program years after writing it, through being able to see all steps and very quickly remember how it works.

cheers,

Aus

Share this post


Link to post
Share on other sites
16 hours ago, Flex727 said:

Put a contact in parallel with MB 4 in rung 2 of my ladder above that turns on when a door is opened. Or better, place all the alarm conditions that you want to stop the machine (including "Door Open") in parallel and use them to activate MB 4.

Do you need to configure the MB4 ? because mine is empty : image.png.ea2694763af6999510d0ddd110699577.png

 

Share this post


Link to post
Share on other sites

I give you my program. If you have the time to check it. ( sorry it's in french but you have google translate :lol:)

I put the "emergency stop" contact (normally closed) in parallel with my "presence defect" (normally closed) contact before my "start switch" contact (normally open). And the "door open" contacts (normally closed) before my condition for the sandblasting.

And at the end of the program, i put my security sub-routines with my   "emergency stop" contact (normally open), my "presence defect" (normally open) contact and my "door open" contacts (normally open) in first to precise what the program needs to do if one of these contact is activate.

I think it can work. Tell my if I'm wrong.

programme_automate_grenailleuse_V6 - Copie.vlp

Share this post


Link to post
Share on other sites
6 hours ago, BaToO said:

Do you need to configure the MB4 ? because mine is empty : image.png.ea2694763af6999510d0ddd110699577.png

I was providing guidance on how to assemble your logic, not writing your program for you. You can use any Memory Bit you wish and label it any way you wish.

I'm going to repeat what I said previously - do NOT call HMI screens on a continuous basis. They MUST be called with a transition contact, not a direct or inverted contact, and certainly should NEVER be placed directly on the left ladder rail.

It is strongly recommended that you not perform conditional subroutine calls. Sometimes it makes things easier, but always avoid when you can.

Why do you call a subroutine, then the first step of that subroutine is to call another subroutine?

Do not place any logic after an HMI call. In fact, I recommend that any HMI call be on a separate ladder rung from any other logic.

I want to impress on you that EVERY line of code should be executed on every scan (and executed only once). In PLCs, subroutines are typically just a means to break your logic up into manageable pieces. They are NOT like subroutines in regular computer programming. Good programming practice with ladder logic is for the MAIN Routine to handle Power-Up (SB 2) items, then simply have each sub-routine following that. Good programming will rarely have any logic in front of the subroutine call. As far as I can tell, your program is simple enough that you probably don't need ANY subroutines. Try to write your program without them. As an exercise, try putting all your logic in the MAIN routine and do not make any subroutine calls.

Share this post


Link to post
Share on other sites

This is only my opinion and might sound harsh, but it's time to give up, Flex.

Baptiste, Flex has given you many tips and a lot of time and effort.  Remember that most members on this forum are volunteers, him included.   And it looks like you are an employee of the firm with the equipment you are working on. To my eye, you need to learn how PLCs actually work through the ladder, which is vastly different to many other methods you may already be familiar with.  This seems to be a cause of your continually wanting to do things that aren't needed, as you seem to be only thinking along certain lines you already know.

You really need to either go and do a course, or on your own start experimenting with PLCs at the very basics of programming.  This means the first thing is the simple act of programming one input to turn on one output, learning naming conventions and processes, and then building your knowledge from there with progressively more complex operations.   Everyone who is experienced enough to be offering advice on this forum began at this point.

Please take this advice in the spirit intended.

cheers,

Aus

Share this post


Link to post
Share on other sites

Baptiste -

I took a look at V6 of your code.  You're still calling the !Start-Up Display continuously in the first rung of the Main Routine, which will cause the display to flicker and won't let anything else work.

Stop screwing around with subroutines and jumps until you have a better handle on how they work.  You've created a train wreck here.

It is good that you know how a Grafcet works.  These are the basis for the State Machine programming style I am such a big fan of.

On 4/3/2018 at 8:58 AM, BaToO said:

As you can see I'm a beginner and i have a lot of things to learn

You've made the classic beginner mistake of writing a whole program, downloading it, and then wondering why it doesn't work right.

21 hours ago, Ausman said:

you need to learn how PLCs actually work through the ladder, which is vastly different to many other methods you may already be familiar with.

This is extremely true based on the questions you've asked in this post.  This is not a fatal problem, but you are biting off way more than you can chew.  

There is no way you can learn to program a PLC without having one in front of you.  In your current state of understanding you need to write a little code and then see how it works.  Then write some more and continue.  If you don't have a real PLC to practice with then you are just banging your head against the wall.

Baby steps, Baptiste.  We will help you along the way but we're not going to write your code for you.  Unless you have a credit card and are willing to pay my $125/hr USD rate.  Then I will.

I have attached my State Machine example program, which uses a pointer and transitions to jump between functions.  Remember that a PLC "runs" all the time and is nothing more than a collection of IF-THEN and logical AND and OR statements.  

If you study it well you will be able to write your Grafcet program.

Joe T.

 

State machine example.vlp

Share this post


Link to post
Share on other sites

I found this thread to be relevant to a program I am currently writing.

Programming PLC's is a tiny element of my job and I only do around 2 per year, hence why I am not particularly good at it!

On my current program I have tried to use the state machine method  - for the first time. Each state has its own sub routine(5 in total), the main program only calls the sub routine required based on the indexer. So each PLC scan consists of the main routine and one subroutine. The program has thrown out some weird behaviour (timers not resetting, coils remaining energized, cycle 1 works cycle 2 doesn't ) leading me to believe that running one sub routine at a time is not the correct way of implementing the state machine method.

I then read this:

Quote

I want to impress on you that EVERY line of code should be executed on every scan (and executed only once).

Is the correct way therefore to call all subroutines in the main program and use the index coil to activate each rung of the subroutine you want to execute?

Share this post


Link to post
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

×