Loading...
  Show Posts
Pages: [1] 2
1  Community / Exhibition / Gallery / Re: Barcode piano on: February 15, 2011, 01:10:57 pm
Even if the schematics and the source code are quite simple I thought someone might be interested in having access to them.
So here they are, just scroll to the very bottom of this page:
http://www.cs.uic.edu/~mtriveri/Marco_Triverio/Tangible_barcodes.html

...Let me know if you find any mistake!
Have a good day.
2  Community / Exhibition / Gallery / Re: Barcode piano on: February 14, 2011, 12:57:15 pm
Thanks!
In case you want to see more of the process that has brought us to develop such project please have a look at this webpage
http://www.cs.uic.edu/~mtriveri/Marco_Triverio/Tangible_barcodes.html
(in case the link breaks please refer to: portfolio.marcotriverio.com )
3  Community / Exhibition / Gallery / Re: Barcode piano on: February 12, 2011, 04:45:12 am
Thanks for your question.
Barcode is a technology that is very common but there are many aspects that are not clear to the vast majority of people (ie, 4 b/w stripes signify a number). The project is about making children grasp these concepts, not about making them read a barcode.

Thanks for your comments!
4  Community / Exhibition / Gallery / Barcode piano on: February 10, 2011, 12:42:09 pm
Hi!
I'd like to share a project developed by me and other two students at the Copenhagen Institute of Interaction Design (CIID, www.ciid.dk).
It is a project that aims at teaching barcodes to children through the use of music.

Video:


It has been developed in 4 days during Massimo Banzi/David A. Mellis/David Gauthier's Physical Computing class.
Feedback is welcome!
Thanks.

5  Forum 2005-2010 (read only) / Syntax & Programs / Re: Maximum array size on: July 25, 2008, 10:35:51 am
Thanks!  smiley
6  Forum 2005-2010 (read only) / Syntax & Programs / Re: Maximum array size on: July 24, 2008, 08:13:42 am
Quote
Variables are not stored in program memory (flash), they are stored in RAM, and the mega168 only has 1k of RAM.
[...]  If your array is constant you can store it in program space (which is 14k) by including <avr/pgmspace.h> and using the PROGMEM attribute in your array declaration, but it looks like in your case this wouldn't help you.

If you need to store a large array, maybe you should look into purchasing an external RAM module.

Thanks for the info!
It's good to know that pgmspace.h exists.
Where can I find a RAM module? Is it fast as interna RAM?

Thank you again  smiley
7  Forum 2005-2010 (read only) / Syntax & Programs / Maximum array size on: July 24, 2008, 03:24:32 am
Hi everybody,

