Close

Control Panel Getting Populated

A project log for WEEDINATOR 2017

An autonomous roving CNC weeding/cultivating machine guided by GPS and coloured markers.

capt-flatus-oflahertyCapt. Flatus O'Flaherty ☠ 12/01/2017 at 12:532 Comments

The PCBs arrived from Elecrow, China, and immediately became populated by a vast array of SMT LEDs, Zero ohm jumpers and some capacitors for the linear voltage regulators. Strangely, at least so far, there are no mistakes in the PCB design!

The overall design is based on a master and slaves system with the master being and Arduino Due and most of the slaves Arduino Nanos, all communicating through the I2C protocol. The Ublox GPS Rover module (lower right) spits out NMEA satellite data every second to be captured through the serial1 port on a "Pro Micro" (not shown). The data can then be processed into headings and distances and accessed whenever the Master requires it by polling the slave via I2C.

Some of the components on the board are 3v and others 5v so care has been taken to make sure the I2C bus from the Due to the Nanos goes through a level shifter, which is bolted onto the back of the PCB. The Ublox is 3v and outputs serial directly to the 3v Pro micro, which in turn connects directly to the 3v Due via the I2C bus.

My I2C code has been vastly improved by turning all the data into characters, which are much easier to manipulate on the 8 bit system than trying to manipulate integers and floats directly. Here's a snippet of the Master code:

void loop(void) 
{
  characterCompile();
  introText();
  Wire1.beginTransmission(26); // transmit to device #26
  Wire1.write("Important number: ");        // sends 21 bytes
  Wire1.write(url);              // sends one byte  
  //delay(100);
  Wire1.endTransmission();    // stop transmitting
  x++;
  delay(100);
}
void characterCompile()
{
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////        BME280Temperature
// This is where the data is compiled into a character ....
  dataString =  initiator + x ;
  int n = dataString.length();
//  Serial.print("Data string to send:     ");Serial.println(dataString);   
//  Serial.print("Size of string:  ");Serial.println(n);
  // Builds the url character:
      for (int aa=0;aa<=n;aa++)                                              
      {
          url[aa] = dataString[aa];
      }
  Serial.print("Character data to send:  ");Serial.println(url);
  Serial.println("");
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////  
}

And here's the Slave code:

#include <Wire.h>
long result=0;
char c[100];
String y;
String w;
String a;
String b;
String triggerWord = "Important";

void setup() {
  Wire.begin(26);                 // join i2c bus with address #8
  Wire.onReceive(receiveEvent);   // register event
  Serial.begin(115200);           // start serial for output
}
void loop() 
{
  delay(100);
}
// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany) 
{
  int i=0;
  y="";
  a="";
  b="";
  while ( Wire.available())
  { 
    char c = Wire.read();     // receive byte as a character
    if (isAlpha(c))           // analyse c for letters
    {
      a=a+c;
      if (a==triggerWord)
      {
        b=a;
        Serial.print("Trigger word detected!: ");Serial.println(b);
      } 
    }
    if (isDigit(c))       // analyse c for numerical digit
    {
      y=y+c;            // string = string + character
    }
    i++;
  }
    w=y;                  // string w = string y
    if (b==triggerWord)
    {
      result=(w).toInt();
      Serial.print("Resultant integer: ");Serial.println(result);
    }
    if (b!=triggerWord)
    {
      Serial.println("Nothing detected");
    }
    Serial.println("");
}

 There's still quite a lot of work to do, for example setting up the GPRS link to a database on the interweb, but nothing too tricky. The only aspect of the project that I have not previous experience is the object recognition ....... That's a challenge to look forward to!

Discussions

Capt. Flatus O'Flaherty ☠ wrote 12/02/2017 at 12:30 point

Thanks! I researched a few alternatives but having a "Base" and "Rover" config seemed to be the way to go.

  Are you sure? yes | no

Ulysse wrote 12/01/2017 at 13:32 point

The Ublox C94-M8P RTK is a good product. Good choice

  Are you sure? yes | no