07/11/2009

The End or the Beginning - Flex Accelerometer


AstroJAM Effectively stopped Jamming at the end of our time at university in Leeds. All the Jammers have gone our separate ways and effectively the collective which is JAM is no more. However... gone but not forgotten.

For me, JAM was an intense crash course in alternative appropriation of web technologies which I still refer to today.

I'm currently working on a project to get an Accelerometer to control a flash (Flex AIR) application. I feel that JAM is the best place to showcase this as, if we could have done this at the time... we would have.

So here we go, this is my tutorial for the integration of a Serial Accelerometer into FLEX.

The starting point for this project was completly coincitental. I found a serial (RS-232 (Old school COM port) ) Accelerometer from SparkFun in a shoe box in the office - something which the boss had bought for R+D but hadn't got round to yet.
For those of you who don't know what an accelerometer there's is a bunch of information on Wikipedia
However, if you can't be bothered reading that that know this - there are three of them in your Wii remote working together to sense movement. Essentially, they sense acceleration (change in movement).
My vision was that I would try and develop software to enable me to read its output which I could then use to control some kind of flash visualisation/game/experiment/whatever; so I asker the boss if I could take the device home with me along with a USB to Serial converter - my laptop like many today don't have a serial port so I've used a USB/Serial port adapter to turn one of my available USB ports into a Serial (RS-232) Port. Such devices can be picket up for a few pounds (or $ or Euros) - see http://www.google.co.uk/products?q=usb+serial+port+converter&scoring=p



So I had a functional USB serial device and an a Serial Accelerometer in my hands... What next!?

Firstly, a few searches on Google highlighted a problem - Neither Flash, Flex or even AIR support Serial Port communications. There simply is no support for this in current version and no mention of it in forthcoming versions of the platform; another solution is required.

Then I came across this - http://freshmeat.net/projects/serproxy/
Serproxy is a Serial Proxy (TCP/IP) server. It allows you to a serial device via a serial port through a TCP Socket. (EH What..!? SerProxy acts as a web server listening for incoming connections (on specific ports). When a connection is established SerProxy connects the appropriate socket directly to the COM port specified in the config).

The flash.net.Socket class has been available to developers for *yonks*! (AIR 1.0, Flash Player 9 to be exact). This allows you to read an write binary data to a Socket.... see where this is going? :)

'We can use a flash Socket to connect to SerProxy which will allow us to send and receive binary data to an attached Serial device'... woop!

In reality is doen't quite work. SerProxy won't talk nicely to the Acceleromener I have. As the device is not powered by an external source it relies on the DTR pin to be held high as its power source (its powered by the host machine). I couldn't get SerProxy to do this - the source is provided but I don't know C++ well enough to do anything with it. So I wrote my own version of SerProxy - TCPSerialProxy.

For the record, you can achieve similar Serial proxying results using Apache MINA. I wrote my own version in C# so three reasons, firstly I wanted to experiment, secondly, I didn't want to install MINA and thirdly, I've never written a windows service before and relished the chance to do so (sad I know...).

So to recap on the ramblings so far: The Serial Accelerometer has been connected to a free USB port using a USB/Serial adapter. The final software will be based on the Adobe Flash AIR platform so in order to do this I've written a SerialProxy in C# .NET 3.5 to act as a bridge.

My Serial Proxy "TCPSerialProxy" can be downloaded here

All source is provided.

Configure '.\TCPSPConsole\bin\Debug\TCPSPConsole.exe.config'
Run '.\TCPSPConsole\bin\Debug\TCPSPConsole.exe'

Sorry I can't provide a more detailed manual for this fortware at the moment - it keeps changing. This version is stable. I'll be building it into a windows service shortly.

So, on to the Flex app.

At the moment the software which is written is some debug software which demonstrates the implementation. I've not got JAMMY with it yet.

The app demonstrates how to decode/interpret the data stream from the accelerometer. The way its configured at the moment the accelerometer reads packets of data like this:

X= 0.900 Y=-0.700 Z= 0.500\n\r

I've also included a papervision visualisation (cube) which rotates on its XYZ axese base on the output from the accelerometer.

I've also applies some motion smoothing and a motionthreshold in order to render more stable motion.

