Before we start to write the program we first
need to select a name that is representative of the facilities shown here.
Within this machine we have these two level switches and this stop switch, these are the
machine's inputs; the outputs are these two pumps, the mixer
and this valve. If the “Low level”, “high level” and
“stop” switches are connected respectively to the “first”, “second” and “third”
inputs of the PLC input module, their addresses in sequence will be: “I 0.0” , “ I 0.1”
and “ I 0.2” . Similarly, if pumps one and two, the mixer
and the valve are connected respectively to outputs one to four of the PLC's output module,
their addresses will be “Q 4.0”, “Q 4.1”, “Q 4.2” and “Q 4.3” sequentially.
OK now that we know all the addresses of the inputs and outputs, we can go to the option
menu and open the symbol table" to give each address a representative name”.
We enter the name “L_LEVEL” for the "low level" switch and leave the type as Boolean
because the switch is digital. We continue naming the addresses with representative
names until all addresses have a name, then we save the table and navigate back to the
"OB1" OK so as we did before, we want this switch
here and both pumps to be energized when the level of the liquid in the tank drops to the
minimum. We do this by inserting an "SR” flip-flop
from the “bit logic” folder here. The functions of the flip-flop are quite basic.
It has two inputs and one output; when the "set" input is energized, the "Q" output is
true, and when the" reset" input is energized, the "Q" output is false.
So now we are going to add two coils, one will be assigned the address of pump number
1 and the other will be assigned the address of pump number 2.
In order to turn on the two pumps when the "low level" switch is energized, we place
an open contact here and assign to it the address of the "low level” switch.
As we know already, the switch has an open contact inside it, and when the level of the
liquid in the tank drops to the minimum, a 24 volt signal is sent to the “I 0.0”
input causing this contact to be closed and the "set" input to be energized, resulting
in the two pumps being turned on. Now that our pumps are running, at what point
should they be shut down? Well, as we said before the pumps should run
until the level of the liquid in the tank rises to its maximum when the "high level"
switch is energized. So let's insert another open contact here
and assign it the address of the "high level" switch. So now when the switch is energized
both pumps will be shut down. We also add the address of a memory bit here
for the flip-flop. OK so after the tank has been filled and the
pumps shut down, we want this mixer to start up automatically to mix the liquid in the
tank for seven seconds. So first we need to add a new network here
then insert an “extended pulse timer” here, giving it an address of "T0."
Now we add an open contact here for the "set" input, assigning it the address of the "high
level" switch, and then we add a coil here for the output giving it the address of the
mixer. Now we need to set the duration of time for
the mixer to run in the "time valve" input, using "S5 Time" formatting.
In our case we want to enter 7 seconds, so first we enter "S5T," then the "#" sign, and
then "7s" which represents 7 seconds. We also need to add an open contact and assign
it the address of the valve for the "reset" input.
Now with these settings, when the "high level" switch is energized, the mixer will be turned
on and run for seven seconds. So because the "reset" input has an open contact
with the address of the valve, the mixer can never be energized while the discharge valve
is open and liquid is being discharged from the tank.
Now, what should happen after the mixer is turned off? That's right! The discharge valve
should open to discharge the liquid from the tank to be used elsewhere in the factory.
So now we need to insert a new network and insert another "SR" flip-flop here.
Now, which one of the outputs do we need to turn on with this flip-flop?
Yes, it's the valve that we need to activate with this instruction. So we place a coil
in the flip-flop output, assigning it the address of the valve.
Now, when exactly should this valve be energized, or in other words when should the valve open?
Right again! As we said earlier, the valve should open after the tank has been filled
and the mixer has finished mixing the liquids. So we need to insert an open contact for the
"high level" switch here and following that we insert a closed contact for the mixer.
With these settings, when the tank is full and the mixer is off, the valve will open.
So how long will the valve stay open? Well, it will remain open until level of the
liquid drops to the minimum set level, which means the tank is fully discharged at this
point. So which one of these facilities will be energized
when the level reaches the minimum? Right! The "low level" switch. So we should insert
an open contact into the “reset" input so that when the switch is energized, the valve
will be closed. We also assign an address of “M 0.1” to
the flip-flop memory OK our program is almost complete but we also
have a “stop" switch here. Stop switches normally remain closed. This
means that the contact within the switch usually remains closed allowing the signal to pass
through them. When the switch is pushed, the contact is opened and the signal is disconnected.
The stop switch here is normally closed too, so we can add a closed contact on the "reset"
input of this flip-flop, and we can also copy and paste it for the other networks.
With these settings, when the stop switch is pressed, all outputs will be turned off.
So that completes the programming, now we can save our program and move on to test it.
Here, because we are using "PCS7" instead of "STEP 7" this download icon is disabled,
so we need to go to the SIMATIC Manager and click on this icon in the toolbar to open
the "online" window. In the window, open the "block" folder and
drag the "OB1" from the offline window to the online window like this....
The offline window contains our computer's data and the online window contains the PLC's
data. This “HMI Station” has been added to the
project tree because we are going to use “WinCC flexible” to test the program in addition
to the “PLC Simulator” but it is not imperative to use this station, you can test the program
using the “PLC Simulator” alone. OK now we are going to put the CPU into "RUN"
mode and then put the program into "online" mode.
We know that the "stop" switch is normally closed so we need to close it manually in
the simulator before we can test the program. So to start, we first energize the "low level"
switch and as expected pump numbers 1 and 2 are both turned on.
Note that in the simulator the relevant outputs of “Q 4.0” and “Q 4.1” are now "true"
and illustrated in this graphic you can see both pumps are turned on, and are pumping
liquid into the tank. When the liquid rises past the level of the
"low level" switch and it stops being energized, the pumps will continue operating because
the tank is not yet full. When the level of the liquid rises to the
maximum, the "high level" switch is energized, which turns off the pumps and starts the timer.
Here you can see that the mixer is going to be turned on for 7 seconds and after it has
been shut down the discharge valve will be opened automatically.
This process continues until the level of the liquid drops to the minimum again. At
this point the low level switch will be energized again, the valve will be closed and the pumps
will be turned on, thus repeating the cycle. At any point during the machine's operation
if we press the "stop" button all the outputs are turned off, as you see here.
OK so in this lesson we learned how to write a program to control this machine automatically
using an “S7 300” PLC and “STEP 7” software.
Thank you very much for watching this video! Make sure you subscribe to PARSIC if haven't
already because we've got some more awesome videos coming your way very soon.