Autonomous Handwriting Robot

ECE 4760 Final Project by Shelly Zhou (sz498) and Sayee Edekar (ste27)

A microcontroller-driven robotic arm that converts digital letter definitions into physical handwriting using real-time servo control.

Project Introduction

This project features an autonomous handwriting robot that produces physically written block letters using an embedded microcontroller system. We designed and implemented a robot that generates X–Y motion trajectories and precisely controls multiple motors to produce consistent, legible handwritten output on paper. The project was motivated by an interest in bridging digital automation with physical motion, and it provided hands-on experience with real-time embedded control, motion filtering, and mechatronic system integration in a human-centered application.

High Level Design

Rationale and Sources of Project Idea

The idea for this project originated from an interest in robotic arm systems and plotters, combined with our interest in building a mechanism that demonstrates how software-defined motion translates into physical behavior. Unlike traditional Cartesian plotters, this system mimics a simplified human arm with rotational joints, making it a more intuitive platform for studying servo-based motion control.

Background Math

Implemented Design. Our design relies on empirically tuned angular trajectories for each servo. Trigonometric functions such as sine and cosine are used to generate circular and arc-based strokes, while linear interpolation and incremental stepping are used for straight lines and diagonals. Motion smoothness is enforced by limiting angular step size and introducing fixed delays between servo updates.

Discrete-time servo stepping:
\( \theta_{k+1} = \theta_k + \Delta \theta \)
\( \Delta \theta = \text{clip}(\theta_\text{target} - \theta_k, \pm \theta_\text{max}) \)

Servo motion is implemented in discrete time by incrementally stepping the current angle toward a target angle. The maximum step size is limited to enforce smooth motion and reduce mechanical oscillation.

Circular and arc-based letter strokes are generated parametrically using sine and cosine functions. Incrementing the parameter angle in small steps produces smooth curved motion when mapped to servo trajectories.

Inverse kinematics (IK). IK was our initially intended approach to arm movement. Appendix C uses the following math exactly in its IK function to integrate a coordinate system with the arm. IK describes the mathematical process of computing the joint angles require for a robotic arm to place its end effector at a desired position in Cartesian space. For this project, the robot can be modeled as a two-link planar arm with rigid links of lengths \(L_1\) and \(L_2\), connected by rotational joints. The base of the arm is fixed, and the pen tip position is defined by coordinates \((x, y)\) on the writing surface.

Given a target point \((x, y)\), the distance from the base of the arm to the pen tip is

\[r = \sqrt{x^2 + y^2}\]

Using this distance, the elbow joint angle \(\theta_2\) can be computed using the law of cosines applied to the triangle formed by the two arm links and the line to the target point:

\[\cos(\theta_2) = \frac{r^2 - L_1^2 - L_2^2}{2 L_1 L_2}\]

This equation yields two possible solutions corresponding to the elbow-up and elbow-down configurations of the arm. To ensure predictable motion and avoid sudden configuration changes, a single consistent configuration would be selected during operation.

Once \(\theta_2\) is known, the shoulder angle \(\theta_1\) can be computed by decomposing the geometry into two angles. The angle from the base to the target point is

\[\phi = \tan^{-1}\left(\frac{y}{x}\right)\]

The internal angle between the first arm link and the line to the target point is

\[\psi = \tan^{-1}\left(\frac{L_2 \sin(\theta_2)}{L_1 + L_2 \cos(\theta_2)}\right)\]

The shoulder joint angle is then given by

\[\theta_1 = \phi - \psi\]

Together, \(\theta_1\) and \(\theta_2\) fully define the arm configuration required to reach a given point on the page. In practice, inverse kinematics must be computed repeatedly for closely spaced points along a trajectory to ensure smooth motion.

Although this inverse kinematics formulation was explored, mechanical backlash, limited servo resolution, and imperfect link geometry made precise positioning unreliable. As a result, the final implementation implemented the above method of tuned angular trajectories that produced more consistent handwriting results on the physical hardware.

Logical Structure

At the lowest level, the system generates PWM signals using RP2040 hardware peripherals to control servo motors. These signals are abstracted into smooth motion primitives such as straight lines and arcs by gradually stepping servo angles toward target values. Individual letters are constructed from sequences of these primitives, and higher-level routines sequence letters into complete words.

Handwriting Robot
Figure 1: High Level Code Overview.

Hardware/Software Tradeoffs

Servo motors were selected for their simplicity, low cost, and ease of integration. This choice sacrifices absolute positional accuracy and repeatability compared to stepper motors or closed-loop systems. Open-loop control was used instead of encoders or feedback sensors, reducing hardware complexity while increasing reliance on software-based motion smoothing and calibration.

Relevant IP Considerations

Handwriting robots and plotting mechanisms are well-established concepts with many existing patents and open-source implementations. This project does not attempt to replicate any proprietary mechanism and is intended strictly for educational use.

Program and Hardware Design

Program Details

PWM

Each MG90S servo expects a pulse between 500 µs (0°) and 2500 µs (180°) at a period of 20 ms (50 Hz). Using the RP2040's hardware PWM modules, we configured each GPIO pin connected to a servo as a PWM output:

This was done in the following functions:

Smooth Motion Algorithm

Rather than moving servos directly to a target angle (which causes jitter), the firmware implements incremental stepping:

Testing and Initialization

Handwriting Primitives

Utility Functions