☠WEEDINATOR☠ Part 2: Satellite Navigation

14,438

158

34

Published

Introduction: ☠WEEDINATOR☠ Part 2: Satellite Navigation

About: Ugly pirate roaming the seas in search of Treasure.

The Weedinator navigation system is born!

A roving agricultural robot that can be controlled by a smart phone.

... And rather than just go through the regular process of how it's put together I thought I'd try and explain how it actually works - obviously not EVERYTHING but the most important and interesting bits. Please excuse the pun, but it's how the data flows between the individual modules that I find interesting and broken down into it's lowest denominator we end up with actual "bits" - zeros and ones. If you're ever been confused about bits, bytes, characters and strings then now may be the time to become unconfused? I'm also going to try and unconfuse a slightly abstract concept called 'Error Cancelling'.

The system itself features:

  • GPS/GNSS: Ublox C94 M8M (Rover and Base)
  • 9DOF Razor IMU MO digital compass
  • Fona 800H 2G GPRS cellular
  • 2.2" TFT screen
  • Arduino Due 'Master'
  • Various Arduino 'Slaves'.

Strangely, a lot of Sat Navs don't have a digital compass which means if you are stationary, and lost, you have to walk or drive in any random direction before the device can show you the correct direction from satellites. If you get lost in a thick jungle or underground car park you're stuffed!

Step 1: How It Works

At present, a simple pair of coordinates is uploaded from a smart phone or computer, which are then downloaded by the Weedinator. These are then interpreted into a heading in degrees and a distance to travel in mm.

The GPRS fona is used to access an online database through the 2G cellular network and receive and transmit the coordinates to the Arduino Due via an Arduino Nano. The Due is the Master and controls an array of other Arduinos as Slaves via the I2C and serial buses. The Due can interact with live data from the Ublox and Razor and display a heading calculated by one of it's Arduino slaves.

The Ublox satellite tracker is particularly clever as it uses error cancelling to get very accurate fixes - a final nominal total deviation of about 40mm. The module is composed of an identical pair, one of which, the 'rover', moves with the Weedinator, and the other, the 'base' is fixed onto a pole somewhere out in the open. Error cancellation is achieved by the base being able to achieve a really accurate fix by using a large amount of samples over time. These samples are then averaged to compensate for changing atmospheric conditions. If the device was moving, it obviously would not be able to get any kind of averaging and would be at the complete mercy of a changing environment. However, if a static and moving device work together, as long as they can communicate between one another, they can get the benefit of both. At any given time, the base unit still has an error but it also has a previously calculated super accurate fix so it can calculate the actual error by subtracting one set of coordinates from another. It then sends the calculated error to the rover via a radio link, which then adds the error onto it's own coordinates and hey presto, we have error cancelling! In practical terms, error cancellation makes the difference between 3 metres and 40mm total deviation.

The complete system looks complicated, but is actually fairly easy to build, either loose on a non conductive surface or using the PCB that I designed, which allows all modules to be securely bolted on. Future development is built onto the PCB, allowing a vast array of Arduinos to be incorporated to control motors for steering, forward motion and an on-board CNC machine. Navigation will also be assisted by at least one object recognition system using cameras to sense coloured objects, for example fluorescent golf balls, which are carefully positioned in some kind of grid - Watch this space!

Step 2: Components

  • Ublox C94 M8M (Rover and Base) x 2 of
  • 9DOF Razor IMU MO digital compass
  • Fona 800H 2G GPRS cellular 1946
  • Arduino Due
  • Arduino Nano x 2 of
  • SparkFun Pro Micro
  • Adafruit 2.2" TFT IL1940C 1480
  • PCB (see attached Gerber files) x 2 of
  • 1206 SMD zero ohm resistors x 12 of
  • 1206 LEDs x 24 of

The PCB file opens with 'Design Spark' software.

Step 3: Wiring Up the Modules

This is the easy part - especially easy with the PCB that I got made - just follow the diagram above. Care is needed to avoid wiring 3v modules to 5v, even on the serial and I2C lines.

Step 4: Code

Most of the code is concerned with getting data to move around the system in an orderly manner and quite often there is a need to convert data formats from integers to floats to strings and to characters, which can be very confusing! The 'Serial' protocol will only handle characters and whilst the I2C protocol will handle very small integers, I found it better to convert them to characters and then convert back to integers at the other end of the transmission line.

The Weedinator controller is basically a 8 bit system with lots of individual Arduinos, or 'MCU's. When 8 bit is described as actual binary zeros and ones it can look like this: B01100101 which would equal:

(1x2)+(0x2)2+(1x2)3+(0x2)4+(0x2)5+(1x2)6+(1x2)7+(0x2)8 =

