Introduction: Irrigation Logic Controller/project Log

Picture of Irrigation Logic Controller/project Log

Hello, I am going to explain my project in just a minute, but first I wanted to explain how I became involved in this project.

I like to save money were I can, so it is not hard to understand why I carpool to work. It is only two people at the moment, but it definitely makes a difference in the gas my car consumes in a month. So on my way to work one morning I was listening to my companion explain to me how he had just rented a 120 acre field (I should state at this time that my co-worker farms on the side). His plan was to plant corn on the ground, but the ground was in sand country and he knew the crop wouldn’t make it through the summer unless it received water multiple times a week. The rented ground had an existing irrigation system installed but had not been used for some years

Step 1: Concept of Operation for Irrigation System in Question

Picture of Concept of Operation for Irrigation System in Question

.

The irrigation system happened to be of the center pivot style. In this scenario there was a dug pit at one end of the field (that collects water). Water is pumped from the pond, out to the center of the field via 8” irrigation pipe (laid on the ground) to the center pivot. From there the multiple sections on wheels, all connected together (end to end) pivot around the pivot point, making a complete circle.

Here is a picture to give you an idea of what the system looks like.

Notice that each section has two wheels on the end, then the next section is coupled in series to the previous one with a rubber boot. This rubber boot allows the two sections to flex as they move across the field. As the irrigation system makes its way around the pivot point the sections at the end are required to move faster than the ones closer to the center in order to stay in a straight line. This is why there is a rubber boot separating the sections to allow them to flex as they try to maintain the straight system. Different contours of the field sometimes slow one or more sections, as the sections get behind they need to speed up and the sections closer to the pivot need to slow down in order for the system to travel the circle in unison. If the end sections were allowed to out run the inner sections or vise/versa, the rubber boot would rip off and water would poor into the field destroying the crops in that location. Not to mention that if the irrigation system was not shut down in a scenario like this it would destroy itself by wrapping around itself and bending up the framework and linkages.

Newer irrigation systems are driven across the field by electric motors, but not this one. This is an old pivot that relies on a water/mechanical drive system. The water drives a turbine at the end of each section; the turbine drives a shaft that goes down to a gear box that in turn drives the wheels. I should also mention that there is also a linkage arm on each section, and depending on the angle of the first section to the next, rotates a water valve that controls the amount of water allowed to travel through the water turbine driving the wheels. I.E. more water that section moves faster, less water flowing means that section would move slower allowing the sections after it to catch up.

OK, but what if something unforeseen happens, a flat tire on one of the sections. This would more than likely stop that section dead in its track. The other sections on either side of the dead section would still be trying to complete their cycle. This is where limit switches at each junction come into play. If these were not there, the sections would wrap around one another, and destroy things.

Step 2: ​Problem

Picture of ​Problem

Now that I have explained the system, here is the problem; there is a 14/2 direct burial UV rated wire that travels from the pump location (at the pond) out to both pivots and then from there along the pivots to each section junctions limit switch. (Did I not mention there were two of these center pivots? Well there are.)

This wire has been chewed, cut, and just plain abused over the last how many years and no longer has continuity through two of the three wires. Without this wire there is nothing to tell the pump to shut-down if a pivot gets outside the limits of operation.

The cost of 5-6000ft. of wire to replace the original wire was why outside my friend’s budget.

Step 3: ​Solution

Picture of ​Solution

Listening to his predicament I suggested he place a few wireless transceivers on each pivot and then another at the pump location. This in turn volunteered me to put together a quote on a bill of materials and inevitably build and install the wireless system.

Step 4: ​Build Progression

I had never worked with Xbee radios before but I had read about them and seen them in the parts catalog of my favorite vendor, and I thought they looked like a really cool solution to so many different problems. So I thought… what a great opportunity to work with them, and even better I didn’t have to pay to play!! J

So I set out to decide which Xbee radio I would need. There are so many different options to choose from! After careful consideration and reading countless blogs, postings, and reviews, I decided on the Xbee SB2. They were supposed to have more than enough rang for my application and they had mesh capabilities to allow me to reach the farthest pivot, if I couldn’t reach it directly. I could also use them stand-alone, meaning I didn’t need a microcontroller with them. This was important because I didn’t want to burn up batteries left and right.

