Tea-Cooker in Assembly

About the Project

This project, written in the scope of a microcontroller course, was my first contact with assembly programming.

The Problem

Having your coffee in the morning is easy: you press a button on the coffee machine and a minute later you have a delicious coffee. However, some people, including myself, sometimes prefer tea in the morning. Makin tea takes a little more time as you need to heat the water, add a teabag, and extract it at the right time. Our goal with this project was to make a tea as simple as a coffee.
The tea-cooker should prepare your tea on command as simple as the pressing of a button. The temperature and steep time should be configurable.
As the goal of this project is a prototype and not a final design, the tea-cooker shall be controllable from a computer which can easily be replaced by an IOT node later on.

The Hardware

Our solution is based on a normal water heater where we replaced the switch with a relay. This allowed us to not care about the heating element and the water container. A temperature sensor glued into a hole in the water heater detects boiling water and a servo motor inserts and extracts the teabag. Additionally, an LCD display and UART interface cable interact with the user and display status information.
It is worth noting that we're used a lot of different protocols for the peripherals. This was well thought out as the goal of the project is educational rather than producing an industry-ready product.

The final protoype. One can clearly see the temperature sensor glued into the water cooker and the servo motor (left) pullin gon a tea bag.

The Software

The tea cooker is fully written in AVR assembly. Obviously, an implementation in C was possible as there are no performance and timing constraints. However, we used assembly due to the educational scope of the project.
The tea cooker is controlled by the state machine shown below. Each state consists of an initial command sequence followed by an infinite loop.

The one-wire, I2C, and RS323 were fully controlled by software due to constraints on the microcontroller we had to use. The full code can be found in the annexe of our report.

About Logic Levels

A, usually small, problem we encountered during this project were logic levels. The ATMeag128L pins are on 5V while our relay was on 3.3V. This is easily solved with a logic-level shifter. However, we had none, and ordering one would have been too easy.
In theory, the relay should be 5V tolerable and the open-drain implementation of the I2C should ensure proper logic levels for the ATMega. However, things did not work in practice even though the observed waveforms were identical to the ones obtained by testing the relay with an Arduino. The problem was most likely due to pull-up resistors on the relay.
We finally solved the problem by using the arduino as a gateway for the I2C channel.