csuzw
Posts: 4
Joined: Tue Jul 17, 2012 10:17 am

Electronic chess board and identifying specific pieces

Mon Jul 15, 2019 5:23 pm

Hopefully this is the right forum for this.

I'm thinking about starting an electronic chess board project using a raspberry pi. All the projects that I've come across so far seem to use reed switches to determine whether a piece is on a particular square or not and use the fact that in general the initial position is fixed to determine the piece. This approach is limited as it struggles to cope with things like under-promotion, puzzles and variants like chess960. I'd like to do something a bit cleverer and use something like RFID/NFC to identify exactly what piece is where. I've come across things like this https://shop.pimoroni.com/products/nfc- ... -pack-of-5 that seem ideal for the purpose to put on the pieces. What I'm less sure about is how to read and locate the pieces. Should I be looking to have a tiny reader under every square on the board - if so does anyone know what/where I can find these? The options I've seen so far are too big. Alternatively can you use 1 reader than can track all items within a certain distance and also say how far away they are? Am I barking up completely the wrong tree and if so what alternatives are there on this front? I'm happy with the software side of things but clueless on the hardware side of things.

User avatar
omegaman477
Posts: 148
Joined: Tue Feb 28, 2017 1:13 pm
Location: Sydney, Australia

Re: Electronic chess board and identifying specific pieces

Fri Jul 19, 2019 8:37 am

I have seen two version of this;

The first version had a 3.5mm TRS plug extending from the base of each piece which plugged into a corresponding socket on each square. Each piece had two different resistors inside, and the CPU scanned these resistor values (as part of a simple voltage divider), determined the two resistor values and from that looked up the piece ID.

The second had a small battery, IR led and shift register in each piece that flashed out a serial byte encoded with a binary ID of the piece. Under each square was its own IR photodiode, detecting that stream of data for each.

By far the most common approach these days is machine vision. Painting the pieces in bold stripes and dots with IR reflective (clear) paint allowed a IR camera to easily see the various pieces. Most of these systems seem to have 2 cameras to compensate for blocked sight paths.

I wouldn't give up on NFR, but it will be challenging to get a cheap enough reader into each square, plus ensuring that they were so activated that they only read that square, and not the adjacent. Radio Waves are hard to confine :-)

NFR/RFID is an option but not for very close range, and the readers are generally too bulky for you application
..the only thing worse than a stupid question is a question not asked.

bzt
Posts: 393
Joined: Sat Oct 14, 2017 9:57 pm

Re: Electronic chess board and identifying specific pieces

Fri Jul 19, 2019 10:59 am

Hi

If transparent or semi-transparent chess-board is an option, then I'd put a camera beneath and a small easily identifiable shape or color code on the bottom of each chess-piece. That's the simplest and cheapest solution, requires only one reader, and it is guaranteed that pieces won't interfere (I'm not sure you can get a so sensitive RFID reader that read is limited to one square only, and you would need 64 of them in close proximity).

Depending on the distance to the board, you probably won't need a hi-res camera. Color codes are easy to identify with a low-res cheap camera too (you paint half of the bottom of the piece black or white, and the other half with some color, like orange=king, red=queen, blue=pleasant etc.). Then you divide the picture captured into boxes, one for each square, and you simply look for the RGB color codes to "read" the table. Pretty easy.

Cheers,
bzt

JohnsUPS
Posts: 122
Joined: Fri Jul 06, 2018 2:13 am
Location: USA

Re: Electronic chess board and identifying specific pieces

Wed Jul 24, 2019 12:50 am

Possibly a bar code or Q code on the bottom to identify each piece......

User avatar
Gavinmc42
Posts: 3878
Joined: Wed Aug 28, 2013 3:31 am

Re: Electronic chess board and identifying specific pieces

Wed Jul 24, 2019 1:21 am

Have a matrix of 8x8 NRF coils.
A single nRF reader but 2 x 8 multiplexers.
The multiplexers must be able to pass only enough power to read the RFID on the base of the chess piece and not the next door ones.
16 relays?

I have done this in reverse for multiple RF induction charging, alternating the coils winding directions.
Find out how many turns and of what size are needed.
I have even made coils on 4 layer PCBs.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
jbeale
Posts: 3498
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Electronic chess board and identifying specific pieces

Wed Jul 24, 2019 1:22 am

If you don't like the idea of a transparent chess board, remember you can get a black plastic that is very nearly transparent at 800 nm or so, where an IR camera like a PiNoIR still works fairly well. Making squares that appear light-colored or white yet still transparent in IR is probably harder though. Also I assume the board structure would have to be fairly deep for one camera to see the entire playing field without extreme fisheye distortion.

blimpyway
Posts: 183
Joined: Mon Mar 19, 2018 1:18 pm

Re: Electronic chess board and identifying specific pieces

Thu Jul 25, 2019 12:01 am

I would consider vision approaches.

e.g. A single board is not a very diverse and complicated world, I'm sure a image recognition neural network trained only on a specific set of pieces can be trained quite quickly and be small enough to be usable on a Pi.

This needs to be done only once then the computer can just track which fields are occupied and which are empty and how they change (as in your example with magnet sensors but with a camera) in order to figure out following moves.

It's quite tricky the machine learning thing but once its done it is much better than having a special board/pieces made for this because the same program could learn any particular playing set so it could be an app for everybody to use.

Generating a labelled training set could be as easy as letting the camera record a few actual games - starting with known position it can easily figure out which piece is which in order to label pictures of pieces in different positions/parts of the table.

User avatar
Gavinmc42
Posts: 3878
Joined: Wed Aug 28, 2013 3:31 am

Re: Electronic chess board and identifying specific pieces

Thu Jul 25, 2019 1:34 am

Are we over thinking this?
Plenty of older ones just use reed switches and magnets.

Assuming to pieces are placed correctly, then the cpu can track the pieces by finding which switch goes open when a piece is lifted and then it can track where it goes by scanning for the switch going closed.

Hall effect switches are more reliable.
DIY Keyboard scanning methods/wiring will give clues.
Even an Arduino could be used as a USB HID interface.

32 key roll over ;)
Could a membrane keyboard be used?
Two magnets, one on the board, one in the chess piece.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

csuzw
Posts: 4
Joined: Tue Jul 17, 2012 10:17 am

Re: Electronic chess board and identifying specific pieces

Thu Jul 25, 2019 8:05 am

Thanks for all the responses, not entirely sure which approach I'm going to take yet but given me plenty of food for thought.

@Gavinmc42 : I specifically want something better than magnet and reed switches (unless it can be used to identify pieces properly). There are scenarios where this approach just won't work. For example there are chess variants where pieces do not start on the normal positions (in chess960 for example the back ranks are randomized). If you want to analyse particular positions or do chess puzzles then you're not going to starting from the initial position. Even in a normal game of chess you have under-promotion, that while admittedly rare does happen, and it can't be easily detected with a binary magnet approach.

Return to “Automation, sensing and robotics”