" /> Julian Bleecker: September 2006 Archives

« August 2006 | Main | October 2006 »

September 26, 2006

The Blind Camera — Sascha Pohflepp's "Buttons" Series

Ever sense Sascha started talking, quite animatedly, about this project — The Blind Camera — I became almost as excited as he. A camera..that takes someone else's photo. The semantics are tricky — it doesn't take a photograph of someone else, but take's (as in, borrows or copies or "snags") a photograph that someone else has captured, somewhere else in the world.

I mean..that's kind of brilliant in a playful, thoughtful way. The project captures all the amazingly promising characteristics of a world of sharing and circulating culture and experiences. And the most engaging part of the project, in my mind, is that it's an object, a tangible camera — an actual camera — and not just a bit of code, that you can download for free or whatever, and put on your laptop to play with for a few days and then discard or foreget about. It's an object — a physical affordance or whatever you want to call it. And that makes all the difference in the world for this project.

And another reason why I think Things that are networked matter. The idea of a general purpose computational device like your laptop has much less appeal in this regard. Or even the idea of the mobile phone being the one device you carry with you.

How, conceptually, from the perspective of design or even practicality, can we expect that this idea of one mobile device will sustain itself? There are so many things wrong with the mobile phone as an address book, for instance, or a game interface, or even as a telephone. Even the simplest of annoyances seem beyond the capabilities of the common phone to avoid. For example, how can you get people to stop shouting into their phone? People talk louder than they do when they're just having a normal human conversation — from inside my house on a nice pedestrian street, I can hear the phone conversations of neighbors walking their dogs as if they were sitting right here in my office.

Anyway, I am very fond of the idea of a diversity of devices at our disposal, whether or not we have them all the time. A baroque assembly of various instrumentalities, one of which is a camera that takes other people's photographs, another of which allows me to carry my online persona out into 1st Life so it can interact with other, offline objects, another that reminds me how to get where I'm going, etc. One device for everything seems positively impossible to achieve, practically or even conceptually speaking. And there's heuristic proof out there — my Treo is great because it has QWERTY. My Treo stinks cause it has Sprint. My Treo is great because it has a decent camera. My Treo stinks cause it weighs a ton and strains the seams of my pocket. My Treo stinks cause it has Sprint. This Nokia E61 I have is great cause it has QWERTY. This Nokia E61 stinks cause it has no camera. Etc. I think it is a conceit driven by corporate avarice and design hubris that there is One Thing that will embody all the interesting things we could do in our mobile lives.

Technorati Tags: ,

September 24, 2006

Arduino and the LIS3LV02DQ 3 Axis Accelerometer

A mouthful otherwise known as a nice little 3-axis accelerometer from STMicroelectronics with a SPI bus, which makes it handy for interfacing in microcontroller style applications. I picked up one of these in breakout board style from the DIY heros at Sparkfun Electronics to see about its suitability for a DIY pedometer. A bit pricey (single units at $15.95), but it's register-based configuration and data reading is pretty cool and eliminates any issues with pulse-width measurements or analog-to-digital conversion. It's not a slam-dunk replacement for simple projects, but I thought it'd be a good idea to learn more about it, and also learn more about interfacing over the SPI bus.

Ultimately I want to interface through some Atmel AVR device, but I figured I'd start with the Arduino, since it's pretty easy to get up and running in that environment.

The LIS3LV02DQ has two interfaces, one of which is SPI. For that, we need four data lines. One for chip select (also known as slave select), one for a clock, one for data in (to the microcontroller, from the slave chip), and one for data out (from the microcontroller, to the slave chip). The idioms in the SPI world vary, as I learned. For instance, here's a table of how they're referred to in this case:

LIS3LV02DQArduino/AtmelHuman
SDOMISO (master in, slave out)data in to Arduino from chip
SDAMOSI (master out, slave in)data out from Arduino to chip
SCLSCKclock
CSSSchip select

