Cakebot
  • Home
  • Meet The Cakebot
  • Mechanical
  • Electrical
  • Software

Software  and  Firmware  

CAKEBOT GITHUB
The software system consists of a Python GUI that provides an interface for users as well as being the master control code for Cakebot. It was built using Python's Easygui module as well as Pygame to handle events. There are separate functions for all tasks, such as moving the platform or calibrating each motor. The program was designed to be as modular as possible in order to facilitate rapid changes and to make testing easier. 

The GUI allows users to draw a custom design in the editor window. This drawing is saved by tracking the cursor's position and saving the drawing as many short line segments. The lines in the GUI are 20px wide, which corresponds to about 3/16 of an inch, an accurate depiction of how wide of a bead the Cakebot will lay down. This way the user can get a realistic idea of how detailed of a design will work before they draw it. The drawing window is a square, which will translate to being inscribed within the top surface of the cake. 

The GUI sends control codes through Pyserial to the Arduino. These consist of a 3 letter code attached to a number detailing how long or far to turn a motor. For example, the code "RPC23" tells the Arduino to rotate the platform 23 steps clockwise. After almost all commands, the GUI awaits for a certain timeout period for confirmation from the Arduino that the command was executed. If the timeout passes without reply, it's assumed that the command failed. 

The GUI also contains many different options for interacting with Cakebot. Some of these include:
  1. A testing menu where a user can test for connection, test whether each motor is functioning, or test overall functionality.
  2. A calibration menu where the user can calibrate the stepper motors using the built in limit switches, and can also calibrate the frosting motors manually.
  3. A manual control window where a user can control every motor in every direction manually. 
  4. Printing preset designs such as an outside border or spiral.
  5. Printing the design currently drawn in the drawing window.


A sample drawing in the drawing window
Control Flow Diagram for Testing Routine
Manual Control of Cakebot
Cakebot's firmware consists of Arduino code running on an Arduino Uno. The Arduino controls all low-level tasks and can receive commands from the Python control code as well as send commands back to Python. It communicates through Pyserial to a Linux computer running the Python GUI. 

The Arduino code always starts by establishing a serial connection, then immediately goes into a waiting state where it awaits serial instructions from the Python control code. After receiving a command, it splits the incoming string into the first 3 characters and then whatever follows. These first 3 characters are the command code. The remaining characters are usually a number representing how many steps to move, how long to spin for, etc. It checks the command code against a series of if else statements. Once it finds the correct command, is executes it, using the remaining characters as numerical input as needed. Most commands will end with a confirmation code being sent back to the GUI. This ensures a linear, consistent control flow.

Here's a list of some command functions the Arduino performs:
  1. Spin the platform motor.
  2. Spin the top stepper motor.
  3. Spin either frosting motor.
  4. Check whether Cakebot is powered.
  5. Check the state of the green confirmation switch.
A sample Arduino Command
Using Github to track files
Sample DC motor test code
Create a free web site with Weebly