Skip to content

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Winding Turns Meter

Firmware for a coil winding machine turns counter. Displays revolution count and RPM on an SSD1306 OLED display, reads rotation from a quadrature encoder. Counts in both directions.

Written in Rust, using RTIC framework and Embassy HAL.

image

Hardware

  • MCU: STM32F103C8 "Blue Pill" (ARM Cortex-M3, 72 MHz)
  • Display: SSD1306 128x32 OLED (I2C)
  • Encoder: Quadrature encoder (1024 PPR, x4 = 4096 counts/rev)
  • Programmer: ST-Link or any probe-rs compatible SWD debugger

Pinout

Function Pin
I2C1 SCL PB6
I2C1 SDA PB7
Encoder CH1 PA0
Encoder CH2 PA1

Schematic

https://app.cirkitdesigner.com/project/313b2b6d-25d9-41d3-8ceb-3a537f561505

image

How it works

  • TIM2 runs in quadrature encoder mode, counting pulses from the encoder
  • QeiManager wraps the 16-bit hardware counter, tracking overflows/underflows to extend the range to 64-bit
  • TIM1 fires at 20 Hz, triggering the display update interrupt
  • Each update reads the encoder count, computes revolutions and RPM (smoothed with a 20-sample moving average), and renders to the OLED

Display output

   XXX.XXX r     <- RPM (moving average)
  XXXX.XXX cn    <- total revolution count

Build

Requires:

  • Rust toolchain with thumbv7m-none-eabi target
  • probe-rs for flashing/debugging
rustup target add thumbv7m-none-eabi
cargo install probe-rs-tools

Run

cargo run            # debug build, flash via probe-rs
cargo run --release  # release build with LTO

License

MIT OR Apache-2.0

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages