This is the story of how I got a $100 3018 CNC machine and turned it into a homework robot. This project was mostly software, and only a few hardware modifications were necessary to get my machine running. In this post, I’m going to run through how I achieved this and how you can do it at home!
Buy a 3018 CNC machine and build your own homework machine!
Just one thing before I begin: This project was written in node.js, since that is what I am most comfortable with. I know it’s not as optimized as it could be, but I kept the code as simple and rudimentary as possible to make sure anyone can read and understand it.
The Hardware
The hardware for this project was fairly simple, requiring only a 3018 CNC machine, which you can pick up at Micro Center for about $100, and a piece of cardboard w/a pencil. All I had to do was glue a pencil to the spindle holder of the 3018 and put the paper on the moving base of the machine. The real challenge was software.
The Software
For this project, software was key. I wanted the machine to write in my own handwriting, so I could use it for doing my homework. This was.. easier said than done. In the end, I had to create a web interface that allowed me to draw my handwriting. Then, I needed a data file to store my handwriting data. The actual code that generates the G-Code for the 3018 CNC is fairly compact, but it took hours of work to get it working how I wanted it to.
Here’s my code, for anyone interested:
const fs = require('fs');
const prompt = require('prompt-sync')();
const data = JSON.parse(fs.readFileSync('data.json', { encoding: 'utf8', flag: 'r' }));
let output = "";
const input = prompt('Text: ');
const sizeInMm = prompt('Height of text (in mm): ');
const lengthInCm = prompt('Length in CM: ');
let line = 0;
let ind = 0;
let isOverLength = true;
let length = 0;
for (let i = 0; i < input.length; i++) {
if (isOverLength) {
ind = 0;
line++;
isOverLength = false;
}
ind++;
for (let j = 0; j < data.letter_data[input[i]].length; j++) {
let x = data.letter_data[input[i]][j].x/(275/sizeInMm)
let y = data.letter_data[input[i]][j].y/(275/sizeInMm)
x += (ind*200/(275/sizeInMm)) - (200/(275/sizeInMm));
y -= line * sizeInMm
output = output + `G01 X${x} Y${y} Z${data.letter_data[input[i]][j].z} F600\n`
if (x > lengthInCm) {
isOverLength = true;
}
}
}
fs.writeFileSync('output.gcode', output);
This code works by iterating through the letters you give it. It appends the appropriate data to our g-code variable, depending on which letter is next in the string. In order to get the data for my handwriting, I wrote a simple HTML file with JavaScript. This let me draw on a canvas, then save that data for use in the g-code.
I simply opened the HTML file in Google Chrome, drew a letter, and clicked save. In the console, it prints the data necessary for the node.js program. In Chrome, you can right click the console output and click “copy object”, then paste it into the data file. Once formatted, this can be used to emulate your handwriting in g-code.
I would then send the g-code file to the machine and it would write out what I asked it to! This was a fairly simple project compared to other projects I’ve worked on in the past, but it was a lot of fun, as I’ve been trying to do something similar to this for a while. Overall, I enjoyed building this homework robot, and I highly recommend trying something similar if you have a 3018 CNC or similar machine lying around.