I like to have actual paper documentation in from of me when I work. Datasheets, Manuals, Schematics, Design Notes, Pin Outs, all come in handy when I work and I like to be able to set two documents next to each other so I can cross reference as I work. So this was my next step.

After I had my paperwork in order and had read a little about the radios in question, their capabilities, power consumption, and other options. I felt I had a pretty good feel for what needed to be done.

Having never played with these radios before I wanted to do what anyone would want to do, I wanted to make them talk to each other! So I grabbed a few breadboard and wired one radio up with and LED on a output, and through a tactical button on an inputs on the second radio. The next step was downloading a program called X-CTU. This program allowed me to configure my radios to talk with one another. I should mention at this point that there are some great tutorials on the Web showing how this is done. After a little bit of puttsin around I was able to make my radios talk just fine.

Now with proof of concept I was ready to set down and design my project, draw up some schematics, and figure out the fun stuff like enclosures, and power sources.

Step 5: ​Design Phase

I want to apologies right of the bat. I was really good about taking pictures during this whole ordeal. Documenting my progress, failures, and triumphs, now do you think I can find those pictures? I can’t for the life of me figure out where they went or how they were deleted from my phone. So I am going to attempt to reconstruct this project from memory and I will try to get you pictures of the finished circuit boards and enclosures.

I knew I was going to need some sort of logic program in order to do everything I wanted as well as for future expansion of the system. For this I chose the Atmel 328 chip. Some may say this is way too much processor, but I had a few lying around and felt this would be a good way to use one up. The 328 chip had plenty of inputs/outputs and processing power for anything I might dream up. So the 328 it was.

I thought about the project for a while and drew up a list of what was required of my little wireless network. Let’s make a list now.

  • Wireless communication from pivot 1 and pivot 2 back to pump location
  • Monitor center pivot, shut down pump if system got out of alignment
  • Shut down pump when the cycle is complete
  • Shut down pump if radios fail to check in
  • Shut down pump if there is a loss of pressure
  • Shut down pump if engine temp is too high
  • Shut down pump if engine loses oil pressure
  • Test button to allow a com check of radios
  • Minimal power consumption of radios( i.e. sleep mode)

Step 6: ​Programing Phase

Picture of ​Programing Phase

Now that I had a checklist to go off from I quickly go to work writing a script in my Arduino IDE (Integrated development environment). I’m not going to bore you with everything that goes on in my script, there are also countless YouTube videos out there showing how to write a script, but I will explain what happens in the script.

I use my Arduino Uno to program my Atmel 328 Chip.

My inputs/outputs

Output = const int pivotoneerror = 7; //This is a red LED to indicate pivot one error

Output = const int pivottwoerror = 8; //This is a red LED to indicate pivot two error

Output = const int runled = 9; //This is a Amber LED to indicate system is in a run state

Output = const int startbutton = 10; //This is a Start button to start system

Input = const int engineRly = 11; //This is the output for relay, connected to murphy switch

Output = const int testlight = 13; //This is a communication test light, when test button is pressed on remote radio this light will lite

The Libraries I used

#include //Xbee library. Source: http://code.google.com/p/xbee-arduino/

In the script SETUP I start Xbee Serial Port with:

xbee.begin(9600);

Now, for the main loop of my Arduino program, it looks something like this…

