Monday, February 29, 2016

Hockey scoreboard

What's missing from this picture (of a backyard hockey rink)?


You got it (probably the post title helped too): a scoreboard.
For those not familiar, a traditional one looks like in the photo below (click on it to see it bigger).


It may look simple, but it provides a lot of functionality:
  • display 2-digit home score;
  • display 2-digit visitor score;
  • countdown timer, with the starting time configurable/settable; timer displays mostly minutes and seconds, but under 1 minute, it displays seconds and tenths of a second;
  • stop/resume the countdown;
  • display round/period; number of periods is configurable/user-settable;
  • buzzer sounding at the end of the round, game or on demand;
  • penalty timers for up to four players (that also stop/resume with the main timer);
  • functions as a clock when not used in a game.
The control for the hockey scoreboard is pretty complex too. The control console is usually wired to the scoreboard. Sometimes the console is detachable (brought in to the booth by the score keeper), connected to a cable that plugs in.

An easy and quick way to build a home-made hockey scoreboard is to re-program a dual-display (16 x 64 pixels) Wise Clock 4. The scoreboard should be controlled wirelessly, from a distance of at least 10 meters (which disqualifies infrared remotes and also the most common Bluetooth, "class 2"). Potential solutions for the scoreboard remote control are:
  1. XBee
    • good distance range;
    • not cheap;
    • reliable communication;
    • requires building and programming a remote control device;
    • already hardware-supported by Wise Clock 4 board;
  2. RFM-12
    • good distance range;
    • cheap;
    • reliability probably ok for short messages;
    • requires building and programming a remote control device;
    • uses SPI interface, requiring some hardware hacking;
  3. RF 4-button key fob
    • cheap
    • easy to integrate
    • does not require any software support;
    • reliability at distance greater than 10m (?);
    • no need to build the remote control;
    • unfortunately limited to only 4 buttons;
  4. WiFi
    • cheap (ESP8266)
    • works as access point; user connects from smart phone or tablet, to access HTML form pages to type/input commands;
    • requires extra coding;
    • no need for extra remote control device (since using phone or tablet);
For the user, the easiest way to control the scoreboard would be by pressing physical buttons (the other, less-friendly, way would be by entering/selecting messages, e.g. "STOP", or "resume").

If using buttons, at least 4 are required to cover the minimum functionality:
  • reset scoreboard - D0;
  • start/stop/resume countdown timer - D1;
  • increment home score - D3;
  • increment visitor score - D2 (available) or D22 (re-routed)
which makes the 3rd solution above (RF 4-button key fob) an easy pick.

This is how the prototype scoreboard works on my desk:



The software is a branch-out of the Wise Clock 4 main software (using the same libraries, classes and functions, but in a separate .ino file). I created a new font (file fontFull.h) for the score digits, defined in a 8x16 matrix.
To add extra features ("clock mode", "chrono mode", message scrolling etc), more buttons/commands would be required on the remote control. Which means that the RF 4-button key fob is barely enough for now, and another solution must be implemented. My next favourite is the RFM-12, a topic for a future post.

Saturday, February 20, 2016

Add a barometer sensor to Wise Clock 4

While cleaning up my desk, I found a little I2C module that I completely forgot about. It is a breakout for BMP180 barometer sensor, which I probably bought on ebay for a couple of dollars (I just checked, it is still under $2). This tiny board can be added literally to any Arduino clock to display atmospheric pressure, with the help of Adafruit_BMP085 library.

Connecting the barometer to Wise Clock 4 is trivial: I soldered wires directly to processor pins (SDA, SCL, VCC and GND), as shown in the photo. There is plenty of clearance between the board and the display.


In the software, as mentioned, I used the Adafruit BMP085 library, which also covers the compatible BMP180. There is no extra setting required from the user: the pressure is displayed together with the temperature, and enabled/disabled from the TEMP+/- menus. Also, there is no extra settings when compiling/building: if the BMP180 module is not installed, no pressure data will be displayed.

Essentially, the new code consists of 2 functions added to the AppTmp class:

boolean CAppTmp::initBarometer()
{
  bmp = new Adafruit_BMP085_Unified(10085);
  isBaro = bmp->begin();
}

int CAppTmp::getPressure()
{
  int pressure = 0;
  if (isBaro)
  {
sensors_event_t event;
bmp->getEvent(&event);
    if (event.pressure)
{
  pressure = event.pressure;
}
  }
  return pressure;
}      

Another nice thing about BMP180 is that it can also provide the temperature. But, like DS3231, it seems to be a little off compared with a regular thermometer sitting nearby.

Next, I will try to attache the little barometer to wsduino in an aesthetically pleasing manner, probably in the empty space in the top left corner.

Sunday, February 14, 2016

New Wise Clock 4 software release

The latest release of the Wise Clock 4 software can be found here.

It includes a few new features:
The WiFi settings are configured in the SD card file message.txt, and they look like this:

#### ESP8266 configuration
#
# Esp8266.ssid Wireless SSID to connect to
# Esp8266.phrase pass phrase to use (WPA authentication)
# Esp8266.sntp optional SNTP server IP address (not hostname) for time synchronization
# Esp8266.rssurl optional URL of an RSS feed, like http://w1.weather.gov/xml/current_obs/KMYF.rss

Esp8266.ssid   BELL475
Esp8266.phrase 7xyz1E9F6
Esp8266.sntp   
Esp8266.rssurl 

This feature is enabled in the code by the following line in file UserConf.h:
#define WANT_ESP8266
  • support for GPSBee (from seeedstudio): only the minutes and seconds are set from the GPS data, the hours remain as set from the buttons; synchronization is performed once a day and/or when the clock is reset (powered off-on);
To enable this feature, make sure the following line in UserConf.h is not commented out:
#define WANT_GPS
  • "Night" mode: turns the display off at night, between the hours set in message.txt file, as shown:
#### turn display off at night (in conjunction with menu "NIGHT");
#### formatted as HHMM (military time);
Night.start 2230
Night.end   600

This feature is enabled/disabled from the NIGHT+/- option in the SETUP menu. In Night mode, the display shows just a random dot. The implementation is in AppNight.class, and can be changed to display any desired effect (e.g. Bezier splines, Lissajous curve etc).
  • "Unix time" mode: displays advancing Unix time (passing seconds from Jan 1, 1970); accessed through the "UNIX" menu option.
Also, debugging (sending messages to Serial port) is now controlled by a single line in UserConf.h:
#define _DEBUG_

Before compiling and uploading the software, make sure the debug macro above is commented out (since it is not in the code you just downloaded). With the debug disabled, the code runs faster and takes less memory space.