Decimal Digit Value
1286432168421
Binary Digit Value
01100101

= 101

And the maximum value possible is 255 .... So the maximum integer 'byte' we can transmit over I2C is 255, which is very limiting!

On an Arduino we can transmit up to 32 ASCII characters, or bytes, at a time using I2C, which is much more useful, and the character set includes numbers, letters and control characters in 7 bit format as below:

Fortunately, the Arduino compiler does all the work of conversion from character to binary in the background, but it still expects the correct type of character for data transmission and it won't accept 'Strings'.

Now is when things can get confusing. Characters can be expressed as single characters using the char definition or as a one dimensional array of 20 characters using char[20]. An Arduino String is very similar to a character array and is literally a string of characters often interpreted by the human brain as 'words'.

// Builds the character 'distanceCharacter':
      String initiator = "";
      distanceString =  initiator + distanceString ;
      int n = distanceString.length();
      for (int aa=0;aa<=n;aa++)                    
      {
          distanceCharacter[aa] = distanceString[aa];
      }

The code above can convert a long string of characters into a character array of characters which can then be transmitted over I2C or serial.

At the other end of the transmission line, the data can be converted back to a string using the following code:

 distanceString = distanceString + c;           // string = string + character

A character array can not be converted directly to an integer and has to go into the string format first, but the following code will convert from a string to an integer:

      int result = (distanceString).toInt();
      int distanceMetres = result;

Now we have an integer which we can use to make calculations. Floats (numbers with a decimal point) need to be converted to integers at the transmission stage and then divided by 100 for two decimal places eg:

 float distanceMetres = distanceMm / 1000;

Lastly, a string can be created from a mixture of characters and integers eg:

// This is where the data is compiled into a character:

 dataString = initiator + "BEAR" + zbearing + "DIST" + zdistance;  // Limited to 32 characters

//  String  =  string + characters + intereger + characters + integer.

The rest of the code is standard Arduino stuff that can be found in the various examples in the Arduino libraries. Check out the 'examples >>>> Strings' example and the 'wire' library examples.

Here's the whole process for transmit and receive a float:

Convert Float IntegerStringCharacter[ ] array ..... then TRANSMIT character array from Master ➜➜

➜➜ RECIEVE individual characters on Slave .... then convert CharacterString IntegerFloat

Step 5: Database and Webpage

Above is shown the database structure and the php and html code files are attached. Usernames, database names, table names and passwords are blanked out for security.

Step 6: Navigation Tests

I managed to hook up a datalogger to the Weedinator control board via I2C and get some idea of the Ublox M8M satellite positioning performance:

On 'Cold Start', shown by the green graph, the module started off with lots of error, quite similar to a 'normal' GPS, and gradually the error became reduced until, after about 2 hours, it got a RTK fix between rover and base (shown as the red cross). During that 2 hour period, the base module is continually building up and updating an average value for latitude and longitude and after the pre-programmed time interval decides that it has got a good fix.The next 2 graphs shows behaviour after a 'Hot start' where the base module has already calculated a good average. The top graph is over a 200 minute period and occasionally the fix is lost and the rover sends a NMEA message to the Weedinator that the fix has temporarily become unreliable.

The lower blue graph is a 'zoom in' on the red box in the top graph and shows a good representative snap shot of the Ublox performance, with total deviation of 40 mm, which is more than good enough to guide the Weedinator to it's loacation, but possibly not good enough to cultivate the soil around individual plants?

The third graph shows data gathered with the Rover and Base 100 metres apart - No additional error was detected - the distance of separation made no difference to the accuracy.

Step 7: Final

I'm very happy with how the Weedinator control system is turning out :) The data seems to flow between the different modules without any particular problem and the foundations for additional modules seems to be pretty solid with plenty of room for motor controllers and object recognition systems.

In the meantime, the Weedinator chassis design has progressed to the stage where it has an on board CNC machine for cultivating the soil. It will soon be time to get back to the workshop to do some more fabrication.

*Special thanks to SlashDevin for the Ublox NMEA Arduino code.


