Software for Chess Playing Robot

Hi, I said I would make a new post for the software of the robot (advised by mehtaatur).

I've began testing my switch matrix and Ive been having a bit of a problem. On the serial monitor I get rows of 8 1's (11111111). And when I put the magnets close some of the 1's turn to 0's. But it does not happen to all of them. I'm not sure if maybe some of my wiring is wrong or maybe some of my switches could be broken?

This is the program I am using.
_______________________________________________________________________________________________________________________________________________________
void setup() {

Serial.begin(9600);
}

void loop() {
Serial.println("Reed Switch Array: \n");
int ColumnDetect[9] = {A5, A4, A3, A2, A1, A0, 11, 10}; //Array with the 8 detection pins in sequence from left to right in diagram
for (int i=2; i<10; i++)
{ // connect to pins 2, 3, 4, 5 , 6, 7, 8, 9 here - VCC
digitalWrite(i, HIGH);

for (int j=0; j<8; j++)
{ // connect to pins in ColumnDetect array in order - Reads signal from here
Serial.print(digitalRead(ColumnDetect[j]));
}

digitalWrite(i, LOW);
Serial.println();
}

Serial.println("\nEND \n");
}

My Internet is not working on my laptop tonight so when I get it back I will upload more detailed photos.

wvantoorn's picture

Cannot see the picture very

Cannot see the picture very good, but i would say check your wiring, if that little program says only some turn on and off, then it would be right.
I also see, but dont know the schematics, that some wires attached to the small lines are soldered to 2 differen points, on the left side of the picture, the soldering between the 2 parts of the board seem to be connected to different points.

But the only way is to take the multimeter and check every point.
Goodluck and looks like its going to be a very interesting project to follow!

Paddymcd's picture

I had another look at my

I had another look at my wiring and changed the wires as I thought that was the problem. 

(I just realised that I used the wrong colour wires for rows and columns, not that it makes any difference)

But even with this I am getting the same results. Sometimes if I move around the arduino board with my hand some of the switches do change, does this mean it is probably bad connections?

Paddymcd's picture

Motors

My motors are using toothed belts and pulleys to move my carriage's in each direction. The slides are slightly stuff and from carrying out some tests I think it would be best if the motors are driven quite slowly to get the most torque and the best movement. 
GroG's picture

Ahoy Paddymcd.. Here's a

Ahoy Paddymcd..

Here's a script I put together for you...


#file : home/Paddymcd/chessgame.py edit raw
port = "COM15"
chessgame = Runtime.start("chessgame","ChessGame")
arduino = Runtime.start("arduino","Arduino")
arduino.connect(port)

chessgame.addListener("publishMove", "python", "onMove")

xmap = {"a":100,"b":200,"c":300,"d":400,"e":500,"f":600,"g":700,"h":800}
ymap = {"1":100,"2":200,"3":300,"4":400,"5":500,"6":600,"7":700,"8":800}
  
def onMove(move):
  print(move)
  x0 = move[1]
  y0 = move[2]
  x1 = move[3]
  y1 = move[4]
  print("move from", x0, y1, "to", x1, y1)
  print("steppers from ", xmap[x0], ymap[y0], "to", xmap[x1], ymap[y1])
  # xstepper.moveTo(xmap[x0])
  # ystepper.moveTo(ymap[y0])
  # routine to drop claw # grab piece
  # lift piece
  # xstepper.moveTo(xmap[x1])
  # ystepper.moveTo(ymap[y1])
  # lower piece
  # open claw

You'll see in the video what the script does.

It starts ChessGame, Arduino and Serial service.
It subscribes Python service to the ChessGame's publishMove event - the data in the parameter is a String.
The String contains a "x", a from & too coordinates, then a "n" or an "i" .. I believe "i" is illegal move and "n" is normal? 

It then breaks the coordinates up and re-maps them to numbers of steps (I was guessing a 100 steps between squares - but its probably less)  

The stepper stuff is commented out because its not implemented yet.. you might want to defer to mehtaatur and send the data to the Arduino where it could be consumed by some stepper library.

Paddymcd's picture

Thanks Grog, from your video

Thanks Grog, from your video it looks to be workign very well. 

You said in your email that I must have the latest myrobotlab.jar, but when I download from the link you have given I do not get any services available and the whole thing freezes. The version I have been using all along is gui 1.0.99, is this an older version? 

Also when I paste the MRLComm.ino version 21 into my Arduino IDE I get the following errors.

Arduino: 1.6.1 (Windows 8.1), Board: "Arduino Uno"
 
sketch_apr07a.ino: In function 'void loop()':
 
sketch_apr07a.ino:856:13: error: 'struct stepper_type' has no member named 'step0'
 
sketch_apr07a.ino:857:13: error: 'struct stepper_type' has no member named 'step1'
 
sketch_apr07a.ino:1181:27: error: 'struct stepper_type' has no member named 'step1'
 
sketch_apr07a.ino:1183:27: error: 'struct stepper_type' has no member named 'step1'
 
sketch_apr07a.ino:1189:27: error: 'struct stepper_type' has no member named 'step1'
 
sketch_apr07a.ino:1191:27: error: 'struct stepper_type' has no member named 'step1'
 
Error compiling.
 
  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
 
Im not sure, might I be doing something incorrectly? 
GroG's picture

My Bad, I partially

My Bad,

I partially implemented steppers - should be good now

wvantoorn's picture

Guess that those wires put in

Guess that those wires put in the arduino dont make full contact, and if you wiggle them on the arduino and the go on, yeah you have some bad connections. Try if you can get some male headers and solder the wires to them, makes a much better connection.

 

updowner9's picture

hello r u still here ?  

hello r u still here ?