Home Contents Start Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Next

Telemetry

I'm going to be testing Moana in a field so the days of watching a robot trundle around a garden are long gone. It may be the mower will head off to a GPS waypoint 50 metres away. It is therefore important to have some form of wireless communication with the mower to understand what it is doing. The ability to send it commands will be very useful as chasing it around a field may be rather too time consuming!

There are a few technologies available but it comes down to a choice of High Power Bluetooth or standard radio. High Power Bluetooth gives a range of about 100 metres which may be adequate although radio can outstrip this. XBee Series1 come with ranges of 300ft or 1 mile so it gives some options for upgrading if necessary. Having built projects with both technologies, I will opt for radio, especially as I have a couple of XBee radios to hand.

Using the standard arduino serial port will allow log statements to be transmitted back to a laptop with an associated XBee dongle. Reprogramming can be achieved by switching out the XBee as needed. I remember having to do this with Sandbot II. There are three other serial ports that are available on the Mega2560, and one will be used for a GPS communication channel. Its fantastic to have so many resources!

So lets get to it.

XBee Modules

XBees come in various flavours, but broadly are Series 1 or Series 2 devices. Series1 are simple point-to-point (effectively wireless UARTS) while Series2 are useful in mesh networks. I need Series 1.

Series 1 devices come in low power (1mW) and high power (60mW) versions. The 1mW devices give about 300ft range and the higher power devices give a mile. They are plug in replaceable so I am going to start with the low power devices (as I have some) and upgrade to the 'Pro' devices if I need to

Low power Series 1 XBee

High Power Series 1 XBee (Pro)

XBee Configuration

The Series 1 devices work more-or-less out of the box. The XBee is quite a neat device and you can do a lot with one without needing a microcontroller. In my case, I just want to use it as a two way wireless serial link to the robot so there is not much to configure. Two things you do need are provided free by Digi who manufacture the device:

  • The X-CTU Xbee configuration software
  • An FTDI driver for an XBee breakout board

XBee Driver and X-CTU downloads

I reasoned that I will communicate with the mower through a laptop. This allows the use of the Arduino Serial monitor and/or a custom python/Java program. To do that I needed an explorer board like this or this to connect to a laptop

Basic Setup

  • Download and install the FTDI driver.
  • Download and install the X-CTU software. The Mac version asked to install Java6 which is pretty ancient so I abandoned and moved to windows
  • Plug in the XBee to the explorer board and connect to the laptop.
  • Run the X-CTU software. I used auto-detect and loaded the config for the XBee and have a look.
  • Unplug and repeat for the other Xbee. They should use the same panid

xbeeExplorer

Now it is ok to do all the config setup in X-CTU and there is nothing wrong with that. Since I will be connecting via serial ports, I decided to approach this old-school so I could test my serial connections out so I pulled out CoolTerm, which is a serial communication program and used this to connect to the explorer board with an XBee plugged in. There are a few things that need setting up to ensure the two modules can talk:

  • Both modules must have the same PANID
  • Each module must have its own address.
  • Each module must have a destination address.
  • The two modules need to know each others address as a destination address.

At this stage, both XBees should be running at 9600 baud and use the default serial parameters. These match those on Coolterm so it was possible to connect to them. The coolterm terminal was setup to use and local echo. Here is how I configured one of them using AT commands

+++
ATID5555\r
ATMY1357\r
ATDH0\r
ATDL2468\r
ATWR\r

I repeated this for the other XBee but transposed the values in the myAddress and DestLow address so we ended up with this:

xbee panid myid destidH destidL
1 5555 1357 0 2468
2 5555 2468 0 1357

For now I will leave the baud rate alone and get things talking. When we have a solid communication channel, it will be possible to increase the baud rate if necessary.

Serial Communications

The Arduino is programmed via the UART on pins 0 (Arduino Rx) and 1 (Arduino Tx). This is the same on both the Uno and the Mega. The Serial Monitor also sends logging output through this interface. The aim is to insert XBees in this data path to allow a two-way wireless communication protocol. This achieves the primary objective of being able to remotely monitor the robots log output on the computer, and secondly, to allow commands to be sent to the robot to change its behaviour.

One snafu is that the Xbee can interfere with the programming of the Arduino. To overcome this, the Sparkfun Xbee shield has a two way switch. In one positions (DLINE) it disconnects the Xbee and allows direct connection to the USB port allowing unhindered programming. After programming, it can be changed to the UART position to connect the arduino pins back to the Xbee. I've been here before, it saves a lot of grief having a simple switch!

To send a log output through the Xbee back to the computer is no different to logging normally

Serial.print("log without a linefeed");
Serial.println("log with a linefeed");

To read from the serial port, we do something like this:

if (serial.available() > 0) {
  char val = Serial.read();
}

After testing on a Uno, the shield was added to the mower, the Arduino programmed and then the switch moved to the UART position. CoolTerm was run and connected to the Xbee explorer board. Once the mower was up and running, log lines appeared in the CoolTerm window. We have telemetry!

xbeeShield

A simple test was made to send data from the computer to the mower and the result was displayed in the terminal window that confirmed the data was received. This was a simple test and will be fleshed out later if needed, for now I am more interested in the telemetry from the mower back to the computer.

The basics of locomotion and telemetry are now complete. The bump switches (and a sonar range finder) need to be added soon. However, the next thing to tackle will be adding a digital compass as the bearing will be used in a feedback loop to control the steering. This will be my first experiment at mowing in straight lines.


March 2018


Home Contents Start Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Next