void loop() {

// read the state of the start button into a local variable:

StartButtonRead = digitalRead(startbutton);

StartButtonState = StartButtonRead;

//if start button is pressed and the state of the button is not the same as it was previously, change the state of START

if (StartButtonState == HIGH && StartButtonState != StartButtonLastState){

START = !START;

}

// make sure that the next time through the loop StartButtonLastState is equal to Start button Status

StartButtonLastState = StartButtonRead;

//if START is set to HIGH, energize the engine relay and run LED

if (START == true){

digitalWrite (engineRly, HIGH);

digitalWrite (runled, HIGH);

}

//if START is set to LOW, deenergize engine relay and run LED

if (START == false){

digitalWrite (engineRly, LOW);

digitalWrite (runled, LOW);

}

//attempt to read a packet from Xbee

xbee.readPacket();

if (xbee.getResponse().isAvailable()) {

// got something

if (xbee.getResponse().getApiId() == ZB_IO_SAMPLE_RESPONSE) {

xbee.getResponse().getZBRxIoSampleResponse(ioSample);

//check to see if xbee's are checking in by comparing ioSample Xbee address with Xbee address I have in programing

if (ioSample.getRemoteAddress64().getLsb() == pivotoneaddressLSB){

pivotonecheckin = millis(); //marks pivot one xbee as checked in

}

else if (ioSample.getRemoteAddress64().getLsb() == pivottwoaddressLSB){

pivottwocheckin = millis(); //marks pivot two xbee as checked in

}

//see if the pin we want is low

if (!ioSample.isDigitalOn(1)){

//there is an error shut down engine

START = false;

//lets check to see which radio it is from, and send it to the display.

if (ioSample.getRemoteAddress64().getLsb() == pivotoneaddressLSB){

digitalWrite (pivotoneerror, HIGH); //turns on LED1 for error

}

else if (ioSample.getRemoteAddress64().getLsb() == pivottwoaddressLSB){

digitalWrite (pivottwoerror, HIGH); //turns on LED2 for error

}

}

if (!ioSample.isDigitalOn(2)) {

//cycle complete, shut down engine

START = false;

}

if(!ioSample.isDigitalOn(3)) {

//way to test node by turning on an LED

digitalWrite(testlight, HIGH);

}

else{

digitalWrite(testlight,LOW);

}

}

}

// checks to see if xbees have checked in, in the last 1 min. if they havent; shut down (xbees are

//programed to checkin every 20sec.) if Xbee has not checked in Shut down system and turn on

//appropreat LED to show the error

if (millis() - pivotonecheckin >= 60000){

START = false;

digitalWrite (pivotoneerror, HIGH); //turns on LED1 for error

}

if (millis() - pivottwocheckin >= 60000){

START = false;

digitalWrite (pivottwoerror, HIGH); //turns on LED2 for error

}

}// end of loop

Step 7: ​Testing Phase

Picture of ​Testing Phase

After I get my initial script put down, I then use that at a template for laying my components on the breadboard. This is where I apologize because I do not have any pictures of this stage of the build. Basically I set up three bread boards.

One bread board has an Arduino circuit laid down on it. There are many examples of building an Arduino on a bread board, all you have to do is grab your favorite search engine and you’ll get plenty of examples. The Xbee radios need to be powered with 3.3vdc. So there is also a 3.3 volt regulator on the board as well. Other than that there is an LED for indicating power, an LED for indication com checks with the remote radios, and LED for indication the system is running, and two more for indicating an error on each of the pivots.

The other two boards are built identical to one another. The beauty of the Xbee is that I can tie into it directly with an input and I don’t need a microprocessor on the board. This allows me to save considerably on my power consumption. My plan here is to power the remote units with 4 AA batteries. I will hook up the batteries in pairs. Two pair of AA batteries wired in parallel, with each individual pair wired in series will give me 3vdc. I could get by with just a single pair of batteries, but by adding a second pair in parallel I double my amps and can get a longer run time before needing to change out the batteries. It was at this point where I thought a solar panel would fit nicely into this project, but the individual financing the project didn’t want the overhead of more parts.

The Xbee radios can be configured to send sample data of their inputs every 30 seconds while their awake. This brings up another way save my batteries. By putting the Xbee to sleep I can drop my power consumption to practically nothing! Now the question is, how do I put the radio to sleep but still have it check in so I know the radio is still active? It will also have to have the ability to wake up and send data if there is a problem with the pivot.

This is how I get around those few points. The radio can be configured to wake up at specific timed increments. It can also be configured to send sample data at predetermined intervals when awake. The only thing left is to wake up the radio if the pivot has a problem. To accomplish this I use AND gates.

I chose to use three of the inputs on the Xbee. Input one was used to monitor the limit switches in between every section of irrigation. Input 2 was used to monitor the limit switch indicating the end of a complete revolution (end of cycle). Input 3 was wired to a button to test the com link. The Xbee inputs are all wired to be defaulted in a HIGH position. Sending an input LOW will cause a response at the Base Station (Radio at pump location).

Step 8: Here Is a Schematic of the Remote Radios

