YMVBWph

3x3 Rubik's Cube Solving Robot

 
Overview
This article, "3x3 Rubik's Cube Solving Robot,"
(https://gitee.com/hemn1990/rubiks-cube-robot )
, introduces
a low-cost Rubik's Cube robot design. It includes schematics, PCB layout, microcontroller source code (C language), structural diagrams (OpenSCAD/STL format), and a BOM for major components. It uses an RP2040 microcontroller for control, with both control and cube solving handled by the microcontroller. For randomly scrambled cubes, the average number of steps to solve is around 21, with a worst-case of 22.
Version 2.0 updates include:
1. Schematic and PCB layout provided.
2. Resolved the issue of short lifespan, breakage, or loosening of the slide's latches by replacing them with magnetic fixation.
3. Supports power supply via Type-C chargers from mobile phones or computers.
4. Resolved the issue of the cube clamping structure loosening after prolonged use and potential breakage under abnormal conditions.
5. Optimized the Hall switch installation method, simplifying the installation process.
6. Resolved the issue of excessive noise from the ratchet structure.
7. Provides a detailed assembly tutorial suitable for beginners.
8. Improve the bill of materials.
9. Supplement performance test data.
Future updates planned:
1. Optimize firmware flashing speed. (To be continued)
Image textV1.0 demo video: video/VID_20220618_165444.mp4
V1.1 (21-step version) demo video: http://www.bilibili.com/video/BV1Qt4y1476Y?share_medium=android&share_source=copy_link&bbid=XYF29BCF6DF22C72C26DED32037959465ED97&ts=1657889031274
V2.0 demo video: https://b23.tv/s6q7KzU
Assembly and debugging tutorial:
(1) Control board debugging https://b23.tv/Xj93aZk
(2) Rubik's Cube selection https://b23.tv/2x8Be0n
(3) Mechanical part assembly https://b23.tv/huJY1xt
(4) Whole machine debugging https://b23.tv/o8LBCXT
About hardware design
2023-12-25 Update: Added schematic diagram and PCB design files
2022-07-07 Update: SPEPPER_EN changed to GP2, added SPI NAND FLASH model W25N01GVZEIG
2022-07-10 Update: Buttons changed from GP0, GP1 to GP27, GP28) Only modified ./src_21_step
Connect the GPIO of the RP2040 microcontroller to the stepper motor driver, color sensor, and Hall sensor. Except for SPI and UART, only GPIO is used for other pins, and no other multiplexing functions are used.
The Hall sensor can only be powered by 5V, while the RP2040 microcontroller IO is 3.3V. Pay attention to the level conversion design.
FLASH is optional. If FLASH is not used, the average number of restoration steps is about 32.
The reference GPIO allocation method is as follows:
Stepper motor enable signal

SPEPPER_EN GP2 Stepper motor control signal

SPEPPER_STEP0 GP11
SPEPPER_DIR0 GP10
SPEPPER_STEP1 GP9
SPEPPER_DIR1 GP8
SPEPPER_STEP2 GP7
SPEPPER_DIR2 GP6 Hall switch, used to find the zero point

HALL_0 GP5
HALL_1 GP3
HALL_2 GP4 Button

BUTTON_0 GP27
BUTTON_1 GP28 Color sensor signal

SDA0 GP14
SCL0 GP15
SDA1 GP12
SCL1 GP13 SPI NAND FLASH signal

CS(1) GP17
DO(2) GP16
DI(5) GP19
CLK(6)

Regarding the structural design of the GP18
: 1. ABS material is recommended for 3D printing, with a nozzle of 0.4mm, a layer height of 0.2mm, 5 layers for the top layer, 5 layers for the bottom layer, 4 outer shell rings, and 20%-40% infill to generate supports. For
microcontroller firmware compilation (./src_21_step, a version with an average of around 21 steps)
, Linux is recommended for development. The development environment can be set up according to the scripts in the RP2040 official documentation.
After completion, pypy3 can be installed additionally for calculating lookup tables. (This step can be omitted; a pre-generated version is provided.)
Windows is also possible, but I haven't verified it.
Generate a lookup table and verify it (optional step; a pre-generated lookup table is provided in the prog_flash directory).
After completion, you will get lookup.dat, a file approximately 70MB in size.
`cd ./src_21_step/ verify_on_pc`
`pypy3 prun.py` `
make
./solve`
Compile the microcontroller firmware .
`cd ./src_21_step/
mcu` `mkdir build`
`cd build`
`export PICO_SDK_PATH=xxxxxxxx` `
cmake ..
make`
Then locate cube_robot.uf2 and flash it to the RP2040 microcontroller.
You can connect via USB and use the command `minicom -D /dev/ttyACM0` to view debugging information, for example:
color_detect: URUFUBDDUFRRFRDDFURLLLFUDLLLUBRDLRBFLDBDLBFFFBUBRBBRUD
Find 21-step solution in 139ms: B F' D' L' BFR B' U2 RB U2 B2 R2 U F2 D' B2 L2 U F2
Total time cost 7.772s:
color_detect: UFFFURURRBDRRRDDLFBUDBFFBDFLBLLDBUBDFURLLRBUDUDLLBFRUL
Find 19-step solution in 95ms: F L2 B' R' L2 B L' B' F' D B2 D F2 DU B2 F2 L2 B2
Total time cost 7.575s:

To flash the SPI NAND FLASH,
connect the computer and the RP2040's serial port. Note that the cable must be short, and the baud rate is up to 1Mbps.
While holding down BUTTON_0, power on the Rubik's Cube robot. The program will calculate the CRC32 checksum of the NAND FLASH. If it fails, it will automatically enter the flashing mode.
`cd ./src_21_step/prog_flash
make
./prog /dev/ttyS0` # Replace `/dev/ttyS0` with your computer's serial port number

. If the computer terminal running `prog` displays the following debugging information, the flashing was successful.
MCU in SPI FLASH programming mode.
Check lookup.dat CRC32 = A8093698
0, size=131072
Erase Block 0 Program Block
0 ................................................................
Verify Block CRC32 0................................................................
(Several lines omitted here)...
Erase Block 565
Program Block 565 ................................................................
Verify Block CRC32 565................................................................

Microcontroller firmware compilation (./src, version with an average restoration step count of around 32 steps, no external 1Gbit FLASH required).
This version is no longer maintained, use with caution.
It is recommended to use a Linux system for development; you can set up the development environment according to the scripts in the official documentation.
Windows is also possible, but I haven't verified it.
After setting up,
cd src
mkdir build
cd build
export PICO_SDK_PATH=xxxxxxxx
cmake ..
make
Then find cube_robot.uf2 and flash it to the RP2040 microcontroller.
You can connect via USB and use the command `minicom -D /dev/ttyACM0` to view debugging information, for example:
`color_detect: FLDFUUUDBDLRURRFDLBFRDFBFLRDDURDBBUBLURBLRLBLFFUFBLDRU
stage=0, D' B U' L F' stage=1
, B2 R2 U2 F2 D R' L' U L'
stage=2, R2 D' F2 D2 R2 D R2 D' B2 D'
stage=3, B2 R2 U2 B2 U2 L2 U2 L2 F2 R2 B2`
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2026-03-27 01:09:55

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号