Sunday, February 10, 2008

"Impossible Buildings" (Ableton Live, Arduino and uVGA)

"Impossible Buildings" (Audio Visual)
Video URL: http://www.youtube.com/watch?v=3F0kaLbm9ck


"I am working on trying to incorporate synchronised, synthesised video into performances where a computer is not necessarily available or desirable. This is my first attempt at using 4D system's uVGA module. This is a small circuit board that takes serial commands and generated video that can be displayed on any VGA-compatible display device (projector, monitor etc). In this video, a minimalistic drum track data from Ableton Live is sent to an Arduino, which is in turn connected to a 4D systems uVGA and a 15" monitor. Some nice visuals are thus generated. If only i had a data projector... then this sort of stuff would look much better. "


The uVGA module and Arduino
Below are some pictures of the uVGA module and a breadboard of the Arduino setup. The physical connections are extremely simple - for basic operation (without receiving an acknowledgment byte) only three connections had to be made, namely Arduino TX to uVGA RX, 5V and ground. The filter caps as seen in the manual are not necessarily needed (at least, performance has not suffered due to their exclusion).

A special connection cable was improvised using a left over snippet of stripboard, an eight pin dual inline socket, some rainbow cable and a four pin header. The reason for this cable is simply that the horizontal header pins of the uVGA do not make for a very stable breadboard.


Software Interfacing
Writing data to the module is straightforward. The uVGA module is "woken up" by sending 85 after waiting at least 900ms after power up. This is so that the module auto-detects the baud rate. I found it very strange that the device would not respond correctly to Serial.print() commands, but did respond to printByte() (thanks to Oscar G. at the 4D Systems forum for helping me out with this - this is very appreciated).

Once the module has been activated, it is just a matter of sending commands with variables so that the device draws the correct shapes and colours on the screen.

For example, this Arduino sketch makes use of only the "Pain Area" command, which takes the form of "0x70, A, B, C, D, E, F, G, H, I" (sent without the commas or spaces over the serial port), where A to I are bytes as follows:

A = Upper left corner of area, horizontal co-ordinate, most significant byte
B = Upper left corner of area, horizontal co-ordinate, least significant byte
C = Upper left corner of area, vertical co-ordinate, most significant byte
D = Upper left corner of area, vertical co-ordinate, least significant byte
E = Lower
right corner of area, horizontal co-ordinate, most significant byte
F
= Lower right corner of area, horizontal co-ordinate, least significant byte
G = Lower right corner of area, vertical co-ordinate, most significant byte
H
= Lower right corner of area, vertical co-ordinate, least significant byte
I = 8 bit colour variable, b7 and b6 are blue, b5, b4 and b3 are green and b2, b1 and b0 are red



Code
int i;

byte data;

void setup() {

Serial.begin(57600);

DDRB = DDRB | B00000000;


delay(1000);

printByte(85);

delay(100);


}


void loop() {

if(Serial.available() > 0) {

data = Serial.read();

for(int j = 0; j < data; j = j + 8) {

drawP(i % 190, i % 180, i % 20, i % 30, data % j, 1);

delay(1);

i ++;

}

}

if(i == 32767) {

i = 0;

}


}


void drawP(byte X1, byte Y1, byte X2, byte Y2, byte colour, int delayTime) {

printByte(0x70);

printByte(0);

printByte(X1);

printByte(0);

printByte(Y1);

printByte(0);

printByte(X2 + X1);

printByte(0);

printByte(Y2 + Y1);

printByte(colour);

delay(delayTime);

}



Max/MSP Patch
The Arduino receives data from Live via MIDI in this patch.

Download the patch here:
http://milkcrate.com.au/_other/downloads/max_patches/vgahack.pat

9 comments:

Tristan Louth-Robins said...

I like this. It reminds me of something like Max Headroom or (OMG) The Lawnmower Man.

I find it a little foreboding as well. :/

Sebastian Tomczak said...

i don't know what max headroom is.

it reminds me of the game rez.

Anonymous said...

Hey this is great. What exactly is the 2 pins that the rainbow wire is connected to. I was going to try this but i dont understand what those connections are. Thanks!

Sebastian Tomczak said...

So, okay, on the uVGA module, there are four connection pins. These are GND, RX, TX and 5V.

These are the four pins that are connected along the rainbow wire to the Arduino.

The Arduino is connected to the GND, RX and 5V lines of the uVGA. The RX is connected to the TX on the Arduino (digital I/O pin 1).

Make sense?

Anonymous said...

Perfect sense! Cheers mate.

Anonymous said...

Serial.print(85);

is probably equivalent to:

Serial.print("85");

try instead:

Serial.print((char)85);

Sebastian Tomczak said...

works great with printByte()!

Andrew L. Ayers said...

Building something like this, and not knowing who Max Headroom is, makes me a sad panda:

Max Headroom

It also makes me feel old.

Anonymous said...

So...where can I buy this particular uVGA setup?

-Tim G.
tg@click-vroom.com