Picture of Here Is a Schematic of the Remote Radios

Step 9: Here Is a Schematic of the Base Radio (Pump Location)

Picture of Here Is a Schematic of the Base Radio (Pump Location)

Now that I have a working project I grab some solderable PC protoboards

and solder my components onto the boards. This is always a fun and challenging part of any project. The goal is to get a functional but yet eye pleasing product when you’re all done. I never took this project to the next level (I was trying to keep coast down) but instead of using protoboards I could have laid out my parts and created custom PC boards that would allow me to further shrink the project down as well as give the project a very professional look.

Step 10: ​Enclosures

Picture of ​Enclosures

Once the boards were completed and testing was done to ensure they were functional I needed to place them in some sort of enclosure. In the end I needed something that was going to be water tight, resistant to UV deterioration, easily accessible and most importantly very cheap. So were to you go to get low cost enclosures in a timely fashion? (It is now well into the growing season and he has been running the irrigation system manually for a few weeks now. He has already had a few instances where this system would have saved him considerable time and money in repairs due to that fact that the corn is now too high to monitor the entire pivot let alone two of them. Faulty gear boxes and flat tires have caused sections to stall letting the rest of the irrigation system to twist around and damage framework and crops.)

WALMART!!! A trip to Walmart and a walk down the fishing isle reviled some pretty cool water tight cases .PLANO was the answer.

The larger blue one was around $7.19, and the smaller clear red one was right around $ 4.49. So for around $18.00 I was able to procure three cases for the project. Now all I had to do was drill some holes in them for wire access. The blue one required some of the internal compartments to be cut out to accommodate the circuit board and radio. But a razor blade makes quick work of that.

We thought about the best way to fasten these enclosures to the pump and pivots, and thought that hook and loop tape (Velcro) would work great. It had self-adhesive backing so all we had to do is peal and stick. This worked out great, but as time would tell us that the weight of the box combined with all the internals couldn’t stand up to gravity once the sun warmed up the glue on the back to the strips. They were found dangling from the wires entering the box’s one afternoon. This problem hasn’t been solved at this very moment but I am thinking we will end up screwing through the back of the box, retaining our water tight seal with a quick squirt of silicon.

Pictures of Boards in their enclosures (remember these are how they look now)

Step 11: ​Trials and Errors

Picture of ​Trials and Errors

For starters I would like to boost that since the wireless system has been in; it has prevented any more damage to equipment. It has worked like a charm. A number of times my farmer friend has gone out to check on his field and noticed the irrigation system has not completed its cycle, and with a quick check of the main panel at the pump was able to determine which pivot had an issue by inspecting which error LED was lit. This allowed him to save time by being able to go straight to the pivot with the problem and walking that pivot. (Remember once the corn is so high you can’t see the entire pivot, only half of the first section if you’re lucky.)

Well I already mentioned that our hook and loop tape idea didn’t turn out so well and as murphy would have it, that wasn’t our only hurtle we had to overcome.

Let’s see, were to begin…

I rang tested this system in my front yard and down a road near my home. Unbeknownst to me I created a scenario close to how the old analog antenna systems use to be rated. They would test out these TV antenna systems down in Texas or some other place very flat and then rate the antenna for 100 miles. Put that same antenna in the real world with hills and trees and that rang drops dramatically! That is what happened in my case. I had great range during testing, but as soon as I tried to install the system in the field with 5 foot corn, my single quality deteriorated drastically to the point where I could not communicate from node to node.

My solution to this was height, but within reason. I was not going to install a small tower in order to make this system work. So we put the remote radios on 3-4ft poles at the top of the center pivots and then placed the base radio on a ten foot pole near the pump. This in itself presented a few problems. Now the enclosure is on a ten foot pole so in order to start the system one has to take down the pole and push the button to start the system, and then re-mount the pole in order to have connectivity. To overcome this obstacle we had a couple of options. Remote the buttons and LEDS lower so they could be monitored from the ground, or remote the antenna. It is no surprise that we decided to remote the antenna. With a short chunk of CAT-5 we had the antenna on a pole and the base radio down near the engine. (When I say antenna I mean entire Xbee radio. We enclosed this in a short chunk of 1 ¼ “ pvc to keep it out of the weather.)

