Thursday 30 January 2014

Electronic board game - more than one section at a time

Having got one board section working, we got straight to work soldering up a second one, to see how the two would interact with each other.

All our board sections share a common serial tx (transmit) line, so we had to make a slight change to the firmware. When any board section is not sending serial data, we need to make the tx pin high-z or high-impedence (so it's treated as being disconnected from the board). For the PIC microcontrollers we're using, this simply means, turn it into an input pin.

If we leave all tx pins as outputs, when not transmitting, they're pulling the output either high or low (depending on the last state set in the firmware code) and we want them to be floating about - basically if they're not being used, don't let them influence the tx line at all.

After getting success with one board section on it's own, the next step was to see how it worked with two or more board sections connected together.


So after updating the firmware, we connected one board and checked it was still working (firmware updates are a great way of introducing bugs and while you're trying to resolve one problem, it can often be a completely unrelated something that is causing another!). After confirming that the firmware update hadn't broken anything, we plugged in another board.

Each time the playing piece is moved we get the square number in the lower 6 bits, and a 1 or a 0 in the MSB to indicate whether the piece has been put down or removed. Look out for values starting 0x80 or 0x90 when the piece is put down, and values less than 0x24 (36 in decimal) when the piece is removed.


The video shows the serial output from our test firmware after a second board has been plugged in to an already live, powered board. We get a broadcast message telling the host which board has just been plugged in (and in this example, it also reports the initial state of each input pin being used - this behaviour will be amended in future versions).

You can see as the playing piece moves from one board section to the other, the square numbers reported back to the host change (since one section is rotated in relation to another) but all that can be handled by the host's software, so long as it knows which way around each section is facing. At the minute, both boards report back their serial numbers as 0xFFFF because my PIC programmer doesn't burn values to EEPROM when it writes firmware down to the device. I need to build something that will allow me to write data to the PIC internal EEPROM (over serial perhaps?) to give each board section type a unique serial number/identifier.

But other than that, it's pretty cool to see something working properly, at long last!

No comments:

Post a Comment