Sunday, October 23, 2011

WiseClock / BookClock with I2SD - part 2

As promised, I am returning with the sketch (download from here).



Justin and Wyolum Co. also promised (wink, wink) that the next revision of I2SD will have the needed digital pins accessible through headers.

This "mixed breed wise clock" is using the I2SD (with on-board RTC and SD card), the display (and idea) from Book Clock, and code borrowed and adapted from Wise Clock 2.

Missing are the user buttons and a tilt switch, which may be connected to the free A0/D15 - A3/D18 pins available on the header of the I2SD board. (Note: The buttons and the tilt switch should be also supported in software as well, code which can be copied from the existing Wise Clock 2 and Book Clock sketches.)

Friday, October 21, 2011

Mixed breed Wise Clock (with I2SD)

The great I2SD board from Wyolum (also introduced here) offers almost everything one needs to make a simple Wise Clock:
  • it's an Arduino with ATmega328 (and FTDI connector);
  • has on-board RTC (DS3231) with backup battery;
  • has on-board SD card (with the 3V3 regulator and voltage level shifter).
In other words, I2SD is equivalent to Arduino + Adafruit Logging shield, but equipped with a better RTC (DS3231 instead of DS1307). And it is much smaller. And cheaper (I think).

One of the essential ingredients in making the clock is the display. I chose to use the simpler 3208 LED display because it requires only 3 wires (CS, WR, DATA) in addition to the Vcc and GND and it's easier to manage in software (requires less code).

Here I show how to connect the I2SD to 0832 display from Sure Electronics.

First, we need to realize that this is a hack. I2SD was not designed to be used as a full-fledged Arduino. Most of the digital pins are not accessible through headers. Well, in our case, we only need access to 3 digital pins. It just happens that D5, D6, D7 and D9 are connected to some test points, basically holes where we can solder wires. It also happens that in other 3208-related sketches, I used these almost same pins as well. So, we will connect the nicely aligned D6, D7 and D9 to DATA (pin 7), WR (pin 5) and CS2 (pin 1), respectively, as shown in the photos.















The rig is a helper for the display connector. If you want to follow the same idea, this is the sequence of actions:
  1. solder the 3 wires to the I2SD board, on the top side;
  2. on the rig board, solder the connector (near the side) and the wires (to pins 1, 5, 7, 15 and 16);
  3. solder the three I2SD wires (D6, D7, D9) to the rig.















It is now time to run the test sketch. It requires a small change in line 31, where we replace 8 with 9 (as I said earlier, we are using the easier-to-access D9 instead of the usual D8).

Note: Make sure you know how to handle the 3208 display you have, since there are two different types (see this post).


Now that Test_3208.pde runs successfully, we will work on integrating the SD card and RTC into the software (which shouldn't be a problem, since I will just copy chunks of tested code from the older sketches). The clock will alternate between displaying the quotes from SD card and displaying the time from RTC. Stay tuned.

PS It's worth mentioning that even with this hack applied, I2SD can still be used as initially intended: none of the headers was taken over and all connectors are still accessible. Nice and clean hack :)


Related posts:

Saturday, October 15, 2011

How to make a cheap two-axis tilt sensor

I am sure many of you will find this trivial, but since I couldn't see any reference to something similar, I thought I should document it.

This hack allows you to measure tilt with a 90 degrees "accuracy" in a vertical (or I should say "non-horizontal") plan, basically to determine the orientation "up", "down", "left" or "right".

You will need 2 simple tilt switches and 3 resistors, wired as in the schematic below and assembled on a piece of prototyping board as shown in the photo.



















It is important to place the 2 tilt switches as shown, 45 degrees on each side of the "vertical" axis. The little board now becomes the "2D tilt sensor". It is shown connected to the Arduino with 3 wires: Vcc (red), GND (black) and A1 (white-orange). I used axial tilt switches, but radial (as those sold by adafruit) work as well.















The voltage on analog input A1 of Arduino is dependent on the orientation of the 2D tilt sensor. I selected the value of the resistors so that the voltages are spread as much as possible over the 5V range.
Basically, by closing any or both of the switches, unique voltage dividers will be created. By reading the voltage on the analog pin we can easily figure out the orientation of the 2D tilt sensor.

Here are the 4 possible combinations:
  • S1 open, S2 open: A1 = 0V
  • S1 close, S2 open: A1 = 1.6V
  • S1 open, S2 close: A1 = 2.5V
  • S1 close, S2 close: A1 = 3V
As always, comments are appreciated.

Friday, October 7, 2011

Difference between 3208 and 0832 LED displays from Sure Electronics

Many people are building stuff using the 3208 LED display from Sure, based on projects I have shown here (e.g. BookClock). The test code I published doesn't work "out of the box" with these newer displays. So they ask the question: why? Here is the answer.

The "older" 0832 LED display uses the HT1632 chip. The "newer" 3208 (which comes with either 3mm or 5mm LEDs) uses the slightly different HT1632C chip. (Note that HT1632C chip is also used in the bi-color 3216 displays.)
The difference between these two chips, from the software perspective, is in the initialization procedure.

Here is part of the ht1632_setup() function for the 0832 display (with HT1632):

  ht1632_sendcmd(HT1632_CMD_SYSDIS);  // Disable system
  ht1632_sendcmd(HT1632_CMD_COMS10);  // PMOS drivers
  ht1632_sendcmd(HT1632_CMD_MSTMD); // Master Mode
  ht1632_sendcmd(HT1632_CMD_SYSON); // System on
  ht1632_sendcmd(HT1632_CMD_LEDON); // LEDs on


And here is the similar code for the 3208 display (both the 3mm and 5mm versions, only the LED matrices are different) with HT1632C:

    ht1632_sendcmd(HT1632_CMD_SYSDIS);  // Disable system
    ht1632_sendcmd(HT1632_CMD_COMS00);
    ht1632_sendcmd(HT1632_CMD_MSTMD); /* Master Mode */
    ht1632_sendcmd(HT1632_CMD_RCCLK);  // HT1632C
    ht1632_sendcmd(HT1632_CMD_SYSON); /* System on */
    ht1632_sendcmd(HT1632_CMD_LEDON); /* LEDs on */


Saturday, October 1, 2011

I2SD kit

A while ago I received the good-looking I2SD kit from Wyolum. This is another open source project created and generously shared by the same team that brought us ClockTHREE and C3Jr.

The I2SD kit is pictured below. As you can see, it is mostly SMD (0805 and SOIC packages). Not for a novice, but definitely easy to solder by anyone with a steady hand and a good pair of eyes.















As always, when I assemble a kit, I try to skip the "read the manual" part. I don't recommend this to anyone though. This is just a test for me to assess how user-friendly the kit is. (Note: Ironically, this test would fail for my own Wise Clock 3 kit because of the 3 resistors of 4K7. One really need to know exactly where those resistors go (R5, R6 and R7). An improvement in a future version of Wise Clock 3 would be to have the resistor values on the silkscreen, as C3Jr has.)
Well, the I2SD kit passed the "no manual required" test, which means that the kit is well thought and designed. Again, if you are not sure what you are doing, you should not attempt building this kit without reading the documentation first.

The next photos show the top and bottom sides of the assembled I2SD, with the SD card inserted into the socket.




























As you can notice from the photos, I2SD has an on-board ATmega328, thus making it an (software-wise) Arduino-compatible. It also has an SD socket, an RTC chip (DS3231) with backup battery, and the 6-pin FTDI connector.

The I2SD was designed to be used as an Arduino storage peripheral, linked with Arduino devices on I2C.
For this purpose, the I2SD runs a sketch that:
- receives "read" commands from a host and returns the required data it reads from the SD card file;
- receives "write" commands from the host and stores the data in the SD card file.

As mentioned above, the I2SD itself can be used as a standalone Arduino (since the ATmega328 has the bootloader). To test it, I uploaded (with the Arduino IDE 22) this sketch which writes to the file TEST.TXT on the SD card.

I2SD can be integrated within many devices requiring data storage and retrieval, ranging from data logging (the RTC chip is definitely helping here), to system configuration, image capturing etc.