Our radios were now a good 3-5’ above the crop at the lowest point, but this was still not enough to overcome the distance and signal lose we had. Our only option at this point was different radios. Back to the computer I went to order up some 900 MHz Pro Radios. (These new radios clam 6 miles to 20 miles depending on antennas mounted. So I crossed my fingers) I was lucky because these new radios had the same footprint as the old ones and I was able to unplug the SB2’s and plug the 900 Pro’s with not problems. I am happy to announce that after configuring the new radios I was able to communicate with no additional problems after installing the new Xbee radios.

Another problem I encountered was the wires to the limit switches and the switches themselves. The 14/2 that ran the length of the pivot was just as deteriorated as the wire running along the ground. It all needed to be replaced. We chose to do this by replacing the 14/2 with CAT-5, which was great because now we had 4 pair of wires to work with. We were fortunate enough to run into an individual that had 1000 foot boxes that he was willing to part with for 40 bucks a box. This took care of the wire.

Now for the limit switches, the old irrigation system had crud but effective contacts on the sections that amounted to a center contactor set between two grounded contacts. It was an OK set-up; I mean all it had to do was ground out my Xbee input in order to sense a problem. Needless to say, my very sensitive Xbee input and open contacts being sprayed by water equals an error being tripped every time!

Back to the farm we went to see what kind of parts we could scrounge up. We needed a switch that was watertight, was capable of being mounted in a fashion to use as a limit switch, and we needed at least eight of them, possibly ten. We were fortunate to come up with actual industrial limit switches that fit our application perfectly.

Picture of limit switch without arm attached:

My next issue was totally my fault, I was in such a hurry to get this project off the table and into the field that I rushed the design process just a little, and that is never a good thing. In my hast I failed to put a protection diode on the incoming power lines, and it didn’t take long for that to come back and bite me.

The pump is diesel driven; it has a 12 volt battery for starting. Well little did I know that the alternator on this engine was not working. So the farmer was rotating two batteries, one would sit on the charger back at the farm while the other one was in use. During one of these battery swap sessions, the farmer was being assisted by another individual and that individual accidently reversed the battery cables. That was all it took for my 5 volt regulator to say I give up and explode! So back to the bench it went to have a new regulator soldered in place, along with a protection diode.

Picture of Diode in place:

Later on I had a capacitor fail (or should I say explode) on the 3.3 volt regulator soldered to the main board. I am still not sure why this happened; it may have just been a bad Cap. The unit was still functioning but I could see burn marks on the 3.3 volt regulator from the Cap. So I decided to swap out the regulator, but I didn’t have another regulator. I did have a variable voltage regulator pack that I was willing to part with, so I pulled the 3.3 volt regulator and remaining Cap off the board and soldered jumper wires to the variable regulator. A small dap of JB weld to the back of that board kept the smaller board fastened to the main board.

I chose JB weld because I initially used hot glue to fix all my components in place. Just like the hook and loop tape, the hot glue started to lose its grasp on my components when the sun heated it up. Live and learn I guess, hot glue is great to work with. It’s quick, easy, there is relatively no mess, and it can be removed if need be, but not the best choice when there will be exposure to the hot sun.

Step 12: Conclusion

Picture of Conclusion

This interment panel shows how we overcame some of the other

challenges regarding engine temp, oil pressure and water pressure on irrigation side.

In the end we ended up with three enclosures. The one on the pump (the Base Radio) was powered from the 12 volt battery used to start the engine. This radio had its antenna mounted on a 10 foot pole. The other two radios (remote radios) were mounted 3-4 foot off the top of the center pivots. They were powered internally from 4 AA batteries. Their antennas were mounted inside the enclosure.

All in all, I had a lot of fun with this project! I was introduced to a few new components, got to keep the SB2 radios for future projects, and learned a lot in the process. I always enjoy a challenge and even though this project was fairly simple and straight forward. I did get to experience Xbee hands on and I think they are a great product! I hope to be able to use them again in the future.

The X-CTU software used to configure the Xbee radios was a little confusing in the beginning but I caught on and feel comfortable using it now. I really like the flexibility and options you have when configuring the radios.

