Project showcase
Automated Chess Piece Mover

Automated Chess Piece Mover © GPL3+

The aim of the project is to play chess in a completely automated environment.

  • 39 views
  • 0 comments
  • 2 respects

Components and supplies

About this project

As the world is developing and making new technologies, chess hasn’t changed ever since it was invented. Automating the physical platform of the chess game is a big step to change the way we play chess. The user will be able to enjoy a fully automated game of chess in different formats. With the opponents moves completely automated. Various electronic components were used in the making of this project such as Controller, several actuators along with programing language C to achieve automation between software and hardware. The pieces are moved automatically from underneath the board using an electromagnet, which is moved around the board with a XY table.

1. INTRODUCTION

Chess never changed since it was invented 1500 years ago. This project aims to bring a new experience for the chess players to enjoy. There are several aspects we should bear in mind before building such project:

Our objective is to build system that is:

1.1 Cheap: The system should not require any costly materials, thereby increasing the cost of implementation.

1.2 Accurate: The system should not be affected by high error.

1.3 The application should be easy to use by the user.

If you asked any professional chess player, most of them prefer real platforms instead of a digitized game.Automating the famous chess platform can open new doors to implement the fiction of self-moving chess pieces into reality. There are two methods to move the chess pieces from one position to another, one of them is the use of a robotic arm mounted above the chess board. Another is to use a XY table underneath the chess board. The complexities that come with a robotic arm are quite few, plus it is not visually pleasing to have an artificial hand always hanging above your board! This pushed us to use the XY table, which is much simpler to implement, plus it feels futuristic to see your piece invisibly being moved! However, this requires designing a special chess pieces which allows the electromagnet controller by the Arduino to move the different pieces.

2.AIMS OF THE PROJECT: The aim of the project is to play chess in a completely automated environment according to the given movement codes that will be applied on the chess board. When the user plays a move, the chess piece will move physically on the chess board and position itself on the desired location to represent a computer’s move.

The main goal is to develop an automated chess board that is easy to use and has a unique function that takes chess to another level, and a piece of hardware which has the potential of being a real thing that anyone can go and get one for themselves in the future.

3. BACKGROUND

3.1 HARDWARE

In order to accomplish our project, several components were used, which will be listed in Table 1.1. The components were picked under 3 specifications: cost, efficiency and quality. The components are relatively cheap, yet efficient and durable for such a project.

Arduino Uno: Arduino is an open-source platform used for building electronics projects. Arduino consists of both a physical programmable circuit board (often referred to as a microcontroller) and a piece of software, or IDE (Integrated Development Environment) that runs on a computer, used to write and upload computer code to the physical board.

Arduino Uno is the main brains of this project;it was picked out of the other microcontrollers because it is easy to program, it can be used in a wide verity of applications, cheap, easy to find and it does not occupy a large space.

Motor: Stepper motor for our application the needed motors had to answer to a certain requirement:

Motors should be able to turn crazy

Motors should be precise (and possibility to control)

Motors should be powerful enough

Stepper-motors are the motors that answer all the requirements listed above. This is thus the type of motor that has been chosen for this project.

It is used because it works on a lower power rating(12V) and provides higher speed

and torque with minimal heating. These motors control the accurate movement of chess pieces over the board in the form of a co-ordinate system. For example: the X-axis stepper motor move the distance of one chess box from the origin in the X-axis direction along with Y-axis stepper motor moving one chess box from the origin in the Y-axis direction, would in turn move a chess piece over the chess board to co-ordinates (1, 1).

Motor Driver: Motor drives are circuits used to run a motor. In other words, they are commonly used for motor interfacing. These drive circuits can be easily interfaced with the motor and their selection depends upon the type of motor being used and their ratings (current, voltage). They are easy to operate using microcontrollers, which makes them commonly used in such projects.

The A4988 driver Stepper Motor Driver is a complete micro-stepping motor driver with built-in converter, easy to operate. It operates from 8 V to 35 V and can deliver up to approximately 1 A per phase without a heat sink or forced air flow (it is rated for 2 A per coil with enough additional cooling). It has two main outputs which are responsible for controlling the direction and speed of the motor.

Electromagnet: An electromagnet is a type of magnet in which the magnetic field is produced by electric current. An electric current flowing in a wire creates a magnetic field around the wire, due to Ampere’s law. To concentrate the magnetic field, in an electromagnet the wire is wound into a coil with many turns of wire lying side by side. The magnetic field of all the turns of wire passes through the center of the coil, creating a strong magnetic field there.

Grove – Electromagnet can suck 1 KG weight and hold on. It is easy to use as well. Which makes it perfect for this project.

The chess pieces are light and do not require a powerful magnet to hold them. It used as a kind of a “hook” to attach to the chess pieces from underneath the chess board.

Limit switch: A limit switch is a component which has an analog input as a click, once that button is clicked it sends a signal which is received by the microcontroller and converted by the code into the desired action. It is used in machinery and control systems as a safety tool to prevent any unwanted movements. Limit switches have a verity of applications and it is widely used because of its ease of installation, reliability and ruggedness.

In this project, the limit switches are placed on the corners of each axis. It will detect when the moving axis have reached the corners and stopping them at that point.

DC power supply: The motor driver requires a power supply to feed the motor with power. It can hold up to 35V. An outlet plug was preferred over an ordinary 9V battery because of its steady flow and its efficiency. Plus, it offers more voltage, in our case a 12V is supplied to the driver.

3.2 SOFTWARE

Two software’s were used in order to achieve the goals of this project. The first and the main one is the Arduino UNO IDE provided by the Arduino Inc. The motors, electromagnet and the limit switches all were programmed using the Arduino IDE. The software was preferred over other Arduino coding programs because it is easier to interface with and it is faster operating under the serial port than other programs.

The second program is the Visual Studios. It was used to make a graphical interface that communicates with the Arduino IDE.Visual Studios offers lots of options to program and in the making of graphical interfaces. One of them can communicate with the Arduino using the serial port, as mentioned before, which makes it perfect for this project. This is called Windows Forms App.NET. The type of communication done is a bit tricky, yet very convenient. The serial port offers a read function that takes data from the visual studios and prints it directly to the Arduino. In the Windows forms, pictures can be used and programed later, so a chess board was set as the background, and each box was defined as a “picture box” which is a tool in the windows forms which allows graphics to be programed easily. Each picture box was assigned with a “x” and “y” position as an integer. Now here is the tricky part! Since the two programs can communicate through serial port and printing from visual studios to the Arduino IDE, when a chess piece is selected, the picture box will be selected with it as well, selecting the x and y position of that box, therefor selecting the location of the chess piece, the Arduino IDE will receive these values as integers, and from there the Arduino IDE will convert these integers into a meaningful values, sending the electromagnet to the chess piece to initiate the movement. The new position of the chess piece goes through the same procedure.

3.3 XY-TABLE

There are different ways to move the pieces from one position to the other, it can either be done using a robotic arm or an XY table mechanism. Although the use of a robotic arm would theoretically allow the integration of the camera into its mechanism, the bad viewing angle as well as the more complex mechanism of a robotic arm pushed the team towards choosing the XY mechanism. A XY table like mechanism underneath the chess board, gives the player more space to move his own pieces to the different positions compared to the other alternative (the perturbing camera would not hinder much the player’s movement). However, this solution requires to design special chess pieces which allow to accommodate the permanent magnets used to move the different pieces by means of an electromagnet controlled by the Arduino.

The purpose of the XY table is the movement of the electromagnet that is responsible for moving the chess pieces from underneath the table.

The build of the XY table is quite simple.

The XY table has two axis controls. It has a smooth surface on its base so that electromagnet can slide easily. The axis is powered using two stepper motor sand belts.

Two motors were used at each axis. One of them is responsible for the movement on the x-axis, while the other is responsible for the y-axis.

In order to ensure a smooth movement and synchronization between the axis, two shafts were installed at each extremity, which are guided by the belts, connecting the two opposite sides together.

On the top of the box, a thin sheet of wood was used. It had to be thin and durable to ensure a proper function of the electromagnet and so the top wouldn’t bend. It also must be flat so the electromagnet would not find any obstacles while sliding

4. INPUT CYCLE

In this section, the mechanism of receiving data and the movement of the electromagnet will be explained.

The user will select the desired piece to be moved, then the new position of that chess piece will be selected too, all done using the visual studios program. Each box of the chess board is assigned to a specified X and Y location. Afterwards, the visual studios will communicate with the microcontroller (Arduino Uno) through the serial port. The visual studios will send the information using the (Serialport.Write) function, and the Arduino will receive it using the IDE Arduino program through the (Serial.parseInt) function, giving the microcontroller the needed information to execute the desired movement.

5. OUTPUT CYCLE(POSITIONING)

The Arduino will begin to give commands to the motors to move the electromagnet towards the selected chess piece. The stepper motors are programed according to number of steps. The board is a 40 x 40 cm which converts into a total of 312 steps. In this case, a mathematical equation can be used to calculate the path of the electromagnet. Which is as follows:

Steps Between Squares × (x1-x2)

x1= initial piece position

x2= final piece position

and the same is applied to the Y axis.

The motors drivers will receive this information and direct it to the motors through two pins. One of them decides the direction of the motor’s rotation, and the other controls its speeds.

Once it arrives at the selected piece location, the electromagnet will pick up that piece. Then, the motors will move the chess piece to its new position, and the electromagnet will let go of that piece, placing it at the new location. Finally, the motors will move the electromagnet back to its initial position at the corner, waiting for a new move.

Code

Automated Chess piece mover codeArduino
Copy and paste to your Arduino IDE!
const int stepsBetweenSquares = 500;
const int stepPinX = 8; 
const int dirPinX = 9; 
const int stepPinY = 7;
const int dirPinY = 6;
const int limitSwitchX = 5;
const int limitSwitchY = 4;
const int magnetPin = 2;



int x1 = 0; int x2 = 1;
int y1 = 0; int y2 = 1;
int xsteps;
int ysteps;
int x = 0;
int y = 0;

void setup() {
  Serial.begin(9600);
  pinMode(stepPinX,OUTPUT); 
  pinMode(dirPinX,OUTPUT);
  pinMode(stepPinY,OUTPUT); 
  pinMode(dirPinY,OUTPUT);
  pinMode(limitSwitchX, INPUT);
  pinMode(limitSwitchY, INPUT);
  pinMode(magnet, OUTPUT);
  
  
  zeroDiagonal();
  digitalWrite(magnetPin, LOW);



}


void loop() {

  x1 = 0; x2 = 1;
 y1 = 0;y2 = 1;


  Serial.print("Piece to be moved letter adress:  ");
  while (!Serial.available());
    x1 = readSerialNumber(); 
      
  Serial.print("Piece to be moved number adress:  ");
  while (!Serial.available());
    y1 = readSerialNumber();      




  xsteps = stepsBetweenSquares*(x1-x2);
  ysteps = stepsBetweenSquares*(y1-y2);
  
  movePieceDiagonal(xsteps, ysteps);
 
  digitalWrite(magnetPin, HIGH);

//_______________________________________________________________________________________________
// Recieve position adress of piece new location from Serial Monitor (Letter, Number)
//-----------------------------------------------------------------------------------------------
  Serial.print("New location letter adress:  ");
  while (!Serial.available());
    x2 = readSerialNumber(); 

  Serial.print("New location number adress:  ");
  while (!Serial.available());
    y2 = readSerialNumber();
  Serial.println();

  


  

  xsteps = stepsBetweenSquares*(x2-x1);
  ysteps = stepsBetweenSquares*(y2-y1);
  
  digitalWrite(dirPinX, HIGH); digitalWrite(dirPinY, LOW);
  offsetPiece();
  delay(50);
  movePiece(xsteps, dirPinX, stepPinX);
  movePiece(-ysteps, dirPinY, stepPinY);
  delay(50);
  digitalWrite(dirPinX, LOW); digitalWrite(dirPinY, HIGH);
  offsetPiece();
  digitalWrite(magnetPin, LOW);

while(true){}

}






