Hardware Design
The Cooking Coach Consists of a mega103L processor on a STK-300 development board, a Seiko 321D LCD display and seven pushbuttons. We chose the mega103L because we needed many I/O lines and a large amount of SRAM. The components have been laid out as:
- Port A - used to access external SRAM
- Port B - control lines for the LCD
- Port C(output only) - used to access external SRAM
- Port D - data lines for the LCD
- Port E - appliance and buzzer control lines
- Port F(input only) - Pushbuttons with external pull-up circuits.
The LCD is powered off a separate 24 volt power supply though a 10kΩ wiper.
Refer to the Schematic Appendix for a diagram of our connections.
Software Design
The Cooking Coach consists of three simultaneously executing state machines
- File Transfer and Memory Management
- Receive characters when processor is free
- Pushbutton detection, debounce and execution
- Capture Button Press
- Wait State to debounce button press
- Current Screen State Management
- Main Menu
- Options Menu
- Select Recipes for Shopping List
- Shopping List
- Select Recipe
- Display and Execute a Recipe
Memory Usage
Memory is allocated such that commonly used variables get lower memory addresses to maximize use of the Atmel's on board RAM. Larger data structures, such as stored actions, pending timers, the list of recipe names and the complete recipes are allocated last.
File Transfer
Files are transferred over a serial cable connected to a PC. The UART receives one character at a time and inserts them into the their appropriate place in the recipes database. It also listens for control sequences to build a list of recipes at the same time.
Timing
Timing is based on a one second tick from the timer1 clear on compare match A. On each tick, the number of seconds is decremented by one and the minutes and hours are adjusted appropriately. If either of the timers are changed a flag is set so when the processor is free it will update the time displayed on the screen.
When either timer 1 or timer 2 expires, pendingAction1 or pendingAction2 is prepared to be executed.
Push Buttons
The meaning of each button is dependant on the current state of the screen and which actions or timers are ready to be executed.
Scroll Up - moves the line highlighted up and ensures that the user cannot move the cursor over the title or borders.
Scroll Down - moves the line highlighted down and prepares to execute actions and start timers by presenting a button for execution to the user.
PANIC - the PANIC button is a button to only be used in a kitchen emergency. It shuts off all of the appliances at any state of the program.
Selection0 - At the main menu, this button changes the state of the screen. In all the other screen states, this button takes the user back to the main menu.
Selection1 - If the screen state is:
- Select Recipe -> Displays highlighted recipe
- Cooking -> Display the Selected Recipe
- Select Recipes for Shopping list -> add highlighted line to the recipes in the shopping list
- Shopping List -> checks off the highlighted item
- Options Menu -> adds control for the highlighted appliance
Selection2 - If screen state is:
- Select Recipe -> Displays the list of recipes
- Select Recipes for Shopping List -> takes the highlighted recipe out of the shopping list
- Shopping list -> Checks off highlighted ingredient
- Options Menu -> Removes the highlighted appliance control
- Cooking and on a Timer line -> Starts Timer 1
- Cooking and on an Action line -> Executes the pending Action
Selection3 - If screen state is:
- Select Recipe -> delete the highlighted recipe
- Select Recipes for Shopping List -> Shows the shopping list
- Cooking -> Starts Timer 2
Push Button State Machine
Button presses are recorded and executed when released. Timer 0 overflow ticks every 30ms, which is slow enough to take care of debouncing the buttons. A set of pull-up resistors are attached to the buttons because Port F does not have them built in.
Screen States
Display Main Menu(Default screen state) - Presents the user with the option to pull up the Options Menu, Build a Shopping List or to Select a Recipe.
Display Options Menu - Lets the user enable and disable control of appliances
Create List for Shopping - Presents the user with all of the recipes in memory and lets him/her check off the ones to put on the shopping list and then displays the list on a button press.
Display Shopping List - Shows all of the ingredients needed for the recipes just selected in the Create List for Shopping State.
Display Recipe List - Lists all of the Recipes in memory. The user can view recently added recipes, delete old recipes and execute a recipe.
Show Recipe - Displays the ingredients and steps in a recipe. It also stores away pending actions and timers and starts them when the user scrolls down the appropriate line on the recipe.
Recipe Execution Methods
Action - writes data out to Port E to control the appropriate appliance if The Cooking Coach is set to control that appliance.
Ready to Start Action/Timer1/Timer2 - Turns on a button to start the Action/Timer1/Timer2 respectively.
Start Timer1/Timer2 - Sets the appropriate timer and loads up the action to be executed on its completion into pending Action1/pending Action2
Start Timer1/Timer2 Pending Action - This method is executed when the respective timer expires. It reads the pending Action and executes it.
Delete Recipe - removes a recipe from the main database, list of recipe names and its pointer into the main database.
LCD Methods
Print Word - shortcut to print a word from flash onto the screen. Used for buttons.
Print Blank Line - used to clear buttons when they are no longer applicable.
Display Timer Labels - Puts the labels for the timers on the screen.
Update Timers - This method prints the current time on each timer to screen. Only called when the processor is free and timers have changed since the last screen update.
Display Buttons - Displays the default buttons on the screen for each screen state.
Display Borders - Draws lines for windows on the screen
Highlight - Turns on pixels on layer 2 of the LCD which we XOR with the text to highlight the text.
Un-Highlight - Turns off the pixels for a specified line on layer 2 of the LCD which we XOR with the text.
Initialize LCD - The sequence of commands used to initialize the LCD. See the datasheet for more details
Write Command - Writes a command to the LCD
Write Data - Writes an 8-bit data element to the LCD
Clear LCD - Sets all memory locations on the LCD to zero.
Main - Enables external SRAM, initializes UART to receive files, fires up interrupts. Then it loops over the screen states and timer updates to execute them when the processor is free.
Terminology
Timer1/Timer2 - The Cooking Coach has two timers built in which are set by the recipe but started by a button press. (Timers can be confused with the timers built into the micro-controller.)
Actions - Events in a recipe which are automatically executed by The Cooking Coach. For example, set the oven temperature to 350 degrees.