• Stars
    star
    142
  • Rank 258,495 (Top 6 %)
  • Language
    C
  • License
    Other
  • Created almost 2 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Rotary Encoder with NeoPixels and USB Interface

CH552E USB Knob - Rotary Encoder with USB Interface

The USB Knob is a versatile device that combines the functionality of a rotary encoder with the convenience of a USB interface. It is based on either the CH552E or CH554E microcontroller and is equipped with addressable LEDs, commonly known as NeoPixels. The unique combination of these components makes the USB Knob an ideal choice for a wide range of applications, including volume control for PCs.

One of the standout features of the USB Knob is that it requires no driver installation, making it incredibly easy to use. The device acts as a USB human interface device (HID), meaning that it can be recognized and utilized by most computers without the need for additional software.

USB_Knob_pic1.jpg

Hardware

Schematic

USB_Knob_wiring.png

CH552E 8-bit USB Device Microcontroller

The CH552E is a low-cost, enhanced E8051 core microcontroller compatible with the MCS51 instruction set. It has an integrated USB 2.0 controller with full-speed data transfer (12 Mbit/s) and supports up to 64 byte data packets with integrated FIFO and direct memory access (DMA). The CH552E has a factory built-in bootloader so firmware can be uploaded directly via USB without the need for an additional programming device.

Building Instructions

  1. Take the Gerber files and send them to a PCB manufacturer of your choosing. They will use these files to create the circuit board for your device.
  2. Once you have the PCB, you can start soldering the components onto it. Use the BOM (bill of materials) and schematic as a guide to make sure everything is connected correctly.
  3. Upload the firmware by following the instructions in the next section (see below).
  4. To create the case for your device, use the STL files with your 3D printer. Make sure to use transparent filament for the ring.
  5. After printing, secure the PCB to the bottom of the case using four self-tapping M2x5mm screws.
  6. Next, glue the ring from the bottom into the circular recess in the top of the case.
  7. Finally, assemble the case. Place the knob onto the rotary encoder. Your device is now ready to use!

USB_Knob_pic2.jpg USB_Knob_pic4.jpg

Software

Firmware Versions

Volume Knob

This firmware enables the USB Knob to control the volume of your computer. By turning the knob, you can increase or decrease the volume, while pressing the knob will mute or unmute the sound. The device is recognized as a USB HID consumer multimedia keyboard and should work immediately without the need for any driver installation.

Mouse Wheel Knob

This firmware is designed to transform the USB Knob into a mouse wheel. By rotating the knob, it emulates the movement of a mouse wheel, allowing users to scroll up and down web pages, among other things. Pressing the knob is equivalent to clicking on the mouse wheel or the middle mouse button. The device registers as a USB HID mouse on the computer and should work immediately without the need for driver installation.

Custom Knob

This firmware is perfect for customizing it according to your own preferences. It allows for the free mapping of USB HID actions to USB Knob events. The firmware is structured and commented in such a way that it should be possible to make adjustments even with basic programming skills. It is designed as a USB HID composite device that combines a keyboard, a mouse, and a game controller.

Compiling and Installing Firmware

Preparing the CH55x Bootloader

Installing Drivers for the CH55x Bootloader

On Linux you do not need to install a driver. However, by default Linux will not expose enough permission to upload your code with the USB bootloader. In order to fix this, open a terminal and run the following commands:

echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="4348", ATTR{idProduct}=="55e0", MODE="666"' | sudo tee /etc/udev/rules.d/99-ch55x.rules
sudo service udev restart

For Windows, you need the CH372 driver (recommended). Alternatively, you can also use the Zadig Tool to install the correct driver. Here, click "Options" and "List All Devices" to select the USB module, and then install the libusb-win32 driver. To do this, the board must be connected and the CH55x must be in bootloader mode.

Entering CH55x Bootloader Mode

A brand new chip starts automatically in bootloader mode as soon as it is connected to the PC via USB. Once firmware has been uploaded, the bootloader must be started manually for new uploads. To do this, the board must first be disconnected from the USB port and all voltage sources. Now press the BOOT button and keep it pressed while reconnecting the board to the USB port of your PC. The chip now starts again in bootloader mode, the BOOT button can be released and new firmware can be uploaded within the next couple of seconds.

Once the USB Knob firmware is installed, the bootloader can also be entered by holding down the rotary encoder switch while connecting the device to the USB port. In this way, the case does not have to be opened when new firmware is to be installed. The NeoPixels will then light up white as long as the device is in bootloader mode (approx. 10 seconds).

Compiling and Uploading using the makefile

Installing SDCC Toolchain for CH55x

Install the SDCC Compiler. In order for the programming tool to work, Python3 must be installed on your system. To do this, follow these instructions. In addition pyusb must be installed. On Linux (Debian-based), all of this can be done with the following commands:

sudo apt install build-essential sdcc python3 python3-pip
sudo pip install pyusb

Compiling and Uploading Firmware

  • Open a terminal.
  • Navigate to the folder with the makefile.
  • Connect the board and make sure the CH55x is in bootloader mode.
  • Run make flash to compile and upload the firmware.
  • If you don't want to compile the firmware yourself, you can also upload the precompiled binary. To do this, just run python3 ./tools/chprog.py firmware.bin.