//////////////////////////////////////////////////////////////////////////////////////////////////////

int readSerialNumber(){
  int i;
  while (i < 1 || i > 8){
     i = Serial.parseInt();
    }
  Serial.println(i);
  Serial.parseInt();
  return i;
  }



void zeroDiagonal(){
  digitalWrite(dirPinX, LOW);
  digitalWrite(dirPinY, HIGH);
  while (digitalRead(limitSwitchX) == HIGH && digitalRead(limitSwitchY) == HIGH){
    moveDiagonal(1.5);
  }
  while (digitalRead(limitSwitchX) == HIGH){
    moveLinear(stepPinX, 1.5);
  }
  while (digitalRead(limitSwitchY) == HIGH){
    moveLinear(stepPinY, 1.5);
  }
  while (digitalRead(limitSwitchX) == LOW){         
   for (int i = 0; i<130; i++){
     digitalWrite(dirPinX, HIGH);
     digitalWrite(stepPinX, HIGH);
  delay(2);
  digitalWrite(stepPinX, LOW);
  delay(2);
  }
  
  }

  
  while (digitalRead(limitSwitchY) == LOW){         
    digitalWrite(dirPinY, LOW);
    for (int i = 0; i<90; i++){
     digitalWrite(stepPinY, HIGH);
  delay(2);
  digitalWrite(stepPinY, LOW);
  delay(2);
  }
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////

void movePiece(int steps, int dirPin, int stepPin){
  if (steps > 0){
    digitalWrite(dirPin,HIGH);
  }
  else{
    steps = abs(steps);
    digitalWrite(dirPin, LOW);
  }
  for(int i = 0; i < steps; i++) {
    moveLinear(stepPin, 2);
  }
  }

////////////////////////////////////////////////////////////////////////////////////////////////////////

void movePieceDiagonal(int xsteps, int ysteps){
  if (ysteps >= 0){
    digitalWrite(dirPinY, LOW);
  }
  else{
    ysteps = abs(ysteps);
    digitalWrite(dirPinY, HIGH);
  }
  if (xsteps >= 0){
    digitalWrite(dirPinX, HIGH);
  } 
  else{
    xsteps = abs(xsteps);
    digitalWrite(dirPinX, LOW);
  }
  x = 0; y = 0; 
  while (x < xsteps && y < ysteps){
    moveDiagonal(2);
    x++; y++;
  }
  for(x; x < xsteps; x++){
    moveLinear(stepPinX, 2);
  }
  for(y; y < ysteps; y++){
    moveLinear(stepPinY, 2);
  }
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////

void offsetPiece(){
  for (int i=0; i < stepsBetweenSquares/2; i++){
    moveDiagonal(2);
  }
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////

void moveDiagonal(int delayTime){
    digitalWrite(stepPinX, HIGH);
    digitalWrite(stepPinY, HIGH);
    delay(delayTime);
    digitalWrite(stepPinX, LOW);
    digitalWrite(stepPinY, LOW);
    delay(delayTime);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void moveLinear(int stepPin, int delayTime){
  digitalWrite(stepPin, HIGH);
  delay(delayTime);
  digitalWrite(stepPin, LOW);
  delay(delayTime);
}

Comments

Similar projects you might like

Automated Chess Board

Project showcase by Michael Guerero

  • 13,380 views
  • 21 comments
  • 101 respects

Wooden Chess Board with Piece Recognition

Project showcase by MaxChess

  • 34,490 views
  • 43 comments
  • 94 respects

Automated Chess Play Using Alexa

Project in progress by Automaters

  • 12,435 views
  • 2 comments
  • 53 respects

LX' Arduino Tetris

Project showcase by RomanSixty

  • 15,114 views
  • 17 comments
  • 58 respects

Automated Watering Plant

Project in progress by Saikan45

  • 9,658 views
  • 29 comments
  • 38 respects

Automated Model Railway Layout with Passing Siding

Project tutorial by Kushagra Keshari

  • 8,292 views
  • 10 comments
  • 41 respects
Add projectSign up / Login