New development in Project: Interactive Sculpture
From Physical Programming
I have decided to change my project to something more achievable, and ultimately more tangible, it will be an interactive sculpture. I came up with this idea just by lying in bed one night, but I have a feeling it is a subconscious derivative of the many programmed interactive visual displays I youtubed throughout the research phase of this project, more particularly I think this:http://www.youtube.com/watchv=dghosAzI6k&feature=PlayList&p=DA965DE9233688A6&index=27 crept into my creative psyche :) It is the work of Daniel Rozin who has developed a series of interactive mirrors, you can look at them here:http://www.smoothware.com/danny/index.html
My idea is to have an approximately square metre size collection of rods (maybe wood, or even just sticks I find on the ground?)that will be placed equally within the square metre space and with capitalising on the awesome capabilties of the wii nunchuck remote's accelerometres and an arduino I am hoping to be able to programme the wii to control servos that the rods will be resting on. So the effect will be like a mexican style type display by the rods which the user can control, though only to the limits of the display itself. I am hoping it will simulate tall grass in the wind.
I have decided to write a diary about its progress so as to give an idea of how painful it can sometimes be, and also satisfying, to undertake such projects.And it begins today:
The Chronicles of Lara's Physical Programming Project(Now in Hardcover)
By Lara Mikocki
CHAPTER 1: The Treacherous Saga of Acquiring Necessary Components
I was happily sniffing out all the parts I needed for my project (that I know of so far, more will become needed in time I'm sure) on the internet as some of them are not available in Melbourne, and to my luck Australia! I can get the nunchuck, servos and arduino here but I need a special wii chuck adapter to be able to connect it to the arduino. THERE ARE ONLY THREE OUTLETS IN THE WORLD THAT SUPPLY THIS TO AUSTRALIA! It was developed by some guy known as todbot, and if you feel so inclined you can read about here:http://todbot.com/blog/2008/02/18/wiichuck-wii-nunchuck-adapter-available/. The only Australian outlet that operates in Sydney which supplies this component is called Little Bird Electronics, and casually was collecting items in my virtual "shopping basket" when ofcourse the nunchuck adapter is not available at the moment. I tried to give them a call to find out some info and apparently is a dead line. I searched around on the internet for people having the same issue contacting them as me, and apparently people have a BIG problem with this company based on a forum I stumbled across. The only means of contact is through email and apparently go unreplied, orders do not come for months at a time with no information to a paying customer of their purchases progress. It was almost a relief to find this out so I could take my business elsewhere but also annoying because now I must look to the UK and America.
This is where the trouble really begins. I look first at the American one called FunGizmos.com and I am filling in all the blanks when for some insane reason I can't fill in the payment details which clearly is the most important, it just would not let me type in the relevant fields.I don't know and still don't know why to this day. So I thought, that's okay two down, one to go which is the company in the UK called Tinker.it, which is originally based in Milan.Anyway so I come to the payment options again, and lo and behold "Unfortunately there is no Shipping Rate available for your destination and/or weight of your cart.
Please contact the Shop Owner for further assistance." and it would not let me click the purchase button regardless of this silly discrepancy: By this time I was fuming. I calmed down, and decided to make a paypal account because I was able to, for some strange reason, type in the paypal section for FunGizmos. I went through the motions to set up the account and realised I accidentally forgot to put the "student" in my email address, so it looked something like this : s3135253@rmit.edu.au. The confirmation email was never going to reach me, by this time I had already ordered the adapter, because it allowed me to continue on through the complete payment, but unless the email was confirmed, it would never be completely complete...if you know what I mean. So I went about trying to change the email, but this was never going to happen because to change the email would mean to have to confirm the original one, obviously for security reasons. I did not have time for the system, days later to realise the email I originally gave, was not valid, so I went about calling the assist help line from paypal. Talking through static and a thick accent, I was having trouble explaining to operator my problem about the email, and they were having trouble understanding. Even though it was my own fault for the WHOLE chain of events, I was getting very aggravated with the operator for not understanding so I just asked them to cancel my account after 20 minutes of struggling with them. Finally I set up another, correct, account and tried it all again, after many a frantic email to FunGizmos (which are a very good company by the way, highly recommended) to explain my circumstance,I finally received my adapter in the mail Monday morning and am far more pleased than the average person would be to receive a nun chuck adapter.The next painful struggle was finding enough mini servos to accommodate my project.I had to travel to three different Jaycar outlets just to get nine servos at 30 bucks a pop, this is when you ask if it's all worth it...I travelled to Nunawading(three in stock, but only needed two by this time) and Sydney Rd (only three in stock) and of course the city store kindly only stocked four servos at a time and the warehouse was on backorder for them.Any way after that long rant I can move on to the next chapter. This chapter has a message: IT IS SAFE TO DECLARE AUSTRALIA IS TERRIBLE FOR EASE OF FINDING ELECTRONIC COMPONENTS.
Below are the images of the final (main) components acquired for the project:
CHAPTER 2: The Meeting of the Physical to the Virtual a Romantic coupling: a love story.....interrupted
Alright, so this is where joy and love, pain and sadness are all experienced in one big explosion of emotions. I had some outside help, only because it wasn't as easy as I thought it would be, tweaking scripts etc.and it comes in the form of Erwan, a wonderful tech nerd, I can definitely not take credit for all of this beautiful creation. There are a myriad of codes out there and I was hoping to use and abuse, but it's just not that easy.
The first step was to build a jig (very quick ad easy) that would hold all 81 rods upright, and would also aid in reaching optimal up and down movement tranferred by the circular motion of the servos.I have made three levels, one to hold a grid of servos, and two to support the rods a different levelfor the least wobbling. Here is a pic of ones of ply wood levels and the rods:
Then the next step was to hook the components up before anything, where I found Todbot, as mentioned earlier, came very much in handy again which you can see for yourself below: http://images.google.com.au/imgres?imgurl=http://todbot.com/blog/wp-content/uploads/2007/10/boarduino-nunchuck-servo-450.png&imgrefurl=http://todbot.com/blog/2007/10/25/boarduino-wii-nunchuck-servo/&usg=__g_0xHQN9jSHYJw0mwa9cQk_oEdU=&h=297&w=450&sz=142&hl=en&start=9&um=1&tbnid=5mK6POUF1lNuCM:&tbnh=84&tbnw=127&prev=/images%3Fq%3Darduino%2Bmultiple%2Bservo%26hl%3Den%26client%3Dfirefox-a%26rls%3Dorg.mozilla:en-US:official%26hs%3DQIr%26sa%3DG%26um%3D1
He describes how to hook up a nunchuck and servo to an arduino, though with the nunchuck he has not used an adapter like me, but directly attached it to the arduino with cutting off the end of the cable, and he also uses a Boarduino, but that is really not so much of an advantage.So temporarily attaching a servo for testing to PMW Pin 9 it was tested with using a code already in the Sketchbook Examples from downloading the servo library to Arduino.cc :
// Sweep // by BARRAGAN <http://barraganstudio.com>
- include <Servo.h>
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
} And that worked perfectly, note how the sketch mentions it can handle up to 8 servos for future reference.The physical number of servos an arduino can hold is six because there are six PWM inputs to plug them in, but the library downloaded manages more than this because it effectively turns other non PWM pins to act like them, don't ask me how, it just does, that's why other people write the libraries, so I don't have to think twice about it! From this sketch I learnt you ALWAYS have to have to define two methods, or functions :setup and loop, setup literally means what is is, and only has to happen once in the sketch, but must be there to initialise the activity, in this case the servo, and loop can also literally be translated, it repeats the action so that the entire sketch doesn't just happen once and then....tumbleweed.
Following this was making that one little baby servo react to the nunchuck, which is where my new best friend Erwan came very much in handy! To allow the Arduino to handle the nunchuck a wiichuck library was downloaded.In the programming you have to read the data that the nunchuck sends and play with it until you find an approximate value that nunchuck is at when twisitng it, this was a problem at the beginning because the data we were getting was all jibberish but adjusting the "baud" rate allows the computer to read the data at the speed it needs,is is like an agreement they make to communicate, otherwise it is too fast and they can't understand each other, hence the jibberish!In this case it at the value 254, you can translate this value in the sketch: degree = map(accel, 0, 254, 0, 90); so that when the nuncuck is at 254 the servo will rise to 90 degrees, the arduino can understand the nunchuck through serial data, which is basically messages sent constantly through the USB cable in sentences of 1's and 0's, eight of these in a row is called a byte, one is a bit.This is known as digital data, all output is called digital, and can be described as either on, or off or low or high (the 1's and 0's). These 1's and 0's are all the same length, so cleverly mixing them up can make sensible data even though they are all the same length, for example 0,0,0,0,1,1,0,0 would mean the output device would be idle longer than it was active, if that makes sense...So you may notice the sketch coming up has "#include <Wire.h>" these allow for serial communication for the Arduino, and this is known as a library that decodes the data.The nunchuck will send a packet of data at the particular point the wire requests a packet from the arduino, so, in laymans terms, the arduino is like "hey, what chu up to bro?" and the wii chuck is like "here, have this packet, open it, and find out", not the ideal metaphor,bu it works.
Now, the hardest thing about this whole schamozzle for lack of a better word, is that programming is LIKE TRYING TO LEARN JAPANESE IN A MONTH, it's a whole other world and language, and language barrier for that matter, but a few important bits I understand that I can TRANSLATE for you before I show you the next sketch of the 4 servo ripple, so you a bit of a foundation. I already described the setup and loop previously, which is a MUST,and self explanatory for that matter, but the 3 basic statements are "if", "for loop" and "while loop". "If" provides a conditional, for example, I have programmedd myself that IF someone hands me 100 dollars, then I will accept it. It is the same in code, IF the value is at x, then the output will function accordingly. a "for loop" is like a mini loop that was described at the beginning, and will repeat a set number of iterations. The "while loop" essentially has of a block of code and a condition, the differnce from a for loop is that the for loop repeats for a specified number of times whereas a while loop repeats as long as a certain condition is true, so if I have accepted the money, then I will buy two arduinos, or not :) Also, "define" is important to let the arduino know of what it is controlling and how many, a constant, and "array" especially in my case because I have several servos that need to be controlled, and the array can hold multiple values.So, that's the main gist,
here is the 4 servo ripple code:(if you are ever using servos and arduino, remember to state "servos[i].refresh();" or nothing will happen, found this out the hard way)
- include <Wire.h>
- include <WiiChuck.h>
- include <SoftwareServo.h>
- define NUM_SERVOS 4
int pins[NUM_SERVOS] = {8,9,10,11}; SoftwareServo servos[NUM_SERVOS]; WiiChuck wiiChuck = WiiChuck(); int dvals[NUM_SERVOS];
int i; int accel; int degree;
void setup() {
for(i=0;i<NUM_SERVOS;++i) {
pinMode(pins[i], OUTPUT);
servos[i].attach(pins[i]);
servos[i].write(0);
}
wiiChuck.begin();
wiiChuck.update();
}
void loop()
{
delay(50); // Wait for 50ms
wiiChuck.update(); // Get pack from the wiiChuck
// only move the servos when Z button is held down.
if (wiiChuck.zDown()) {
accel = constrain((int)wiiChuck.readAccelX(), 0, 254); // Get the Z-Acceleration data from the library
degree = map(accel, 0, 254, 0, 90); // translates the x-accel data to a different range.
// shift the values along the array...
// Should be able to do this in a for loop... somehow
dvals[3] = dvals[2];
dvals[2] = dvals[1];
dvals[1] = dvals[0];
dvals[0] = degree;
for(i=0;i<NUM_SERVOS;++i) {
servos[i].write(dvals[i]); // ASsign the value to the servo (in degrees)
servos[i].refresh(); // Sent the data to the servo.
}
}
} and here it is in action http://www.youtube.com/watch?v=XkT-UbnSWHA
For the servos to effectivley "ripple" the values follow one another in the array. To add another four servos to make eight, was not difficult in the programming, all it was was assigning pins 4,5,6 and 7, plugging them in and changing the number of servos the arduino has to acknowledge in define and adding them in the array:
8 servo ripple:
- include <Wire.h>
- include <WiiChuck.h>
- include <SoftwareServo.h>
- define NUM_SERVOS 8
int pins[NUM_SERVOS] = {4,5,6,7,8,9,10,11}; SoftwareServo servos[NUM_SERVOS]; WiiChuck wiiChuck = WiiChuck(); int dvals[NUM_SERVOS];
int i; int accel; int degree;
void setup() {
for(i=0;i<NUM_SERVOS;++i) {
pinMode(pins[i], OUTPUT);
servos[i].attach(pins[i]);
servos[i].write(0);
}
wiiChuck.begin();
wiiChuck.update();
}
void loop()
{
delay(50); // Wait for 50ms
wiiChuck.update(); // Get pack from the wiiChuck
// only move the servos when Z button is held down.
if (wiiChuck.zDown()) {
accel = constrain((int)wiiChuck.readAccelX(), 0, 254); // Get the Z-Acceleration data from the library
degree = map(accel, 0, 254, 0, 90); // translates the x-accel data to a different range.
// shift the values along the array...
// Should be able to do this in a for loop... somehow
dvals[3] = dvals[2];
dvals[2] = dvals[1];
dvals[1] = dvals[0];
dvals[0] = degree;
dvals[7] = dvals[6];
dvals[6] = dvals[5];
dvals[5] = dvals[4];
dvals[4] = degree;
for(i=0;i<NUM_SERVOS;++i) {
servos[i].write(dvals[i]); // ASsign the value to the servo (in degrees)
servos[i].refresh(); // Sent the data to the servo.
}
}
}
but the only problem was that there was not enough power from 1.5 AMP power source to sustain the arduino and 8 servos, or even 4 servos and an arduino. With the arduino getting power from the computer and the four servos getting power from the battery, it worked fine, but 8 on the battery and the arduino on the computer did not work either. Scott helped clear up the techinical issue with providing a higher voltage power source to the servos and a separate battery for the arduino and is now a successful execution, thanks Erwan and Scott!
Putting together the whole setup was a breeze, I setup the grid of servos and pulled a sheet of lycra over the servos (which I lengthened the arms with for more go) to maximize the energy of fewer servos to accomodate more rods, and provide a more of a flowing movement. I had two levels of ply with holes to translate the rotary the movement of the servos to a perpendicluar movement to the rods, this was surprisingly successful, though not as smooth as I would like, but it does the job! here is a video of four servos supporting 24 rods, pretty cool:
mexican wave a la lara! http://www.youtube.com/watch?v=jJICq6EJ_y0
In conclusion, this was a very ambitious project, that I wouldn't have been able to achieve with outside help, but I have learnt a lot but still struggle with the finer details, especially the electronics side, I find it very confusing.Regardless of this I want to dedicate time to understanding what I still don't and to take it to the next level with pan and tilt mechanisms on a larger scale, and install a large scale public interactive sculpture, I love what programming can provide, and doing this project has dfinitely confirmed this, anything is possible.
The End
Research sites: http://images.google.com.au/imgres?imgurl=http://todbot.com/blog/wp-content/uploads/2007/10/boarduino-nunchuck-servo-450.png&imgrefurl=http://todbot.com/blog/2007/10/25/boarduino-wii-nunchuck-servo/&usg=__g_0xHQN9jSHYJw0mwa9cQk_oEdU=&h=297&w=450&sz=142&hl=en&start=9&um=1&tbnid=5mK6POUF1lNuCM:&tbnh=84&tbnw=127&prev=/images%3Fq%3Darduino%2Bmultiple%2Bservo%26hl%3Den%26client%3Dfirefox-a%26rls%3Dorg.mozilla:en-US:official%26hs%3DQIr%26sa%3DG%26um%3D1
http://diydrones.ning.com/profiles/blogs/705844:BlogPost:31713
http://robot-overlord.blogspot.com/2009/04/arduinoservo-tutorial.html
http://www.glacialwanderer.com/hobbyrobotics/?p=7
http://www.arduino.cc/playground/Learning/SingleServoExample

