PLC Programming

Thank you very much! I have never seen the boxes that is called ''='' and ''MOVE''. What are those?


They are function blocks. The = compares the values of two inputs and determines if they are equal. It is very much like a mathematical function. It gets some INPUT and then does some OPERATION on the INPUT then gives an OUTPUT. In the case of the =, or any other comparison block, the output has two possibilities. They can be TRUE(1) or FALSE(0) and then execute the following logic based on that.


This is a video for excel, but the exact same principals being illustrated here hold true:


https://www.youtube.com/watch?v=eWMD0pKmg48
 
Thank you very much for your video!

Sorry, im a bit confused. Because I thought that using SR was correct, but then I heard using RS is the correct one. I know that the SR is start dominance, and RS is reset domincance, but I dont know when to use which one.. And I dont now any other method that is easier for me than using that.

Using SR is not incorrect. I just said that I would not do it that way. Perhaps this is because I mostly program in Ladder logic. I made another version of my example using Set/Reset. Note that the Equal and Move mentioned above are more correctly called functions and not function blocks. They do not have to be defined because they do not store any information in them.

Function blocks like SR, and timers, have internal data and so they must be declared like variables and given names. You will see in my video that I declared an SR function block named SR_H0. I moved all my variables to the global variable file so that I could call them from multiple routines. The SR function block has to 'remember' that you energized the SET1 input and keep the Q1 output on until it sees a signal on RESET.

One would say that I have declared SR_H0 to be an instance of an SR function block.

https://youtu.be/UCHUsKSKP2w
 
Using SR is not incorrect. I just said that I would not do it that way. Perhaps this is because I mostly program in Ladder logic. I made another version of my example using Set/Reset. Note that the Equal and Move mentioned above are more correctly called functions and not function blocks. They do not have to be defined because they do not store any information in them.

Function blocks like SR, and timers, have internal data and so they must be declared like variables and given names. You will see in my video that I declared an SR function block named SR_H0. I moved all my variables to the global variable file so that I could call them from multiple routines. The SR function block has to 'remember' that you energized the SET1 input and keep the Q1 output on until it sees a signal on RESET.

One would say that I have declared SR_H0 to be an instance of an SR function block.

https://youtu.be/UCHUsKSKP2w

Thank you, I will take a closer look! By the way, I can't add 3 outputs using only 1 SR/RS? do I have have to make 1 SR for every output?
 
To answer your question, you can have more than one output to a block. You right click on the line coming out of the block and choose Insert assignment. It will add a branch and area for you to type another tag name. Like this:

attachment.php


Now for the real fun. Why, just because. I have created a simulation of your application from your description. Here's the thing in action with a program I wrote.

https://youtu.be/407T8KZ_09s

I also exported the relevant files so that you could play with it too. The file you need to import into your CoDeSys project is attached to this message as a zip file. You need to unzip it ant then import it as shown here:

https://youtu.be/QP431WuTVm4

Once you have done the import, Use the tags in the Global Variable file GVL in your PLC_PRG. Make sure you are in simulation mode (see video) and then go online and run the project. You can see if you are doing things right.

It would be no fun it I give you my program right away since you want to do this as a learning exercise. Start slow. Just run it with the one network shown in this post and you should see the light come on and M2 come on. The tank won't fill because you haven't turned on a valve yet. Once you get that one network working, then try to open the first valve and start filling.

2Outs.PNG
 

Attachments

  • Kkona.zip
    59.4 KB · Views: 1
Thank you very much for your video!

Sorry, im a bit confused. Because I thought that using SR was correct, but then I heard using RS is the correct one. I know that the SR is start dominance, and RS is reset domincance, but I dont know when to use which one.. And I dont now any other method that is easier for me than using that.

I'm speaking from Siemens experience, but with with RS/SR, whatever is on the bottom is dominant, since that's how the scan cycle sees it. I'm not sure if CodeSys is the same way though.
 
I'm speaking from Siemens experience, but with with RS/SR, whatever is on the bottom is dominant, since that's how the scan cycle sees it. I'm not sure if CodeSys is the same way though.

SR = Set dominant and RS = Reset dominant in Codesys. The block looks equally, but it says RS instead of SR inside the block and vica versa if that is a good answer to you!

The real problem for me, is that I dont know when is it properly to use SR or RS, and what factors decides what to choose?
 
To answer your question, you can have more than one output to a block. You right click on the line coming out of the block and choose Insert assignment. It will add a branch and area for you to type another tag name. Like this:

attachment.php


Now for the real fun. Why, just because. I have created a simulation of your application from your description. Here's the thing in action with a program I wrote.

https://youtu.be/407T8KZ_09s

