Automatic Irrigation System

I am totally dumb when it comes to PLC/ladder logic so please for indulgence.
We have subject about PLCs an we have to make project (CoDeSys), mine is about: Automatic Irrigation System. I have few problems with it, but first I'll present how it should work (algorithm block in attachment):

I declared inputs and outputs
M1min: BOOL; (*minimum moisture on area1, sensor1*)
M1max: BOOL; (*maximum moisture on area1, sensor1*)
M2min: BOOL; (*minimum moisture on area2, sensor2*)
M2max: BOOL; (*maximum moisture on area2, sensor2*)
M3min: BOOL; (*minimum moisture on area3, sensor3*)
M3max: BOOL; (*maximum moisture on area3, sensor3*)
valve1: BOOL; (*valve1*)
valve2: BOOL; (*valve2*)
valve3: BOOL; (*valve3*)
pump: BOOL; (*pump*)
How it works:
1) I declare minimum moisture Mmin=30% and maximum moisture Mmax=90%.
2) Simultanously program checks if moisture on any of three areas is below 30%. If no program backs to the beginning. If yes program opens valves whose correspond with areas and then pump turns on.
3) Water flows and programs checks if moisture on any of three areas is above 90%. If no program backs to the beginning. If yes program closes valves whose correspond with areas and then pump turns off.
4) Program backs to the beginning.

Here are my problems and doubts:
1) The moisture values are BOOL (1/0). How to make them to work like INT (0,1,...,100). I have been thinking maybe use slider for each area? When I move slider below 30% pump will turn on (Mmin controls turn red) and when I move it below 90% the pump will turn off (Mmax controls turn red). But I have totally no idea how to make it. Or maybe is better much simple solution?
2) I wrote prototypical program in ladder (please don't laugh) which I think to work but it is not exactly what I wanted to achieve.

I attach: block algorithm, CoDeSys file and CoDeSys screenshot.

I really hope if someone will help and clearly explain how to solve it. Thank you so much in advance.


Presumably your block algorithm is close to a flow diagram / flowchart which almost makes sense.
What you describe as ladder logic is total can’t think of a moisture sensor in Boolean terms when it is an incoming variable to your process.

Does the pump move water, if so where is it coming from - and is it allowed to run dry ?
What starts the process and does anything stop it ?

As stated in your ‘other’ thread about PLC ladder logic - you need to know exactly what your PLC will do - different makes/models have different instruction sets.
Yeah, sure my mistake, it should be: M1min: INT; (*minimum moisture on area1, sensor1*) etc.
When it comes to water, it comes from well/public water supply.
'What starts the process and does anything stop it ?' - moisture sensors start pump when moisture is <30% and stop it when it is >90%.
when I move it below 90% the pump will turn off You may wanted to write "move it above " instaead of below 90%

So where or what do you think it need to get improved...

As the presented system seem to be quite ok ...
you might want to consider a hysteresis controller ...that's what it sounds like on your control system..this should also sort out possible debouncing issues on your set points. Google 2 term hysteresis controller set the high and low points and dead band window. It's probably the simpler control algorithm and at least it's a well-documented algorithm and is used a lot on slow-moving processes where the precision of PID controller is not required.
be careful that you don't exceed your duty cycle( dead-band setting ) on the motor and obviously interlock against pumping against a closed valve....
if you have the hysterises controller under your belt ,,,then at least you can apply a more generic solution to similar gives you more free time to go to the pub for a refreshing pint of beer......sorry soothing pint of beer
Have a good read on this article from this link:

It is showing a system which inculding water level sensor ...

PLC Automatic Irrigation System

There are two different plants line in the garden. Both the plants types are different so we need to provide water as per demand of the plants. Design Automatic irrigation system for two different plants line using PLC ladder Logic.
Automatic Irrigation System
PLC Automatic Irrigation System Ladder Logic Project

PLC Solution :
Here two types of methods are used for the plants.
For first plant line, we are using float switch because in this line it is necessary to maintain water level in the pool, so here water level will be controlled according to minimum level and maximum level.
In second plants line, we will operate different water pump as per moisture in the plants. If sensor detects low moisture, water pump will start and it will stop working when moisture is sufficient in the plants.
List of Inputs/Outputs
List of Inputs
  • I1 :- Minimum level
  • I2 :- Auto on
  • I3 :- Moisture sensor
  • I4 :- Maximum level
List of Outputs
  • Q1 :- Water pump for plants line A
  • Q2 :- Water pump for plants line B
Ladder Logic – Automatic irrigation system
Automatic Drip Irrigation System Using PLC

PLC Logic Description
Network 1 :-
In this network we have used set reset logic for the water pump which is used for plants line A. When level is minimum in the pool, SET instruction will be executed and if level is normal, then reset condition will be executed.
Network 2 :-
Here water pump for the plants line A will be ON when both conditions (Set condition and auto on condition) are met.
Network 3 :-
When moisture is not available in the plants, water pump for the plants level B will be ON.
Note :- Above application may be different from actual application. This example is only for explanation purpose only. We can implement this logic in other PLC also. This is the simple automatic irrigation system for two different plants line using PLC; we can use this concept in other examples also.
All parameters and graphical representations considered in this example are for explanation purpose only, parameters or representation may be different in actual applications. Also all interlocks are not considered in the application.
Author : Bhavesh

Always glad to support !

Any time

I am sure that it can help!

Hi I'd like to give update but I have plenty of other very timetaking subjects which make my situation way worse and worse when it comes to understand this subject. Maybe on weekend I'll continue.
.. Just be aware that we here doing effort (extra work) and without perceving any fees...
So keep in mind that anyone of us deserve an update /feedback...
It is not just posting here and leave thread...