Tile communications protocol test

Hi, I’m happy to finally have something to contribute.

Some background first. When I settled on a Blinks project to start, I dove straight in and started coding the project’s systems. Once I was further along, I decided to get tiles talking to one another.

Hooboy did that trip me up. I knew I needed something more involved than the simple “values on faces”. So I started playing with datagrams. Slippery little beasts, let me tell you. I had some success passing data between tiles, but corner cases became a real issue. I had the dreaded red blink of a failed communication, and without a way to set breakpoints and step through code I was getting frustrated with my slow progress. Also, coding around corner cases was costing me precious code & data space.

Eventually I knew I had to tackle this communications hurdle independently before I could include it in my project. I created a new project and settled on a more simplified communications protocol. I finally got it working and wanted to share in case others are interested.

My protocol builds on the standard “value on face”, which is a more reliable way to send data. It uses four of the six bits as payload and the other two bits to handshake between the tiles.

It works like this. Tile A sends data in [3:0] and sets “toggle” bit[4]=1. When Tile B sees this, it saves the data, and sets its “ack” bit[5]=1. When Tile A sees that Tile B’s ack bit equals its own toggle bit, it knows it can send the next payload. Tile A then sends new data in [3:0] and sets its toggle bit[4]=0. When Tile B sees the toggle bit change, it knows there is new data, captures and processes it, and sets its ack bit back to zero. This continues as long as there is more data to send.

I am treating these successive pairs of 4-bit values as command+data, but you could actually treat them independently, as a single 8-bit value, or whatever.

The key feature is the handshake between the toggle and ack bits that lets tiles know when it is safe to send a new piece of data. It turns the “value on face” interface from a simple “here’s my state” to something that the tiles can use to more easily talk to one another (query+response).

One of my goals was to make something simple (fewer corner cases) with a small footprint on both code and variables. I’m going to need all the space I can eke out once I get back to my main project.

Here’s the code. I welcome input!

2 Likes

Forgot to mention. When you run the test program above you will see any connected blinks alternating between green and blue on their connected face.

This change of color is happening because one tile is telling its neighbor to change via the protocol described above.

1 Like

@ScarPixel This sounds like a great idea and am interested to see how you develop it, I think I will give it a try once I get my replacement Pogo pins for my Devkit.

great work keep up the progress :slight_smile:

Lee

1 Like

@ScarPixel Like a tiny little version of TCPIP! :slight_smile:

This is very cool and effective, but I’d be interested in understanding why datagrams were not working for you.

Can you share the simplest datagram code that did not work as expected? Does the SimpleDatagramDemo (under the Getting Practical examples menu in Arduino) example program work as expected for you?

Thanks!

1 Like

I tried incorporating this code into my main program and am having trouble. So there may be a bug in there I guess? I’ll update again once I have it figured out.

This is very cool and effective, but I’d be interested in understanding why datagrams were not working for you.

I have no doubt that my datagram troubles were on my end - not anything technical. I bit off more than I could chew.

1 Like

Ah found the bug and pushed the fix to the repo above.

Now my main project mostly works and I think the next bugs I need to track down are not in the communications code.

I’ll post a new topic once I get it share-worthy :slightly_smiling_face:

2 Likes