Thursday 30 January 2014

Electronic board game - success at last!

It's been a long time coming, and we've had to make yet more revisions to our final design (strobing multiple connected sensors in a keypad type arrangement didn't work either!) but we've finally managed to get a positive result with our digital board game.

Our new board section has had to undergo major revision, and we've had to cut yet another design for the top layer/mdf - including cutouts for our surface mount SMT resistors (some of which are 0R resistors, acting as vias on a single-sided board)



Here's the output from recent testing:


We placed a magnet over each of the 12 input points on the L-shaped game board section and wrote some firmware that sends data over the serial connection whenever any of the sensor inputs change.
The output message begins with a zero value, followed by two bytes (the serial number of the board section) and a single byte character to indicate which square has caused the message to be sent.

For example, square one on our board section generates the message 0x00, 0xFF, 0xFF, 0x8D

The value 0x8D translates into binary value 10001101
We're using the first (most significant) bit to indicate whether a piece has been added (1=piece added, 0=piece removed) and the remaining bits to indicate which square the activity took place over. In this case, 1101 is the decimal value 13 and the leading bit (msb) 1 tells us that a piece has just been added.

Although our board section is an L-shape, and the playing piece was placed over the first square on our board, the number coming back is 13. This isn't a mistake: we're treating each of our board sections as if they have been "cut out" of a 6x6 square

The next value was 0x0D. In binary this is 00001101.
From the previous example, we can see that this represents the decimal value 13 and the leading (most significant) bit is zero - indicating that the playing piece has been removed.
The next value in the list is 0x8E. This is 10001110 in binary.
Or rather, the decimal value 14 with a single bit indicator to tell us that a playing piece has just been placed on the board (i.e. a playing piece has been added to the board at square number 14). The next value received over serial is 0x0E (playing piece removed from square number 14).

The list of numbers in the results continues through 13, 14, 15, 16 then  the next value received is 0x93 (playing piece placed at square number 19).

This is because our L-shaped board has been cut out of a 6x6 grid and square numbers 17 & 18 are unused (the square immediately below 13 on our board section is numbered 19). Likewise, once we get to square number 22, the next square number received is 27 (since squares numbered 23 through 26 are not part of this particularly shaped board section).

Reading through the list of messages received over serial, it's possible to calculate that our board section is correctly (and more importantly, consistently) reporting back which squares have playing pieces placed over them, and which squares are becoming vacant as a playing piece is removed.

In short, a success!
At last.


No comments:

Post a Comment