Introduction: Q-Bot - the Open Source Rubik's Cube Solver
Imagine you have a scrambled Rubik's Cube, you know that puzzle form the 80s that everyone has but nobody really knows how to solve, and you want to bring it back into its original pattern. Luckily these days it is very easy to find solving instructions. So, go online look at a video learn how to turn the sides to bring you joy. After doing it a couple of times, however, you will realize that there is something missing. A hole inside that can't be filled. The engineers/maker/hacker within you simply cannot be satisfied with solving something so amazing in such a simple way. Wouldn't it be much more poetic if you had a machine that did all the solving for you? If you'd built something all your friends would be amazed by? I can guarantee you that it doesn't get much better than watching your creation do wonders and solve a Rubik's Cube. So, come and join me on the wonderful journey of building Q-Bot, the open source Rubik's Cube Solver that most certainly won’t beat any world records, but will give you hours of joy (after of course going through all of the frustrations during the building process).
Step 1: Designing the Hardware
The complete solver was designed with CAD in Catia. This way most of the design errors could be found and corrected before manufacturing any physical components. Most of the solver was 3D printed in PLA using a prusa MK3 printer. In addition, the following hardware was used:
- 8 pieces of 8 mm aluminium rod (10cm length)
- 8 linear ball bearings (LM8UU)
- a little under 2 m of GT2 6mm timing belt + some pulleys
- 6 NEMA 17 bipolar stepper motors
- 6 Polulu 4988 stepper drivers
- an Arudino Mega as the controller for the project
- a 12 V 3A power supply
- a step down converter to safely power the arduino
- some screws and connectors
- some plywood for the base
Hardware description
This section briefly covers how the Q-Bot even functions and where the above mentioned components are used. Below you can see a rendering of the fully assembled CAD modell.
The Q-bot works by having four motor attached directly to the Rubik's Cube with 3D printed grippers. This means that left, right, front and back can be turned directly. If the top or the bottom side need to be turned, the entire cube must be turned and so two of the motors have to be move away. This is done by attaching each of the gripping motors onto sleds driven by another stepper motor and a timing belt along a linear rail system. The rail system consists of two 8 ball bearings that are mounted into cavities in the sled and the whole sled rides on two 8mm aluminium shafts. Below you can see the sub assembly of one axis of the solver.
The x- and the y-axis are basically identical they only differ in the height of the mounting point of the belt, this is so that there are no collisions between the two belts when fully assembled.
Step 2: Picking the Right Motors
Of course, selecting the right motors is very important here. The main part is that they need to be strong enough to be able to turn a Rubik's cube. The only problem here is that no manufacturer of Rubik's cubes gives a torque rating. So, I had to improvise and do my own measurements.
Generally torque is defined by the force directed perpendicularly to the position of the rotational point at the distance r:
So, if I could somehow measure the force applied to the cube I could calculate the torque. Which is exactly what I did. I clamped my cube to a shelf in a way that only one side could move. That a string got tied around the cube and a bag attached at the bottom. Now all that was left to do was slowly increase the weight in the bag until the cube turned. For the lack of any accurate weights I used potatoes and measured them afterwards. Not the most scientific method but because I'm not trying to find the minimum torque it is quite sufficient.
I did the measurments three times and took highest value just to be safe. The resulting weight was 0.52 kg. Now because of Sir Isaac Newton we know that Force equals mass times acceleration.
The acceleration, in this case, is the gravitational acceleration. So the required torque is given by
Plugging in all of the values, including half of the diagonal of the Rubik's cube, finally reveals the required torque.
I went with stepper motors that are able of applying up to 0.4Nm which is probably an overkill, but I wanted to be safe.
Step 3: Constructing the Base
The base consists of a very simple wooden box and it houses all the required electronics. It features a plug to turn on and off the machine, an LED to indicate if it is turned on, an USB B port and a socket for the power supply to plug into. It was constructed using 15mm plywood, some screws and a bit of glue.
Step 4: Assembling the Hardware
Now with all the required parts, including the base, the Q-bot was ready to assemble. The custom parts were 3D printed and adjusted where needed. You can download all of the CAD files at the end of this ible. The assembly included fitting all of the 3D printed parts with the bought parts, extending the motor cables and screwing all of the parts to the base. In addition, I put sleeves around the motor cables, just to make in look a little neater, and added JST connecters to their ends.
To highlight the importance of the base I built, here is a before and after shot of what the assembly looked like. Tiding everything up a bit can make a huge difference.
Step 5: Electronics
As for the electronics the project is rather simple. There is a main 12V power supply, that can deliver up to 3A of current, which powers the motors. A step-down module is used to safely power the Arduino and a custom shield for the Arduino was designed that houses all of the stepper motor drivers. The drivers make controlling the motors much easier. Driving a stepper motor requires a specific control sequence but by using motor drivers we only need to generate a high pulse for each step the motor shall turn. In addition, some jst connectors were added to the shield to make connecting the motors easier. The shield for the Arduino was firtsly built on a piece of perfboard and after making sure that everything works as it was supposed to it got manufactured by jlc pcb.
Here's the before and after of the prototype and the manufactured pcb.

