My boat was fitted with a Garmin GPS, a Garmin FishFinder (FF) and a fuel flow sensor. All of these are potential sources of interesting information. Having tried to process data with a VB.Net application running on a netbook proved tricky - the software was huge, there were timing issues and the netbook wasn't always as robust as might be needed.
The challenge was to gather all of the useful data from the GPS, the Fishfinder and the fuel flow sensor and write it to an SD card. The three lots of data are not synchronised in any way - making it an ideal task for a Parallax Propeller. Why? Well, let me explain...
The Propeller is a great little micro-controller. As an almost blank sheet of paper, it has eight separate processors (cogs) kept in step by a central hub that also has 32 Kb of RAM. Start to add software objects and all of those cogs can start to be put to some use, without any restrictions on hardwired input/output connectors, etc. It doesn't need any interrupts - at all. Ever! On the first of two Props I allocated:
One cog to the receipt of GPS data. References to an open source object provide an RS232 interface capable of receiving NMEA-0183 data. All it has to do is keep looking at the incoming GPS data and strip out the useful parts.
One cog to the receipt of FF data. References to an open source object provide an RS232 interface capable of receiving NMEA-0183 data. All it has to do is keep looking at the incoming FFdata and strip out the useful parts.
One cog to the receipt of Fuel flow pulses. All it has to do is sit there counting pulses from the fuel flow sensor and updating the quantity in a global variable.
One cog is dedicated to monitoring the position of the 'on-off-on' three position momentary-make switch.
The main code could take as many of the remaining cogs as it needed. It included another RS232 interface for the connection to the LCD display and an SPI interface to the SD card holder.
The SD card holds a file "calib.txt" which contains a three digit number that represents the volume of fuel associated to each pulse from the fuel flow sensor. The specification of the flow sensor states one pulse per 0.4 ml; experience measuring fuel usage against the amount of fuel required to re-brim the tank suggests this is slightly too much - a value of "393" in the calib.txt file tells the Prop that each pulse is worth 0.393 ml of fuel.
One cog of the second Propeller was dedicated to reading the data from the accelerometer and writing it to the SD card.
A serial connection from the first prop sends to the second the count of the number of data items that have been written. This value is also written to the SD card (when it changes) allowing the GPS/FF and acceleromter data to be synchronised at a later data (the accelerometer data updates very rapidly).
No accelerometer data is recorded until the first item of data is received from the first prop; it stops when data stops being sent - this ensures data is only recorded when GPS or Fishfinder data is available
There are a huge number of sites providing information on NMEA-0183 datastreams from all sorts of devices. NMEA stands for National Marine Electronics Association and standard 0183 describes the format of information transmitted to/from devices that might be found on vessels of all sizes. I was interested in two:
The image below (taken directly from the comments included in the code, shows the structure of the GPRMC word transmitted by the GPS unit.
The GPS code sits there reading the data stream, looking for the leading '$' and the asterisk towards the end of the sentence. If the word starts with 'GPRMC' the fields transmitted are processed (other sentences are transmitted but they are not directly relevant). Fields such as speed are converted to decimal values for subsequent manipulation and storage.
The image below (taken directly from the comments included in the code) shows the structure of the $DDBT word transmitted by the Fishfinder unit.
The following connections were made to the the Propeller Project Board used as the basis for prototyping. The Project Board provides a 3.3V supply:
- 12V DC from the boat's regulated supply
- 5V (using a 7805 regulator), gnd and RS232 connection (transmit only) to the LCD
- Gnd and signal from the fuel flow sensor, with 12 V supplied to it.
- A DB-9 connector for the fishfinder (the fishfinder is terminated with a DB-9 connector to connect to a PC/Laptop)
- A DB-9 connector for the GPS (the fishfinder is terminated with a DB-9 connector to connect to a PC/Laptop)
- Connections to the SD card holder, which is mounted on the protoboard
- Two wires from the switch 'make' connections, one wire to 3.3 V
- Three LEDs ("GPS data received", "FF data received", "data write”)
- Various other LEDs to help debugging.
- The USB connection of the Protoboard allows code to be uploaded and for debugging data to be displayed on the PC during development.
This is a prototype, hence the poor soldering and routing.
The details of the connections are included in the code (the Propeller Tool contains a font that includes symbols for components, etc.,). These diagrams are included below. The pin names used in the code are shown also.
Data is displayed on a 16 x 2 LCD from Devantech. The LCD is yellow/green in colour - this combination generally suggests a that the display is transflective and therefore readable in bright sunlight