Quadrino GPS on Linux
Total Page:16
File Type:pdf, Size:1020Kb
Quadrino GPS Integrators Guide Robotshop.com FlyingEinstein.com The QuadrinoGPS can be purchased from RobotShop.ca at: http://www.robotshop.com/ca/en/flyingeinstein-gps-quadrino.html The QuadrinoGPS can communicate with any host that supports I2C. This guide explains how to connect to three popular embedded hosts: Arduino Raspberry Pi (RPi3) BeagleBoard Black (BBB) Table of Contents Preface TL;DR version Quick Facts My Personal Favorite >>> Files <<< Connecting to an Arduino Alternative wiring to Arduino Nano using the ICSP header. This alternative wiring is valid for RaspberryPi, BeagleBone and other embedded boards as well. Quadrino GPS on Linux Wiring to Raspberry Pi Wiring to BeagleBone Black Installing the Linux I2C tools and developer libs (RPi) Re-configure the raspberry to enable i2c: (RPi) Checking QuadrinoGPS electrical connection QuadrinoGPS on Linux from Scratch (...if you absolutely must) Comparison Between Boards for Source Builds Raspberry PI BeagleBone Black Other Embedded Boards Retrieving the current kernel configuration Compiling the QuadrinoGPS I2C client driver Configuring the QuadrinoGPS client driver on the I2C bus Using the /sys interface Configuring the driver to load at boot time Testing the QuadrinoGPS client driver Installing the GPSD tools GPSD Clients Configuring GPSD (GPS device & listen on all interfaces) Appendix A Command Log for preparing RaspberryPi image Appendix B Command Log for preparing BeagleBone Black image Appendix C Updating the Firmware on the QuadrinoGPS Flashing Firmware Preface This document is available online as a Google Doc at http://tinyurl.com/quadrinogps. This was done so you will always have the latest updates to the document and you are welcome to add feedback via comments which will be read by the authors and used to improve this document. Please, help us make this document better for the community! TL;DR version Arduino: You’re only a few steps away, review the Arduino wiring diagram and download the sample sketches. Upload a sketch and start the Arduino Serial Monitor. Linux: Download pre-made SD images for your linux board and burn to a new SD card and enjoy...you’re good as a crunchy roll with any GPSd client (including Windows). Otherwise, be ready to build a linux kernel, driver source, and RTFM! So grab some beer, send your wife to the day spa. TL;DR won’t work for you, this document is now your best friend. ;-) (You’re a woman? No worries. Give the man the beer, grab your favorite wobbly pop.) Quick Facts If you’re a seasoned developer you may just be interested in the following facts: ● Logs to SD card if present, LED startup sequence indicates SD card status. SD card must be formatted as FAT16 or FAT32 filesystem. ● GPS listens at I2C address 0x20 (7bit) and supports “repeated starts”. ● Read the 0x00 register for status information such as 2D/3D fix and number of satellites ● For location read two 32bit integers starting at register 0x07 which are latitude and longitude. Encoding is fixed-point decimal degrees x10’000’000. ● Refer to Quadrino_gps_registers.h for list of I2C registers including GPS date/time, altitude, ground speed, etc. ● QuadrinoGPS has an on-board Arduino (like Nano v3) that you can reprogram to suite your needs. See Customizing QuadrinoGPS firmware. My Personal Favorite The RPi3 has a quad-core processor and is currently my favorite embedded Linux board. In my experience the BeagleBoneBlack (BBB) was comparable to the performance of the RPi2 with a slight advantage in speed but the BBB was a better overall experience. However the latest RPi3 now sports a quad-core vs BBB’s single core and it’s a faster per-core GHz so it’s currently in a class of it’s own. The RPi3 is also 64bit where the BBB is 32bit, however, the RPi3 is still using the 32bit Linux ARM kernel so this isn’t an advantage yet. I do still like the BBB quick-start process more than any RPi. The BBB team went the extra distance of configuring the BBB as a USB flash drive and web server with documentation and samples on it and a web interface that includes a great web IDE, Node.js and GPIO tools. The BBB is immediately ready to jump into the world of IoT without a single shell command. The RPi is basically like an installation of Ubuntu or Debian Linux on a desktop computer, it’s just as capable as the BBB for IoT but requires a higher Linux skillset. Whatever your favorite may be the operation of the QuadrinoGPS won’t change. So let’s begin. >>> Files <<< Arduino Download here or from GitHub. Firmware & Sample Files The included sample projects read from the GPS and print basic location information. The included firmware can be used to update the GPS device to the current version. Raspberry Pi Image SD card image provides the fastest and simplest way to get RPi the Quadrino GPS connected to an RPi. This image requires at least an 8GB SD-card. http://flyingeinstein.com/downloads/raspbian-jessie-quadrin ogps.zip BeagleBone Black Image SD card image provides the fastest and simplest way to get BBB the Quadrino GPS connected to a BBB, although compiling on an existing BBB linux is easy compared to the RaspberryPi so go either way. http://flyingeinstein.com/downloads/bone-debian-8.4-quadri no-gps.zip Quadrino GPS Linux Driver Kernel driver provides a TTY interface /dev/ttyGPS0 that can RPi, BBB, LInux be used with GPSd or custom programs written in python, Node.js, C/C++, bash or other languages. https://github.com/flyingeinstein/quadrino-gps-driver Connecting to an Arduino This example connects to an Arduino Nano V3 board from Gravitech. The process for any other Arduino is the same but you may need to lookup the pin-out for i2c wiring and in the Arduino IDE select the proper board. FYI You may be interested to know that the Quadrino GPS already contains an Arduino-like chip on it and the firmware on that chip is coded in Arduino and open-source. You only need an off-the-shelf usb-serial adapter to reprogram the firmware. If your project is small enough you may want to just modify the existing firmware to include your project code and not need a second Arduino! The basic steps to getting your Quadrino GPS wired to an Arduino board is as follows: 1. Wire the GPS to the Arduino (See example Arduino Nano v3 below) 2. Download the QuadrinoGPS sample files for Arduino IDE 3. Open one of the samples in Arduino IDE (We suggest Arduino_QGPS_Maps) 4. Select your Board Type and the Serial Port from the menu 5. Click Compile and Upload 6. Open the Arduino Serial Monitor to see the sample code output As a reference the table below shows where I2C pins are located on various Arduino boards. Arduino Board SDA SCL Uno / Ethernet / Nano A4 A5 Arduino Nano v3 from Gravitech Mega2560 20 21 Leonardo 2 3 Due 20 21 Example Wiring to Arduino Nano v3 from Gravitech. Plug the Nano into USB and you are ready to roll! In this image, The Green wire is SCL (clock) and the yellow wire is SDA (data). The pins on the Arduino Nano are labeled for GND (black), 5V (red) and A5 (green) and A4 (yellow), where A5 is SCL and A4 is SDA. The pins on the Quadrino GPS are labelled CLK (green) and DATA (yellow) but for power the labels are icons on the top side ICSP header indicating GND and 5V. Alternative wiring to Arduino Nano using the ICSP header. This alternative wiring is valid for RaspberryPi, BeagleBone and other embedded boards as well. Quadrino GPS on Linux The easiest way to start using the QuadrinoGPS is to download our pre-made image for RPi or BBB. Burn the image to an SD card, wire the GPS, boot and enjoy! The image contains the QuadrinoGPS tty driver, GPSd daemon, and python gps clients. ● Download the RPi SD card image o RaspberryPi o BBB ● Wire the GPS to the board, see Wiring the RPi or BBB chapter. ● Boot the board ● Login using pi/raspberry on RPi or debian/temppwd on BBB ● Test the GPS o From Gnome/x-windows run xgps o From ssh, run gpsmon o From ssh, cat /dev/ttyGPS0 Wiring to Raspberry Pi This example connects to a Raspberry Pi version 3 (latest). There should be no changes for RPi2. There may be minor changes for RPi1, if you encounter any issues please contact me so I can update this document. Wiring to BeagleBone Black The BeagleBone Black has 3 I2C ports with 2 of them available externally, but only I2C port 2 is shows in the pin-out diagram so we’ll wire our GPS to this port as shown in the image below. This is on expansion header P9 pins 19 (SCL) & 20 (SDA). Once connected and powered on you can confirm proper wiring using the command i2cdetect -y -r 2. Installing the Linux I2C tools and developer libs (RPi) On RaspberryPi, Install i2c tools and developer libs. This provides some useful user-space i2c commands and the development libraries for writing gps applications. These tools are installed by default on BeagleBone Black. sudo apt-get install i2c-tools libi2c-dev Re-configure the raspberry to enable i2c: (RPi) You need to run the raspi-config program (as root) and select the modules (SPI or I2C) that you wish to load/unload there and reboot. This will create the i2c device control directory: /sys/devices/platform/soc/3f804000.i2c/i2c-1 There is more information here: https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=97314 sudo raspi-config ● Select Advanced Options | I2C ● Enable both the ARM I2C interface and i2c kernel module Checking QuadrinoGPS electrical connection We can check that the proper wiring connection to the GPS has been made by using the i2c-tools to scan the i2c bus.