Embedded Systems B.Tech/B.E Beginner

Penny the plotter

[Fall 2025] Penny the Plotter is a remotely controlled swerve-drive robot that draws geometric patterns on paper using closed-loop motor control.

  • Suitable forB.Tech/B.E Embedded Systems students
  • Build time4-6 weeks
  • LevelBeginner
  • Available atAjvika Labs, Kakinada

About this project

Penny the Plotter - Final Report
Table of Contents
1. Project Introduction
2. High Level Design
3. Program/Hardware Design
4. Results of the Design
5. Conclusions
6. Intellectual Property Considerations
Appendix A: Permissions
Appendix B: Code Listings
Appendix C: Schematics
Appendix D: Team Contributions
References
1. Project Introduction
High Level Overview
Penny the Plotter is a remotely controlled swerve-drive robot that draws geometric patterns on paper using closed-loop motor control.
Watch video on YouTube
Summary
Penny the Plotter is a differential swerve-drive robot designed to draw geometric patterns on a white paper or whiteboard surface.
The system combines WiFi communication for remote control with closed-loop PID motor control and quadrature encoders for precise movement.
The robot receives drawing commands via UDP from a Python control script running on a laptop, which simultaneously visualizes the path
using python turtle graphics.
The motivation for this project was to create a platform that combines multiple engineering disciplines: embedded
systems programming, mechanical engineering, and robotics. The swerve-drive mechanism provides omnidirectional
movement capabilities, allowing the robot to draw complex paths including curves and sharp turns.
2. High Level Design
Rationale and Sources
The project idea was inspired by HTX studio's whiteboard plotter robot, but adapted to use swerve drive technology and
to drive on the floor. Swerve drive systems are commonly used in competitive robotics (FIRST Robotics, VEX) for
their omnidirectional capabilities. The differential swerve design allows each wheel module to independently control
both translation and rotation, enabling smooth curved movements ideal for drawing.
Background Math
Differential Swerve Kinematics
For a differential swerve module with two motors (m1, m2), the wheel speed and steering angle are calculated as:
wheel_speed = (m1 - m2) / 2
steering_angle = (m1 + m2) / 2
For the entire robot with two modules (A and B), forward/backward translation requires:
Module A: m1 = +speed, m2 = -speed
Module B: m1 = +speed, m2 = -speed
Rotation in place requires:
Module A: m1 = +yaw, m2 = +yaw
Module B: m1 = +yaw, m2 = +yaw
PID Control
The motor control uses proportional (P) control with gain Kp = 0.25:
error = target_speed - actual_speed
duty_change = error × Kp
new_duty = current_duty + duty_change
Logical Structure
The system consists of two main components:
Robot (Pico W)
: Runs C code with protothreads for:
WiFi communication (UDP receive/send)
Motor control (closed-loop PID)
Encoder quadrature decoding (ISR-based)
LED indicator for UDP
Control Script (Python)
: High-level path planning:
Turtle graphics visualization
UDP command generation
Timing coordination
Hardware/Software Tradeoffs
Design Decision
Hardware Cost
Software Cost
Benefit Gained
Added Quadrature Encoders
4 additional sensors, 8 GPIO pins consumed, more wiring complexity
4 additional ISR handlers, encoder counting threads, more complex motor control logic
Closed-loop speed control enabling precise motor synchronization
Differential Swerve Drive
Motor count of 4, 4 motor driver channels, higher power consumption
Complex differential kinematics implementation, sign convention handling for mirrored modules
Omnidirectional movement without separate steering actuators
WiFi/UDP Communication
Required Pico W (vs standard Pico)
Full lwIP stack integration, UDP threading, packet parsing, connection handling
Untethered operation, real-time remote control, and path visualization on laptop
Software PID (vs Open-Loop)
None additional
PID calculation thread, tuning parameters
Motor speed matching within ±5%, prevents drifting
Protothread Concurrency
None additional
Thread management overhead, state machine design, shared variable synchronization
Simultaneous motor control, UDP communication, and LED status without RTOS complexity
Patents, Copyrights, and Trademarks
Relevant intellectual property considerations:
Protothreads
: Cornell ECE4760 library - provided for course use.
UDP Communication
: Based on code by Andrew McDonnel - provided for course use.
3. Program/Hardware Design
Program Details
C Code (robot.c)
The main robot firmware runs on the Raspberry Pi Pico W with the key components being:
Motor Control Thread
: 50ms control loop implementing PID for speed regulation.
Uses encoder feedback to adjust PWM duty cycles. Handles four cases: stopping, pure translation,
pure rotation, and mixed arc motion.
UDP Receive Thread
: Parses incoming commands in format "<linear> <angular>"
and updates motor setpoints. Includes error handling for malformed packets.
UDP Send Thread
: Sends debug information back to computer including motor
duties, encoder counts, and packet statistics.
Encoder ISR
: Quadrature decoding in interrupt service routine. Updates global
encoder counts for all four motors.
Tricky Parts:
Differential Swerve Math
: Getting the sign conventions correct for left vs right
modules required testing. Module B needed opposite wheel command signs due to physical
mirroring.
PID Tuning
: Initial implementation caused motors to overshoot. Added rate limiting
(max 50 units per loop) to prevent rapid duty changes.
Open-Loop Startup
: Motors initially waited for encoder feedback, causing lag.
Fixed by initializing duties to setpoint values on command start.
PWM Slice Conflicts
: Had to ensure all four enable pins use different PWM slices
to avoid conflicts.
Python Control Scripts
datasender.py
: Handles UDP socket communication with the Pico W. Creates a UDP socket
connection to the robot's IP address and port, provides a
forward()
method to send string
commands, and exposes a
robot
attribute for high-level control. Includes IP/port validation
via
InvalidAddressError
robot_instr.py
: Provides a high-level API for robot motion commands. Wraps the datasender
to offer intuitive methods like
move_forward()
move_backward()
rotate_ccw()
rotate_cw()
, and
stop()
. Also supports arc motions
via
arc_forward_left()
and similar methods. All speeds are clamped to 300 (MAX_SPEED) and
commands are formatted as
"linear angular"
strings for UDP transmission.
draw_L.py
: Generates L-shaped drawing pattern with curved rotations.
draw_square.py
: Generates square drawing pattern with curved rotations.
All commands sent over UDP are sent continuously (every 50ms) to prevent packet loss. We use Python turtle package
for visualization with curved arc animations matching swerve drive behavior.
Hardware Details
CAD Files
Our CAD files for the differential swerve drive mechanism are available for download.
The complete CAD model files contain the 3D models and design specifications for the swerve drive modules and our chassis that was used in this project.
File Name
Download
Chassis.step
Download
Roller_0_3_mm.step
Download
swerve - base.stl
Download
swerve - bracket.stl
Download
swerve - frame.stl
Download
swerve - large gear.stl
Download
swerve - long motor gear.stl
Download
swerve - middle gear.stl
Download
swerve - motor lid.stl
Download
swerve - short motor gear.stl
Download
swerve - spacer.stl
Download
swerve - wheel hex.stl
Download
swerve - wheel spacer.stl
Download
swerve.step
Download
Download All CAD Files (ZIP)
Motor Control
Component
Part
Specifications
Microcontroller
Raspberry Pi Pico W
RP2040, 133MHz, WiFi (CYW43)
Motor Drivers
OSOYOO Model Y 4-Channel H-Bridge
PT5126 chips, 4 independent channels, 2.8A max per channel, 2.0-24V motor supply, 2.7-5.5V logic
Motors
N20 DC Motor with Magnetic Encoder (Adafruit #4638)
4x motors, 6V nominal, 1:50 gear ratio, built-in magnetic encoder with hall effect sensors, 14 counts/revolution, ~100mA current draw
Pin Mapping
Function
GPIO Pins
Module A1 (Left)
EN: GP10, IN1: GP11, IN2: GP12
Module A2 (Left)
EN: GP13, IN1: GP14, IN2: GP15
Module B1 (Right)
EN: GP4, IN1: GP19, IN2: GP18
Module B2 (Right)
EN: GP22, IN1: GP8, IN2: GP9
Encoders
A1: GP6/7, A2: GP16/17, B1: GP2/3, B2: GP20/21
Power System
The system uses a single 6V 900mA battery pack as the primary power source. The battery directly
powers the motors and the OSOYOO Model Y motor driver's VM (motor supply) input. A buck converter
(logic converter) steps down the 6V battery voltage to 3.3V to power the Raspberry Pi Pico W,
eliminating the need for a separate USB power connection. The motor driver's VCC (logic supply)
receives 5V, which can be provided by the battery through a voltage regulator or a separate 5V
supply if needed.
Build Instructions
To build this project:
Print and assemble two swerve drive modules with two motors each using the CAD files provided, bearings, bolts, nuts, axles, and wheels.
Connect the swerve drive modules to the 3d-printed chassis using bolts and nuts.
Mount OSOYOO Model Y 4-channel motor driver and RP2040 Pico W onto the chassis using screws on the standoffs. Note that the Pico W is mounted on a protoboard to allow for easy connection to the chassis.
Connect motors to the driver sockets of the motor controller: AK1/AK2, AK3/AK4, BK1/BK2, BK3/BK4
Connect PWM pins (ENA/ENB for each channel) and direction pins (IN1-IN4 for each channel) to Pico GPIO
Wire encoders: A/B channels to GPIO pins with pull-up resistors
Connect Pico W GPIO pins as specified in pin mapping table
Use the Vout channel to connect the motor controller to a buck converter to power the Pico W
Connect the 6V 900mA battery to the Vin channel of the m

Technologies used

RP2040Raspberry Pi PicoCPythonSPIPWMProtoThreadsProtothreadsLEDBLEWiFiRF

Hardware components

  • RP2040
  • Raspberry Pi Pico
  • DC motor
  • IMU
  • H-bridge
  • motor driver

Software & tools

  • Python

Project demo video

What you get

  • Working project / hardware kit, tested before delivery
  • Complete source code with explanation
  • Project demo and guidance for your viva
  • Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed. Payment is in two parts: • 50% advance to start the project • Remaining 50% before delivery Note: • Documentation and PPT are not included by default • If you need documentation/PPT, it can be arranged for extra time and cost We'll confirm the exact timeline and cost with you after reviewing your requirements.