Create your pancakes with code!
This lesson introduces you to the concepts behind CNC Computer language called G-Code and walks you through a step by step introduction on creating your own computer generated pancake designs with your PancakeBot.
Outcomes/Objectives
Use G-Code to learn how to control PancakeBot and use the coordinate plane to create horizontal or vertical lines in G-code.
Lesson Overview
In this lesson, students will relate their earlier work with the coordinate plane to the PancakeBot. The teacher will demonstrate, using this exciting technology, a real-world application of this math skill. The teacher will show students how to use G-code to communicate with PancakeBot to print out horizontal or vertical lines on the machine’s coordinate plane.
After understanding the basic commands needed for printing out a horizontal or vertical line on PancakeBot, students will work in pairs to write the code. The teacher and/or other adults will circulate among pairs to give real time, constructive feedback on whether their code will work.
Students can then assess each other’s code, making any changes as needed. Once they are happy with their work, they can use PancakeBot one pair at a time to enter their code.
When all students have had a chance to enter their code, they can approach the PancakeBot one pair at a time to test out their code. Teacher or other adults in the room will assist with turning the machine on and off, filling the machine with pancake batter, clean up, etc. Each pair of students will create two lines using their code, so that they can eat the results afterwards.
At the end of the lesson, students will complete a short assessment, the Sample Coding Scenario sheet, that presents them with the following question: If Student X wrote the following code for PancakeBot, would it produce a horizontal line? Why or why not?
Teacher: Laptop, LCD projector, big G-code chart, PancakeBot, premixed batter, towels, forks and plates.
Students: 1 laptop per pair, G-code sheet, Sample Coding Scenario sheet, plates, forks, and assessments.
Grouping Strategy: Students can be paired according to their comfort level with the coordinate plane, their comfort level with technology, or their comfort level with programming languages. Goal-oriented students with greater stamina or a greater ability to try new challenges can be paired with students that need more support and encouragement. If all students are close in ability, pairing them according to stamina and readiness for challenge may be a good strategy.
Academic Vocabulary:
Programming language
G-Code
Zeroing
Extrusion
Polygon
Pressure
Vacuum Pressure
Calibration
Feed Rate
Standard
CNC
SAFETY FIRST
When operating the PancakeBot, there are few precautions one must take.
Become familiar with PancakeBot's G-code commands and a G-code file.
G-code Commands
PancakeBot is a CNC machine which uses basic commands to move the bottle to different places on the griddle, and drop pancake batter.
The commands are written in a programming language called G-Code that tells a machine how it should make a pancake.
Here is a list of the commands that commands that PancakeBot uses.
Typical G-Code File Setup
When creating a G-Code file, you simply use a text editor and change the extension of the file from .txt to .gcode. You will neet to set up your settings on your computer to see file extensions if you cannot see them.
You can add comments after the semicolon after any command.
For Example, if you want to make a comment after the G-Code command to turn the motors off, you write the following:
M84; Turn Movement Motors Off
You can also just add a semicolon and a comment afterwards.
A newline is a new command.
Task 1:
Write the G-code command to create a line from the following points:
10,15 to 30,40
Task 2: Write the G-code command to set the speed to 5.4 meters per minute
Task 3: Write the G-code command to turn the batter pump on, and then add a the comment “Batter is flowing!”
It is time to code and draw your first pancake. You'll set up the coordinates, and print out your pancake. You'll aslo get an opportunity to review your design and make changes to it.
*******
;Set Up My PancakeBot
G21; Set Units to MM
G1 F7600; Set Speed to 7600 mm per minute
M107; Turn Batter Dispenser off to stop batter flow
G28; Home All Axis
;Making My Pancake
;Finish Printing
G28 X0 Y0; Home all axis
M84; Turn Movement Motors Off
*******
Once the file is set up, we can now begin looking at how we will draw our square pancake.
Note that this setup can be used for al types of pancakes!
In this step you'll make a drawing on graph paper, and use that drawing as a reference for your square pancake. The PancakeBot uses mm as its unit of measurement, but your graph paper does not have to be in mm, you just have to be consistent with your numbers.
When you look at the griddle of the pancakebot, you will need to imagine that there is a grid made up of one by one mm squares. There are 220 squares along the short side of the PancakeBot griddle, and 485 squares on the long side of the PancakeBot griddle, this means we have an area of 220mm x 485 mm. In Figure 1, we shows squares every 10 mm (not to scale).
For your first pancake, you’ll only need to go out at least 150 mm. You can set up your graph paper to have as many mm per square as you want based on the scale of your drawing. In Figure 2, each square is 10mm X 10mm
This grid shows a square with the following coordinates
(30,30)
(130,30)
(130,130)
(30,130)
Notice that the points aren’t in any order, so you could start drawing your pancake from any point. For this example, we will start at (30,30) and move in a counterclockwise fashion. Use Figure 3 as a referance.
Next, we need to take these coordinates and write them into the G-Code so PancakBot can understand what to do.
We’ll go ahead and start off with 30,30 as our first point and work our way around.
G00 X30 Y30; Move bottle to coordinates (30,30)
G00 X130 Y30; Move bottle to coordinates (130,30)
G00 X130 Y130; Move bottle to coordinates (130,130)
G00 X30 Y130; Move bottle to coordinates (30,130)
G00 X30 Y30; Move bottle to coordinates (30,30)
Figure 4 shows how the G-Code and Coordinates relate to one another.