MagKnob

Let’s control volume with a (moderately) fancy knob!

AS5601 might be my favourite sensor right now. It’s an on-axis magnetic rotary position sensor. It generates a signal typical for encoders, but it does it by detecting the change in a magnetic field of a diametrically magnetized, rotating magnet.

The knob acts as a USB HID device. That means that, currently, it can do everything that a 2 button keyboard could do.

I used a Bluepill board for this device, but it needed some changes to make it work for this project:

  • changed USB D+ resistor to 1.5kOhm (all the Bluepill boards come with an incorrect resistor - surprise!)
  • changed reset switch to a smaller one to reduce the board’s height
  • removed boot pins' headers and replaced them with a piece of wire, to reduce the board’s height

AS5601 adapter board changes:

  • added 4.7kOhm I2C pullup resistors (AS5601 adapter board has empty pads for that purpose)
  • desoldered interface pins' header
  • desoldered the voltage selection header and replaced it with a wire

One, unique (compared to what I’d usually do) thing about this project is how I’ve designed the 3D printed parts. They have been designed using the OpenSCAD. It allows you to model 3D objects by writing code. One can easily version control the designs using git. It’s especially useful when you need to tune some dimensions to get a better fit between parts. It’s also very easy to store and share the project files - they are pure text.

You can find the firmware source and the OpenSCAD models here.