FabAcademy 2014 - Takuma Oami

Fablab Vestmannaeyjar

Interface And Application Programming

Assignments: write an application that interfaces with an input &/or output device

For my final project, I tried to develop a way to figure out geometry of APA network in this week.
And not only scannning connection between nodes and save it as data like CUI but also show the result in graphical way (GUI) as visualizer is the goal.

Node and Spring

I started coding from visual side. To show the geometry of nodes, I've decided to use 2D particles with springs simulation so APA nodes(perticles) are connected together by Spring which explainss cable between boards and nodes keep distance form each other (not too close, not too far) by simple phisical simulation.
I've found its example for openframeworks but it's wrote in C. Since I want to learn wxPython to make interface, I rewrite the code in python. Here is the code and the video.

New commands for apa IO board

Original program for APA board send back packet like below when user send packet to destination.

send packet: {^00|n}
receive packet: {00^|}

Inside {}, packet has two data separated by '|'. Route to destination is contained before '|' and payload is contained after '|'. In case above, "00" means packet goes port0 of node1 and then goes to port0 of node2. And route of receive packe is just reversed. because of that, we know only sending port not receiving port in communication between nodes.
To scan geometly, It's needed to know not only sending ports but also received ports. So I modified the program for apa.io.board to add one extra command to get route of receiving ports to destination. It works with original programs of APA sample from Academy page. And receiving ports route is contained in receive packet if "s" is used as payload like...

$ python apa.py /dev/tty.usbserial-FTFBF5IQ 115200 "00" "s"
send packet: {^00|s}
receive packet: {00^|212}

In receive packet, route is just reversed version of send packet but you can see other route in payload area. It shows receiving ports packet went through from FTDI board to destinaion board. Here is my version of the code (apa.io.c).

Scanning connections

For hardware side, I just used same board I made in Network week


I connected three of this in straight.


And I modified apa.py to scan geometry of data by using "s" command mentiond above and recursive process with Python. To record geometry of network, dictionary array of python is used. which has 4 elements.

0: node connected with port0 or 'none' 
1: node connected with port1 or 'none' 
2: node connected with port2 or 'none' 
'id': unique id for this node

For example, if the network in the photo above is scanned, result will be like that...

{0: {0: {0: 'none', 1: 'none', 2: {...}, 'id': 2}, 1: {...}, 2: 'none', 'id': 1}, 1: 'none', 2: 'none', 'id': 0}
{0: {0: 'none', 1: 'none', 2: {...}, 'id': 2}, 1: {0: {...}, 1: 'none', 2: 'none', 'id': 0}, 2: 'none', 'id': 1}
{0: 'none', 1: 'none', 2: {0: {...}, 1: {0: {...}, 1: 'none', 2: 'none', 'id': 0}, 2: 'none', 'id': 1}, 'id': 2}

If node is connected with port, list contains node self.


The Graphic section and The back-end section are done but they are still separetaed so I merged these code into one. I also add some code to show port number on both side of springs to show numers of send/receive ports. And First node is fixed in center of window so nodes don't fly to out of window. Here is result...

I tired with other network geometry.
Nodes are connected which is branche off.


and run the code...

Next step

My system doesn't support loop structure yet so if geometry has loop in somewhere scanning keep looping and never stop. That's one of problem I have to solve.
And I need to expand number of port from 3 to 6. To do this, probably I will use AtMega88 instaed of AtTiny44 because of more pins and more memory which could solve speed of scanning as well since it's a little bit slow even though I use onle three nodes for now.