Mechanical and Machine Design Group Project: Cross-border AI Writing Machine - "The WordMiser Oracle"
For the original one, we have put it on the Youtube.
Project Overview
"The WordMiser Oracle" is a cross-border collaborative project that connects the SenseCAP Watcher AI assistant at Chaihuo Makerspace in Shenzhen with a mechanical writing machine at the Macau Science Center, creating a unique interactive experience.
The core idea of the project is to create a "WordMiser" AI oracle, which must limit its answers to 25 characters and have them physically written out by the mechanical writing machine. This design aims to remind people that in an age of information explosion, concise expression is often more valuable than lengthy content.
The project achieves real-time communication between the two locations via the MQTT protocol:
- Shenzhen Side: Uses the SenseCAP Watcher AI assistant to receive user questions and generate concise answers.
- Macau Side: Designs a mechanical writing machine to receive AI-generated text and physically write it on paper.
System architecture of The WordMiser Oracle
Team Members
- Chon Kit Kuok: Responsible for writing machine hardware and programming
- Long Wai Chan: Responsible for mechanical structure design
- Hongtai Liu: Responsible for SenseCAP Watcher AI programming
- Lei Feng: Responsible for MQTT text-to-G-code converter design
Phase One: Machine Design and Construction
In the first phase, our goal was to build a basic writing/drawing machine capable of receiving text or images and performing writing/drawing.
Machine Structure Selection
After researching and comparing different machine structures, we chose the Cartesian coordinate robot structure because the X and Y axes are controlled separately, making it easier to control and program.
Hardware Components
To save time and focus on improvement and application, we assembled the machine using as many existing resources in the lab as possible:
Component | Specification | Quantity |
---|---|---|
Aluminum profile | 20 × 20 × 25cm | 2 |
Aluminum profile | 20 × 40 × 35cm | 2 |
Aluminum profile | 20 × 40 × 29.7cm | 2 |
Stepper motor | Nema 17 | 3 |
Microcontroller | Arduino Nano | 1 |
Stepper motor driver | A4988 | 2 |
Arduino CNC Shield | Rev2.7 | 1 |
Assembling the hardware of the writing machine
Machine design_v1
Firmware and Control
We used GRBL as the firmware to control the CNC machine. GRBL is a popular open-source firmware for controlling CNC machines with Arduino. It interprets G-code commands and controls the stepper motors accordingly.
Steps to Upload GRBL Firmware
- Download GRBL firmware from GitHub
- Add the library to Arduino IDE
- Upload the firmware to the Arduino board
Connecting the CNC Shield
According to the wiring diagram, we connected the stepper motors, servos, and limit switches to the CNC shield, then connected a 12V power supply to drive the stepper motors.
CNC shield wiring diagram
Using
G-codePlot
extension to convert images to G-code
We then tested whether the relevant G-code could run on the machine.
G-code simulation in the UGS interface
Phase Two: AI Integration and Communication
We integrated the SenseCAP Watcher AI assistant and implemented the following features:
- Offline speech recognition
- Local inference and command parsing
- Access to online large language models
- MQTT communication extension
MQTT Configuration
We configured the MQTT client:
- Server address:
broker.emqx.io
- Topic:
fablab/chaihuo/machine/text
- Port:
1883
- Authentication (username/password): None
AI Response Handling
After the AI generates a response, we wrap it in a standard format and publish it to a specific topic via MQTT.
MQTT Text-to-G-code Conversion
We developed a Python program to convert the received text into G-code and send it to the GRBL controller. The main functions include:
- MQTT Client:
- Subscribes to the specified topic and receives text messages
- Text-to-G-code Converter:
- Converts text into G-code instructions
- Supports English letters, numbers, and some punctuation
- G-code Sender:
- Sends G-code to the GRBL controller via serial port
- Status and Error Handling:
- Manages program status and error handling
- Configuration and CLI:
- Provides full configuration options via
config.yaml
- Supports precise control of pen height parameters and feed rate
- Provides full configuration options via
MQTT G-code converter program GitHub repo: MQTT-text-G-code-GRBL
When running the project program, if the MQTT content "Life is a journey of growth." is received, the following output can be seen in the programming environment:
--- MQTT Message Received ---
Topic: fablab/chaihuo/machine/text
Raw Payload: b'Life is a journey of growth.'
Decoded Text Payload: Life is a journey of growth.
Checking Serial Port: ser=Exists, is_open=True
Converting text to G-code...
Warning: Character '.' not found in definitions. Skipping.
Processing 377 G-code line(s) generated from text:
[G-code->GRBL] G0 F1500.0 X0.00 Y6.04
[GRBL<-] ok
[G-code->GRBL] M03 S150
[GRBL<-] ok
[G-code->GRBL] G1 F1500.0 X0.00 Y0.00
[GRBL<-] ok
[G-code->GRBL] G1 F1500.0 X3.56 Y0.00
[GRBL<-] ok
[G-code->GRBL] M05 F1500.0
[GRBL<-] ok
...Omit intermediate content
[GRBL<-] ok
[G-code->GRBL] G1 F1500.0 X122.24 Y0.00
[GRBL<-] ok
[G-code->GRBL] M05 F1500.0
[GRBL<-] ok
[G-code->GRBL] G0 F1000.0 X123.74 Y0.00
[GRBL<-] ok
Finished processing G-code from message.
Sending post-message G-code (input did not end with newline)...
[G-code->GRBL] G1 F500.0 X0.00 Y-8.00
[GRBL<-] ok
Successfully sent post-message command: G1 F500.0 X0.00 Y-8.00
--- End MQTT Message Processing ---
Disconnected from MQTT broker with reason code Unspecified error
Successfully connected to MQTT broker with reason code Success
Subscribed to topic: fablab/chaihuo/machine/text
Project Demonstration
The project workflow is as follows:
- At Chaihuo Makerspace in Shenzhen, a user asks the AI via SenseCAP Watcher: What's the meaning of life?
- The AI generates a short answer (limited to 25 characters): "Life is a journey of growth." and sends it via MQTT.
- The program at Macau Science Center receives the text and converts it to G-code.
- The writing machine executes the G-code instructions and physically writes the answer on paper.
Project Summary and Reflection
The "WordMiser Oracle" project is not only a technical challenge but also an exploration of "how to rethink the value of communication in the digital age." Through the relatively "slow" medium of physical writing, we hope to remind people that sometimes "less is more" in this age of information explosion, and concise expression may be more valuable than lengthy content.
The project successfully achieved cross-border technical collaboration, integrating AI, IoT, and mechanical control technologies to create a unique interactive experience.
Future Improvements
- Support drawing more characters and symbols
- Optimize the drawing path algorithm to improve writing speed and quality
- Develop a more user-friendly interface to enhance system usability
- Add more error recovery mechanisms to improve system stability in complex environments
- Improve the hardware structure to increase the writing area
Personal Contributions
Chon Kit Kuok
- Writing machine hardware and programming
- MQTT data receiver
Long Wai Chan
- Mechanical structure design
- Hardware connection and upgrades
Hongtai Liu
- SenseCAP Watcher AI programming
Lei Feng
- MQTT text-to-G-code converter design
- Text-to-G-code conversion
- MQTT transmission
- Project video directing and post-production
References
- GRBL: https://github.com/robottini/grbl-servo
- Universal G-Code Sender: https://winder.github.io/ugs_website/
- G-codePlot: https://github.com/arpruss/G-codeplot
- SenseCAP Watcher: https://www.seeedstudio.com/watcher
- XIAOZHI AI: https://github.com/78/xiaozhi-esp32
- MQTT-text-G-code-GRBL: https://github.com/mouseart/MQTT-text-G-code-GRBL