What I would do different- I tried to make improvements to this project, but was limited by the budget that I was given. If I had the option I would have made at least two changes to this project. Actually not really changes but maybe a better word for it would be additions. I would have added a solar panel to each remote station to charge the batteries.

The second thing I would have added to this project would be LCD readout for a more user friendly interface. With an LCD display with I2C backpack and an analog joystick I could have made a really attractive front end panel with different menus for making changes to different settings, for example how often the radios need to check in. As it is now I have to reprogram the IC chip every time a change is needed, with a LCD readout and joystick I could have made adjustments to settings right at the panel.

There was a little bit of stress involved as well. The farmer hounded me pretty good about when the project would be completed. I kept being told “my corn is burning up, I’m losing money!!” well there is Nothing like waiting till the last minute to start build somethingJ. I’d say it took us about 3 weeks to get everything going start to finish. A lot of the time was waiting on parts, then re-ordering different radios and waiting for them.

There is now talk of adding a traveling gun to this irrigation system. That should add a whole different set of challenges to the logic side of this project. BRING IT ON!!!

Comments

diy_bloke (author)2016-06-10

and here I am, making irrigation systems for a raised bed, or maybe a small hydroponics system, but you definitely took it up a notch. Great instructable

filosganga (author)2015-06-11

thanks for sharing very good job indeed

Tom Hargrave (author)2014-09-02

Nice project and a excellent use for radios, but I would have just run CAT5 out to the limit switches. CAT5 has 4 pairs, use one wire for a common and you have enough return wires for up to 7 switches.

ccweb1 (author)Tom Hargrave2014-09-03

I forgot to mention that we did run a CAT-5 from the base station all the way out the first pivot (that was the farmers initial fix) , and it did work that way. But then we would have had to protect the wire from the sections of the pivot running over the wire numerous times. We would have also had to get more wire to reach the second pivot. Not to mention all the little rodents that think that wire is a chew toy and nest making material for them.
Also the particular CAT-5 we had was not UV or direct burial rated cable.
There is also a third location being put in that is in need of a third remote radio. So the system is expanding as time progresses.

Tom Hargrave (author)ccweb12014-09-06

It looks like you have everything under control!!! Good luck with your future projects.

ccweb1 (author)Tom Hargrave2014-09-03


You’re exactly right!
And that is just what we did. We mounted the radio at the center pivot itself to keep a constant distance to the base station at all times. Then ran a CAT-5 out from there with each limit switch having a dedicated wire home run back to the radio.
Once back at the radio all limit switches were tied together to form one input on the X-bee. I could have kept them separated out. That would have allowed me to identify which particular section was having problems. But because I was shot down on the idea of putting an LCD readout at the base station( which could have easily displayed which pivot and what section in that pivot was giving the trouble) my only other option would have been to have an LED for each section on a pivot or I could have flashed the pivot LED a number of times to indicate which section was in trouble. But to eliminate confusion for the operator (not me) I chose to group all the switches. This way there are just two LED’s, one for each pivot and the operator can then walk the pivot with the error light.
Thanks for commenting.

xp14629 (author)2014-08-31

What part of the world are u in? How much did u wind up investing in this? What brand is the center pivot u were working with?

ccweb1 (author)xp146292014-09-03

I'm located near central MN. Lots of lakes but not always enough rain for the crops, especially in the sand ground.
Off the top of my head I would have to say I have around $50 in the circuit boards, $18-20 in the enclosures, we found an old telecom guy willing to part with a 1000’ box of CAT-5 for $40, and the most expensive part of the project was the Radios. They were purchased of the Digi website(they have an office in Minneapolis which makes for fast delivery) and I believe at the time they were around $45 per radio, with another $6 for the 7” whip antenna.
So all and all I'd say around $263 total, give or take.
As for the pivot itself, I'm not sure what brand center pivot it is. I know its been around for a long time. I even asked the guy that is renting the property and he couldn't tell me what brand it was either. Sorry,

Thanks for looking at my project!

Monteagus (author)2014-08-31

Marvelous work.

MsSweetSatisfaction (author)2014-08-31

I love how enthusiastic you are about problem solving! Also that you helped out a friend it ended working so well! Thanks for sharing!

About This Instructable

11,181views

100favorites

License:

More by ccweb1:Irrigation logic controller/project log
Add instructable to: