HOME  CONTACT

July 25, 2011

Stillduino v2

    With the acquisition of a new distillation unit, I decided to transfer and adapt the arduino control interface from my previous distillation unit to this one. I wanted a redesign that would reduce size and increase functionality. The 120VAC solid state relays, arduino, and a resistor were the only components that made the cut into the new design. A 16x2 LDC and a rotary encoder with a push button were picked up from Sparkfun for input and feedback. The rotary encoder allows unrestricted rotation as well as having a normally open push button. This, in combination with an LCD, seemed to be the simplest interface with the greatest functionality.




    On the breadboard, the blue potentiometer controls the backlight brightness, and the black relay switches the backlight on and off. Some of the code from my previous interface could be used, but much of it had to be rewritten for use with a rotary encoder instead of a 6-position dial and an LCD instead of a lone LED.
    Coding was fairly straight-forward. The LCD was used in 4-bit mode to allow a connection requiring only 6 output pins, and was controlled with the LiquidCrystal library. I could not find an LCD menu library for a rotary encoder, so I wrote it. The rotary encoder outputs gray code, which was easily handled with the QuadEncoder library. Setting the arduino to sleep was handled by the sleep library.
    When all coding was finished, I ended up with more than half of my available memory on the ATMega328 unused (20 of 32K). I decided to fill the space by coding a function to display a character string across the LCD in the form of a randomly selected short quote. This function runs while the fan test is being performed, which is upon powering or waking up. Like many arduino projects that use LCDs, the 1K variable memory can quickly get used up, leading to unpredictable results when the program runs. To get around this limitation, the quotes are stored and read from a 2-dimensional character array, which is placed in program memory with the pgmspace library.
    To make the quote selection random, I turned to arduino's own random() function. Even with the suggested randomSeed() called to initialize a pseudo-random series from unconnected analog pin 0 noise, I found that the resulting random numbers were heavily biased, leading to the same few quotes being played. After finding and testing the TrueRandom library, I discovered it too is not that random. On the quest for better code, I found an article by David Pankhurst that laid out exactly what I was looking for.

If interested, my code can be found on github.

Current program features include:
The rotary encoder's push-button wakes the arduino from sleep mode and a menu option puts it back into sleep mode.
The LCD displays a random quote during the mandatory start up fan test.
The amount of water that has been distilled is stored in PROGMEM until it is reset through the menu. A warning will be displayed when 114 liters have distilled, requiring a carbon filter change and the resetting of the total-volume-distilled counter.
The volume to distill can be selected from 1 to 3 liters (1/1.5/2.5/3).
There is the option to start distillation after a desired period of time.
The LCD displays a summary of the volume to be distilled and (if selected) the delayed start time, with confirmation to begin.
The LCD displays the number of liters distilling and time remaining until the start/finish.
The LCD displays "Caution, Hot" warning for 30 minutes after distillation finishes.
The LCD backlight turns off and the arduino goes into sleep mode when the cool-down warning finishes.

    Future plans include removing the arduino board, leaving the ATMega328, once I feel the code has fully matured. I would also like to get my hands on some metal-working tools to put everything behind the metal exterior, for a more polished appearance.






2 comments:

  1. Hello from Argentina (and sorry for my english)!

    I'm trying to use your code but when i try to compile have this message:

    error: ‘class QuadEncoder’ has no member named ‘hb’

    Thanks for your help.

    ReplyDelete
    Replies
    1. I see this has been solved by you at http://arduino.cc/forum/index.php?topic=154457.0
      Nice work!

      Delete