Author: | Dima Diall & Dmitrios Airantzis |
---|---|
Organization: | Proboscis & Birkbeck College |
Date: | 10 March 2006 |
Version: | 1.1 |
Abstract
This report provides technical documentation for a prototype mobile environmental sensor that integrates with the Urban Tapestries public authoring system -- the Feral Robot, version 2. Descriptions of the main requirements, as well as the steps in the hardware/software platform development are presented.
In the context of the Urban Tapestries (UT) project, Proboscis in collaboration with Birkbeck College developed a mobile sensor prototype -- dubbed "feral robot" -- capable of wirelessly uploading real-time, geo-referenced environmental data into the UT public authoring servers. Interested parties can visualize the collected data (e.g. air quality, etc) overlaid on a geographical map.
The first generation feral robot, developed by Natalie Jeremijenko, adopted an autonomous behaviour, roaming in the direction where the on-board sensor detected greater pollution concentration. However, this original system was based on a very simple microcontroller (PIC) that is unlikely to support real-time data communication using modern wireless networking technologies, thus making it unsuitable for integration with the UT public authoring framework.
For the second generation feral robot, documented in this report, due to time and funding constraints a key simplification to the requirements was defined to complete a working proof of concept: the autonomous mobility feature was sacrificed. The system was, instead, simply mounted on a remotely controlled all-terrain vehicle, without any interfacing to the car's control module.
The basic requirements outlined for the system prototype were defined as follows:
Regarding the wireless communication between the mobile sensor system and the UT server systems, for prototyping purposes wi-fi (IEEE 802.11) was selected due to common software support available under GNU/Linux. Also, wi-fi internet access was within easy reach from the target demonstration workshop location through mesh networking. Nevertheless, other wireless networking technologies could be employed, such as GSM/GPRS, etc.
The feral robots fit into a similar client/server paradigm underpinning other applications within the UT public authoring system. One or more feral robots act as clients sending real-time data to a UT server. These geo-referenced, environmental data is written to a database for later retrieval via a web interface.
A very simple UDP-based protocol was devised for communication between the feral robots and the UT server. Basically the clients are programmed to periodically sample their sensors and the GPS receiver and, for each reading, packages the data into a UDP datagram, that is then sent to the server. The protocol, in its version 1, defines a packet structure with the following data fields (details in appendix Packet Format):
More details about the Feral Robots sub-project can be found at the following website: http://socialtapestries.net/feralrobot/
This reports attempts to describe the feral robot prototype with sufficient technical detail to enable its reproduction and/or adaptation for similar types of application.
The remainder of this report assumes that the reader has at least some degree of familiarity in system administration and programming on GNU/Linux (or other UNIX-based) environments. Furthermore, experience with computer hardware in general is required, as well as an understanding of basic concepts of electricity and electronics.
Finally, documentation for the hardware and/or software involved must be referred to on an as needed basis, including but not limited to product datasheets, user guides, technical manuals, etc.
This chapter outlines the hardware components used to build this second generation feral robot prototype. Initially, several alternative hardware platforms were considered to host the client software, as documented in an earlier report where more details on the rationale are available.
The gumstix platform -- which includes a customized GNU/Linux distribution with out-of-the-box support for its hardware features -- was selected as the cornerstone to assemble this prototype. A summary of the hardware setup follows:
The following sections provide further detail on the main hardware components, focussing mainly on the actual prototype developed. Most of design decisions were constrained not only by time and budget, but also by reasons of practicality and ease of implementation of this proof of concept. Naturally, many aspects can and must be adjusted or changed altogether to meet the requirements of a specific target application -- some of these possibilities are pointed out throughout the text.
The following stack of gumstix boards was used in this prototype [1]:
[1] | Commercial information about gumstix products is available at http://gumstix.com, while technical details are shared on the user community website at http://gumstix.org/tikiwiki. |
The gumstix connex board sits the middle of the stack, connecting to the robostix via the 60-pin Hirose I/O header on one side, and to the netCF via the 92-pin bus header, on the opposite side.
The high-end connex 400xm-bt platform was selected to offer more flexibility during development and prototyping, chiefly in terms of more flash memory for troubleshooting tools and support for using a bluetooth GPS receiver (more details below). Alternative platforms, slower and with less flash memory (e.g. connex 400-bt model with only 4MB of flash), can also be employed by sacrificing some extra software packages (discussed further in the section Gumstix Linux). It must be also noted that the XScale processor's (successor of ARM) can be adjusted to lower clock frequencies (e.g. 200 or 100 MHz) to consume less power.
The robostix runs independently from the main gumstix board, with dissimilar processors: AVR Atmega128 and Intel XScale, respectively. To enable exchange of data between programs running on the two boards, both were interconnected through one of their serial ports: UART0 on the robostix, and STUART on the gumstix. The figure below illustrates which pins on the robostix header need to be connected:
The netCF board was chosen to enable using both, ethernet and wi-fi networks during development and testing. Alternatively, the much cheaper cfstix board can be used if only wi-fi networking is required.
Other gumstix components were used during development, namely the tweener board to provide serial console access, a corresponding null-modem cable (with mini-DIN and DB-9 connectors) and a 5V power supply. However, the use of a dedicated circuit board in the final setup eliminates the need for these elements.
This section briefly describes other relevant components to the prototype's hardware setup.
The CompactFlash wi-fi interface used was the Netgear MA701 -- now discontinued --, which is the only one "officially" supported. Nevertheless, it should still be possible to procure them through eBay or similar websites.
Other gumstix customers also reported success with different cards, such as Belkin F5D6060 and AmbiCom WL1100-CF. During the first weeks of this project there were attempts to provide support for the Symbol Spectrum24 card using the Linux ORiNOCO driver, but without success in the amount of time available (more in Feral Robot Buildroot Branch).
The choice to use a bluetooth GPS receiver, was based mainly on the fact that two such units were available to the the project at its very outset. These are portable devices with independent battery power, providing NMEA-compliant positioning data over a bluetooth communication interface.
Other types of GPS receiver could be attached to the system via a serial port (e.g. HWUART) and powered from same circuit board. The gpsd software (see Feral Robot Buildroot Branch) used to access GPS positioning data can be configured to support various formats, so non-NMEA receivers can be used too.
Two Figaro sensors were used in this prototype:
Obviously, the choice of sensors will depend on the type of pollutants to be detected or measured in each case. Up to 8 different inputs can be attached in this prototype's setup.
A custom electronic circuit board (10x16cm) was developed in order to underpin all others components of the prototype (further information about design and layout provided in Circuit Details). The purpose of this support circuit board is to:
The robostix is screwed to the circuit board, and the whole gumstix stack (robostix + connex + netCF) is carefully secured with two extra-fine plastic tie-wraps, one on each end. The bluetooth "rubber duck" antenna is secured using reusable adhesive material (i.e. Blu-Tack).
The sensors' output pins, as well as the gumstix's input voltage and battery voltage are wired to the robostix's ADC channels. Each of these can be routed through a potentiometer so that, if needed, the voltage is decreased by an adjustable factor to fit into input range of the ADC (0.0 to 5.0V). Software running on the ATmega128 microcontroller can obtain readings of the voltage level present on each ADC channel in digitized form, integers in the range 0 to 1024 (2^10, as ADC has 10-bit resolution). The table below summarizes the setup of the 8 ADC channels:
Ch# | Description | Range | Pot. Factor | Adjusted | Notes |
---|---|---|---|---|---|
0 | Input voltage | 0.0-5.0V | 1/1 | 0.0-5.0V | Acceptable: 3.4 - 5.0V |
1 | Battery voltage | 0.0-9.8V | 1/2 | 0.0-4.9V | Charged: 9.8V; Low: 8.4V |
2 | Carbon dioxide | 0.0-3.0V | 1/1 | 0.0-3.0V | Equivalence: 0 - 3,000 ppm |
3 | Air quality | 0.7-2.5V | N/A | 0.7-2.5V | Low value = better quality |
4 | N/A | N/A | N/A | N/A | |
5 | N/A | N/A | N/A | N/A | |
6 | N/A | N/A | N/A | N/A | |
7 | N/A | N/A | N/A | N/A |
Moreover, the gumstix serial console is brought out on a 4-pin header of the robostix. The TX/RX pins were routed through a standard TTL to RS232 level signal converter and finally connected to a DB-9 port, thus enabling easy access to the Linux console using a null-modem cable and serial terminal emulation software.
Both, the gumstix system and sensor modules are powered through the circuit board, that can be connected to a standard 12V DC power supply and/or batteries. The circuit is designed to charge the rechargeable batteries if they are plugged in whilst receiving power from mains supply.
Given the prototype system's power requirements (gumstix stack, wi-fi card and two sensor modules) a battery pack was built using 7 rechargeable 1.2V AA batteries and an 8-battery holder (with one of the slots shorted). The current draw was measured at an average of 800mA on a running system, so using 2000mAh battery cells which gives about two hours of operation.
The circuit board hosting the gumstix system was packaged into a 17x12x5cm plastic box. One of the side walls was cut out to expose the DB-9 console port and the power supply input jack. Three other holes were made to drive out the wires of the battery pack and the two sensors.
The roof of the R/C vehicle was drilled to mount the box with four long screws. The battery pack was fastened to the back of the vehicle using strong adhesive tape. The sensor modules were protected inside plastic bags, with the a small opening to expose the sensing element, and fixed to the in the front of the vehicle using reusable adhesive material.
This chapter describes the software environment used to support the feral robot prototype, both in terms of the underlying operating system (GNU/Linux for the gumstix platform) and the actual client application implementing the feral robot behaviour (sensing, reading GPS, sending data to server).
The first part deals with cross-compiling the software and setting up the operating system for the gumstix computers. The second part looks at the implementation of the feral robot client software.
The gumstix hardware platform is supported by customized GNU/Linux distribution based on the Buildroot system -- "a set of Makefiles and patches that makes it easy generate a cross-compilation toolchain and root filesystem for [a] target Linux system using the uClibc C library" -- and the U-Boot boot-loader. The evolution of the gumstix distribution (or buildroot) is maintained under version control with Subversion, and the repository is hosted at http://svn.gumstix.com.
To develop applications for gumstix platforms it is recommended to use a Linux-based host system with a fully-featured GNU software development environment properly set up (autoconf, make, gcc, etc), including the Subversion tools (svn, etc). Alternatively, Microsoft Windows with COLINUX can be used as host system for gumstix development. The host must be connected to the Internet in order to interact with the Subversion repository and download software packages during the build process.
There are several ways to gain command-line access the GNU/Linux system on a gumstix, but the most powerful (as it also allows access to the boot-loader) and failsafe is usually via the serial console. For this, the host computer must be connected to the gumstix's serial console port with a null-modem cable. The default parameters for the serial terminal emulator on the host should be the following: 115200 bps, no parity, 8 data bits and without flow-control.
More details about programming and building gumstix systems is available at the community website and technical support can be obtained through the user community mailing list.
The main development trunk in the gumstix Subversion repository contains the latest version of the generic default buildroot to generate a GNU/Linux operating system image suitable for installation on gumstix devices. The following command would to check out the latest gumstix buildroot into the gumstix-buildroot/ sub-directory:
svn co http://svn.gumstix.com/gumstix-buildroot/trunk gumstix-buildroot
The next sequence of commands would build the cross-compilation toolchain (basically gcc for the ARM processor architecture), compile the GNU/Linux operating system and applications and, finally, package it into a root filesystem ready to install on the gumstix hardware:
cd gumstix-buildroot make
If all goes well, gumstix-buildroot/ will contain the following items [2]:
[2] | Based on information from http://www.gumstix.org/tikiwiki/tiki-index.php?page=buildroot |
Besides the main gumstix buildroot development trunk, a structure is defined in the Subversion repository for branching different buildroot configurations to meet or implement a specific project's requirements. Several branches can coexist in the repository and be developed independently in parallel, while changes can be merged back and forth between branches or the main trunk.
For this prototype such a branch was created on the gumstix hosted Subversion, not only to track modifications to the custom buildroot's configuration, but mainly to ease the process importing bug-fixes or new features developed in the main trunk (after the has branching occurred). So to download [3] and build a working copy of this customized "Feral Robot" buildroot branch, including extra software for the robostix board (further described in Robostix ADC), the following sequence of commands must be issued:
mkdir feral-robot cd feral-robot svn co http://svn.gumstix.com/gumstix-buildroot/branches/users/ddiall/robostix robostix svn co http://svn.gumstix.com/gumstix-buildroot/branches/users/ddiall/feral-robot \ gumstix-buildroot cd gumstix-buildroot make
[3] | To work around any potential problem with gumstix's Subversion repository, a snapshot of the feral robot branch is available at http://socialtapestries.net/feralrobots/software/gumstix (revision 853, at the time of this writing). |
The structure of the buildroot system was described in greater detail in the previous section. The full range of changes to the standard gumstix buildroot can be scrutinized using svn log, but below are summarized the main additions or modifications to produce a root filesystem image tailored for this feral robot prototype:
Welcome to Gumstix, implementing the Urban Tapestries FERAL ROBOT! ========================================================================== Do not forget to change the root password with the 'passwd' command. Change the hostname in /etc/hostname and update /etc/hosts accordingly. Set up the ESSID in /etc/pcmcia/wireless.opts to match the wifi network. If there is no DHCP server, set IP for 'wlan0' in /etc/network/interfaces. Update NTPSERVER in /etc/init.d/ntp to address of the local time server. Adjust the /etc/init.d/gps script to set-up the connection to the GPS receiver (set receiver's bluetooth MAC address in the variable GPS_BTADDR). In /etc/init.d/utrobot, set UT_SERVER to the Feral Robot server address and NET_IF to the interface name to be used as the robot id (MAC address). Rename the file s99local in /etc/init.d/ to S99local (notice capital 'S'). [This information is stored in /etc/motd, which can be deleted afterwards.]
The current feral robot buildroot configuration produces a root filesystem image of roughly 5MB. Non-mandatory items in the main Makefile are marked with the comment "OPTIONAL", therefore it should be safe to exclude from the root filesystem to conserve space in the gumstix flash memory.
[4] | It is probably worth trying to compile the ORiNOCO driver with the latest Linux kernel version (2.6.14) now included in the mainstream gumstix buildroot. |
A new software image (root filesystem) can be loaded onto a gumstix computer by accessing its boot-loader via the serial console and using the Kermit file transfer protocol.
The sequence below illustrates the commands necessary to transfer a root filesystem image to U-Boot and then commit it to the gumstix flash memory [5]. It is assumed that the host is connected to the console via port /dev/ttyUSB0 and a terminal emulator is used, such as kermit, with the correct parameters (115200,n,8). The symbol $ represents the host's shell prompt, and > the kermit prompt:
$ kermit -l /dev/ttyUSB0 > set carrier-watch off > set speed 115200 > set reliable > connect
The above commands should connect to the gumstix console with the right setup. Once connected to the console, the user can interrupt U-Boot by pressing a key during a (default) 2-second delay, before the Linux boot process is started (reset power to gumstix if necessary). The U-Boot prompt, GUM>, should appear:
GUM> loadb a2000000
After entering the above command, U-Boot is waiting from the transfer to begin. Type the sequence "CTRL-\ c" to return to to kermit and then the following (replacing /path/to/ with the correct location of root_fs_arm_nofpu):
> robust > send /path/to/root_fs_arm_nofpu
This will start the transfer; after it is completed with success, reconnect to U-Boot and enter the commands below to erase everything except U-Boot itself (protected), copy the transferred software image to flash and boot the with the new root filesystem:
> connect GUM> protect on 1:0-1 GUM> jerase all GUM> cp.b a2000000 40000 ${filesize} GUM> boot
[5] | Based on information from http://www.gumstix.org/tikiwiki/tiki-index.php?page=tutorial |
There is no analog to digital conversion (ADC) capability directly available on the main gumstix processor board. Thus, the robostix add-on board was used in this prototype, due to the ADC functionality present in its AVR ATmega128 microcontroller.
As described earlier, the gumstix and robostix boards are interconnected via their serial ports -- STUART (/dev/ttyS2) and UART0, respectively -- making data exchange between software running on both processors possible. This feature is exploited to give the feral robot client application (running on gumstix) access to sensors attached to any ADC channels of the robostix.
Basically, the communication protocol on the robostix side consists of waiting for incoming ASCII characters on UART0, that represent ADC channel numbers (from '0' to '7'), and responding with the current voltage value on that ADC channel, in hexadecimal format encoded as an ASCII string (e.g. "0x03f9"). On the robostix's ATmega128 this function is implemented with an endless loop in a C program, named Read-ADC.
This program and other software for robostix can be downloaded from the gumstix repository [6] as was shown in Feral Robot Buildroot Branch (robostix/ sub-directory of feral-robot/ in the example procedure). To compile Read-ADC for the robostix an appropriate cross-compiler, such as avr-gcc, must be installed on the host computer:
cd feral-robot/robostix/Read-ADC make
After compilation, the resulting Read-ADC.hex file must be programmed (i.e. flashed) to robostix's ATmega128. Several possible methods to program microcontrollers of the AVR family do exist, and the ones applicable to robostix, are described at http://gumstix.org/tikiwiki...
However, in this case the most straightforward way of doing this is to take advantage of the gumstix/robostix serial interconnection setup to perform in-system programming (ISP) of the software image, directly from the GNU/Linux system running on the gumstix. First, the .hex image file must be transferred from the host computer to the gumstix by console (Kermit) or network (SSH), and then (on the gumstix) use the uisp command-line tool:
uisp --wr_fuse_l=0xbf --wr_fuse_h=0xc9 --wr_fuse_e=0xff uisp --erase --upload if=Read-ADC.hex
[6] | The branch http://svn.gumstix.com/gumstix-buildroot/branches/users/ddiall/robostix was copied from http://svn.gumstix.com/gumstix-buildroot/branches/projects/robostix. The Read-ADC/ sub-directory was added and gumstix/ (which contains scripts and drivers) was tweaked to be compiled from within the buildroot. |
The utrobot application forms the core of the current feral robot behaviour -- sampling its attached environmental sensors, reading the GPS position and sending data to the UT server.
The package, hosted at http://socialtapestries.net/feralrobots/software/utrobot-1.0.tar.gz, is automatically downloaded and cross-compiled as part of the feral robot buildroot (by the make/utrobot.mk sub-makefile, see Feral Robot Buildroot Branch).
This application requires TCP/IP access to an active GPS daemon (gpsd), either running locally (default) or over a network connection. Also the serial port of the robostix may have to be specified to access the sensors. Finally, the robot id (MAC address) and remote UT server address must be specified on the command-line -- on the gumstix this is done by a wrapper script.
For reference, below is presented the application's embedded usage instructions:
Usage: utrobot -i hwaddr -u addr[:port] [-g addr[:port]] [-a serial_port] [-ldvh] -i hwaddr Robot id as MAC address (6 bytes in hex) -u addr[:port] UT server (default port: 1979) -g addr[:port] GPSD server (default: 127.0.0.1:2947) -a serial_port Serial port for ADC access (default: /dev/ttyS2) -l Log sensor data to standard output (stdout) -v Print extra information (on stderr) -d Print debugging information (on stderr) -V Show version, then exit -h Show this help message, then exit More information on Feral Robots at http://socialtapestries.net/feralrobots/
The source code for utrobot relies on GNU's autotools for its build system to enhance portability across platforms. The compilation of this package is similar to that of other common open source projects and, besides a standard Unix environment, only requires the gpsd access libraries and header files:
gunzip -C utrobot-1.0.tar.gz | tar xvf - cd utrobot-1.0 ./configure make
The main modules of C code in the utrobot application are briefly described below (refer to source code for further information):
The client/server communication protocol uses the UDP transport over IP, and the Urban Tapestries server listens on port 1979 by default. The following fields are specified in packet format (version 1):
Field | Size | Notes |
---|---|---|
Version | 4 bits | Protocol version, must be 1 |
GPS fix | 1 bit | Whether GPS has a fix (i.e. positioning data is valid) |
[Reserved] | 11 bits | Reserved for use in future versions |
Robot id | 6 bytes | Standard network interface MAC address |
Latitude | 4 bytes | Network byte-ordered IEEE-754 float |
Longitude | 4 bytes | Network byte-ordered IEEE-754 float |
Timestamp | 4 bytes | Network byte-ordered long, with Unix timestamp (seconds) |
Sensor type | 4 bytes | Type defined in UT database (ASCII string) |
Sensor value | 4 bytes | Network byte-ordered IEEE-754 float |
A set of Gerber files [7] suitable for producing printed circuit boards (PCB) are available for download from http://socialtapestries.net/feralrobots/docs/. Below is presented a snapshot of the circuit's layout:
During the prototyping phase, it was deemed to be more flexible to experiment with the various possibilities of the circuit on a general purpose strip board. The design options were as follows:
1. Provide power to the gusmtix stack assembly
The processor board and its peripherals required a clean 5V supply in order to feed their internal 3.3V regulators. It was not clear how much current would be required though. Experimentation with the prototype showed that a current of 800mA would be required. This meant that the use of a switch mode power supply circuit would not be necessary as its linear alternative was much simpler and lower cost to implement. In practice the line regulation provided was satisfactory, but the solution lead to two problems: the regulator generated a lot of heat, and the internal Hirose connector provided a rather high impedance path to the supply current.
The large amount of heat generated was dealt with the choice of a bigger heatsink. A heatsink with a thermal resistance of 3.7 degrees per dissipated watt was finally chosen, thus ensuring the reliable operation of the circuit beyond the winter months.
The relatively high impedance of the Hirose connector manifested itself through unexpected resets occuring during the power-up sequence of the wi-fi card. A sudden drop to the overall supply voltage activated the reset circuit of the processor. The solution to the problem was to distribute the current to the power hungry parts of the assembly via an external wire. In this way, the supply by-passed the Hirose connector and the voltage drop was minimised.
2. Provide power to the sensors
Power to the sensors was provided by a second linear regulator. Because the overall power consumption was within the limits of the regulator (less than 1A), the same heat dissipation solution was applied as in the case a, above. A fuse was provided towards the sensor boards in order to avoid any problems that might have been caused by a short circuit occuring on the external load.
3. Charge and maintain the battery cells
The choice of batteries was rather limited to NiMH cells due to their good performance/price ratio. Their weight was not an issue so Li-based options were ruled out. A constant current source providing charging current to 1/10 of the capacity was formed. Their capacity (2000mAh) would provide enough charge for a significant number of readings to be sent to the server, but would not provide the necessary power for the sensor warm-up period. The circuit would have to be powered by the external wall transformer during that period. A fuse was included towards the battery connection so as to protect both the battery and the PCB from any potential short circuits.
4. Provide serial console access to the gumstix system
The robostix brings out the gumstix console port on a 4-pin header. This port is a TTL level signal, so a standard TTL to RS232 level signal translator was used. No special protection was built into the circuit as the console port was expected to be connected directly to the PC within a rather well protected environment.
5. Form the mechanical host of the gumstix stack
The overall mechanical assembly of the heatsinks, the terminal block connectors and the processor boards was quite heavy. A final choice of epoxy glass pcb was made in order to cope with the weight.
Although, simple tie-wraps were used to secure the gumstix stack, a better alternative would be to make proper spacers, such as the design described at:
http://www.davehylands.com/Machinist/Projects/Gumstix-Spacer
[7] | Various Gerber viewers are available for download on the Internet free of charge. |