Whatever they're called, the functionality is pretty straight forward. The Arduino/Atmel is the "master" device — it tells the accelerometer chip what to do and when. In this case, "we" (the Arduino) can do things like read or write registers on the accelerometer. These registers configure the chip, tell it to start up or shutdown, read its sensor values, etc. The great thing about SPI is that you can do this all with only a few wires, and the protocol is simple enough that you could write your own firmware to handle it if your microcontroller doesn't support it in hardware. (Cf Nathan Seidle's SPI firmware source code example for the PIC.)

Fortunately, the ATMega8 and most of the Atmel ATMega's handle SPI in hardware.

Getting the LIS3LV02DQ up and running is pretty straightforward. I basically wanted to create a simple framework for reading and writing it's registers, which means that first I need to hook it up to the Arduino and then initialize the chip and I'd be set. First, hooking it up. Easy peasy.

I'm a bit out of bounds here, because I hooked up the chip to +5V generated by the Arduino. It's a 2.16V - 3.6V device, ideally. The IO lines can work at 1.8V for logic high. Here I am..in TTL land. Not wanting to destroy the chip, I played around with level shifting but ultimately, for this test, decided that I'd risk TTL logic levels. It's supposed to be able to take up to +5V, but I suspect the chip isn't terribly happy with that.

So, here's what gets hooked up and where:



VDD -> 5V
GND -> GND
INT -> N/C
SDO -> Arduino 13
SDA -> Arduino 12
SCL -> Arduino 11
CS -> Arduino 10

Easy enough. In the source code (available here) are defined a few useful things, such as functions to read and write the registers. The idiom is straightforward. For instance:


// write to a register
void write_register(char register_name, byte data)
{
// char in_byte;
// clear bit 7 to indicate we're doing a write
register_name &= 127;
// SS is active low
digitalWrite(SLAVESELECT, LOW);
// send the address of the register we want to write
spi_transfer(register_name);
// send the data we're writing
spi_transfer(data);
digitalWrite(SLAVESELECT, HIGH);
}

Performing the actual transaction over the SPI bus is handled largely in hardware. The ATMega8 has a register called SPDR that, when written to, begins an SPI transaction. Once you start a transaction, you have a choice of two ways to handle it. One is to simply wait around until the transaction is over, indicated by the SPIF bit being set. The other is to set up an interrupt vector for this bit, which will result in a designated function being called when the interrupt occurs. We're not doing all that much, so it's easier to just sit around and wait for the data rather than set up the interrupt vectors. The way you do this is to loop until the SPIF bit gets set.


char spi_transfer(volatile char data)
{
/*
Writing to the SPDR register begins an SPI transaction
*/
SPDR = data;
/*
Loop right here until the transaction is complete. The SPIF bit is
the SPI Interrupt Flag. When interrupts are enabled, and the
SPIE bit is set enabling SPI interrupts, this bit will set when
the transaction is finished. Use the little bit testing idiom here.
*/
while (!(SPSR & (1< {};
// received data appears in the SPDR register
return SPDR;
}

The spec sheet for the LIS3LV02DQ has specific instructions about reading and writing registers and what all of the registers are for, and other important stuff, like clearing bit 7 of register name to indicate that what's happening is a register write. I recommend reading it carefully to understand some of the nuances. But, it's pretty easy to work with, all in all.

My main loop() simply reads the registers that contain the X, Y, and Z axis values indicating acceleration along those vectors. The value that are generated by the LIS3LV02DQ represent a range of acceleration readings between -2g and +2g (the device can be configured to read +/-6g as well.) The registers contain either a high or low order value, so there are actually six registers to be read, two registers to compose a 16bit value. Although, actually, the default range of precision is 12 bits, with the most significant four bits, in this mode, containing the same value as the 11th bit, which effectively is the sign (+/-) of the data.

The values that are generated, once formed into a 16 bit word (with 12 significant bits) is such taht 2g = 2^12/2 = 2048, which means that 1 x gravity should be a value of 1024. If you place any of the chip's axes normal to the ground, you should see the value 1024, or thereabouts (possibly -1024).

Calculating a reasonable acceleration in the normal, human units (meters per second per second), you'd multiply the value by 1/1024. You'll need to scale the values into the long datatype range, I'd suspect, as you can't do floating point math. And you're 9th grade physics will tell you that:

velocity = a * t (meters/sec)
distance = v * t (meters)

So, you would sample the acceleration along an axis in the direction of motion and use an average of the acceleration over the sample period to calculate velocity.


void loop()
{
byte in_byte;
int x_val, y_val, z_val;
byte x_val_l, x_val_h, y_val_l, y_val_h, z_val_l, z_val_h;

// read the outx_h register
x_val_h = read_register(0x29); //Read outx_h
// high four bits are just the sign in 12 bit mode
if((x_val_h & 0xF0) > 0) {
Serial.print("NEG_X");
}
// comment this if you care about the sign, otherwise we're getting absolute values
x_val_h &= 0X0F;
//Serial.print("x_h="); Serial.print(x_val_h, DEC); Serial.print(", ");

// read the outy_h register
x_val_l = read_register(0x28);

//Serial.print("x_l="); Serial.print(x_val_l, DEC); Serial.print(", ");
x_val = x_val_h;
x_val <<= 8;
x_val += x_val_l;

// the LIS3LV02DQ according to specs, these values are:
// 2g = 2^12/2 = 2048
// 1g = 1024
// if you use the sign, that gives a range of +/-2g should output +/-2048

Serial.print("x_val="); Serial.print(x_val, DEC);

y_val_h = read_register(0x2B); //Read outx_h
y_val_l = read_register(0x2A); //Read outx_l
y_val = y_val_h;
y_val <<= 8;
y_val += y_val_l;
Serial.print(" y_val="); Serial.print(y_val, DEC);


z_val_h = read_register(0x2D); //Read outz_h
// Serial.print("z_h="); Serial.print(z_val_h, DEC); Serial.print(", ");
z_val_l = read_register(0x2C); //Read outz_l
// Serial.print("z_l="); Serial.print(z_val_l, DEC); Serial.print(", ");
z_val = z_val_h;
z_val <<= 8;
/*Serial.print("z_h_<<8="); Serial.print(z_val_h, DEC); Serial.print(", ");*/
z_val += z_val_l;

//long g_z; // say approx 100 cm/s/s
//g_z = z_val * 10 / 1024;

Serial.print(" z_val="); Serial.println(z_val, DEC);

}

Why do I blog this? Notes on how to get this accelerometer to talk to the world.

Technorati Tags: ,

September 10, 2006

Arduino Boards — Buy Yours Now..Seriously

In the computational media portion of CTIN541 laboratory this semester, we'll be working with the Processing programming language to learn fundamentals of software and hardware for media arts design-technology. One of the required supplies for the class is an Arduino, which is a small programmable device based somewhat on the Processing language.

I strongly recommend you get one right now. There is only one distributor in the US and, although they are quite efficient when it comes to stocking them, many media arts and engineering programs in the US seem to be using these (they're cheap, open-source/open-hardware, have a robust user community behind them, scale to many levels of user sophistication, can be used in a variety of projects, etc., etc.)

When I went to purchase a spare or two a couple or three weeks ago, there were zero available, when there had been a couple of hundred just a short while before — likely the semester began somewhere and they got scouped up for lab equipment.

You can purchase them at Spark Fun Electronics, $31.95 last I checked. You might cluster your orders and save a bit on shipping.

Device Art

I just read through a short, incisive little essay by Machiko Kushahara called Device Art: A New Form of Media Art from a Japanese Perspective in the v6, n2 issue of intelligent agent.

There are a couple of things that resonated in the piece, mostly the way the piece starts by explicating this notion of device art as a kind of theory object (here we go again..) that allows for what Kusahara describes as a re-examination of the relationships amongst art, science and technology. That is, the practice of creating a kind of media art that dices, slices and re-arranges what we understand to be art, what we understand to be science and what we take for granted as technology. I'm also intrigued by the Kusahara's description of the cultural distinctions between Japanese cultural traditions in this area, versus what I understand about American cultural traditions surrounding device technologies and creation practices.

Many of the concepts in there I think are relevant for the projects that end up happening at IMD — it's a short read that I highly recommend.

Why do I blog this? You know — the familiar sense that there are things we make that are framed as media art, some things framed as engineering technologies or science research. Personally, I would like to do both simultaneously, a sentiment I think I share with many others.

Obviously, these goal are in the life-long category. That's hard, but certainly not impossible. You have to be able to reframe your work in a variety of contexts, which means being able to talk about your work (literally, or write about it) fluently in many idioms. (Many of the artists mentioned in the essay do that expertly — Maywa Denki being the one with whom I am most familiar.)That's a challenge, which can be overcome through diligent practice. That is, as an exercise, frame your work as a media art, engineering design, contributing to long-term science research, etc. Naimark framed this notion as a variety of pitches to different sorts of people. It was something like, making your project resonate with a film producer, venture capitalist, media arts curator, your parents and a kindergarten teacher in 3 minute pitches?