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
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 workes as it was supposed to it got manufactured by jlc pcb. The egale files can be downloaded at the end of this ible.
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 college 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.
Source Code of the Firmware:
Source Code of the control software
This is an entry in the
Epilog X Contest