Thursday 19 February 2015

Creating Instruments

Fun and learning has brought me to my next progression of sailing, mainly building my own flavor of digital instruments. Over the last few years I found that the instrumentation on Santeria had poor visibility at night (green back light), not plainly visible to the driver in daylight, along with other pains along the way (not working in heavy sea state)!

On a poor mans mentality, I set out to conquer the display of the 3 most important pieces of sailing data onboard Santeria, mainly:
  • Apparent wind speed
  • Apparent wind angle
  • GPS speed

Here is what I was looking for:
  1. Instrumentation must be below deck. Water resistant, but not waterproof.
  2. Must be red letters with black background
  3. Must be visible from a standing or seated position in the cockpit by leaning midship and peering through the companionway with the bottom companionway board in place
  4. Must be plainly readable from 14 ft
  5. Use common circuit components available though local or online electronic stores
An above deck B&G mast display on the VOR65 Alvimedica, and not what I was setting out to achieve! These are excellent
displays if you have the budget

I was hoping that this exercise wouldn't be too tall an order and that this would be a continuation from my previous electronics learning from years past. Here is how it went:

Googling "digital display" brought up several different display options. LCD displays were "a dime a dozen" and were generally very inexpensive but I couldn't seem to find one that had large visible digits. Reading the electronic datasheet and schematic of these displays quickly showed that there was significant wiring and development necessary just to display information.

I found some online stores (Adafruit and Sparkfun) that sell LCD displays for Arduino and Raspberry Pi and incorporated a serial backpack. This backpack uses common serial communication protocols to easily communicate with the display from these micro computing platforms. The backpack simplifies the integration of these display into common electronic project use SPI and I2C serial communication. In the end the text size would be too small to be clearly readable from 14 ft. I dropped the idea of affordable LCD displays ad this little guy was approximately 24$ US. The price was good, but scaling up to large readable LCD digits was too expensive for my budget. This was a 16 character X 2 lines. To display wind speed, wind angle and gps speed I only need 4 X 1.

LCD Negative Red display - This model allow the developer to change the text color with a static black background.

Googling "4 X 1 display" brought up a new type of digital display, the 7 Segment Display. 7 segment displays decimal characters using a 7 segment approach. These displays are commonly found it digital clocks, calculators and digital meters.

Each of the 7 segments are used to display decimal characters
and some alphabet characters

Going back to the online stores (Adafruit and Sparkfun) I also found that they sell these displays and are very inexpensive by themselves. Reading the datasheet and schematic of these displays also showed that there was significant wiring and development necessary just to display information.

Both adafruit and sparkfun have incorporated a serial backpack with these devices, but only Sparkfun sell a large 20mm digit with a serial backpack. Like the LCD display, this backpack uses common serial communication protocols to easily communicate with the 7 segment display and uses SPI and I2C serial communication. I felt that 20mm digits would be large enough to be clearly readable from 14 ft. I found a Toronto based retail company, Creatron, that sells Arduino peripherals. They have 2 Toronto location (Victoria Park and Sheppard, College and Spadina) and I could easily go to their store and pick up the components and avoid shipping charges from adafruit and sparkfun. A sparkfun 4 digit 7 segment red display with open segment serial backpack shield. 20mm 7 segment display with sparkfun's open segment shield. Has breakouts for UART, SPI and I2C serial

Next, I needed a "brain" for my electronics project. In electronics the brain is called integrated circuit (IC) or more commonly known as microchips. Picking an IC for this project was based on the following criteria:

  • Must be well supported by way of forums and source code
  • Simple interface that's easy to understand
  • Must have a Universal Serial Interface (USI) that supports one of the SPI, I2C or UART serial protocols
  • Preference to UART as I'm familiar with this protocol from previous projects
A google search later and I found several different Atmel microchips with a ton of user support and source code, mainly the ATTiny2313, ATTiny45 and ATTiny85.

  • All chips support USI
  • The ATTiny2313 had built in SPI, I2C and UART capabilities, whereas the Tiny45 and 85 didn't
  • The ATTiny2313 was a 20 pin chip and the ATTiny45 and 85 used 8 pins
  • Even though the ATTiny85 didn't have hardware to handle UART, I found out that it was possible to handle the UART in code on the ATTiny45 and 85
  • The ATTiny2313 has 2KB of programmable memory, the ATTiny45 and 85 4KB and 8KB respectively
In the end I decided to go with the ATTiny85 because of the number of pins and the significantly higher programmable memory available with this chip.
Pinout of ATTiny85 chip



Next I had to figure out how to both program and write programs for this chip.

To write programs for the ATTiny85, I used the Arduino IDE. It's an excellent IDE environment that compiles and builds the HEX file for a chip. The HEX file is flashed to the onboard chip memory. There doesn't appear to be limitations on the number of times you can program these chips.

I had a Raspberry Pi on lease from a friend so I wanted to use this device to flash programs to the chip. I found an excellent instructable that gives good instruction on how to program an ATTiny chip. Following the instructions, I created and loaded a very basic "blinky" program that flashes an LED on and off from an output pin of the chip. Another way of programming the ATTiny is using Sparkfun's ATTiny programmer that plugs into the USB port of your computer. The USB programmer coupled with the Arduino IDE development environment can accelerate the programming of these chips in a very streamlined fashion. If I were going to do this again, I would likely buy this programmer and simplify the programming of the chips.

Programming the ATTiny85 with the Raspberry Pi


Now having an approach to programming and flashing the chip, I now wanted to be able to read an inbound UART signal, parse out the data and send it to the display. After a few days of searching, I found this blog where someone had already figured out how to parse out data using the ATTiny85 chip from an incoming UART data signal and output the result to a 7 segment display. This was an amazing find and this blog post alone super-accelerated my ability to work with these chips and complete this project before the sailing season. Many thanks to the author for a well written instruction set and answering my questions in a professional and timely manner.

Next I purchased an Ultimate GPS chip from Adafruit. This chip would supply realtimeGPS speed information for my project.

Adafruit Ultimate GPS Breakout - 66 channel w/10 Hz updates - Version 3

The GPS chip outputs UART based NMEA sentences. The sentence we are interested in is $GPRMC as it contains the data for speed over ground. Hooking this GPS chip up to the ATTiny85, and the ATTiny85 to the display will satisfy my project GPS speed reqiurement. For detailed wiring diagram of the gps, ATTiny85 and display see this blog.

To get both apparent wind speed and apparent wind angle from my boats anemometer to the 7 segement display, I had to convert the RS-232 signal down to UART and then push the UART signal to ATTiny85's, one for wind speed and one for wind angle. The code on each chip was modified to output either wind speed or wind angle to the display. I had to modified ParseGPS code from this blog post to instead parse out the $IIVWR sentence from the anemometer and output the result to a 7 segment display. Having dedicated ATTiny's and 7 segment displays for each data point (GPS speed, wind speed, wind angle) would make my project a reality.

My project needed an enclosure box and I found one at Creatron.

190x120x60mm enclosure


After some serious modifications of the project box, soldering of circuitry, testing and debugging, we have a winner!

The final product hooked up to an anemometer on my workbench.
Top: wind angle
Middle: wind speed
Bottom: Gps Speed


  • 1" digits
  • Box isn't for above deck use
  • Spent under 200 $ in components to build it.
  • Ultimate GPS chip is mounted inside the box.

  • To help the visibility of digits in sunlight, I added a clear red plastic sheet over the 7 segment displays. It helps with the visibility by adding contrast.

No comments:

Post a Comment