Wednesday, November 18, 2009

The software for Wise Clock 2 is getting pretty hairy, thanks to the 4KB of available RAM. I actually have variables whose name include "app" (short for "application" :) Not that it's becoming windoze or something, but they suggest that there could be multiple "applications". For example, the functionality of the clock is an application. Conway's game of life is another application, as is an audio spectrum analyzer. The application running at a given moment is selectable through the menu.

So, it's about time to start putting together a user manual, a task more difficult than writing the code itself. The completion (if ever) will take some time. I plan on posting bits and pieces whenever I get some inspiration. Eventually I will assemble all these chapters into a coherent document.

Setting the clock with the current time and date

The Real Time Clock keeps time and date. The small on-board battery ensures timekeeping even when the power is disconnected. At the moment, the only way to set the time is through the SD card. This is not an inconvenience, since there is no reason to set the clock too often (unless accuracy is the goal, but then other variables, like temperature, should be considered as well).

In order to set the clock, the file time.txt must contain the time and date in a specific format, hh:mm:ssZyyyy-MM-dd-n, as shown in the example below, extracted from the file ("n" is the day-of-week):

# current time used to set up the clock;

12:22:45Z2009-11-14-6

As previously explained, the clock is set right after the board is powered, from the SD card containing time.txt. As soon as the clock is set, the file gets deleted (actually, marked as "deleted", through the insertion of 0x03 as the first character). So, next time you want to set the clock, just remove the first character, edit the line containing time/date, then reset (or power up again).

Displaying the current time and date

The time is shown continuously on the bottom row of the display, as hours and minutes. The separator between them indicates the state of the alarm: colon (":") means "alarm enabled", a dot (".") means "alarm disabled".

The current date is, by default, not shown. It can be displayed optionally, between quotations, by selecting the menu item "DT+" (press Menu repeatedly until you reach "DT+", then press Set).

TODO: The latest version of the software has the date format hard-coded. A future release should allow the user to specify the date format in the time.txt file.

Setting the alarm

Setting the alarm is usually a more complicated process than setting the clock itself (unless it's a mechanical clock with one "alarm" hand). The flowchart below explains how to set the alarm time. In a few words, here is how this works:

press Menu button repeatedly until you reach the item "ALRM";

press Set button to select this item;

now, by pressing Plus button, the hours will get incremented (rollover to 0 after 23);

pressing Set again will switch the "focus" of the Plus button to minutes;

now, by pressing Plus repeatedly, the minutes will get incremented (rollover to 0 at 59, obviously);

when the desired alarm time is shown, just wait a few seconds for the automatic menu expiration (when no button is pressed) to kick in; the alarm time is now set.

In order for the alarm to sound, it must be enabled. This is done by selecting the item "AL+" from the menu. To do that, press Menu button repeatedly until you reach "AL+". Then just press Set button and the alarm is ready to go at the set time. The diagrams below describe alarm enabling and disabling, respectively.

The fact that the alarm is enabled is indicated by the colon sign (':') between the hours and minutes. When the alarm is disabled, a dot ('.') is used to separate the hours and minutes.

After the alarm goes on, it can be dismissed by clicking on any button (not really practical when waking up in the morning, I agree), or by sending any command from the remote control.

The alarm time, together with other user settings, are saved in the non-volatile RAM of the real time clock (powered by the backup battery).

Menu items

The following menu items are currently implemented (or planned to be):

Monday, November 9, 2009

I get suggestions and ideas from many people these days. Thank you, I honestly appreciate it. This will only make the "product" better. As a result, I made a few corrections to the "Assembling Duino644" post and I added a couple of more posts (included this one). There are more photos coming (thanks Mike B.), software updates, and board fixes.

"MatrixType" 2-pin header

A few words about the "MatrixType" 2-pin header, found between the EEPROM and PORT_C header. With the jumper on, pin D11/PD3 is pulled down (that is, connected to the ground). When the jumper is not present, pin D11/PD3 is pulled up by the 10K resistor. By reading the state of this pins, the sketch can adapt to display on either the 16x24 or the 8x32 LED matrix display from Sure Electronics. The software support is almost trivial. The hardware is not. Plugging the active (SV1) connector directly into the 8x32 LED display makes for an awkward beast (since the dimensions of the 2 boards are so different). But it can work with a 16-wire ribbon cable.

Note: As of today, the software support for the "MatrixType" is not yet tested.

ICSP6 6-pin header

This is the standard connector used for programming the microcontroller chip with the AVR programmer. As in Arduino Diecimila, one rarely needs to use it for burning a program, since the bootloader (already burned on the chip) allows for easy upload of a sketch from the IDE.

6-pin inline, right-angled header

This header is used for connecting with the FTDI cable, or with the equivalent FTDI basic breakout from Sparkfun. This is the only way to upload a sketch from Arduino IDE to the Duino644 board. Keep in mind that the USB miniB connector is only used to provide power (5V), unlike the USB connector on most of the Arduino-type boards (which have the FTDI chip on board).

The next batch of PCBs will include a few corrections in the silkscreen: the 16MHz crystal is marked "XTAL" and the places for DS1307 and 24LC256 are clearly marked. Also, the 3 buttons are visibly named on the back of the board, useful if the enclosure has a transparent back panel.

As mentioned in an earlier post, the USB power connector can be either miniB or B type. If you have a preference for either one when you buy the kit, please let me know and I will accommodate it.

Saturday, November 7, 2009

The best tutorials I have seen are, by far, those from adafruit.com. With the effort I can spend, I will never be able to write anything better than those instructionals. So, as the saying goes, "if you can't beat them, join them", I will try to mimic. (One item on my "to do" list is the building of a project site, with a "normal" navigation: projects listed on the left column, description on the wider right column. Hopefully, all these postings will eventually become project chapters. And, of course, one chapter will be named "Use it".)

As we already know by now, Duino644 can be used independently of the LED display from Sure Electronics (this is one of the reasons I re-named the board Duino644 from the original Wise4Sure), more like an Arduino (or, I should say Sanguino) is. For this purpose, all 4 "ports" are exposed through 4 headers (8-pin connectors). On the board, these ports are named PORT_A, PORT_B, PORT_C and PORT_D, and they are highlighted in the picture below.

Since Duino644 is compatible with (or "piggybacking on") Sanguino, here is the pin mapping used when programmed Arduino-style (that is, using digitalWrite/digitalRead rather than accessing the ports directly):