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 16×2 LDC and a rotary encoder with a push button were picked up 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 single 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 were stored and read from a 2-dimensional character array, which was 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 still somehow biased, leading to the same few quotes being favored. After finding and testing the TrueRandom library, I discovered it too is not truly random. On the quest for better randomness, I found an article by David Pankhurst that laid out exactly what I was looking for.
The latest Arduino source code can be found here 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.