- 基础原理验证 ✔
- 基础 UI ✔
- 更多可在UI中调节的值 ✔
- UI 多语言支持 ✔
- 项目自述 ✔
- 无线控制 ✔
- 多平台支持 ✔
- 八音盒 (废话) *1
- 支持串口通信的单片机 *1
ℹ注:推荐使用ESP32或nRF51802
- TMC2209 步进电机驱动模块 *1
⚠注意:模块需要支持以串口方式与MCU进行通信
- 42BYGH40/39 步进电机 (高40/39mm) *1
ℹ注:可以是任意两相四线步进电机, 但其应能够提供足够力矩(推荐300mN*m以上)
- 42步进电机支架 (可选) *1
- 0.4模齿轮(60齿以上,但不宜过大) *1
ℹ注:齿轮越大越好,降低电机转速是减小噪音的有效方法
⚠注意:齿轮需要能够与电机输出轴匹配
- 旋转编码器 *1
- SSD1306 0.96 寸 OLED 模块 *1
- 电源 (Plan A): USB-C PD 诱骗器 *1, 支持PD快充协议的充电器 *1, MP1584 DC-DC 降压模块 *1
- 电源 (Plan B): 3.3/5/12v 多路输出电源模块 *1, 12v/2A 电源适配器 *1
- 用于固定八音盒与电机的木盒、木块等 *1
- 用于固定的M3螺丝、M3螺母若干
接下来的步骤组成了一个简短的安装指南。步骤供参考,可根据实际情况进行调整。
如图所示,改装电动只需使用八音盒传动部分中的部分齿轮。由于避开了传动部分中的易损齿轮,对该齿轮损坏的八音盒进行改装不失为一个绝佳选择。
⚠注意:在手摇八音盒中,手柄部分通常为噪音的源头之一。为了达到静音目的,断开手柄与其他齿轮间的传动是必要的。移除手柄或②号齿轮均可实现。图为移除了手柄及②号齿轮的八音盒。
毫无疑问,电机需要与八音盒固定在一起以进行传动。该部分有较多方案可供选择,故此处将不做较多阐述,实际应用时可不必遵照。
⚠注意:不论以何种方式固定,电机齿轮必须尽量与八音盒齿轮紧密配合,否则可能会产生噪音并损坏齿轮。
考虑到八音盒可能需要一个共鸣腔,推荐将八音盒与电机固定在木盒中。如不考虑共鸣,或不方便对木盒进行钻孔/开槽,则也可固定在木块或其他材料上。此处以固定在木盒中为例。
由于42电机的体积较大,因此八音盒原配木盒大概率需要进行更换。目前市面上有多种尺寸木盒可供选择。上一节示例中的木盒尺寸为 长20cm*宽13.5cm*高9cm。
项目提供了提供一个支架3D模型可进行参考。支架由两部分组成,分别负责替换原有支架与步进电机的固定。
本项目提供两个不同平台版本:一个较为简易的使用ESP32开发板与其他现成部件进行搭建的版本,与一个从零开始构建的nRF51平台版本。您可以根据实际需要进行选择。
ESP32
版本基于现成部件,电路十分简单,如下图所示。
处于空间利用方面的考量,推荐使用PCB实现上图中电路。Gerber文件请点击这里。
ℹ注:仅适用于尺寸为22mm*17mm的MP1584模块与焊接了TX,RX针脚的乐积TMC2209模块
如果无法进行焊接,该版本同样可以考虑使用面包板完成接线。
ESP32版本参考BOM
- 以下链接仅供参考,您可以根据实际情况自行购买
- 链接可能失效,如需更新请提起issue
nRF51
版本将主控、步进电机驱动、DCDC电路等部分集成在一块PCB上,进而减小了控制板体积,但同时也提升了制作难度。电路图如下所示。
项目BOM
参考PCB
焊接辅助工具
改装的最后一步是将电机控制程序烧录至ESP32
或nRF51802/nRF51822
中。
您可以直接刷入 Release 中已编译好的固件,或自行使用Arduino编译并刷入。
-
移步乐鑫科技网站并下载
ESP Download Tool(Flash下载工具)
。 -
点击
下载
按钮。当状态显示完成
后,断开开发板与电脑的连接。
ℹ注:为了向nRF51芯片刷入程序,您额外需要一个适用于ARM架构单片机的编程器,例如
ST-Link
、J-Link
等。下方的流程以在Windows环境下使用ST-Link
刷入为例,您可能需要根据实际情况适当修改命令行参数。
- 移步OpenOCD Github页面,下载并解压
OpenOCD
。 - 将编程器连接至控制板。
编程器 控制板
______ _____________
3V3 | ----> | 3V3 SWCLK | <-----,
GND | ----> | GND SWDIO | <--, |
SWDIO | ----, |_____________| | |
SWCLK | --, `--------------------` |
______| `-------------------------`
- 打开命令提示符(
CMD
)或PowerShell
,并切换路径至OpenOCD
文件夹中的bin
目录下。 - 使用以下命令刷入预编译固件。在刷入完成后,命令行中应出现
** Verified OK **
提示。- 此处假设
Project-Orgel-nRF51.hex
与openocd.exe
置于同一目录下。 - 您可以根据实际情况将
st-link.cfg
替换为其他受支持的编程器配置文件。
- 此处假设
./openocd.exe -f "interface/st-link.cfg" -f "target/nrf51.cfg" -c "init" -c "reset halt" -c "nrf51 mass_erase" -c "program Project-Orgel-nRF51.hex verify reset exit"
首先需要在电脑上搭建Arduino-ESP32环境。知乎用户铁熊的文章可供参考。
在环境搭建完成后,还需要在库管理器中安装以下库:
tcMenu @4.4.0
TMCStepper @0.7.3
U8g2 @2.34.4
NimBLE @1.4.2
准备完成后,使用Arduino IDE打开Project-Oegel
文件夹中的Project-Orgel.ino
进行烧录。
⚠注意:Arduino IDE中的
esp32开发板
版本不可使用3.0.0
及以上版本!
对于nRF51
版本,您需要将arduino-esp32
开发环境替换为n-able-Arduino,具体操作如下:
- 在
文件
->首选项
->附加开发板管理器网址
中添加链接https://h2zero.github.io/n-able-Arduino/package_n-able_boards_index.json
- 待安装完成后,在
工具
->开发板
->Arm (Nim)BLE Boards
菜单中选择Waveshare BLE400
开发板。 - 在
工具
->Low Frequency Clock
菜单中选择Synthesized
选项。 - 在
工具
->编程器
菜单中选择st-link v2
选项。
对于nRF51
版本,您还需要将上述列表中的U8g2
库替换为SSD1306UTF8
库(基于SSD1306Ascii
库),请从此处下载。
ℹ注:对于
nRF51
版本,您需要点击项目
菜单中的使用编程器上传
选项刷入自编译程序。
⚠注意:由于硬件组合及改装操作的多样性,在不同情形下运行可能触发未知的bug,如部分功能不可用等。该指南仅代表在测试硬件上的操作及运行效果。
🛑警告:步进电机驱动器运行会产生高温。请小心烫伤。
将程序首次烧录至ESP32时,所有设置为默认初始值0。请遵照下述方法设置齿轮齿数
、运行电流
并保存后再使用。
在主菜单中选择Back and Save
以保存设置并回到主菜单。在主菜单中无操作30秒会自动返回主界面。
⚠注意:在更改菜单中选项值后必须通过
Back and Save
选项退出菜单,否则在重启后选项值将恢复更改前状态。
在菜单中旋转旋钮查看选项,单击旋钮以与选项交互。在交互状态下旋转旋钮以更改选项值,单击旋钮退出。
各可调节值说明:
- 电机设置
- 反向运转: 控制电机正反转
- 齿轮齿数: 电机齿轮齿数设置
- 运行电流: 电机运行电流设置,单位mA 参考值:1050mA
⚠注意:随着电流的增大,驱动器会产生更多热量并可能导致过热保护,电机可能会产生更大噪音。正常使用请不要将该值提升至1700mA以上。
- 语言
- ENG:英语
- 中文:简体中文
- 蓝牙
- 开:开启蓝牙并启用无线控制功能
- 关:关闭蓝牙并停用无线控制功能
请打开设置中的蓝牙开关,随后访问https://mr258876.github.io/Project-Orgel/并按提示操作。
Have fun!
- Make it work ✔
- A Basic UI ✔
- More Adjustable Values in UI ✔
- UI MultiLanguage Support ✔
- Readme ✔
- Wireless Control ✔
- Multi Platform Support ✔
- Musicbox (of course) *1
- ESP32-D0DWQ6 Dev Moudle 30pin *1
- TMC2209 Stepper Driver Module *1
⚠Caution: the driver moudlue should be able to communicate with the MCU through UART or Serial port.
- 42BYGH40/39 NEMA17 Stepper *1
ℹNote: Could be replaced with any 2-phase 4-wire step motor, however it should provide enough torque(recommand 300mN*m or above).
- NEMA17 Motor Stand (optional) *1
- 0.4M gear(At least 60 teeth, but not too big) *1
ℹNote:It is a good idea to have a bigger gear, reducing the motor speed is an effective way to reduce noise.
⚠Caution: The gear should be able to match the output shaft of the motor.
- Rotatry Encoder *1
- SSD1306 0.96 inch OLED Screen *1
- Power Supply (Plan A): USB-C PD Trigger/Decoy *1, Phone charger with fast charging support *1, MP1584 DC-DC step-down moudle *1
- Power Supply (Plan B): 3.3/5/12v multi-output power moudle *1, 12v/2A AC/DC adapter *1
- Box or something else for mounting musicbox and motor *1
- M3 Screws & Nuts for Mounting
The following steps constitute a biref modding guide, which you could refer to but don’t have to strictly follow.
Only some of all gears in the musicbox will be used after the modding, as shown in the picture below. Avoiding the vulnerable gear(gear #2), it is a good choice to mod a musicbox with that gear damaged.
⚠Caution:The handle is usually one of the main noise source. In order to get silent, it is necessary to disconnect the transmission between the handle and other gears, which could be implemented by removing the handle or gear #2. A music box with handle and gear #2 removed is as shown.
Without doubt, the motor needs to be mounted with the musicbox. With many solutions avilable, there will not be much description here, and you don't have to follow.
⚠Caution: No matter how they are mounted, the gear of motor have to work as close as possible, or there will might be noise and the gear may got damange.
Considering that the music box may need a resonance cavity, it is recommended to fix the music box and the motor in a wooden box. If resonance is not considered, or it is inconvenient to drill/slot the wooden box, it can also be fixed on a wooden block or other materials. Take fixing in a wooden box as an example
Due to the ize of the NEMA-17 motor, the original wooden box of the music box will most likely need to be replaced. There are many sizes of wooden boxes available on the market. The size of the wooden box in the example in the previous section is L20cm * W13.5cm * H9cm.
The circuit used in this project is simple, schematic as shown below.
Considerated in space utilization, using a PCB to imply the curcit is recommedned. As a beginner of drawing PCB, only a poor board could be provided. Click here if you would take a look.
ℹNote:Only applies to MP1584 with size 2mm*17mm and Lerdge TMC2209 module with TX/RX pin soldered.
Using a breadboard to apply the cutcit also works.
The last step is to upload the controlling program to the ESP32.
You can flash the compiled firmware directly into Release, or use Arduino to compile and flash it yourself.
-
Go to Espressif Technology website and download
ESP Download Tool
. -
Open ESP Download Tool, select
ESP32
for chip type, andDevelopment Mode
for working mode.
-
Set the flashed file, flash address, flash speed, serial port and download speed according to the actual situation according to the figure below.
-
Click the
Download
button. When the status showsDone
, disconnect the development version from the computer.
First, you will need an Arduino-ESP32 environment. There's a guide from randomnerdtutorials could be used as a reference.
For ESP32
devices, he following libraries are also required after building up the environment:
tcMenu @4.2.1
TMCStepper @0.7.3
U8g2 @2.34.4
NimBLE @1.4.2
For nRF51
devices, you need to replace U8g2
in the list above as an MODDED SSD1306Ascii
library, which could be found here.
After that, open Project-Orgel.ino
in folder Project-Oegel
with Arduino-IDE to upload.
⚠Note:
esp32
version in Arduino IDE should be below3.0.0
, or compilation will fail!
⚠Caution: Due to the diversity of hardware bundles and differences in modding procedure, unknown bugs might appear in some situations (e.g. functions not working). This manual only represents the operations and results on the testing hardware.
🛑Warning: The driver moudle would generate heat. Please be aware of burns.
When first upload the code to ESP32, all setting values will be default to 0. Please set Geat Teeth
, Current
by following the methods below before use.
In the main view, change BPM by rotating the knob, switch playback status by pressing the knob once.
Pressing down the knob and hold for few seconds to go to the menu.
Select Back and Save
in menu to save the settings and back to main view. After entered the menu, it will go back to the main view without saving automatically with no action in 30 secs。
⚠Caution: Exiting through
Back and Save
option is required after changing any value in the settings menu, or the values will restore after reboot.
In the menu, rotate the knob to go through, intract with options by pressing down once. Change the option value by rotating the knob when option is acticed, and pressing down once to go back to menu.
Explations on adjustable values:
- Motor
- Reversed: To reverse the motor operation direction.
- Gear Teeth: Teeth number of the gear installed on the motor. Related to running speed.
- Current: The runing current of motor in mA. Reference value: 1050mA.
⚠Caution:The Driver moudle would produce more heat as the current goes up, and might trigger overheat protection. The motor will produce more noise as well. Do not raise this value over 1700mA in normal use.
- Language
- ENG: English
- 中文: Simplified Chinese
- Bluetooth
- On: Turn on bluetooth, and enable wireless control
- Off: Turn off bluetooth, and disable wireless control
Turn ON the
bluetooth
option in settings menu, then visit https://mr258876.github.io/Project-Orgel/.
Have fun!