I also exported the relevant files so that you could play with it too. The file you need to import into your CoDeSys project is attached to this message as a zip file. You need to unzip it ant then import it as shown here:

https://youtu.be/QP431WuTVm4

Once you have done the import, Use the tags in the Global Variable file GVL in your PLC_PRG. Make sure you are in simulation mode (see video) and then go online and run the project. You can see if you are doing things right.

It would be no fun it I give you my program right away since you want to do this as a learning exercise. Start slow. Just run it with the one network shown in this post and you should see the light come on and M2 come on. The tank won't fill because you haven't turned on a valve yet. Once you get that one network working, then try to open the first valve and start filling.

I'm speaking from Siemens experience, but with with RS/SR, whatever is on the bottom is dominant, since that's how the scan cycle sees it. I'm not sure if CodeSys is the same way though.

Thank you very much for your videos, I will take a closer look at it! Also, I have almost completed the program now. But it its 2 things I need help with, that I dont understand.

1. Is negation the same as True-false or false true or is negation something else?

2. I know that in the task, I have to set some inputs from true to false. But how do I know what to set as false? Please explain.

3. I tried to add the timer (TOF-block) to the RS block for M1, so M1 can stop after 6 seconds. But it didnt work. I dont know what I should put in the ''IN'' ADN ET. Here is the picture: https://ibb.co/Vgfp8VF
 
Last edited:
The Image showing TRUE and FALSE is a picture of the ONLINE view of a RUNNING program. In CoDeSys you would have to Login (From the menu Online, select Login). Then you have to run the program (From the menu Debug, select Start). You can't see the TRUE/FALSE state of anything because your program still has errors so you cannot login and run the program until all the errors are fixed.

You are getting the errors because you have not declared RS_1 anywhere OR you have declared it somewhere that your program cannot 'see'. If you declared RS_1 in the global variable file (and you left the default name GVL) then you will have to reference it as GVL.RS_1 (there is a way around this but the default behavior is to have to reference global variables with their full name which by default is GVL.xxxx where xxxx is the name given in the Global variable file.)
 
The Image showing TRUE and FALSE is a picture of the ONLINE view of a RUNNING program. In CoDeSys you would have to Login (From the menu Online, select Login). Then you have to run the program (From the menu Debug, select Start). You can't see the TRUE/FALSE state of anything because your program still has errors so you cannot login and run the program until all the errors are fixed.

You are getting the errors because you have not declared RS_1 anywhere OR you have declared it somewhere that your program cannot 'see'. If you declared RS_1 in the global variable file (and you left the default name GVL) then you will have to reference it as GVL.RS_1 (there is a way around this but the default behavior is to have to reference global variables with their full name which by default is GVL.xxxx where xxxx is the name given in the Global variable file.)

Okay, I think I understand, but I can't figure out what to do to solve it.. it still says error!
 
I solved it, so now I have 0 errors.

So now I am at the point to decide what inputs/outputs i should set to True or false. I dont understand that yet.

Like, what factors do come in mind when using True, and in which situations do I use false?
 
I solved it, so now I have 0 errors.

So now I am at the point to decide what inputs/outputs i should set to True or false. I dont understand that yet.

Like, what factors do come in mind when using True, and in which situations do I use false?
That's the whole idea of programming. You need to think and decide what has to happen to get the machine or system to do what you want. Then translate those ideas to the format of your PLC programming software.

It will probably help you a lot if you make a flow chart for each output.
 
1
That's the whole idea of programming. You need to think and decide what has to happen to get the machine or system to do what you want. Then translate those ideas to the format of your PLC programming software.

It will probably help you a lot if you make a flow chart for each output.

Okey, thanks! I think my program is complete now, but I can't see the timer count to 6 seconds and then stop the Mixer_M1? Have I done anything wrong? Because after 6 second, M1 should stop.. But I cant see the block counting. Please see image.

https://ibb.co/6Z6mhZx
 

Similar Topics

Hello colleagues, Some time ago I started my adventure with programming. With your help and the courses, things are starting to come together...
Replies
13
Views
591
Dear All, I need a sample PLC program to count the output pulse of a mass flow meter so that a specific amount of mass (for example 100gm)can be...
Replies
2
Views
80
Hi Please I have zeilo smart relay #SR2A201BD but I don't have it's programming cable. Can I use any general usb/rs232 converter? Or need...
Replies
2
Views
79
Hi, Does anyone have thoughts or know of, can point in the right direction any published materials with a plumbing centric point of you explaining...
Replies
1
Views
125
@ All: what is your best guess on a potential range in increase in efficiency in % (i.e. saved programming hours, greater output, etc.) when...
Replies
5
Views
291
Back
Top Bottom