# Q-Bot - the Open Source Rubik's Cube Solver

10,887

93

20

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

## Recommendations

• ### Internet of Things Class

19,028 Enrolled

## 20 Discussions

I did not see anywhere in your article how the colors are sensed. Did you not need to sense colors?

2 replies

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 ;)

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

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?

7 replies

That’s odd, they should be placed. I’ll have a look at it asap!

Did you get chance to look at the .brd file? were the components all placed okay for you?

I did and the were not ok! I must have uploaded an old version. I hope I can recover the final version, if so I will upload it of course. Sorry for the inconvenience

No worries, I won't be able to make a start on this project for a while (3D printer isn't giving me full Z height on prints) so there's no real rush on my account. Like most people - I don't actually need a machine to solve Rubik's cubes - I just want one because it's cool

Do you still have the gerber files that were submitted for PCB production as they might be a good aid memoir if they all have to be placed again

Cheers
David

I looked in to this a little and it seems to be because some of the layer visibility has been turned off. I turned them all back on and can now move components to the board area (I think you have to ungroup them too)
Could you post a top down picture of the interface card without the Pololu drivers and then I'll have a go at placing the components as you intended
Cheers

Sorry for my late reply, I've been trying to recover the eagle files but it seems I have lost them for good. I did however find a screenshot of the layout, hope that helps!

Thank you, I should be able to reproduce this (given time!). I will pass the files to you when done.

Hi,
Question about the Rubik's cube solver...
I am more than interested in making a very similar model to the one shown on the website.
However, I have a question about the driving mechanism that retracts the grippers to allow the opposite pair of grippers to revolve.
Could you please explain the working of the linear motion that is driven by the stepper motor... it is rather difficult to see in the video.... do you have any full working drawings of the project

It is a relatively simple concept. One stepper motor for each axis moves a timing belt that is attached to both sleds. By rotating in a circular motion both sleds move away or towards the cube together. Hope the attached picture makes it clear.

Thanks.... Your very speedy reply is greatly appreciated.

What is the best method of attaching the belt to the sled? Is there some specially manufactured gizmo or did you just directly fix the two together?

I am just at the design stage and, at this point in time, spending time looking at your photographs and collecting the various small bits and bobs that I consider I will need.

The main components are well covered in your presentation... but I need to detail the other components … then draw it all up.

I have a reasonably well equipped workshop and consider myself fairly well acquainted with CNC. I also have two 3D printers but, so far, I am not over happy with the results I obtain from these machines.

Thanks once again

oyu can download the .step files of my model and look at the sleds in 3D. You'll see that there is a small piece sticking out at the bottom with a recess for an m3 nut. I cut the timing belt and printed a small clamp that simply held the belt to the sled with pressure. It worked fine however I don't think it is the most elegant way, since fitting it all together was a pain. You might wanna look into different timing belt clamps that people designed and printed, there's lots of good work out there ;)

So this replaces the screwdriver method I always used? Great job!

Haha nice one! Now i can cut of my fingers and am still able to solve the cubes <3
Great job, really nice work you did there!!