2010年6月5日土曜日

Tutorial 01 Isadora and Arduino

This is a tutorial for using Arduino as a controller of the Isadora.

This tutorial enable you to understand about how to program Arduino and Isadora, and it will enable us to build up interactive devices for our art works.

*My proglam had little problems at first. I did not realize until I finished to write this blog. I uploaded a fixed program at the very end of this tutorial. Once you read through everything and go. 

Requirement

Basic kit of Arduino (Potentiometer, and several wires are required)

Isadora(PC/Mac I did not check with Mac but I think OK)

USB connector and cable

+ Knowledge of basic programming of Arduino




All you have to do is building up a simple circuit and program Arduino and Isadora.


The first step(Circuit)






 The next step

Build up a program for Arduino. The program that get a value from a analog pin and send the value to the computer through the serial connection (USB)

This is actually a simplified program. It must be better to add little more program for a nice program but it is easy to understand.

You can enable all of the analog and digital pins' input with a more sophisticated program such as using "for" command to automate to read other pins' values.

For more information go Isadora forum.

http://forum.troikatronix.com/

I uploaded a fixed program at the very end of this blog post, you can use this program to see what will happen but I recommend you to use fixed program for your art works.

/*
integration of the swithch with analoginput and Isadora
*/

int val;               //Declare variables. any words are fine.
int ana = 0;       // Value must be same as a number of the analog pin

void setup()
{
Serial.begin(9600);   //Setup serial speed (it is important in a later step)
}
void loop()
{
val = analogRead(ana);  //get data from analog
  Serial.println(1,DEC); // discuss in later
Serial.println(val); //Send a value to computer.
delay(500);  // Regulate a frequency of connection. 
}

/*

End of the program

*/



Let's check the program

Compile>Upload>Serial Monitor

If you succeed, you can change the value by controlling the Potentiometer.



"Serial.println(1,DEC);" must be a strange cord but it is additional information for Isadora to identify Serial In Watcher

The number(or a word) is used for identify a Serial In Watcher in case you use a lot of  Serial in Watcher. A DEC indicates a type of data. 

If you write "Serial.println(99,BYTE);", Isadora will send a value for Serial In Watcher having "c" identity.( Since it is actually ASCII cord, 99 means small c.) You will figure out how it works later in a section of programing Isadora, even though you do not understand right now.

Therefor, if you want to use small "a" you need to use 97 instead of c.

If you want to know more about ASCII, go to Google or go to Resource Category in my blog and find a link to a list of ASCII cord. 


We have already done 70%.

Please, Please note that close Serial Monitor to avoid future problems when you done.

To much information to the monitor makes your Arduino program unstable and causes conflict with Isadora when you try serial connection with it. Also Please not to use serial monitor while you are using Isadora with serial connections. Isadora will die because of the conflict. I have experienced it several times. 

The last thing is a programing Isadora and set up a serial connection.

Run Isadora.

Type in a search box "Serial" and find Serial in Watcher Binary. 

 I notice that Serial in Watcher Binary has problem. Serial In Watcher Text is a right chose. Please see at the bottom of this tutorial to figure out the problem. 



You can also find Serial In Watcher under the control Group 7, but using search box is 3 times easier.


It is a regular Serial In Watcher. It does not do much works so let's hack it!

Double crick Serial In Watcher a window will pop up.



Type a program in a window

"1"

value : integer = 4 digits



"1" is used for identify Serial In Watcher, which we specified with ASCII cord(go back and check)

"value" is just a name anything is fine. Since we typed in "integer = 4 digits" the value will be appear like as 1024, 1001, 1005 like that. For digital input, you need to change "integer =  digits", since the digital signal will be 1 or 0, on and off.

For Windows user, when you typed in first line and hit enter to move to second line the window might close, but just double click again and continue.



You will notice that new output named "value" is added. This is what you want and we will use.

Go output of Isadora and hit serial port setup.

A new window will pop up.



Select a device. My computer already connected to a lot of devices, so for my computer COM4 is provided for Arduino. 

For Mac user, instead of COM# it will be a name of devices.

Make sure the connection speed is set as 9600 which we specified in program (go back and check the setup section of the program "Serial.begin(9600); ")



Hit OK. You will notice that nothing happen, since we did not activate a serial connection.

Go to Output and hit "Enable Serial port". It will activate a serial connection.

You will see "mes rcv" is blinking and shows X.

You can change the value with Potentiometer.



All done!


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

IMPORTANT : Problem Solution

I notice that somehow the value 1 appear sometime when you roll the Potentiometer until maximum and also Serial In Watcher is frozen. You will need to hit a reset button.

To avoid freezing, you can connect Wave Generator to the reset button.

To avoid it delete   Serial.println(1,DEC); from program

but if you do that Isadora probably can not identify more than 1 signal.

I think that it is because of circuit but not sure I have to research more to solve the issue.


P.S. I figure out the way to solve even though it is not perfect.

The Isadora cause problem if the value become different digits. So put a resister between Potentiometer and 5 V and reprogram "val = analogRead(ana)/2+100;" and adjust a value with in a Isadora with Calculation


P.S. 2

I solve all of the problem finally.

This is a fixed program

Bold cords are fixed. 

int val; //Declare variables. any words are fine.
int ana = 0; // Value must be same as a number of the analog pin

void setup()
{
Serial.begin(9600); //Setup serial speed (it is important in a later step)

}
void loop()
{
val = analogRead(ana); //get data from analog
Serial.print(1,DEC); // discuss in later
Serial.print(val); //Send a value to computer.

Serial.println(); //Send a value to eom
delay(500); // Regulate a frequency of connection.
}



In stead of use "Serial In Watcher binary" use "Serial In Watcher Text" of Isadora.



Set a value of eom from 13 to 10.

This modification will solve all of the problems.

----------------------------------------------------------------

Advanced control.

In order to control the value there are three ways.

1)Hardware control.

2)Software control.

    a) Change a program of Arduino.

    b)Change a value with Isadora's calculation group.


1, Hardware control


It is not so much flexible but it makes your program more simple.


2-a, Software control (Arduino).

Controlling the value with Arduino program.

"val = analogRead(ana)+1000;" 

It is flexible but you need to compile and upload again and again whenever you need to change the value.


2-b, Software control.

Using Isadora's calculation group to control value.




It is the most flexible and easy to change the value. It just looks like disorganized.




Sorry about disorganizing.




2 件のコメント: