Sunday, March 29, 2015

Modding WiFiChron with GPS or Bluetooth

The latest revision of WiFiChron has an XBee socket (beside the ESP8266 8-pin socket), which allows the addition of a few individual features:
  1. GPS-based time synchronization, by using the GPSBee;
  2. displaying messages sent from a Bluetooth device, by using the BTBee/BLEBee;
  3. displaying data acquired from an XBee/ZigBee network of sensors (not implemented yet);

Things did not go smoothly, without some drama though. Naively (I always seem to forget that there is a difference between theory and practice), I designed the XBee/ESP to connect to the serial port, with the expectation that once the development (including testing with debug statements to the serial monitor) is done, I will just plug in the serial module (either XBee of ESP8266) and things will work properly. Well, I had to re-consider this approach once again. Luckily, I had two pins left available (D7 and D17), which I could use for software serial. I re-wired those to the XBee/ESP and used the hardware serial for console communication. Until the next board revision, anyone wanting to follow will need to re-route a couple of traces manually, as shown in the photos below (cuts are red-circled).

A few details on my implementation of the GPS time sync (so that one doesn't need to look at the code to figure it out):
  • user can set a timezone (stored in eeprom, default is -1); there is no (easy) way to determine if the timezone was set or not, since -1 (eeprom byte being 255) is a valid value;
  • estimate the timezone from the longitude, assuming that a every 15 degrees is an hour difference;
  • a difference between GPS estimated timezone and the user-set timezone of more than 2 hours would mean that the time is way off and the user did not set the timezone; in this case, blink the display; a difference of 2 hours or less would be acceptable (for many reasons, including summer-time, or variations from the "15-degrees-longitude-per-hour" approximation);
  • in any case, the minutes and seconds are set from the GPS data;
  • date and day are not set/synchronized at all (currently);
  • the GPS sync is scheduled to happen every 10 hours (and also after a reset);
  • a successful sync is indicated by an up arrow at the end of the scrolling date (e.g. March 29, 2015 ^).
I will publish the code as soon as I have a chance to polish it (and also test it with BTBee).

As you can see in the photo below, the GPS antenna fits well in the case. It also works well: the GPS has good reception inside the house, 5 meters from the closest window.

Tuesday, March 17, 2015

How to assemble the 2-servo mini pan-tilt kit

Mystery solved!

This is somehow embarrassing, but I post it anyway, hoping that it may help others.

Although it looks easy, I had trouble assembling the mini pan-tilt kit from adafruit, specifically the bottom servo. I just couldn't figure out how to fix the servo with screws to the main arm, since there are no holes for screws (unless I drill them myself). Also, there is no guide anywhere to be found (uncharacteristic for adafruit), nor explicit photos of the assembled parts. I thought that there must be a trick, so I bought the assembled version as well. Guess what? The "trick" is obvious, and I missed it because I was focused on using the screws! The bottom servo must be inserted in the 2 tracks on each side of the two symmetrical parts that make the arm, no screws needed!

When assembling the kit, the easiest way is to start by attaching together the 2 symmetrical parts of the arm, with the servo between them. (In the photo below, i was too lazy to completely dis-assemble the 2 halves of the arm, I only pulled them apart enough to fit the servo in between, with servo's bracket in one of the tracks.) Notice the servo's bracket snug in the groove.

See? No screws on either side of the servo! Because they are not needed!

I hope these photos will bring some light and spare the frustration to (probably very few) people like me.

Friday, March 13, 2015

WiFiChron with software support for ESP8266

Another great software update from MikeM (download here)! This one has support for the ESP8266 module, allowing the WiFiChron clock to:
Before getting excited and jumping to compile and upload the new sketch, there are a few steps to be done on the ESP8266 module:

1. pull the CHPD pin high with a 10k resistor to Vcc;

2. make sure you can communicate with the module using a serial port; this could also include checking the version of the installed firmware (AT+GMR);

3. upgrade the firmware on ESP8266 to version 0.9.6.

After you download the bin files, the next step is to find a tool that would upload those bin files onto the chip. There are many tutorials on how to do this, some sketchy and ambiguous, some detailed and very helpful. In my search, I found references to a few different tools: XTCOM (old MFC Windows app), "NODEMCU Firmware Programmer", ESP flash downloader, ESPtool (python).

The easiest one to use for me seemed XTCOM, with my only complaint being that COM port selection was limited to COM1-6. Luckily, on Windows XP I am using, I was able to change the serial port from the default (assigned by the OS) COM9 to COM2 (the only one available in the range COM1 - COM6). I used this tutorial to load this firmware.

4. Change the baud rate from the default (after firmware upgrade) 115200 to 38400, for the following reason: according to the datasheet (table 20-6, page 189), ATmega328 running at 8MHz has an error rate of approx. 8% communicating on serial port at 115200.

Now, with the ESP8266 module prepared and plugged in, to connect to your wireless network, you will need to configure the module by providing the SSID and the password. To start this process, select "Init" for the "Wifi" menu item. There is an additional "init y/n" option to confirm the init. Once in "init" mode, the ESP8266 module starts acting as access point (another wireless network), using the SSID "WiFiChron". Connect to it using the key "WiFiChron" (*).

The clock will display (scrolling) an IP address, something like "". Connect to the WiFiChron's access point with your computer/laptop/tablet/phone and web-browse to that IP address, as shown in the screenshot below.

Use that page to configure your local access-point SSID and key.  You can also configure an optional SNTP host for synchronizing time and an optional RSS URL.  Fill in something like for the SNTP host or for the RSS URL.

Clicking on the "Submit" button will send the configuration to the WiFiChron system, which will write it into its eeprom. If you check "Activate" before submitting, the WiFiChron will immediately switch out of access-point mode and attempt to connect to the SSID/key that you've entered.  If you have problems, you can power-cycle the WiFiChron.  It will use whatever settings it has stored in eeprom.

(*) Although the "WiFiChron" network was detected, I could not connect to it from my Windows XP machine (acquiring network address takes forever and eventually fails). It worked much better with my Android tablet. This is the reason why the first screenshot above is from my XP machine and the second is from my tablet.

NOTE: The ESP8266 module must be taken out of the socket while uploading the sketch (since it's connected to Rx/Tx as well).

Tuesday, February 24, 2015

WiFiChron clock kit now available

With this kit you build a clock like the one shown in the photos below.

There are two buying options:

1. use or make your own enclosure

 (US$47, free shipping to North America)

2. enclosure included (Serpac A20, transparent front panel, screws, back panel hand-drilled with 3 holes for buttons and rectangular opening for the USB connector)

 (US$61, free shipping to North America)

The kit includes the following electronic parts:

  • main PCB
  • display adapter PCB
  • ATmega328 with 8MHz bootloader, programmed with a clock sketch + 28-pin socket
  • 74HC595 shift register + 16-pin socket
  • HDSP-2534 8-character alphanumeric display + 4 x 6-pin machined headers
  • DS3231 + battery holder + CR1220 coin battery
  • LM1117 3V3 regulator
  • 3 x right angle push button
  • 5 x100nF capacitor
  • 3 x 10k resistor
  • 220uF (or so) electrolitic capacitor
  • 2 x 12-pin right angle male header
  • miniB USB connector
  • buzzer
Schematic and board layout are shown below.

The board supports other types of displays as well, through the use of adapters. So far, beside the HDSP-2534 coming with the kit, there are adapters for HDSP-231x and QDSP-6064 (the sketch is different for this one), shown below.

Assembling the kit

Finding the right place for the components on the board should be straightforward, since the silkscreen shows their values and their orientation.
It is very important to pay attention to a few aspects:
  • the orientation of the DS3231: the key (pin 1) must be the top-right on the board (so that you'll see the marking on the chip upside-down);
  • solder the USB mini-B connector BEFORE the capacitors surrounding it, or otherwise you'll be forced to solder the USB's ground and Vcc pins (the 2 extreme pins among the 5) in a very cramped space;
The procedure to attach the display is as follows:
  • first insert the little adapter PCB all the way into the right-angle headers, then the headers themselves into the main PCB; solder the headers to the main board first, making sure that the small PCB adapter is perpendicular on the main board;
  • solder the display adapter PCB to the male headers, after it's inserted all the way, with the so the headers' pins stick out;
  • cut the sticking pins to the PCB level; at this point you have the adapter attached and connected (perpendicular) to the board, and you are ready to solder the HDSP-2534 display;
  • insert the machined headers into the HDSP-2534 display first, then insert the HDSP-2534 display with the attached machined pins into the adapter PCB until all pins are accessible on the other side;
  • solder the machined pins, on the side facing the main board (the bottom row is just underneath the main PCB, the top row is above the main PCB). In the end, it should look like in the photo below.

Then insert the display with the key (the "cut" corner) in the left bottom of the adapter.

Saturday, January 31, 2015

My experience with Axiris IV-3 shield for Arduino

I recently bought on ebay the PCB for this open source VFD shield, designed and made by Axiris, a company in Belgium. I was attracted by the solid documentation provided on their site, which includes the schematics (even Eagle files), assembly instructions, demo software, files for laser-cutting the enclosure. I should also mention the professional photos, rivaling those of the top sites (e.g. adafruit, sparkfun).

Assembly went smoothly, as expected. I also expected it to work on the first try, like the other two VFD devices I built previously, the Ice Tube Clock and the akafugu VFD clock. I guess I ran out of luck :)
But, as my kid would say, "losing is learning". This became an opportunity for me to actually go one step further than just soldering the components mindlessly (because the instructions are too easy :)

This is how I learned what fascinating little devices VFDs are. They function similar to cathode ray tubes (CRT), used in the previous generation of TVs: the filament gets heated (by about 1V, believe it or not(*)) and frees electrons; a thin grid, supplied with higher voltage, attracts these electrons and speeds them towards the anodes, which are conductors that become fluorescent when hit by these electrons.
VFDs are also similar in functionality to triodes, and probably can even be used as amplifiers (in a MacGyver-kind situation :).

Compared to Numitron tubes or even Nixies, VFDs are more complicated to drive, since they require two voltages: a very low one (around 1V) for the filament (cathode) and a higher one (between 5V and 60V, depending on the model) for the fluorescent anodes and the grid.

IV-3 tubes used in the Axiris shield require about 30V for the anodes and 0.85V for the filament. The power source to generate these two voltages is original (when compared to those in other successful VFD devices). The documentation gives a great explanation on how it works.

In any case, it only "half-worked" for me: I got the high voltage around 32V, but the tubes were still dark.
There were 2 possible causes for this:
  • either defective tubes (with burned filament) or
  • missing low voltage
Not being able to find a "troubleshooting guide", I contacted Axiris. After a few emails, their advice was to check C2 and C3 and eventually play a bit with their values (between 5 and 15 nF). Which I did, with no success.

Needless to say that the design of this power source is out of my league. The filament voltage is high-frequency AC, impossible to measure with a regular multimeter (**). But a VFD's filament, like a light bulb's filament, works with DC as well. So I tried lighting them up with 3 AAA batteries in series (since the 4 filaments are connected in series). I was able to see them glowing (until that moment I didn't even know where the tube's filament was). That did the trick and proved that the VFDs were not defective.

As an alternate (working) solution, I chose to replace the low voltage AC from the oscillator's power supply (which did not work for me) with the PWM voltage from the available D11. I cut the trace to VFIL1 (see schematics below) and re-wired to the anode of diode D1. I took out C2 and C3 (right hand side in the photo above) and connected a wire between VFIL2 and Arduino's D11.

With analogWrite(D11, 200), the 4 in-series filaments are now powered with a measurable 3.2V (3.9V from D11 minus 0.7V voltage drop on diode D1). This is not an outrageous solution when you think of switching power sources driven by pulses from uC used in some Nixie clocks.

With the hack in place, I was then able to successfully run Axiris' demo sketch (shown in action in the photo).
As they say, "all is good when it ends well".

What I would change or improve in this kit:
  • add the ability to adjust the high voltage with a trim-pot; for two reasons:
    • eliminates the restriction to use only a 12V power adapter to generate the required 30V;
    • the tubes' luminescence diminishes over time (I read); a higher anode voltage can bring the brightness back;
  • power the filaments independently (in parallel);
    • if the filament of one tube burns out for some reason, all tubes will go dark; finding which one is defective is not obvious, and will require a multimeter;
  • replace the 8-pin "power" header with a 6-pin header, to be able to plug the shield in the original Arduino 2009 as well; the left-most 2 pins are not used, yet Arduino's capacitors are touching one of them;
  • add a troubleshooting section;
    • include measuring the resistance between VFIL1 and VFIL2 being about 32 ohms; that proves that the filaments are intact;
    • include testing of the filaments with a battery for the common folks that lack an oscilloscope (for those who have one, include some info on the AC voltage);

In conclusion, I find this kit as a great introduction to VFDs. I think it is easier to understand how it works than the Ice Tube clock, since it's all discrete components (no IC driver). It is also a lot more software-hackable, being controlled by an Arduino sketch. It is more hardware-hackable through the use of Arduino shields, which may include an RTC, Bluetooth, buzzer etc.

(*) One can also start a fire with a AA (1.5V) battery.
(**) Nick, I am just one step away from using the oscilloscope you sent me. I promise to write a review on it soon.