Pages: [1] 2   Go Down
Author Topic: Connect physical chessboard with online chess service  (Read 2465 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all, I am a programmer but somewhat inexperienced in the realm of microcontrollers and creating hardware circuits, took a logic design course in college but that was several years ago and I am a bit rusty.

The goal of this project is to take a physical chessboard and allow a player to play against an online opponent (probably through Yahoo Chess or something similar). The basic workflow that I see goes something like this:

1. Player indicates that they want to play a match (via a button bush or something), arduino connects to online chess service and starts a match
2. Player is informed that the game has started and a timer starts on a text-screen hooked up to the arduino
3. Player makes their move on the physical board which is sensed by the arduino
4. Arduino submits move to online service and waits for opponents move
5. On opponent's move, two led's will light up underneath the board to indicate the opponents move start and finish positions
6. Player moves the opponent's piece and starts over at step 3

At this point I foresee the following challenges:

1. Interfacing the arduino with an online chess service: Not sure how difficult this would be, if any of the big players have an api that would be great, if not I'm sure I could sniff whatever the browser is sending and spoof that.

2. Indicating when the opponent has moved: I plan on having a LED underneath each one of the board squares, again these would have to be hooked up to the arduino somehow. I suppose I could have each of the two squares alternate flashing, since if I only need one light lit up then I could just connect this two the arduino's out pins with some binary logic right? 64 squares means 2^6 so I would only need 6 pins

3. Determining where the player has moved: This is where I need the most help. The plan right now is to have two pins on each board square and some conductive material on the bottom of each piece, so when a piece is placed it would complete a circuit. I think I need to hook each of the 64 squares up to the arduino's pins via some sort of multiplexer arrangement but I haven't figured this all out yet. The only information I need to submit a move is the starting and ending squares, if I could loop through the board and check each square at the start of the turn, and then again when the player hits a "submit" button or something, then that would work.

Any help you could give me would be appreciated  smiley
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 220
Posts: 13846
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

First, this sounds like a nice (ambitious) project, getting it to work will take some time.

There are at least 7 partial problems to be solved:

0 inform server you can accept new games
1 need to monitor server for new game (black/white/ names exchange etc)
2 need to monitor for a move
3 need to pull a move from the server

4 make something do the move on the board.
5 need to monitor your move on the board

6 need to push the move to the server
7 need to determine end of game

----

4 and 5 are typical robotics projects
0,1,2,3,6 are network functions . Do you have a URL of this online chess service as you have to connect to it somehow. what protocols are available?

Bonus: do you intend to use a chess clock?
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 631
Posts: 50115
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In the same way that a keypad senses which button is pressed, you could use 8 pins for the "rows" and 8 pins for the "columns" and quickly scan the row/column values that have a piece on them.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you have a URL of this online chess service as you have to connect to it somehow. what protocols are available?

Bonus: do you intend to use a chess clock?


I haven't done the research yet as to where I will connect it. I might start by writing a simple webapp that interfaces with the board and worry about hooking it up to whatever service once I've got the hardware and turn logic all set up. I should find an old chess clock and use that to house all of the guts, would be a nice touch
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In the same way that a keypad senses which button is pressed, you could use 8 pins for the "rows" and 8 pins for the "columns" and quickly scan the row/column values that have a piece on them.
That's not a bad idea, I could connect an output pin to each row and listen on the 8 columns for a complete circuit

A simple solution for (#4) would be to have a red/green LED in each square. Light up the red one for where the piece should leave, and the green one for where the piece should go to. 

A fantasy solution for (#4) would be to build a stepper-motor powered miniature gantry crane that would actually grab the piece, lift it, move to the new spot, and lower it.  Of course, it would probably count against your time and is impractical for at least that reason.

A simple solution for (#5) would be to have a magnet in the bottom of each piece and a reed switch or a hall magnetic sensor in each square. Then you can scan all 8 rows and 8 columns (as PaulS described) to see which piece was picked up and where it went.

A fantasy solution for (#5) would be to use one of those schemes that uses a bunch of rods in a big array. By pushing up certain rods to certain heights, you could make a modern abstract representation of each piece. Then by programming, you could represent any piece in any square.  You can use translucent plastic rods and colored LEDs underneath to represent pieces of opposing sides.
Haha, for now the player is going to be the one doing any physical movement, maybe in version 2 I'll think about adding some of these things!

I had thought about using some sort of magnetic switch but I figured a simple contact might be simpler, I will look into the sensors you listed.
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 632
Posts: 34510
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you seen this project:-
http://www.andreadrian.de/schach/#Selbstbau_Schachcomputer_SHAH
It's in German but the circuits are in schematic.
Logged

0
Offline Offline
Tesla Member
***
Karma: 145
Posts: 9675
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How will you know which chess piece is on each square?
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
How will you know which chess piece is on each square?
The starting lineup is known. Whenever a piece is picked up, you know which one it was by were it was. And if you put it back down, it seems like a safe assumption it is the same piece that was just picked up seconds ago.
Exactly. This assumption should make the wiring a lot simpler
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you seen this project:-
http://www.andreadrian.de/schach/#Selbstbau_Schachcomputer_SHAH
It's in German but the circuits are in schematic.
That's interesting, thanks for the link, maybe I will add a 1 player version as well, or start off with that and then add the networking later. I had no idea you could store a complete chess program in so little space!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I am interested in the same project.  Have programmed a little in various languages but am new to electronics and arduino.  I have an arduino uno and have gone over the examples.  I've ordered the buttons, leds, CD4021BEs and 74HC595s.  Are the last two unnecessary as posted by the original poster?  I might buy a digit shield to relay opponents moves as well as the LEDs.  Are 140 resistors good for both the buttons and LEDs? 

These are the items ordered by digikey
Leds 147XBK-ND RES 147 OHM 1/4W 1% METAL FILM
LEDs   67-1109-ND LED 5MM GREEN TRANSPARENT
296-1600-5-ND IC 8-BIT SHIFT REGISTER 16-DIP
296-2040-5-ND IC STATIC SHFT REG 8STG 16-DIP
P8070SCT-ND SWITCH LIGHT TOUCH 4.3MM 100GF


Is there an alternative to soldering to attach 64 buttons and LEDs?

Interfacing with online chess is revealed by http://blog.mekk.waw.pl/archives/7-How-to-write-a-FICS-bot-part-I.html , thank you mekk! .  Creating a bot in PERL that can observe the players game allows communication between FICS and Arduino.  I think that sending messages from the physical board to arduino and then to FICS should work with serial port.

Ideally each piece could accept instructions and move, but I don't see that happening soon.

It would be great if this chessboard http://www.uscfsales.com/product_p/brdv2.htm could be used, with the LEDs and buttons being an underlay or overlay.

Any comments and suggestions would be great!

Thanks,
cadger


Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 632
Posts: 34510
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Are 140 resistors good for both the buttons and LEDs? 
No they are a bit too low for input pullups.
Also they are a bit low for LEDs, you can get an adequate level of light with between 220R and 390R.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks,

I'm trying to use this calculator http://www.hacktronics.com/Tools/led-resistor-calculator.html to figure out what size resistors to use.

The arduino board shows
Operating Voltage   5V
Input Voltage (recommended)   7-12V

and the LED shows
Current - Test   20mA

R=V/I , but i'm not sure what values to use in this formula?

Thank you






Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 632
Posts: 34510
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Input Voltage (recommended)   7-12V
Not relevant, the arduino regulator takes it down to 5V.

Quote
R=V/I , but i'm not sure what values to use in this formula?

You want 20mA through the resistor (and LED) the LED has what across it when it is taking 20mA , let's assume 1.8V but get this information from the data sheet.
So the voltage across the resistor is 5 - 1.8 = 3.2V
Now you have a current and a resistance so apply ohms law:-
R = E/I this is....... 3.2 / 0.02  = 160R (ohms)
Logged

Chester, UK
Offline Offline
Sr. Member
****
Karma: 2
Posts: 489
Trying to return the love to none logic level MOSFETS
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I suspect that a using contacts in each square would be unreliable.  KE7GKP's suggestion of reed switches and magnets is a great one.
Logged

If your system involves lethal voltages/life critical/flamable elements - you probably shouldn't need to ask.
The Arduino != PC.

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for your clarity mike.  the datasheet shows 2.2V so 147ohms might be ok for these 20mA not so bright lights?  more is usually better for resistors?  i don't want to break the board.  I'm thinking that it might have been better to get buttons that are normally on so that there'd be less wiring needed i think.  Alot of chess computers, you pick up a piece and press buttons on the squares that you're moving from and to and that's where i thought of buttons, but i'll look into using reed switches after i use all of these darn buttons.

I've read that daisy chaining of the shift regesters can work within reason for shifting in/out, i wonder is a total of around 70 inputs and 70 outputs within reason?

It would be great to try it all out without soldering, other than an expensive oversized breadboard 22" x 22" are there other ways of connecting the wires i.e. like wire connectors?   

thanks

Logged

Pages: [1] 2   Go Up
Jump to: