Solenoid Winding Machine

Overview

A group project for ENSC 351. We built a bench top, CNC solenoid winding machine. The machine uses a C-axis spindle to rotate a bobbin and a Z-axis linear traverse to place wire in precise layers. Wire tension is conditioned by a brake and measured via a force sensor, and end-stop switches provide absolute positioning. The working area supports bobbins up to 150 mm radius and 130 mm length.

The team consisted of four members, each responsible for a subsystem: motion system design, wire routing and tensioning, electronics and power, and the logic and control software.

1 / 3

Early spindle and controller test on the winding machine frame

Design

The entire machine was designed in SolidWorks. The frame is constructed from steel tube, cut to length with drilled mounting holes for the motor mounts, linear stage rails, and electronics bay. Both axes use closed-loop stepper motors with the same model of driver. The C-axis drives the spindle rotation, and the Z-axis uses a lead screw to position the wire feed point along the bobbin.

The C-axis was originally driven by a 48V AC servo motor (as in pictures), controlled via Modbus over RS485. It failed due to electromagnetic interference conducted through the steel frame (we measured over 2 Vpp on the frame with an oscilloscope, despite the motor being electrically isolated with a plastic mount). After the servo failed, we replaced it with a larger stepper motor matching the Z-axis driver, using step and direction pulses over GPIO. The steppers later developed thermal issues under sustained use, which we resolved by adding a computer heatsink and fan.

The wire routing stage includes idler pulleys, a brake drum for tension control, and a force gauge for real-time tension measurement. A spool mount holds the wire supply, and the wire is guided through the tensioning system before reaching the bobbin.

1 / 2

Isometric mechanical drawing of the winding machine frame

My Work

I was responsible for the logic system: the control software that runs the machine. The software runs on a BeagleY-AI single board computer and is written in Rust. It communicates with the motor drivers over GPIO and SPI to send position and speed commands.

I built a Terminal User Interface (TUI) using the ratatui library, which displays real-time motor state including position, speed, and target values. The TUI also provides a command input for issuing movement commands and a log panel for debugging. The interface was designed to work over both local HDMI and remote SSH, which led to the decision to use a TUI rather than a GUI.

1 / 3

Terminal interface showing live motor position and speed during development

Firmware Architecture

The firmware is written in Rust and runs on a BeagleY-AI single board computer. It uses a threaded architecture with each motor controller pinned to a dedicated CPU core for real-time performance. The system is built around trait-based hardware abstractions, a type-safe units system to prevent dimensional errors, and a state machine for managing multi-layer winding jobs. The hardware abstraction defines common traits for servos and spindles, so the higher-level machine code is agnostic to the actual motor type. This proved critical when the C-axis AC servo failed: we were able to swap it for a stepper motor with only a configuration change, with no restructuring of the control logic.

  • src/
    • main.rs Entry point, TUI event loop
    • command.rs Command parser with validation
    • job.rs Winding job state machine
    • units.rs Type-safe physical units
    • ratio.rs Dimensional analysis
    • measure.rs Sensor caching with decay
    • logging.rs Log panel for TUI
    • machine/
      • mod.rs Machine orchestrator
      • c_axis.rs Spindle rotation control
      • z_axis.rs Linear traverse control
    • hardware/
      • mod.rs Hardware traits: Servo, Spindle
      • axis.rs Angle-to-distance adapter
      • gpio_stepper.rs GPIO pulse generation
      • pwm_stepper.rs PWM frequency stepping
      • threaded.rs Servo worker thread, CPU-pinned
      • spindle_threaded.rs Spindle worker thread, CPU-pinned
      • tmc5160.rs Stepper driver over SPI
      • laser.rs Laser GPIO control

The winding job state machine coordinates both axes to wind wire in a back-and-forth pattern across layers. It calculates the Z-axis position from the C-axis rotation angle and a configurable stepover ratio, reversing direction at each layer boundary. Motor threads communicate with the main loop through non-blocking channels.

mpg3@sfu.ca, linkedin · Updated 2026-08-13