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

11,351

97

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

Epilog X Contest

Participated in the
Epilog X Contest

Share

    Recommendations

    • Backyard Contest

      Backyard Contest
    • DIY Summer Camp Contest

      DIY Summer Camp Contest
    • Planter Challenge

      Planter Challenge

    20 Discussions

    0
    None
    JohnC430

    4 months ago

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

    2 replies
    0
    None
    JocobsJohnC430

    Reply 4 months 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 ;)

    0
    None
    JosephP203Jocobs

    Reply 8 weeks 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

    0
    None
    zed_thirteen

    3 months 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?

    7 replies
    0
    None
    Jocobszed_thirteen

    Reply 3 months ago

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

    0
    None
    zed_thirteenJocobs

    Reply 3 months ago

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

    board capture.jpg
    0
    None
    Jocobszed_thirteen

    Reply 3 months ago

    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

    0
    None
    zed_thirteenJocobs

    Reply 3 months ago

    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

    0
    None
    zed_thirteenzed_thirteen

    Reply 2 months ago

    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

    0
    None
    Jocobszed_thirteen

    Reply 2 months ago

    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!

    shield_layout.png
    0
    None
    zed_thirteenJocobs

    Reply 2 months ago

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

    0
    None
    JosephP203

    Question 2 months ago on Introduction

    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

    3 answers
    0
    None
    JocobsJosephP203

    Answer 2 months ago

    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.

    axes_movement.PNG
    0
    None
    JosephP203Jocobs

    Reply 2 months ago

    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

    0
    None
    JocobsJosephP203

    Reply 2 months ago

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

    0
    None
    DennisH156

    4 months ago

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

    1
    None
    TeamDroneTech

    4 months ago

    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!!

    1 reply
    0
    None
    JocobsTeamDroneTech

    Reply 4 months ago

    Well I hope, for your sake, you wont cut off your fingers! Who's gonna fly your drones then? ;)

    1
    None
    Steinzel

    4 months ago

    Wow!
    Please excuse my french, but that is pretty freakin' awesome!
    Great job!

    1 reply
    0
    None
    JocobsSteinzel

    Reply 4 months ago

    Tanks man, I really appreciate it :)