simple program to control sprinklers

I'm new to plc.. has anyone written code for controlling a sprinkler system.
I need to turn 4 relays on 4 times a day for 5 minutes.
I just need some code to follow and then I should be able to modify it. Any help will be appreciated!
 
It is easy to do. Do you have details of your plan, for example, when, which one, and how long to turn them on and off?
You can also add rain sensor, wind sensor, and soil sensor to help dynamically adjust your water timing.
 
START
CALLSUB HOURLY
END

HOURLY:
TSTNE RAM1 CH
GOTO spk_ctl
RET
spk_ctl:
SET RAM1 CH
SUB AIP1 AIP2 RAM2
SET OP1 1
DELAY 60000
SET OP1 0
RET

You can also try to use non-blocking delay,
SET OP1[60000] 1
Then you will no need to have DELAY or SET OP1 0. If you have four spingklers, they can go out at the same time.
blocking delay will ensure only one thing happen at one time.
 
@philspargo,
 
Did you finish your sprinkler project to control watering using WC8?  If you have any problem, please let us know.  We are here to help.
 
I know this is an ancient post.... but here's my "solution" to this problem, just for a giggle...
 

START
set ram2 1 # Start with output 1

wait:
tsteq op1[1000] 1 # Test each output has been on for required time
set op1 0 # and turn them off when expired
tsteq op2[1000] 1
set op2 0
tsteq op3[1000] 1
set op3 0
tsteq op4[1000] 1
set op4 0
tstlt cts ram1 # check the time now against the "next station" time
goto wait # loop, just checking outputs until it is

rotl ram2 1 ram2 # Select the next output
tstgt ram2 8 # if it has stepped past station 4 (1, 2, 4, 8)
set ram2 1 # then reset to station 1
set allouts ram2 # set all the outputs
add cts 5 ram1 # Add your required wait time
goto wait # and return to the wait loop
end

This is set to 1 second pulses (the [1000] in each output test), and 5 seconds per output (the "add cts 5" line), but can be changed to whatever. This is fast so you can observe it in operation.
 
Question to CAI:
  why can't we use a variable in the time field?
  It would be great to be able to have
 
      TSTEQ OP1[UROM1] 1
      SET OP1 0
 
for a easily altered variable time delay!  (if not UROM1 then at least a RAM or VAR)
The compiler permits it, but the code doesn't run.
 
Ross,
 
The compiler does not have the most comprehensive error checking. Although it taking variables without complain, it does not work. How to change PLC engine in WC to support Variables, that is something we are thinking, but not very easy to implement.
 
For this sprinkler project, I think it could add analog inputs to measure soil moisture, them determine the length of watering.   What OPx[y] using is to force water valves to shut off after y amount of time by itself, in case any problem caused output ON and forgot about shut off the water valve.
 
This soil moisture sensor can be connected to WC8 AIP input to determine the soil condition
 

http://www.ebay.com/itm/Soil-Hygrometer-Humidity-Detection-Module-Soil-Moisture-Water-Sensor-New-FE-/231510788405

 
This moisture sensor has built-in analog comparator chip, so that one can set at each sensor whether or not watering by setting the trim pot on it. It will connect to digital inputs, IPx, to determine watering or not each day.
 
Back
Top