MUX Chips Are All Wired Up
This is a bit of a mess, but itThe next step is to connect it all to the Arduino and start tweaking the program to work interface with the chess engine.
After about 18 hours of drilling, soldering, and gluing, I have completed the majority of the wiring for the chess board. There are 64 Hall sensors, one for each chess square. Thankfully the Hall sensors can share a common power and ground, which reduces the number of wires. After testing each individual sensor, I liberally smothered the solder points in hot glue to prevent jostling from causing anything to break loose.
The next step is to wire up the multiplexing chips and figure out how to turn the sensing into chess moves. I'm not looking forward to wiring up all the multiplexers. Thankfully, I have the 3rd season of Walking Dead on Netflix to keep me company.
How I spent my Friday night
Tonight I installed the hall sensors to the underboard for my robotic chess board and began wiring. I ran the ground wires and soldered all the resistors between the Vcc and the output pins on the hall sensors. Good thing there were some people around HackPittsburgh to keep my company. Enjoy the pictures.
I wanted to post a quick update about the chessboard. I have tested using several Hall sensors simultaneously using a multiplexer (MUX). The multiplexing chip I chose allows for the controlling of 16 sensors while using only 7 pins on the Arduino. Since there are 64 squares on a chessboard, I will need 4 MUX chips. Adding additional chips only requires 5 additional pins per MUX, bringing the grand total to 22 pins, 20 of which needs to need to be I/O. This is approaching the number of pins on my Arduino UNO and I still have to drive three motors to move the chess pieces. I have two simple options at this point, buy an Arduino Mega, which has a near infinite number of pins (54 digital I/O and 16 analog inputs) compared to the UNO (14 I/O, 6 analog), or I can use a fifth MUX to offload some of the pins. Thankfully, the MUX chips I bought are I/O and therefore will allow me to switch through the 16 pins on each of the other 4 chips. Since I already have 5 MUX chips and I don't want to spend the $60 on the Mega, I'll give this a try first. I might try offloading the sensor work to the Raspberry Pi and use the Arduino for only motor control in the end. I haven't tried using sensors with the Pi yet so I don't know how well that will work. Anyway, I made a little video where I'm driving four Hall sensors with the Arduino through a MUX. Everything seems to be working fine. I didn't do all 16 because it would have been a wiring mess on the tiny breadboard and the sensors would be close enough to for multiple to be tripped a once when the magnet is near by. On the chessboard, they will be far enough to avoid magnetic bleeding (a term that might not describe what I mean, but I like it enough to keep it) away and there will be more space to wire everything correctly. The next step is to start wiring together the sensor array, which I will work on this weekend.
Quick Chessboard Update
I took a little hiatus on the robotic chessboard project I have been working on to better plan out some of my methods. I decided that the sensing of the position of the chess pieces will be done by Hall sensors. I will place a Hall sensor under each square of the board. The kind I bought are essentially switches which turn when one polarity is brought towards the sensor and turns off at the presence of the other magnetic pole. I put small magnets in the bottom of each chess piece. In the first video, you can see that the chess piece activates the hall sensor, which lights the LED. I then use the opposite pole of the magnet, which I glued to a stick, to reset the sensor. (Sorry for the vertical nature of the video. One of these days, I'll remember to consistently hold the phone sideways when recording.)
For the operation of the robotic chessboard, these latching Hall sensors pose a problem. As shown in the above video, the sensors would not turn off when the pieces are removed. Hall sensors that do not latch are nearly twice as expensive at the latching kind. This adds up when 64 are needed. I solve this problem by using a digital pin on the Arduino to control the power input to the Hall sensor instead of the 5V pin. This idea comes from the comments on Sparkfun. As you can see in the second video, the sensor now detects the presence of a magnet.
The next step is learning how to control 64 inputs on the arduino with a mux chip, which allows for control of 16 hall sensors using only 4 pins on the arduino. The next update will hopefully show a full chess board which detects where the pieces are or at least progress in that direction.
Basic LED Patterns
My 9 year old wants to make an LED lightsaber for a science project. I quickly write an Arduino program showing an array of LED blinking patterns that I came up with on the spot. There is nothing interesting or profound here, but since I did it, I thought I'd share it. For the lightsaber, I think I'll get some high intensity LEDs.
The OWI Robotic Arm
The other day, I ordered an OWI Robotic Arm from Amazon. It is by far the least expensive robotic arm I have seen. I also purchased a standard double-weight tournament-style travel chess board from my local gaming store. It's pretty much this. The OWI arm has a large range of motion and the motors provide enough torque to lift the heaviest even at full extension. I took a little video of my using the arm with the remote control to move a queen around. As you can see, I am still having trouble figuring out the controls. Also, you can hear my kids making some craft ghosts for Halloween in the background.
I have had it in my head for a while to build a robotic chess board, a chess board where I play against a computer that controls a robotic arm of some sort that moves real pieces on a real board. The "thinking" will be done on a Raspberry Pi computer, which I bought this week as a graduate gift to myself for having finished my PhD program. The arm will be controlled by an Arduino microcontroller. I have already learned how to get Arduino and Raspberry Pi to communicate with each other by reading Simon Monk's nice book Programming the Raspberry Pi: Getting Started with Python. The Arduino and Raspberry Pi communicate nicely though the serial port using the PySerial package. I have tested this out and it works wonderfully. I must write the Arduino code on my Mac though because the Arduino software released for the Linux Debian operating system is a very old version.
For the chess engine, I have decided to use Stockfish, which uses the Universal Chess Interface. It is consistently rate one of the strongest chess engines. The creators of Stockfish have not provided any documentation for their engine, and the Universal Chess Interface was nontrivial to decipher. Therefore, it took me some time to figure out how to communicate with Stockfish through the terminal.
Tonight, I was able to write a proof-of-concept Python program which let me play chess with Stockfish through the Python shell. This is the first step in writing the software for a USB chessboard. I have included the Python code below. Of course, the Stockfish engine must be installed first.
#This code talks to the Stockfish Chess Engine. Entries are to be made in algebraic
#chess notation (eg. e2e4). Stockfish is set to think for a maximum of 1 sec.
chess = r'/Applications/stockfish-4-mac/Mac/stockfish-4-64'.split()['linux' in sys.platform]
import subprocess as S
getprompt = 'isready'
proc= S.Popen(chess, stdin=S.PIPE, stdout=S.PIPE, bufsize=1, universal_newlines=True)
while True :
text = proc.stdout.readline().strip()
if text == "uciok":
print('Choose skill level (0-20):')
proc.stdin.write('setoption name Skill Level value '+skillLevel+'\n')
moveList='position startpos moves '
proc.stdin.write('go movetime 1000\n')
while True :
text = proc.stdout.readline().strip()
if text[0:8] == 'bestmove':
Some Servo Practice
I realized that I had not done anything with the Arduino relating to motors or servos so I decided to rectify that. I made a quick potentiometer controlled servo. Rotating the pot rotates the servo in a one-to-one fashion. Simple. Quick. Done.
Towards a Homemade Fuzzbox
Today, I put about an hour of effort into creating a guitar effect pedal. I figured I would start small and aimed to reproduce Mike Hayworth's simple distortion pedal since I had most of the parts already. I picked up some diodes, the mono jacks, and the NPN transistor from the Radio Shack down the street.
The first thing I learned when putting the circuit together is that soldering copper wire to the mono jacks is a pain. I could not get the solder to stick to the jack for the life of me. I must be missing some Soldering 101 skills.
After assembling the circuit, I did some minor troubleshooting (including realizing I neglected the k at the end of the resistor values--hot transistor is hot) and plugged it in between my guitar and amp to find a very pleasant fuzz effect. I would include a video, but there are two things I would like to troubleshoot. The first is that the pedal is not very loud so I need to figure out how to boost the outgoing signal. The second and most important problem is that the pedal is a fantastic radio receiver for a local station. It was very hard to her the pedal over the obnoxious radio broadcast that was being amplified through my tube amp. Once I resolve those two problems, I will permanently solder the project into a perf board and make a video. My overall goal is to make several different pedals and to be able to select though them, possibly with an Arduino interface. Below is a photo of the project so far (note, the 9V batter is not attached). Pretty simple, no?