Full Source is available here.

I plan on making something more of this in the future. I'll post more later on too.

Taraa for now!

30/04/2008

Shazam

Its been a while since I, or any of us for that matter, have posted anything here. We've been very busy with our uni work, XLAs, obesity briefs, other websites, animations and the like. Seems like the pressure is really coming down on us now there is just less than 3 weeks before the final, terminal, un-nerving end of the course. May the 16th will no doubt be an interesting, day; falling atr the end of a sleepless week.
Anyway, I'm not a good enought writer for my musings to be that gripping so let me tell you about some AstroJAM updates.
First of all, Ex01 (renamed Experiment0001) was finished and now resides at http://www.astrojam.co.uk/experiment00001
More Importatnly: The clild of Ex01, Today.I.Feel is far more impressive. Running on an updated version of the software today.i.feel (t.i.f) posed the question of its namesake. The majority of the webcame posts on the site are a reflection of how the user is feeling. T.I.F containes some far more creative responces than Ex01 and is worth visiting. It resides here http://www.astrojam.co.uk/today.i.feel/

The AstroJAM homepage has had a facelift. Its still a placholder but the jellys have changed their faces and worked on their dance routine a bit so go chech it out at http://www.astrojam.co.uk/

Finally, there is a new toy on the site for both webcam owners and those who aren't so fortunate ;) .
Interface000001 is a semi 3D interface you can navigate with either a webcam or a mouse!!!! You'll see what I mean :) The address is http://www.astrojam.co.uk/interface000001

More to come... :D

03/04/2008

AstroJAM! ex0.1 - Research and Inspiration


Good extract from a book called "Internet Art - The Online Clash of Culture and Commerce" by Julian Stallabrass. This is about the first interactive art piece. Which was basically a sentence which people added to. It's really interesting because I think it's still going. At the start it's just black and white and then as you carry on browsing through people start to learn how to use HTML and insert colour, images and links. Funny because people tried to sabotage the sentence and use it as a personal advertisement to their company! Two screenshots below of the starting page and one a lot further on. Also the link the the actual site. Our work with AstroJAM! ex0.1 is a modern day version of this experiment...lets see what we get.




Oh and the sentence was started in 1994. Just a bit of background for you guys on where I got the idea from! Might be useful to mention in your XLAs?

29/03/2008

Finalising

Yeah I would agree with you Adz about doing something now with the technology developed by Josh so far.

Whatever we do at this stage needs to be planned and implemented soon. I do realise that my contribution so far has been minimal but hopefully if we can now lay down a couple of aims and objectives I can start putting in more time.

Is Jam tennis still taking place for instance? Or instead shall we concentrate all our combined efforts on the web based idea? I think despite the Jam tennis being the more fun, the latter may be more effective at this stage of the game???

We need a chat soon neways.

Matt

25/03/2008

Jam Trusion - Jam NotSoTrusion

“Unlike bulletin boards or chat rooms, the Web is – for the most part – a read-only medium. It is flat and opaque. You can’t see through it to the activities of others. We don’t socialise with anyone when we visit a web site; we read text and look at pictures. This is not interactivity. It is an ‘interactive-style’ activity. There’s nothing participatory about it.”
Douglas Rushkoff – 1998

Right....I think it's time we get sorted with this NotSoJamTrusion piece. The piece where we're actually having people knowingly submitting their webcam images onto a page "Interacting" with the site. I think basically respond to this quote and show Rushkoff how far technologies gone to allow interaction. I imagine us starting off with a question and people respond to this using their webcam. I think it'd make an ace animation or stills...what you guys think...

Josh, we've done it with JamTrusion. How easy is it to have it put on a website next to each other. Say 8 columns and then continue downwards with however many pictures we get. This involves coding on Josh's half. Design and feel and purpose on my half and then Matt and infact all of us on ways to advertise and get this thing rolling with people interacting. It doesn't need to be a fun piece...just a photo being taken. Maybe they can add a piece of text under their image? Nice and simple. Snap! Picture taken...they're part of the art...

What do you guys think?

11/03/2008

{ Distance Maths }


Click to Witness


02/03/2008

{JamMoDet}