Any views expressed within media held on this service are those of the contributors, should not be taken as approved or endorsed by the University, and do not necessarily reflect the views of the University in respect of any particular issue.

Mark Naylor’s Blog

Mark Naylor’s Blog

I want to know how the Earth works…

GEODUINO TECH: Programming the geoduino

There are two ways to control what the chips are doing.

  1. Use the microcontroller to make things happen
  2. Use functionality built into the chips to control operations

In this post, we are going to look at the latter.

Our Geoduino Seismic ADC system has a few different chips that can be programmed.

We will start by looking at how the Adafruit GPS library can be used to program the GPS chip. Then we’ll look at how we have implemented this on the Geoduino ADC board.

1. Programming the GPS

A PMTK command is MediaTek proprietary data transfer protocol for GNSS. It enables configuring the parameters of the GNSS chipset, aiding assistance position information and receive notifications from the GNSS chip.

We can send commands to the chip using a “PMTK Command Packet”.

The PMTK commands are all send in a specific packet format which is shown below.

Preamble  Talker ID  PktType  DataField  *  CHK1 CHK2  CR LF


A comprehensive list of the PMTK Command Packet instructions for the MT3339 is available as a pdf.

So, this tells us about instructions that we can send to the chip.

The next question is how to send them…

1.1 Programming the GPS chip with the Serial Monitor

During development, we can just send these commands through the Serial Monitor to the chip and observe the consequences. An easy example is to put the chip into standby and restart it (See page 18 of the PMTK Command Packet instruction) using:

To put GPS chip in Standby:

    \[ \$ PMTK161,0*28<CR><LF>\]

To restart the GPS chip:

    \[ \$ PMTK161,1*28<CR><LF>\]

When you do this you should just see the GPS information stop coming in on the Serial Monitor, and then restart again.

Using the Serial Monitor is great during development to check the chip is working as expected – but we also need a way to program this using C++ or CircuitPython etc.

1.2 Programming the GPS chip using C++ code

The Adafruit_GPS library also allows us to program the GPS chip.

They have adapted the structure of their library to clarify the PMTK settings. As well as the standard Adafruit_GPS.h header file, this header also calls a second header file called Adafruit_PMTK.h. If you have a look at this file you will see the same PMTK Commands that are described in the PMTK Command Packet instructions PDF.

The two methods below are defined in Adafruit_GPS.cpp. The first defines a method to send a command to the chip:

    @brief Send a command to the GPS device
    @param str Pointer to a string holding the command to send
void Adafruit_GPS::sendCommand(const char *str) { println(str); }

In the second method, we can see how to send the PMTK Command Packet (PMTK_STANDBY_SUCCESS) that is defined in Adafruit_PMTK.h to the chip using the sendCommand() method.

    @brief Standby Mode Switches
    @return False if already in standby, true if it entered standby
bool Adafruit_GPS::standby(void) {
  if (inStandbyMode) {
    return false; // Returns false if already in standby mode, so that you do
                  // not wake it up by sending commands to GPS
  } else {
    inStandbyMode = true;
    // return waitForSentence(PMTK_STANDBY_SUCCESS);  // don't seem to be fast
    // enough to catch the message, or something else just is not working
    return true;

If we look in Adafruit_PMTK.h we can see that the variable was defined to be the command we originally sent through the Serial Monitor.

#define PMTK_STANDBY                                                           \
  "$PMTK161,0*28" ///< standby command & boot successful message

Similarly, we can send other commands to the chip using the public method GPS.sendCommand() from within our C++ sketches.

This example shows how to program the chip using the pre-defined PMTK protocol. We will now look at how to do a similar job for the Geoduino ADC board we have developed.

2. Developing a driver for the Geoduino ADCs

The Geoduino contains 3xTexas Instrument ADC chips (ADS1284) that are designed specifically for use with Geophones and Hydrophones. We have one ADC chip for each of the horizontal and vertical components we wish to measure.

We need to develop a library that allows us to control the hardware from our software – this is broadly described as a “driver”.

This will allow us to control many useful properties of the Geoduino including:

  • The digital filter provides data rates from 250 to 4000 SPS.
  • The high-pass filter (HPF) has a programmable corner frequency.
  • On-chip gain and offset scale registers support system calibration.
  • The power-down input puts the ADC into power-down mode.

The full documentation is available as a PDF. When you look through the documentation you will see a range of different properties that can be set – similar to those we saw for the GPS chip.

The main difference you will see is that there is not a pre-exsting protocol for controlling the chip – i.e. there is not something equivalent to the PMTK protocol we used above.

Instead, we have a list of register addresses that need to be modified to produce a specific behaviour.The register is just a specific piece of memory on the ADC chips that store the settings for us.

We now need to develop a workflow for modifying the register to make the chip do what we want.




Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


Report this page

To report inappropriate content on this page, please use the form below. Upon receiving your report, we will be in touch as per the Take Down Policy of the service.

Please note that personal data collected through this form is used and stored for the purposes of processing this report and communication with you.

If you are unable to report a concern about content via this form please contact the Service Owner.

Please enter an email address you wish to be contacted on. Please describe the unacceptable content in sufficient detail to allow us to locate it, and why you consider it to be unacceptable.
By submitting this report, you accept that it is accurate and that fraudulent or nuisance complaints may result in action by the University.