Step 6: Software & Serial Interface
The Q-Bot is divided into two parts. On the one hand there is the hardware that gets controlled by the Arduino, on the other hand there is a piece of software that calculates the solving path for the cube based on the current scramble. The firmware running on the Arduino was written by myself but in order to keep this guide short I will not go into any details about it here. If you wish to have a look at it and play around with it, the link to my git repository will be provided at the end of this document. The software that calculates the solution runs on a windows machine and was written by a colleague of mine, again links to his source code can be found at the end of this ible. The two parts communicate using a simple serial interface. It calculates the solution based on Kociemba's two phase algorithm. The solving software sends a command consisting of two bytes to the solver and waits for it to return an ‘ACK’. This way the solver can be tested and debugged using a simple serial monitor. The complete instruction set can be found below.

The commands to turn each motor for one step are a workaround for a problem where some of the steppers would randomly perform small jumps upon power up. To compensate for this the motors can be adjusted to their initial position prior to the solving process.
Step 7: Conclusion
After eight months of developing, swearing, hitting the keyboard and dancing the Q-bot was finally at a point where is successfully solved its first Rubik's Cube. The scramble of the cube had to be inserted manually into the control software, but everything worked well.
I added a mount for a webcam a couple of weeks later and my college adjusted the software to read the cube automatically from the images taken. However, this is not tested well yet and still needs some improvements.

If this instructable sparked your interest don't hesitate and start building your very own version of the Q-bot. It might seem daunting at first, but it is very much worth the effort and if I could do it so can you.
Resources:
Source Code of the Firmware:
https://github.com/Axodarap/QBot_firmware
Source Code of the control software
https://github.com/waldhube16/Qbot_SW

Participated in the
Epilog X Contest
35 Comments
2 years ago
Hi is there any way to contact author of software?
2 years ago
Hi its me again
I have a question.
How you insert individual colors of a rubik's cube into the system?
3 years ago
HI
I am trying to make this robot by myself but i am stucked at softwere i downloades files from git hub but i am confused. Can you explain the softwere to me? It is a aplication or i need to put it into arduino?
Reply 3 years ago
Which part of the software did you download?
Reply 3 years ago
I downloaded all files from github but I don't know how to get them together
Reply 3 years ago
Theres one part that goes onto an arduino mega, the other runs under windows
Reply 3 years ago
hi sorry for late reply i want to thank you for replys and i want to ask you if you got some instruction file for assembling this robot?
Reply 2 years ago
no worries, unfortunately I don't have any instructions, but the assembly should be relatively straight forward when you look at the pictures. If you struggle with a specific step just msg me.
Reply 2 years ago
oh thank you so much i will contact you if something show up
3 years ago
Hi I have printed and assembled the whole machine, and have even got the wiring done and made pc board indigenously as I do not have facility to get a board made locally, it cost arm and leg to get one made. anyway I got the wiring sorted out from the drawings no problem even loaded the code to mega, but I cannot figure out the software how to start it, can you give me some guidelines, I keep on getting error ucrtbased.dll not found and similar dll not found errors, can you help me out. Is there any progress on camera linked to software, do give us some feed back.
Thanks
pervez
Reply 3 years ago
holy cow, that's impressive!
Are you talking about the controlling software? Unfortunately the camera incorporation hasn't been exactly smooth. If you're somewhat comfortable coding I'd suggest building your own controller either directly in Matlab using their image processing toolbox or looking into something like openCV. I didn't build the controlling software myself because the project was split in two parts and I only covered the hardware aspects, but I will consult my colleague and reach back out to you if anything comes up.
Reply 3 years ago
Are you running the program from withtin visual studio or directly by executing the .exe?
Reply 3 years ago
Directly by .exe, I
am little novice in coding, but mechanical,or electrical I can jury rig anything, I have made lots of projects, eggbot, cnc , Lazer printer, selfbalacing robot, Otto,
Reply 3 years ago
Thanks, I got beyond the first software dll errors by checking on the net and installing missing dll, but new error cropped up, I am looking for solution on web will find something and solve it, I am having problems with cube jaws as they are not correct size, going to reprint them by correct size, rest will finish it soon and will post the video, do let me know if you make any progress on cam front
Thanks
3 years ago
Hi
I'm a newbye with programs, how can I use them ? do we need to compile them ? If so do I need a specific compiler?
Thank you
4 years ago
I did not see anywhere in your article how the colors are sensed. Did you not need to sense colors?
Reply 4 years ago
By the time I published this, the camera was not implemented into the software yet. Prior to solving the state of the cube had to be input manually. We're currently working on the image processing, however, and it's partly working now but still needs some tinkering ;)
Reply 4 years ago
I am currently building a slightly modified version of your design and would be pleased to be kept in touch with your progress with image recognition
4 years ago
When I open the board layout in Eagle CAD none of the components are placed. Is this correct or am I usign a different version of Eagle CAD?
Reply 4 years ago
That’s odd, they should be placed. I’ll have a look at it asap!