TU Wien · 384.996 Mikrocomputer LU

Keeping a laser centred on a spinning disk.

A closed-loop embedded system that holds a laser spot on four photodiodes mounted to a rotating disk — at every angle, up to 1.5 revolutions per second. Bare-metal STM32, no RTOS, an empty while(1), and a coordinate-rotation controller running at the hardware's hard 200 Hz ceiling.

Cortex-M4 @ 64 MHz
STM32 LL only
200 Hz control rate
460 half-edges / rev
PD + coord. rotation
01 Hardware

The Physical Setup

A red laser is steered by two mirror-mounted stepper motors onto a 2×2 photodiode array that rides on a spinning disk; two light barriers tell the MCU exactly where the disk is, and the diode brightnesses tell it where the spot landed.

02 Data In · USART1

The Photodiode Data Protocol

The Maya hardware never stops talking: it streams one byte per photodiode over UART, four diodes to a frame, at a fixed 200 frames per second — and the controller fires the instant the fourth byte lands.

03 Position · EXTI3/4

Encoder & Zero-Crossing Detection

Two light barriers offset by a quarter mark generate a Gray-code quadrature signal; decoding its transitions yields direction and an absolute position 0–459, and a special wide null marker resets that count once per revolution.

04 Actuation · TIM6

Stepper Motor Control

Each mirror is driven by a unipolar stepper in half-step mode — an 8-state coil sequence walked one step per TIM6 interrupt — moving the laser in fine, bounded increments.

05 Firmware

Software Architecture

Six modules, zero polling: every action happens inside an interrupt handler, and a carefully chosen NVIC priority hierarchy guarantees that encoder edges and diode data are never missed while low-priority debug output drains in the background.

06 The core

The Control Algorithm

The diodes spin, but the mirrors don't — so a raw sensor error would send the laser spiralling. The fix is a coordinate rotation by the disk angle that turns sensor-frame error into lab-frame error, fed through a PD controller with deadband and saturation.

07 Post-mortem

Bugs Found & Fixed

Four real defects from the original monolithic firmware — each a small, plausible mistake with an outsized effect. Presented as symptom → root cause → fix.

08 Results

System Performance

The refactor hits every grade tier through Sehr gut (1.0) — reliable tracking to 1.5 rev/s — by trading an error-prone if-ladder for a closed-form rotation and locking the control rate to the data rate.

Maya Laser Tracker — STM32F334R8, STM32 LL, fully interrupt-driven.
Firmware & documentation by Harald Fuchs (12447523) and Florian Beer (12421428).
TU Wien LVA 384.996 “Mikrocomputer LU”.