Skip to content

damico/greenwich-experiment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

greenwich-experiment

Radio-Controlled Clock based on GPS receivers

Working hardware

Introduction

This is a hardware and software project, and the main idea behind it is to have a clock with time would be collected by 2 different GPS receivers (Which I call receiver A and receiver B). This is not a GPS disciplined oscillator.

If you want to know more about Radio-Controlled Clocks, there is an excelent text written by Michael A. Lombardi from National Institute of Standards and Technology (NIST), which can be found here: https://tf.nist.gov/general/pdf/1877.pdf

Main board

The hardware is based on a BeagleBone Black (BBB) board, which uses [AM3358 Debian 10.3 2020-04-06 4GB SD IoT] (https://debian.beagleboard.org/images/bone-debian-10.3-iot-armhf-2020-04-06-4gb.img.xz) image.

For Debian image, with SD Cards bigger than 4GB, expand your file system to be able to use all SD Card space sudo /opt/scripts/tools/grow_partition.sh. Also to reduce power consumption is important to decrease the cpu frequency. It can be done by editing file /etc/init.d/cpufrequtils and changing governor key to GOVERNOR="powersave" and then running the following command systemctl daemon-reload. Other thing to decrease power consumption is disable HDMI and AUDIO, and this can be done by updating /boot/uEnv.txt and adding the following line: cape_disable=capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN and disable_uboot_overlay_video=1 and disable_uboot_overlay_audio=1.

BBB

GPS receiver A

Ublox M8N

Ublox M8N

GPS receiver B

Ublox Neo 6 MV2

Ublox Neo 6 MV2

LCD Display 16X2 (Wich I2C Board)

LCD Display 16X2 (Wich I2C Board)

GPS receivers communication

The Ublox modules talks with BeagleBone Black (BBB) using UARTs. In this project the UARTs used are:

  • UART1 (Pins P9_26 RX and P9_24 TX) /dev/ttyO1
  • UART4 (Pins P9_11 RX and P9_13 TX) /dev/ttyO4

However these UARTs needs to be accessible. For that, the /boot/uEnv.txt file of BeagleBone Black must be edited with this line capemgr.enable_partno=BB-UART1,BB-UART4 and with these other 2: uboot_overlay_addr0=/lib/firmware/BB-UART1-00A0.dtbo, uboot_overlay_addr2=/lib/firmware/BB-UART4-00A0.dtbo

The main software that controls the GPS receiver is the GPSD, which is available on Debian 10. The installation of GPSD is done by: sudo apt-get install gpsd. There are 2 main configurations in GPSD:

  • Receivers conf at /etc/default/gpsd where devices must be declared as DEVICES="/dev/ttyO1 /dev/ttyO4" and options as GPSD_OPTIONS="-G"
  • TCP conf at /lib/systemd/system/gpsd.socket where ListenStream must be declared as ListenStream=0.0.0.0:2947

Enclosure

The enclusure was projected in FreeCad and 3D printed:

image

The LCD part was based on this work: https://www.thingiverse.com/thing:614241

Power Supply

All boards work fine with USB power, but I've also added support for 3.7V 18650 battery, using the battery pins (TP5, TP8) of BBB:

image

User Interface

The UI is done through the 16X2 LCD Display, using I2C. The software which controls de LCD is written in Python 3 and was based on the work of MilesBDyson, which can be found here: https://github.com/MilesBDyson/I2C-LCD/blob/master/lcd_i2c.py . At python/ folder there is a lcd_ui.py file which handles the messages into the display. This code requires psutil module (pip3 install psutil). This code only gets the text data from the files created/updated by the Time/Location Engine and displays it on LCD.

In order to make python control the I2C LCD you will need to know the I2C address where the LCD board was connected. For this, first use this command ls -l /dev/i2c* to discover if your BBB sees the I2C adapters. It should send a response with at least 1 device. Then, you need to test the adapders with this command i2cdetect -l. It should respond with at least this adapter i2c-0 OMAP I2C adapter. Finally you need to discover the alocated addresses per adapter, with this command: i2cdetect -r 0

Time/Location Engine

Most of the hard work in terms of software is done by gpsd running on Linux, however there are 2 portions of code that I've wrote (both in Java), which grabs the data from gpsd. The first one is the gpsd.client (https://github.com/damico/gpsd.client) and the second one is the greenwich, that is pushed in this repository (in java/greenwich directory). Both are compiled with maven, but for gpsd.client you should run mvn clean install -DskipTests, while for greenwich you should run mvn clean install -DskipTests package. Once the .jar package of greenwich was generated, you can run it with this command java -jar name-of-package.jar. When the greenwich starts to run it creates 2 files (_dev_ttyO1.gps and _dev_ttyO4.gps) in /tmp directory, these files has the GPS Fix data, Satellites data, Time Data and Time zone data.

OS integration/automation

In order to have all parts of software working togetter, I've made some bash scripts to install the user interface in python and the time/location engine in java as a init.d service. Take a look at shell/ directory of this repository to understand how to use it.

About

Radio-Controlled Clock based on GPS receivers

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published