# Society of Robots - Robot Forum

## Electronics => Electronics => Topic started by: paddymcd93 on December 18, 2014, 06:07:59 AM

Title: Help with sensors for a Chess Board/Pieces
Post by: paddymcd93 on December 18, 2014, 06:07:59 AM
Hi,
I am attempting to make a chess playing robot. This is my original idea but if it turns out to be too difficult I may instead change to checkers. My plan is to make a cartesian robot similar to a gantry crane with a grabber arm to move the pieces.

I am having difficulty in figuring out how to track the movement of each piece across the board. An idea I had was to have the robot move both player's pieces using a keyboard which I can input the co-ordinates. The pieces at the beginning of a chess game are always set up the same. So in the robot's code there are multiple arrays that store where the pieces start off and so will be able to track each piece.

But after thinking about this more I would prefer to have sensors in the board which will allow me to move my own piece and the robot to respond with its' move. Possibly put a magnet in the bottom of each piece and underneath each square have a magnetic reed switch hooked up the an Arduino.

Could anyone offer my any advice on how they would approach this problem?

PS I am quite inexperienced with robotics and programming so i'd appreciate if any responses were kept at simple as possible
Title: Re: Help with sensors for a Chess Board/Pieces
Post by: mklrobo on January 23, 2015, 02:40:47 PM
:) Hello!
I would offer an opinion.....
In reference to the magnets, to keep it simple.
Each chesspiece has a maximum of 6 magnets, all round, and
installed in the bottom of the piece. Each magnet has a specific place,
and the model for all pieces are the same.
The arrangement of the magnets trip the reed switches, when moved to
each spot. (each peice has a max of 6 magnets, and EVERY spot has 6 reed
switches or hall effect transistors-- for sensing)
The position of the magnets identify the part by a bianary code, 6 spots = 62 pieces.
All pieces have to stay forward, so they can be identified correctly. (turning them can
cause them to be wrongly identified.)
This is ALOT of magnets, and ALOT of sensors.
It would be easier to have each piece transmit data.(infrared, RF, etc) to identify
each piece. (infrared through the board, via glass hole.)
I hope this helped!  Good Luck!   ;D
Title: Re: Help with sensors for a Chess Board/Pieces
Post by: Tommy on January 23, 2015, 06:43:42 PM
Quote
Could anyone offer my any advice on how they would approach this problem?
paddymcd93, I'd point a webcam at the board, then use software to detect both the peace being moved,
and it's color.

Tommy
Title: Re: Help with sensors for a Chess Board/Pieces
Post by: bdeuell on January 24, 2015, 09:20:04 PM
Instead of trying to identify each piece uniquely you could just identify if a piece is located on that space. Using this method you would detect when a piece is removed from the board and where it is placed. The computer would see a piece disappear and then a piece appear in a new location. It would then make the assumption that this is the same piece and that was your move. At the beginning of the game the computer would identify each piece based on its location. The computer would keep track of the identity of each piece throughout the game. Yes this is not as robust and error proof as identifying each piece uniquely but assuming you follow the rules of the game it should be sufficient. Picking up more than one piece would break this method.

As for sensors:

Hall Effect sensors are a good choice. The sensor can be placed below the board and can be covered by the board as long as it is not too thick. They can be used to detect a magnet placed in the bottom of the game piece. Or you can place a magnet behind the sensor and move a piece of ferrous metal into the field of the magnet, (many hall effect sensors are designed with a magnet as part of the sensor assembly).

light sensors (IR or visible) could be used similarly but would require holes in the board for the sensor to see through. For that reason these would not be my first choice.

A camera is certainly an option but would be heavier on the programming side. You could start "simple" with just identify if a piece is on a space and then work up to identifying the pieces if desired. Lighting may be necessary to get consistent results from the camera. Also keep in mind the robot would be moving within the cameras field of view.

Title: Re: Help with sensors for a Chess Board/Pieces
Post by: mklrobo on January 25, 2015, 03:17:04 PM
:) Hello!
I forgot to add that I had worked with some industrial robots that used retroreflective
tape to identify zones. You could use the same process, just retroreflective tape on the
bottom of the pieces, to be read by an infrared sensor. (Still have to have the pieces
facing forward, to be recognized.) Good luck! :D
Title: Re: Help with sensors for a Chess Board/Pieces
Post by: paddymcd93 on March 13, 2015, 11:27:00 AM
Thanks for your responses, they gave me a lot to think about. I would love at some stage to adapt my project to include a camera as the method for detection but at the moment I don't think I have the knowledge or time for that matter. I am using magnetic reed switches to detect movement of the pieces rather than to tell which piece is which, as bdeuell talked about. I have a Mux shield which gives me 64 pins so I can have a pin for each switch, but this leads to a lot of wiring which comes out very messy. Is there another way I could avoid having to use an input for each individual switch??
Title: Re: Help with sensors for a Chess Board/Pieces
Post by: bdeuell on March 13, 2015, 09:47:55 PM
you can multiplex the rows of board spaces. this is common for controlling a several 7 segment displays and is the same concept for a pixeled/matrix type display (not sure if the same term is used) ... anyway the concept is you create a grid of columns and rows with the switches connected at each of the grid intersections. each of the rows would be connected to a output and each column to an input. your program would power one row at a time and then check the inputs for each column. repeating this cycle for each row/column combination will allow you to determine the state of each cell/boardspace.

columns and rows can be swapped for which is the input/output.
in its most basic form this would require 8 outputs and 8 inputs for a chess board. however with some supporting circuitry you could reduce the output requirements to 3 pins by decoding a parallel interface with a chip such as the 74LS138.

also, as i  think about the problem in general your programming will need to handle kills and if you chose to include moves such as castling. these are both cases where more than one piece would be off the board at a time. i think you can accomplish this with some creative programming tho.
Title: Re: Help with sensors for a Chess Board/Pieces
Post by: paddymcd93 on March 14, 2015, 02:56:22 PM
In terms of the programming, I found a program on github for a project which sounds very similar to mine. But I am new to prorgramming and have never used python before so I cant understand the program at all.

Would the program for this be difficult to write?
Title: Re: Help with sensors for a Chess Board/Pieces
Post by: mklrobo on March 14, 2015, 06:37:20 PM
:) Hello!
I have not use python, but have used perl. Most of these
languages are similar to C++. I try to stick to languages
that offer the most flexibility. You do not have much
choice in this case. If the program is complex, your
job will be more challenging. I would invest in some
basic python beginner books. Use the beginner books
to ascertain the difficulty of the program. If the program
is not confidential, please share, maybe I can help
you. Good Luck!  :) :) :)