WEEK 12: Mechanical Design

Assignment

Design a machine that includes mechanism+actuation+automation+application.
Build the mechanical parts and operate it manually.
Document the group project and your individual contribution

Sand Drawing Machine - Group Project

The Sand Drawing Machine is a creative automation project that combines mechanical engineering, electronics, and software automation to draw patterns and shapes on sand using servo motors and a magnet-based actuation system. The machine simulates a zen garden-style drawing system where a ball or stylus is moved across a flat sand surface to trace intricate designs.


Our project fulfills the criteria of mechanism, actuation, automation, and application

Mechanism: Mechanical setup with X-Y axis movement and stylus for drawing.

Actuation: Servo motors and a Hall effect sensor-based feedback system.

Automation: G-code generation and parsing for movement control.

Application: Artistic drawing, educational tool for CNC/G-code learning, stress-relief device.

This hardware setup enables smooth and accurate movement in both X and Y directions, forming the base for our automated drawing mechanism.

Hardware Screenshots Laser Cutting machine

Laser Cutting machine

Laser Cutting machine

My Contribution: Electronics and Automation

I was responsible for the electronics, software, and automation aspects of the project.

Overview

The Sand Drawing Machine is a polar-coordinate CNC robot that creates intricate geometric patterns in sand using a combination of:

-> Linear motion (radial arm movement)
-> Rotational motion (circular sweep)
-> Pen lift mechanism (servo-controlled)

Reference Link

ESP32-Powered Tabletop Kinetic Sand Drawing Robot Tabletop Sand Robot

1.2 Key Features

1. Wi-Fi Control: Operate via any device with a browser.

2. Pattern Generation: Predefined shapes (circles, spirals, flowers).

3. Image-to-Gcode Conversion: Draw custom images.

4. Real-time Status Monitoring: Check machine state.

5. Emergency Stop & Homing: Safety and calibration functions.

Hardware Design

Componenets List
Component Specifications Purpose
ESP32 Dual-core, Wi-Fi Main controller
NEMA 17 Stepper (x2) 1.8°/step, 12V Linear & rotational motion
Servo Motor 180° rotation and Linear rotation Pen up/down mechanism
Hall Effect sensor SS49E Detect a reference (home) position

Mechanical Design

Polar Motion System

        Rotational Axis: Stepper rotates the entire arm.
Linear Axis: Stepper moves the pen radially.

Pen Mechanism:

        Servo lifts/lowers the drawing tool.

Conceptual Diagram: Polar Coordinate Robot Arm Laser Cutting machine

Firmware (ESP32 Code)

Key Features

-> Wi-Fi Access Point (AP) Mode: Hosts a web server for remote control.
-> G-code Interpreter: Parses commands (G0, G1, M3, M5, G28).
-> Stepper Motor Control: Uses AccelStepper for smooth motion.
-> Homing Routine: Uses endstops to find zero position.

Algorithm

1. Initialization:
-> Start Wi-Fi AP (ssid: iTN-FORGE/s, password: ForgeXForged).
-> Configure steppers (STEPS_PER_MM = 80, STEPS_PER_DEG = 200/360).
-> Attach servo (PEN_UP_ANGLE = 90, PEN_DOWN_ANGLE = 0).

2. G-code Processing:

-> G0/G1 (Linear Move):


        Converts X (angle) and Y (radius) to stepper steps.
Moves motors asynchronously (stepper.run() in loop()).
-> M3/M5 (Pen Control):

        M3 -> Pen down (servo.write(0)).

        M5 -> Pen up (servo.write(90)).
-> G28 (Homing):
        Moves motors backward until endstops trigger (digitalRead(HOME_PIN)).

Web Server Endpoints:

Endpoint Description
/upload Receives G-code
/status Returns machine state (ready/busy/homing)
/home Triggers homing
/stop Emergency stop
/clear Clears G-code buffer

Web Interface

Key Features

-> Pattern Generation: Circle, Spiral, Flower.
-> Image-to-G-code Conversion: Processes uploaded images.
-> Real-time Status: Checks ESP32 connection.
-> G-code Preview & Download.

Algorithm

Pattern Generation

Circle
for (let i = 0; i <= 100; i++)
{
const angle = (i / 100) * 2 * Math.PI;
gcode += `G1 X${angle} Y${radius}\n`;
}

Sprial
for (let i = 0; i <= 100; i++)
{
const r = (i / 100) * radius;
gcode += `G1 X${angle} Y${r}\n`;
angle += 0.1;
}

Image Processing

-> Converts image pixels to polar coordinates.
-> Dark pixels - Pen down movements.
-> Sorts points by angle for continuous drawing.

ESP32 Communication

Fetch API for sending G-code

fetch(`http://${ip}/upload`, {
method: 'POST',
body: gcode,br> });

Status Polling (every 3 sec)

fetch(`http://${ip}/status`)
.then(res => res.text())
.then(status => updateUI(status));

Controls

Home: fetch(/home, {method: 'POST'})
Stop: fetch(/stop, {method: 'POST'})
Clear: fetch(/clear, {method: 'POST'})

WorkFlow Summary

1. User uploads image/selects pattern.
2. Web UI converts it to G-code.
3. G-code sent to ESP32 via /upload.
4. ESP32 parses and executes movements.
5. Real-time status updates in UI.

Troubleshooting

Issue Solution
ESP32 not reachable Check Wi-Fi AP, CORS headers
Motors not moving Verify stepper wiring & power
G-code upload fails Increase fetch timeout, check server logs
Pen not lifting Calibrate servo angles

Conclusion

This system allows automated sand art creation with
-> ESP32 for motor control.
-> Web UI for easy pattern design.
-> Polar coordinate G-code for smooth drawing.

Hero shots

Webpage Chair - 2D Drawing
Chair - 2D Drawing
Chair - 2D Drawing

Download Original Design Files

Click on the links below to download the Program:

Webpage Code ESP32 Code Sample Gcode

Video

← Back to Home Page