I'm trying to run the following program; it compiles, but it never starts.  :'(
Reducing the array size makes it run but I need to use a pretty big array.

1000 short ints should not overflow ATmega168 memory, should they?
1000 * 16 bit = 1000 * 2 byte = 2000 byte
(compiling this program returns: " 2838 bytes (of a 14336 byte maximum)")

Why is it happening?
Thank you very much!

Code:
#define L  1000

short speed[L];
int gyroPin = 0;

void setup() {
  digitalWrite(13, HIGH);
  delay(500);
  digitalWrite(13, LOW);
}

void loop() {
  long int last = 0;
  long int now = 0;
  
  last = millis();
  
  for(int i=0; i<L; i++) {
    now = millis();
    while(now == last) {      // wait until 1 ms elapses
      delayMicroseconds(50);
      now = millis();
    }
    speed[i] = analogRead(gyroPin);
  }
  
  send();
}

void send() {
  Serial.begin(9600);
  Serial.println("Ang speed-----------------");
  for(int i=0; i<L; i++) {
    Serial.println(speed[i]);
  }
  while(1);
}
8  Forum 2005-2010 (read only) / Syntax & Programs / Re: Arduino skipping part of "loop()" on: July 24, 2008, 03:36:15 pm
Quote
while(pos<theta) delay(1);

Note that you initialize pos to zero, and then call a function that only delays if pos is less than -360 (which is immediately false).  This will cause your function to immediately exit and proceed to one that drives the motors in the other direction until pos is greater than 360 (in this direction the while loop is not true immediately and you actually get a delay).  When you switch directions you need to switch the less-than operator to a greater-than operator.

I'm so sorry it was such a stupid mistake!
Thanks so much for your help!

I fixed it and it now works.
9  Forum 2005-2010 (read only) / Syntax & Programs / Re: Arduino skipping part of "loop()" on: July 24, 2008, 12:12:41 pm
Quote
Hi
I think that a int can only use positive numbers, i think you must use a long int?

Thanks for your reply, Lee; I checked on the reference and int do actually store negative numbers.

http://www.arduino.cc/en/Reference/Int
10  Forum 2005-2010 (read only) / Syntax & Programs / Arduino skipping part of "loop()" on: July 24, 2008, 08:25:55 am
 Hi everybody,

I don't know why Arduino keeps on skipping a instruction (highlighted in code)...   :-/
...Can someone help please?

Thanks so much!


Code:
//variables
int volatile pos = 0;
int sensepin = 3;


void setup() {
  pinMode(13, OUTPUT);
  attachInterrupt(sensepin-2, out, CHANGE); /handles encoder interrupt and update position
  pos=0;
  delay(500);
}

void loop() {
  digitalWrite(13, HIGH);
  delay(500);
  digitalWrite(13, LOW);
  delay(2000);

  //drive motor in one direction until encoder says "-360"
  drivebothTo(120,0,-360);   // <<<<<<< SKIPPED <<<<<<<<<


  digitalWrite(13, HIGH);
  delay(500);
  digitalWrite(13, LOW);
  delay(2000);  

  drivebothTo(0,120,360); //not skipped
  
  delay(1000);
  for(int i=0; i<5; i++) {
    digitalWrite(13, HIGH);
    delay(200);
    digitalWrite(13, LOW);
    delay(200);
  }
  
  digitalWrite(13, LOW);
  while(1);
}


void stopandwait(int time) {
  //STOP
  //motor 1
  analogWrite(10, 0);
  analogWrite(11, 0);
  //motor 2
  analogWrite(6, 0);
  analogWrite(9, 0);
  if(time>0) delay(time);
}

void drivebothTo(int one, int two, int theta) {
  
  //motor 1
  analogWrite(10, one);
  analogWrite(11, two);
  //motor 2
  analogWrite(6, one);
  analogWrite(9, two);
  while(pos<theta) delay(1);
  
  stopandwait(0);
}

void out() {     //handles encoder interrupt and update position
  int val2 = digitalRead(2);
  int val3 = digitalRead(3);
  if ((val2==LOW && val3==HIGH) || (val2==HIGH && val3==LOW)) {
    pos++;
    //digitalWrite(13, HIGH);
  }
  else {
    pos--;
    //digitalWrite(13, LOW);
  }
}
11  Forum 2005-2010 (read only) / Development / Re: Exactly... How fast is Arduino? on: August 07, 2008, 06:25:34 am
Quote
I doubt that worrying about the time spent in the for loop is the right place for your efforts to improve speed.

Thanks for the hint; actually I don't want to improve (250 Hz should be enough) but I want to better understand how things are working.
12  Forum 2005-2010 (read only) / Development / Re: Exactly... How fast is Arduino? on: August 07, 2008, 05:11:04 am
Quote
This may or may not be a valid thought, but doesn't using a for loop add overhead, so you're not getting an accurate result for how long it takes to do a multiple or add?

I get your point but in my program (the one described in the first post) all the operations happen inside for loops, so I guess that in this case it's important not to mitigate the loop overhead.

Thanks for all the replies  smiley
13  Forum 2005-2010 (read only) / Development / Re: Exactly... How fast is Arduino? on: August 06, 2008, 03:28:03 pm
Quote
You can use timer1 which can be accurate to a fraction of a microsecond but its easier just doing a  big loop of floating points and using millis. If you do a say ten thousand fp operations you should get a pretty good estimate of how long one would take

I used a program to separately calculate ADD and MULT time.
The results were: 12 microseconds and 5 microseconds respectively.

My code has 28 multiplies and 36 sums for a total of 572 microseconds.
In addition it must be considered that I'm working with matrixes and that I'm handling 4 PWM outputs and one analog input.

...Is it enough to exceed 3 milliseconds?


PS:
This is the code I wrote (the printDouble function was created by mem!):
Code:
float val = 0.03;
float add = 0.012;
float mult = 1.008;
float time = 0;
int prec = 30000;
long start = 0;
long end = 0;
long total = 0;

void setup() {
  digitalWrite(13, HIGH);
}


void loop() {
  
  //ADD
  start =  millis();
  for( int i = 1;  i < prec;  i++ ) {
    val = val + add;
  }
  end = millis();
  total = end - start;
  
  Serial.begin(9600);
  Serial.print("It has taken ");
  Serial.print( total );
  Serial.println(" milliseconds in total.");
  time = (total*1000)/prec;
  printDouble( time, 6 );
  Serial.println(" microseconds per one ADD");
  
  
  //MULTIPLY
  start =  millis();
  for( int i = 1;  i < prec;  i++ ) {
    val = val*mult;
  }
  end = millis();
  total = end - start;
  
  Serial.begin(9600);
  Serial.print("It has taken ");
  Serial.print( total );
  Serial.println(" milliseconds in total.");
  time = (total*1000)/prec;
  printDouble( time, 6 );
  Serial.println(" microseconds per one MULT");
  
  
  digitalWrite(13, LOW);
  while(1);
}


void printDouble( double val, byte precision){
  // prints val with number of decimal places determine by precision
  // precision is a number from 0 to 6 indicating the desired decimial places
  // example: printDouble( 3.1415, 2); // prints 3.14 (two decimal places)

  Serial.print (int(val));  //prints the int part
  if( precision > 0) {
    Serial.print("."); // print the decimal point
    unsigned long frac;
    unsigned long mult = 1;
    byte padding = precision -1;
    while(precision--)
       mult *=10;
      
    if(val >= 0)
      frac = (val - int(val)) * mult;
    else
      frac = (int(val)- val ) * mult;
    unsigned long frac1 = frac;
    while( frac1 /= 10 )
      padding--;
    while(  padding--)
      Serial.print("0");
    Serial.print(frac,DEC) ;
  }
}
14  Forum 2005-2010 (read only) / Development / Re: Exactly... How fast is Arduino? on: August 06, 2008, 08:27:30 am
Quote
Hello
Why would you not believe it runs at 16MHz? smiley
Simply because I didn't read it on the datasheet... but I guess I can trust Massimo!  smiley-wink

Quote
If you are using an original arduino  you can see by yourself by looking at the quartz next to the processor.
It should say S16B00K7 the 16 means 16MHz
Nice!

Quote
in terms of floating point speed it all depends on the quality of the software implementation as the processor doesn't have a floating point coprocessor
we are using the one that comes with avr-gcc so you should check if there is any indication on the avr-libc website
The question is... how may cycles might it take to sum or multiply two floats?
I've found a few documents (page 34 of http://manet.die.udec.cl/~biomedica/senales/avr-libc-user-manual-1.6.1.pdf and http://www.nongnu.org/avr-libc/user-manual/group__avr__math.html) but they're not useful for my purpose.

...Any idea?


PS: I thought I might calculate how much time it takes for two floats to be added or multiplied but I need a more precise version of the millis() function... does a version of millis() that work with microseconds (instead of milliseconds) exist?
Thank you.
15  Forum 2005-2010 (read only) / Development / Exactly... How fast is Arduino? on: August 06, 2008, 04:52:25 am
I'm implementing a PID controller (similar to this one http://www.arduino.cc/playground/Main/BarebonesPIDForEspresso) on my Arduino and I'd like to use a sampling time of 1ms (frequency = 1 kHz).

I've read that Arduino runs at 16 MHz (btw is that true?) and I thought it would not be a problem to execute (more or less) 60 float operations every 1 ms: it indeed is a problem and I have to slow down to 250 Hz (once every 4 ms).


Do you think that this is an expected result?
Thanks  smiley
Pages: [1] 2