Share

    Recommendations

    • Make it Move Contest

      Make it Move Contest
    • Casting Contest

      Casting Contest
    • Microcontroller Contest

      Microcontroller Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    34 Comments

    I like this a lot I came across it while doing some research into GPS navigation, my motive to attach a programmable navigation system for a quad copter. I wanted to program the flight path of the drone. I found it very interesting full marks you got my vote.

    This is awesome. I'm following this build closely! When do you think you'll have the next instructable up? When do you plan to have the entire build finished?

    1 reply

    Thanks for your comment, Mark. Next instructable will be about building the chassis, which was finished today. Should get it published in the next week or so. After that it would be the CNC build but there might be a bit of a delay whilst I try and get some sponsorship from my suppliers.

    I was not expecting to get the whole machine finished until 2019, but progress has been faster than expected so there will probably be a working prototype in the Spring 2018 for 'Proof of Concept'.

    I’m super impressed! I’d be interested to pick your brain on some work I’ll bedoing in the Amazon.

    1 reply

    "If you get lost in a thick jungle or underground car park you're stuffed!"

    With a compass or any sort you still have to know where you are in the jungle or garage in order to make use of said compass. Doesn't do much good to know where north is if you don't know which direction you need to travel!

    7 replies

    That's probably why there is a GPS and a digital compass in this project.

    I'm not sure why a digital compass is included. A digital compass still operates off magnetism and can unless very closely calibrated at the site of use could easily be off 10-15 degrees. Even calibrated it has a accuracy level far less than the gps. It won't help.

    Even using 3 orbital satellites and 1 in the field the accuracy is about 5 cm. or 2 in. Usually errors in this type of electronics are cumulative. So if the machine is 1 meter wide and the field is 100 by 100 meters, there could be a cumulative error of 100 x 5cm or 500 cm without run time correction. The error whatever it is will not correct itself. It won't be plus one time and negative the next.

    A digital compass cannot provide any correction. And real time corrections will have to be made. Also if the field is not prepared and very level and flat, the cultivation dept will vary.

    A truly autonomous tractor is many times harder to build than an autonomous car. The big 500 hp. tractors than pull 40-50 foot discs are not completely autonomous. They have an operator in the cab that makes small corrections. All the errors in a car can be corrected by optics and radar.

    Another thing to consider is that the GPS systems are either Russian or USA, and in both cases are subject to military priority. Any other country is using a GPS system they have no control over.

    Any system that is used in a small area would probably be easier to build and far more accurate using in field radar reflectors. There is actually no reason to use GPS for this device. A radar unit on the small tractor and several reflectors could be made with the accuracy of a fraction of the wavelength of the radar frequency. Very small error.


    Thanks for the tips. I'll need to repeat my tests with the base station 100 metres away from the rover and see if there is any extra error. Obviously, if it was 10,000 metres away the environmental conditions such as cloud and humidity would be different so there would then be more error.

    Radar sounds like a good idea and I did look into it briefly. I don't think it's so easy to get an 'Out of the Box' solution as with GPS / GNSS. I'm sure that if WW3 breaks out then all the satellites will go offline, but until then I think I'll carry on using them!

    If the Weedinator is placed in a field and there is no history in the database it will have no idea which way it is pointing without a compass and would have to travel forwards in an arbitrary direction before it got a heading. Mind you, that distance would probably only have to be about 500 mm or less so it's no big deal.

    With the compass you'll know which was is north, but without any history as you said, it is still lost. A compass can't tell where it is located. Without gps or a map (or history) the location is not known no matter how far one moves. The line the machine or you moves along could be anywhere. With a compass one has to know where one is to go where one wants.

    I guess the compass could be used to check that the history is still relevant.

    If you know you are south of the river, north gets you there!

    I used to be a software engineer for a company that was the first to make GPS guidance systems for crop dusters spraying swaths across fields. We used exactly the method you describe: a fixed base station broadcasting "drift" error corrections to the GPS systems in aircraft in the area. We were able to get accuracies to about 30 cm*, whereas uncorrected GPS is only accurate to 15m or so, depending on the geometry of the visible satellites at the time. The GPS boards we used gave readings 5 or 10 times per second; necessary in an aircraft traveling 120 MPH. Considering the math involved, this always amazes me.

    ----------------------------
    * This was in the 1990s, when the military still had Selective Availibity (spoofing) turned on for the civilian GPS signals to limit their accuracy to 100m. The Government turned SA off in 2000 as civilian applications such as aircraft and marine navigation became more common and demanded better accuracy. Techniques such as differential which corrected the SA and natural "errors" was a factor in the military's decision as well.

    1 reply

    I did an automonous boat for a lab in my university and we added an inertial measurement unit and a kalman filter to improve the acuracy

    1 reply

    I think this is what the RTK (Real Time Kinetics) does in the Ublox MCU.

    The more this project advances, the more I think you're secretly building a troyan horse mars-rover, in fact. Are you sure this rover is actually weed-related? I think you're also building a rocket to launch this thing to outer space in search of cabbage-big diamonds. I'm right, no?

    1 reply

    Yes .... You are absolutely ..... I'm secretly planning to colonise Mars and build a large 5 star hotel for future travellers. There will be a 'Low Gravity' golf course as well.

    what exactly dose the weedinator do