Wednesday, November 18, 2009

Wise Clock 2 - User manual

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;

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):
  • QUOT - run the Quote application
  • SLP - go to sleep mode
  • ALRM - set alarm time
  • AL+ - enable the alarm
  • AL- - disable the alarm
  • DT+ - show the date between quotes
  • DT- - do not show the date
  • MSG+ - show a special message between quotes (not yet implemented)
  • MSG- - do not show the special message
  • LIFE - play the game of life;
  • DEMO - show a demo application;
  • PONG - run the ping-pong application (not yet implemented).
The menu is accessed/entered by pressing the Menu button.

(to be continued)

Sunday, November 15, 2009

Wise Clock 2 - New software release

Before talking about the new software release, I must point out a few corrections/edits I made in earlier posts:
The new software release can be downloaded from here. Most of the items on a previous "to do" list have been addressed. Following are the items I managed to do so far:
  • included Tone library (written by B. Hagman) to generate alarm sounds;
  • implemented functionality for the three buttons (Menu, Set, Plus);
  • removed the branching for ATmega328 (#ifdef _ATMEGA328P_), since many of the features won't fit in its RAM anyway;
  • ability to set up the date the same way as the time, through the file time.txt on the SD card;
  • display notification when the SD card is not inserted (or, to be more accurate, file quotes.txt is not found);
  • implemented sleep mode (more work is required for waking up from sleep mode with the remote control);
  • scrolling speed adjustable through 1-button (Plus) pushes;
  • dimming adjustable through 1-button (Set) pushes;
  • select to display the date or not;
  • ability to set the alarm time;
  • enable/disable alarm.
(Details and explanations to follow.)

Monday, November 9, 2009

Duino644 - a few more explanations

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.

Next post will be about software. A quick "to do" list includes:
  • functionality for the 3 buttons (menu, scrolling speed, dimming, set clock/alarm etc);
  • IR functions for remote control;
  • extend time displayed to include year/month/day;
  • include the alarm/melody functions (plus 2 sound-intensities through the speaker);
  • sleep (power down) mode;
  • alarm functionality (set/sound/trigger/enable/disable);
  • support for "matrix type".

Edit: As of Jan/10, all (except the last) of the above "to do" items have been implemented and are currently implemented in the latest software release.

Saturday, November 7, 2009

Duino644 - Use it

The best tutorials I have seen are, by far, those from 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):

(D 0) PB0  1|        |40  PA0 (AI 0 / D31)
(D 1) PB1  2|        |39  PA1 (AI 1 / D30)
INT2 (D 2) PB2  3|        |38  PA2 (AI 2 / D29)
PWM (D 3) PB3  4|        |37  PA3 (AI 3 / D28)
PWM (D 4) PB4  5|        |36  PA4 (AI 4 / D27)
MOSI (D 5) PB5  6|        |35  PA5 (AI 5 / D26)
MISO (D 6) PB6  7|   A    |34  PA6 (AI 6 / D25)
SCK (D 7) PB7  8|   T    |33  PA7 (AI 7 / D24)
RST  9|   M    |32  AREF
VCC 10|   E    |31  GND
GND 11|   G    |30  AVCC
XTAL2 12|   A    |29  PC7 (D 23)
XTAL1 13|        |28  PC6 (D 22)
RX0 (D 8)  PD0 14|   6    |27  PC5 (D 21) TDI
TX0 (D 9)  PD1 15|   4    |26  PC4 (D 20) TDO
INT0(D 10) PD2 16|   4    |25  PC3 (D 19) TMS
INT1(D 11) PD3 17|        |24  PC2 (D 18) TCK
PWM (D 12) PD4 18|        |23  PC1 (D 17) SDA
PWM (D 13) PD5 19|        |22  PC0 (D 16) SCL
PWM (D 14) PD6 20|        |21  PD7 (D 15) PWM

(to be continued)