Skip to content

infnorm/stepper_experiments

Repository files navigation

Stepper Motor PIO Controller

A PIO (Programmable I/O) state machine implementation for controlling a stepper motor with the Raspberry Pi Pico.

Features

  • Fixed Frequency Operation: Runs at a base frequency set during initialization
  • Adjustable Speed: Change stepping speed via external multiplier without stopping
  • Step Counting: Maintains an internal counter accessible from your C code
  • Non-blocking: Uses PIO hardware, freeing up CPU for other tasks
  • Low Jitter: Hardware-based timing ensures consistent step pulses

How It Works

PIO State Machine

The PIO program (stepper.pio) does the following:

  1. Generates square wave pulses on the STEP pin
  2. Increments an internal counter (Y register) on each step
  3. Accepts delay multiplier values from the TX FIFO to adjust frequency
  4. Uses pull noblock so it doesn't stall waiting for new values

Step Counter

The Y register is used as a step counter by performing a double-inversion:

Building

mkdir build
cd build
cmake ..
make

License

MIT - Use freely for your projects!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published