Compiling and Uploading using the Arduino IDE

Installing the Arduino IDE and CH55xduino

Install the Arduino IDE if you haven't already. Install the CH55xduino package by following the instructions on the website.

Compiling and Uploading Firmware

  • Open the .ino file in the Arduino IDE.
  • Go to Tools -> Board -> CH55x Boards and select CH552 Board.
  • Go to Tools and choose the following board options:
    • Clock Source: 16 MHz (internal)
    • Upload Method: USB
    • USB Settings: USER CODE /w 266B USB RAM
  • Connect the board and make sure the CH55x is in bootloader mode.
  • Click Upload.

References, Links and Notes

  1. EasyEDA Design Files
  2. CH551/552 Datasheet
  3. SDCC Compiler
  4. ATtiny85 TinyKnob
  5. CH552E MacroPad mini
  6. CH552G MacroPad plus

USB_Knob_pic3.jpg

License

license.png

This work is licensed under Creative Commons Attribution-ShareAlike 3.0 Unported License. (http://creativecommons.org/licenses/by-sa/3.0/)

More Repositories

1

ATmega-Soldering-Station

T12 Quick Heating Soldering Station
C++
915
star
2

Power-Boards

Collection of DC/DC Converters, Battery Chargers and Power Supplies
381
star
3

CH32V003-GameConsole

Handheld RISC-V Mini Game Console with OLED Display
C
214
star
4

C64-Collection

Collection of cartridges, adapters and replacements for the Commodore C64
C
162
star
5

ATtiny13-TinyUPS

Uninterruptible Power Supply
C++
142
star
6

AVR-Programmer

Collection of AVR Programmers and Accessories
C
136
star
7

Development-Boards

Collection of various development boards for microcontrollers (e.g., CH55x, CH32, PY32, STC8, STM32) and accompanying example software.
C
133
star
8

ATtiny412-PocketRadio

Small FM Radio with RDS and OLED
Python
127
star
9

ATmega-Transistor-Tester

Small version of the famous component tester from mikrocontroller.net
C
116
star
10

ATtiny13-TinyOLEDdemo

I²C OLED on an ATtiny10/13/202
C++
98
star
11

CH32X035-USB-PD-Tester

USB Power Delivery Testing Device and Variable Power Supply
C
97
star
12

ATtiny13-TinySolder

T12 Quick Heating Soldering Station
C++
75
star
13

ATtiny13-TinyRemote

IR Remote Control
C++
68
star
14

ATtiny85-TinyFMRadio

FM Radio with RDS
C++
64
star
15

ATtiny85-TinyTerminal

USB controlled OLED Display
C++
61
star
16

ATtiny814-USB-PD-Adapter

USB Type-C Power Delivery Trigger and Monitoring Board
C
57
star
17

ATtiny85-TinyCharger

Single-Cell Li-Ion Battery Charger with Monitoring
C++
57
star
18

CH32V003-FM-Transmitter

Portable Digital Stereo FM Radio Transmitter
C
54
star
19

CH552-USB-OLED

USB controlled I²C OLED
C
54
star
20

ATtiny13-TinyTacho

Simple RPM-Meter
C++
52
star
21

ATtiny84-TinyCalibrator

OSC Calibrator and High-Voltage Fuse Resetter for 8-Pin ATtinys
C++
52
star
22

ATtiny412-USB-Power-Isolator

2.5kV Isolator for the USB Power Rail
C
50
star
23

MCU-Templates

Templates for bare-metal firmware development for some entry-level microcontrollers
C
50
star
24

ATtiny85-USB-Tester

Simple USB Power Tester
C++
49
star
25

ADuM3160-USB-Isolator

2.5kV USB 2.0 Isolator with 200mA Power Supply and Full Speed (12Mbps) Support
48
star
26

ATtiny814-Power-Analyzer

Power Supply Analyzer with USB Interface
Python
48
star
27

MCU-Flash-Tools

Simple ISP Flash Tools for various Microcontrollers
Python
46
star
28

CH552-MacroPad-plus

Programmable MacroPad with Rotary Encoder and NeoPixels
C
45
star
29

ATtiny85-TinyLoad

Electronic Dummy Load
C++
44
star
30

CH32V003-FM-Receiver

Portable Digital FM Radio Receiver with RDS
C
43
star
31

ATtiny13-TinyRemoteXL

12-Button IR Remote Control
C++
42
star
32

ATtiny13-TinyPocketRadio

FM Stereo Radio with Headphone Plug
C++
41
star
33

ATtiny13-TinyProbe

Simple Logic Probe
C++
39
star
34

ATtiny85-TinyKnob

Rotary Encoder with USB Interface
Assembly
38
star
35

ATtiny13-TinyDecoder

IR Remote Receiver and Decoder
C++
37
star
36

ATmega-EEPROM-Programmer

Parallel EEPROM Programmer for 28C64B and 28C256
C++
37
star
37

ATtiny85-USB-C-Tester

Simple USB-C Power Delivery Tester
C++
34
star
38

AVR-Development-Boards

Collection of AVR Development Boards
C
32
star
39

ATtiny412-I2C-Rotary-Encoder

Rotary Encoder with I²C Interface
C
32
star
40

ATtiny85-TinyDFPlayer

MP3-Player
C++
31
star
41

VUSB-AVR

V-USB Board Definition Package for Arduino IDE
C
30
star
42

ATtiny85-IR2USB

IR Remote to USB HID Converter
C++
28
star
43

ATtiny13-TinyRemoteRF

RF Remote Control
C++
28
star
44

ATtiny84-TinyHVSP

High-Voltage Serial Programmer and Fuse Resetter
C++
27
star
45

SAMD-Development-Boards

Collection of SAMD Development Boards, Programmers, Tools and Firmware
C
26
star
46

CH552-MouseWiggler

Simple Board that can be used as a Mouse Jiggler, a Rubber Ducky or a Caps Blocker
C
25
star
47

CH552-USB-NRF

USB controlled nRF24L01+ 2.4GHz Transceiver
C
25
star
48

ATtiny13-VolumeAdjuster

Automatic Volume Adjuster for TVs and Sound Systems
C++
23
star
49

CH32X035-USB-PD-Adapter

Portable Programmable Power Supply
C
23
star
50

ATtiny13-ContinuityTester

Simple Continuity Tester
C++
21
star
51

ATtiny13-TinyTouchLight

Dimmable USB Night Light with Capacitive Touch Control
C++
20
star
52

ATtiny412-BatteryCapacityTester

Single-Cell Li-Ion, LiPo and LiFePO4 Battery Capacity Tester
Python
20
star
53

CH552-DAPLink

CMSIS-DAP compliant debugging probe with SWD, JTAG, and VCP support
C
20
star
54

ATtiny85-PhoneChargeGuard

USB Phone Charge Guard
C++
19
star
55

ATtiny412-VoiceChanger

Change the Pitch of your Voice
Python
19
star
56

ATtiny13-NeoController

Control almost any number of NeoPixels with an IR Remote
C++
18
star
57

ATtiny814-USB-RTC

Real-Time Clock USB-Stick
C
18
star
58

ATtiny412-USB-PD-Inverter

Turn your USB PD Power Adapter into an AC Power Source
C
17
star
59

CH552-Macropad-mini

Programmable Macropad with NeoPixels
C
16
star
60

ATtiny13-TinyMoisture

Soil Moisture Monitor
C++
15
star
61

CH32V003-USB-Joystick

Simple Joystick with USB Interface
C
14
star
62

CH552-picoDAP

CMSIS-DAP compliant SWD Programmer
C
14
star
63

ATtiny13-TinyBling

It just does bling bling ...
C++
14
star
64

ATtiny814-NRF2USB

USB Serial Controlled 2.4GHz Transceiver
C
13
star
65

ATtiny85-TinyCandle

Tea Light Candle Simulation
C++
13
star
66

ATtiny13-TinyNightLight

Night Light with NeoPixels and Rotary Encoder
C++
12
star
67

ATtiny84-TinyICOC

In-Circuit Oscillator Calibrator for AVR Microcontrollers
C++
11
star
68

CH32X033-USB-Knob

Rotary Encoder with NeoPixels and USB Interface
C
11
star
69

ATtiny13-TinyCandle

Simple Candle Simulation
C++
10
star
70

ATtiny13-TinyPlayer

IR Remote Controlled MP3 Player
C++
10
star
71

ATtiny13-TinyDice

Tiny Electronic Dice
C++
9
star
72

ATtiny814-AquaTimer

Programmable Timer for Aquariums
Python
8
star
73

CH32V003-IR-Remote

Simple 5-Button IR Remote Control
C
8
star
74

CH32V003-USB-Knob

Rotary Encoder with USB Interface
C
6
star
75

ATtiny13-TinySat

Solar Powered Blinken Lights
C++
6
star
76

ATtiny412-HamsterTracker

Simple Fitness Monitoring Device for your Pet Hamster
Python
6
star
77

ATtiny13-TinySonar

Ultrasonic Range Finder
C++
6
star
78

ATtiny85-RocketLamp

Dual Core ATtiny85 Board
C++
6
star
79

CH32X033-USB-NRF

USB controlled nRF24L01+ 2.4GHz Transceiver
C
6
star
80

CH32V003-NeoPixel-Pendant

It just does bling bling ...
C
5
star
81

CH32V003-Mouse-Wiggler

Simple USB Plug that can be used as a Mouse Jiggler, a Rubber Ducky, or a Caps Blocker
C
5
star
82

CH32V003-I2C-Knob

Rotary Encoder with I2C Interface
C
4
star
83

CH32V003-USB-IR-Receiver

IR Remote Control to USB HID Converter
C
4
star
84

CH32V003-MacroPad-plus

Programmable MacroPad with Rotary Encoder and NeoPixels
C
4
star
85

TinyRDA

RDA5807 FM radio library using TinyI2C
C++
3
star