2008-03-12

HOWTWO - When Polling Becomes an Issue.

Upplagd av Mneme

This is just a short description of a problem we had, and wheren't really able to solve due to time-constraints, but it is a pitfall that you can avoid pretty easily.

We where building an interactive boxing-bag, where the user would hit a the bag and trigger home-made buttons. Our buttons worked well in the early tests but when we put them in the bag we ended up with large issues in getting the SunSPOT to register a pressed button. We thought that this was an issue with the buttons never making contact. We spend a lot of time and effort on fixing the buttons, and of course it turned out that the buttons where the issue at all.

We where registering hits on the SunSPOT in a polling loop, ie the main program-loop read the inputs on the spot, processed it and sent data on a hit. Due to the polling nature of the program and the fact that the time our buttons got pressed where really short they never registered on the spot. Ie. in our bag the time the buttons made contact (ie. closing the circuit) was a lot shorter than the loop that ran on the spot making us miss a large proportion of triggers.

We never really solved this issue but ended up using the Phidget (it's event-nature was a lot easier to work with), so I can't really present a solution to you but keep in mind that this CAN be an issue in applications with very low time-constraints.

missing HOWTO...

Upplagd av Svenning

I would like to know how the "Klossen" group made all the (54?) LED light and change color (sorry guys, but I'm planning a different project were i have to use a lot color changing LEDs)

We had the problem that the light-thread (thin light) had to be fed with alternating current and the transistor, which had the base connected to the Arduino, was supposed to let the alternating current through when it was fed from the Arduino. The transistor didn’t like the AC so we had to get around the problem somehow. In an earlier stage we bought the DC-inverter which makes AC out of the DC, coming from the batteries inside.

The solution was quite simple but still genius, Frederic was mainly the man behind the plan. We opened up the inverter, got rid of the batteries and connected the battery-connections to the transistor outputs. When the transistor was fed with the DC from the Arduino it gave the inverter DC, coming from other batteries in the circuit. It worked like an auto switching battery. The inverter did its thing and gave us AC to the thread without going through the transistor.

This maybe isn’t the most advanced HOWTO but it can be useful, and we don’t want next coming groups getting trapped in simple problems like this. We still had problems with the cirkuit later on but we haven't determined that this depended on the mix between AC and DC but that might be the case. The light-thread is called Thin Light HighBright and we bought that and the inverter at the ThinLight-store on Brantingsgatan 39, Gärdet. There are nice people working there and they gave us some special price deal, 5 meters of thread and the inverter costed us 300 kr. www.thinlight.se

2008-03-09

HOWTO: Make a cheap button

Upplagd av Svenning

We had a sort of a button workshop and here are some notes from that:

To connect the wires to the tin foil we first winded steelwire with the wire and then taped the steelwire with gaffa tape on to the tinfoil. This had the positive sideeffect of giving the tinfoil strength while it maintained its flexibillity. To connect to a Phidget just put one wire in Ground and the other in digital in. When the two layers of foil connect you will get an 1 from the Phidget. If you user SunSpot or Arduino there should be a resister in between to avoid shortcut. Try experimenting with different patterns in the middle piece of foam rubber (skumgummi) and see whats works best for your kind of button. Also, you don't have to have the extra layer of foam rubber on the two sides of foil, we just had that to make the buttons more robust in our punchbag.

It's also possible to glue the tinfoil on the material you would use for your button, but the tinfoil will more easy get shredded when bended. So this is only a good solution if your making buttons on hard material.

The Foam rubber can be bought in most handcraft stores like Panduro Hobby and cost about 45 SEK for 50x50 cm.

Sockets really seem to be the simplest way to get data from the spot to a desktop application wireless. It's not really as difficult as it seems to start with but it might be a bit messy to start with.

Serversided (to recive data from the spot):
/*Regular ServerSocket. This can of course simply be modified for sending data aswell. Code for stability (handling reconnects on lost connection and so forth I leave to you. Same with the try-blocks.*/
Socket s;
/*ServerSocket(portnumber), portnumber is the port the application will listen on*/
ServerSocket ss = new ServerSocket(4711):
s = ss.accept()
/*Open the InputStream*/
InputStream input = s.getInputStream();
/*Read an integer*/
int in = input.readInt();

Spotsided:
/*To send data to the socket. InputConnection can ofcourse be used to read, for example.*/
OutputConnection connection =
(OutputConnection)Connector.open("socket://127.0.0.1:4711");
OutputStream out = connection.openOutputStream();

/*Write data to the desktop app.*/
out.write(0);
out.flush();

SocketProxy
To run sockets on the SunSpot you need to start up a socket-proxy on the computer you have the basestation connected to. For that you need to run ant so:
1. Locate your ant installation - for mac/*nix users you will most likely already have this in your path so you should be fine. On windows (if you haven't fixed it yourself) you will probably find ant somewhere in your local Eclpise/Netbeans directory.
2. Go to the directory of your spot-application, or more precisely the directory where you have the build.xml (ant buildfile) for spots. Then run:
ant socket-proxy
...and you should be good to go.

2008-03-06

Flute Hero

Upplagd av Svenning

Sadly this is a transverse flute and not recorder but anyway maybe the "USB flute" group could use their flute as a controller for this game
Flute Hero

Thanks for a great course and cool to see the different projects last Wednesday