Show Posts
Pages: [1] 2
1  Topics / Device Hacking / Re: Making a hard disk clickity-clack on: December 18, 2012, 05:22:20 pm
Hello! I have recently started to look into the idea of using an Arduino to interface with an old hard drive spindle. I took apart an old 30GB Maxtor from an old mac tower but i've been having some issues. I looked through this thread, which was extremely informative but I was curious if anyone had a diagram of the schematic that was mentioned on the first page of this thread. Does anyone know of any good tutorial sites instead of just a video and a code example? I've been having a hard time with this and I its slowly getting to me that I can't figure it out. Any ideas?
2  Using Arduino / Installation & Troubleshooting / Re: Old and Newly Purchased Mega Constantly Timing Out! on: October 24, 2012, 11:06:50 am
Thanks for the reply and this seemingly has worked! Awesome!

Appreciated  smiley-grin smiley-grin smiley-grin
3  Topics / Interactive Art / Arduino + MaxMSP Light Sonification/Drawing System on: October 24, 2012, 10:56:26 am
Since July I have been working on a machine that uses an Arduino paired with an ambient light sensor from Sparkfun to collect light data. This data is then routed through MaxMSP via the [serial] object to control 2 stepper motors and a single servo motor which are also connected to the Arduino. At this point the data is collected and parsed within MaxMSP to drive two specific functions: move/draw light patterns with the servo motor based on the movement of the stepper motors and at the same time sonify the data that is being streamed.

For example, if the intensity of the current light source is strong, the stepper motors will pull the servo motor to the top of the page and vice versa for low level light intensity. The varying ranges of light intensity are mapped in 4 different ways: in groups of 4, 7, 11, or random. All of the parameters that determine the ranges of these groups are created by using segments of the Lucas number sequence as a way to influence the system in an algorithmic way. Lets say if the user choses map group 4 (0 - 1023), the page will be broken up into 4 sections (256 x 4). When the light intensity falls within a group, lets say group 1, a random number/position is generated based on the current group you are in. So this would be in group 1, a random number from 0 - 255 will be plotted by the drawing machine. At the same time, the fluctuation of light will create sound based on the streaming parameters. Seven instruments were created for this project and they all have the ability to be compressed, equalized and mixed in real-time.

I hope you enjoyed reading this and if you wanna check it out here is the link below. Thanks for reading and enjoy!
smiley-grin smiley-grin smiley-grin smiley-grin

http://opkach.com/portfolio/weathertextures-2/weather-textures-optical-sonance

4  Using Arduino / Installation & Troubleshooting / Old and Newly Purchased Mega Constantly Timing Out! on: October 22, 2012, 11:23:11 am
So last night I was trying to upload a sketch to my Arduino Mega and everything was lined up correctly. All the pins were in the right positions, the right board was selected and the right serial port is selected. I try to upload the sketch and I keep getting the message.

avrdude: stk500v2_ReceiveMessage(): timeout

I was rather annoyed and I need my mega for a presentation soon. I went to the store and ended up purchasing another Mega. I come home and the same thing is happening, it keeps timing out when I try to upload a sketch. I have tried multiple USB cables, multiple connections, tried with it bare (no connections).

What is the problem here?! Its really getting on my nerves and there are no !!! in my sketch either, which I had read previously may be the culprit.

Any ideas?
5  Using Arduino / Programming Questions / Re: Serial Parsing into 2 Arrays for Steppers on: October 17, 2012, 03:16:00 pm
Quote
Even if I code it with a '.' and no space, it takes a comma and a space for max to properly translate it to MaxMSP.
So why the blankitty-blank-blank don't you make the code expect what you are getting?

This is getting nowhere when you keep trying to modify the Arduino code in ways that do not match what you are ACTUALLY getting as input.

Especially, when you keep insisting that somehow the Arduino is then at fault.

Video of uploading the code with the period and how MaxMSP does not understand how to react. Yet when I used a comma, it prints it properly.

https://www.dropbox.com/s/9zh3yojgp3znch3/Screen%20Capture%20Tool_2012-10-17%2015.44.03.mov
6  Using Arduino / Programming Questions / Re: Serial Parsing into 2 Arrays for Steppers on: October 17, 2012, 02:21:52 pm
Quote
Even if I code it with a '.' and no space, it takes a comma and a space for max to properly translate it to MaxMSP.
So why the blankitty-blank-blank don't you make the code expect what you are getting?

This is getting nowhere when you keep trying to modify the Arduino code in ways that do not match what you are ACTUALLY getting as input.

Especially, when you keep insisting that somehow the Arduino is then at fault.

Its been resolved and it was easy. If we didn't focus so much on the concept of a period and a comma, and realized it was routed through MaxMSP, then we may have resolved it.

.... I've mentioned it before. For some reason, when the data is routed THROUGH MaxMSP, it is interpreted differently than how it would respond in the Arduino Serial Monitor. I am trying to get it to communicate correctly, and now it does. I apologize if I annoyed you but I do not think you were getting my idea from the beginning. Even know I type in ".", when I go and type a number set in MaxMSP with the period, it doesn't respond correctly. For some reason, when I type a set with a comma, it works, even though it is coded within the Arduino as a period.

Its a communication relay issue between the both of them. I don't know if you have used MaxMSP but sometimes they communicate and then sometimes they communicate and they unrelate.

Thank you for taking the time out to help me though, I apologize for confusion. I am going to make a video so you can see what I am talking about.

7  Using Arduino / Programming Questions / Re: Serial Parsing into 2 Arrays for Steppers on: October 15, 2012, 03:07:47 pm
This:
Quote
The example number input I used was "47, 13".
and this:
Code:
    else if (ch == '.')  // comma is our separator, so move on to the next field
still do not go together.

You probably also need to deal with space as a special character, too. Otherwise the space will cause the same problem the comma is now causing.

I understand they are not the same but for some reason when I upload my code and type in integer sets within MaxMSP, anything with a period does not work. That is what was mentioned in the examples a few posts back. Even if I code it with a '.' and no space, it takes a comma and a space for max to properly translate it to MaxMSP.
8  Using Arduino / Programming Questions / Re: Serial Parsing into 2 Arrays for Steppers on: October 15, 2012, 02:22:30 pm

Quote
Code:
        ptr_stepperarray[0] = ch;
I don't understand why you have this here (or anywhere, for that matter). You are stepping on the value in stepperarray[0] when you do this. Why?

Thanks for you patience with this problem, you have no idea how much walking through this helps. I do not know why I was doing that, I don't have a lot of experience so many of the things I have used are random examples. Pointers and multiple arrays are still fairly new to me.

Quote

Code:
      for(int i=0; i < 1; i++)
      {

How may times is this loop going to iterate?

As of the moment, the code loops every time I input a set of integers. As of the moment it seems like it is working as I want it.

Quote
Totally bewildered and pondering how to split up the array, maybe make it a pointer to do that?
I don't think a pointer is the solution. More Serial.print()s to see what you are really receiving would be good. Knowing when you increment stepper1index would be good, too.

Below is the code with more print statements and I also supplied an example print so you don't have to run it. The example number input I used was "47, 13".

Code:

void loop()
{
  if( Serial.available())
  {
    char ch = Serial.read();
   
    Serial.print("ch (Serial.read) -> ");
    Serial.print(ch);
    Serial.println(" "); 

    if(ch >= '0' && ch <= '9') // is this an ascii digit between 0 and 9?
    {
      values1[stepper1index] = (values1[stepper1index] * 10) + (ch - '0');
     
      Serial.print("values1[stepper1index] -> ");
      Serial.print(values1[stepper1index]);
      Serial.println(" ");   
    }
    else if (ch == '.')  // comma is our separator, so move on to the next field
    {
      if(stepper1index < NUMBER_OF_FIELDS_1-1)
      {
        stepper1index++;   // increment field index
             
        Serial.print("stepper1index++ -> ");
        Serial.print(stepper1index++);
        Serial.println(" ");
      }
    }
    else
    {
       
      int i;
     
      for(int i=0; i < 1; i++)
      {
          int a = values1[0];
                       
          Serial.print("a or values1[0] -> ");
          Serial.print(a);
          Serial.println(" ");
         
          int stepperarray[] = {a};
                       
          int *ptr_stepperarray = stepperarray;

          Serial.print("Number#1 -> ");
          Serial.println(*ptr_stepperarray);
          Serial.println(" ");
      }
       
         values1[i] = 0; // set the values to zero, ready for the next message   
        stepper1index = 0;  // ready to start over
    }
  }
}

ch (Serial.read) -> 4
values1[stepper1index] -> 4
ch (Serial.read) -> 7
values1[stepper1index] -> 47
ch (Serial.read) -> ,
a or values1[0] -> 47
Number#1 -> 47
 
ch (Serial.read) ->   
a or values1[0] -> 0
Number#1 -> 0
 
ch (Serial.read) -> 1
values1[stepper1index] -> 1
ch (Serial.read) -> 3
values1[stepper1index] -> 13
ch (Serial.read) ->
 
a or values1[0] -> 13
Number#1 -> 13
 
9  Using Arduino / Programming Questions / Re: Serial Parsing into 2 Arrays for Steppers on: October 15, 2012, 01:08:02 pm
Code:
          int a = values1[stepper1index];
          int b = values1[stepper1index++];
There are postfix operators and prefix operators. They do different things. The prefix version increments (in the case of ++) and then the value is used. The postfix version uses the value, then increments it.

So, in this code, the same value is being stored in a and b. And, it is likely to be the wrong value, as it is the index to the last value stored in the array. I suspect that what you want here are 0 and 1, not stepper1index and stepper1index that is then incremented.

When I make the change below, nothing is printed within values1[1]. Everything seems to be stuck in value within the values[0] part of the array. ptr_stepperarray[0] will always yield both integers that are typed in. Totally bewildered and pondering how to split up the array, maybe make it a pointer to do that?

Code:
     
          int a = values1[0];
          int b = values1[1];   
          int stepperarray[] = {a, b};
          int *ptr_stepperarray = stepperarray;
         
        ptr_stepperarray[0] = ch;

// *ptr_stepperarray = ch; This was another piece I just figured out so that this pointer now holds the input, how to
// split it?

          Serial.print("Number#1 - > ");
          Serial.println(ptr_stepperarray[0]);
            Serial.print("Number#2 - > ");
          Serial.println(ptr_stepperarray[1]);
10  Using Arduino / Programming Questions / Re: Serial Parsing into 2 Arrays for Steppers on: October 15, 2012, 12:12:35 pm
Quote
What is more important is how to resolve the problem
Are the values in the string separated by commas, as you said, or by periods as you coded?

It is coded as '.' within the Arduino code. But what is odd, when I type it into the Serial monitor with a period (ex. 32.12) it does not work but with a comma instead it works (ex 54, 32).

I've narrowed it down to this piece of code i've figured out to be the one that seems to be creating this issue and there are a few examples below of various results
Code:
         
     //    ptr_stepperarray[0] = ch;

----------------------------------------------------------------------------------------------------------------------------------------
When this piece of code is eliminated

Example A1 -- ex. 32.12

prints as follows inside Arduino Serial Monitor = Number#1 - >  12 (second integer is lost)
prints as follows inside MaxMSP from the Serial Monitor = Number#1 -> 0 (second integer is lost)


Example A2 -- 32,12

prints as follows inside Arduino Serial Monitor
Number#1 - > 32
Number#1 - > 12

b]prints as follows inside MaxMSP from the Serial Monitor[/b] = Number#1 - > 0 Number#1 - > 0
----------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------
When this piece of code is uploaded

Example B1 -- ex. 32.12

prints as follows inside Arduino Serial Monitor = Number#1 - >  10 (second integer is lost)
prints as follows inside MaxMSP from the Serial Monitor = Number#1 -> 32 (second integer is lost)

Example B2 -- 32,12

prints as follows inside Arduino Serial Monitor
Number#1 - > 44
Number#1 - > 10

b]prints as follows inside MaxMSP from the Serial Monitor[/b] = Number#1 - > 32 Number#1 - > 12
----------------------------------------------------------------------------------------------------------------------------------------

So pretty much it seems that when this piece of code is uploaded, the one specified above, I can acquire the correct data. Still, I am trying to separate these two number fields from "ptr_stepperarray[0] = ch" so I can send these two individual integers to 2 different stepper motors.
11  Using Arduino / Programming Questions / Re: Serial Parsing into 2 Arrays for Steppers on: October 15, 2012, 10:59:04 am
First off, bare with me please, i'm new to posting and in general I know its mashed together as it was specified above. What is more important is how to resolve the problem, it is now posted properly.

 smiley-twist

Code:
void loop()
{
  if( Serial.available())
  {
    char ch = Serial.read();
    if(ch >= '0' && ch <= '9') // is this an ascii digit between 0 and 9?
    {
      // yes, accumulate the value
      values1[stepper1index] = (values1[stepper1index] * 10) + (ch - '0');
     
    }
    else if (ch == '.') 
    {
      if(stepper1index < NUMBER_OF_FIELDS_1-1)
      {
        stepper1index++;   // increment field index
 
      }
    }
    else
    {
     
   // any character not a digit or PERIOD ends the acquisition of fields
      // in this example it's the newline character sent by the Serial Monitor   
       
        int i;
      for(int i=0; i < 1; i++)
      {
          int a = values1[stepper1index];
          int b = values1[stepper1index++];   
          int stepperarray[] = {a, b};
          int *ptr_stepperarray = stepperarray;
         
          ptr_stepperarray[0] = ch;

          Serial.print("Number#1 - > ");
          Serial.println(ptr_stepperarray[0]);   
     
        }
               values1 = 0; // set the values to zero, ready for the next message   
               stepper1index = 0;  // ready to start over
      }
    }
    }
12  Using Arduino / Programming Questions / Re: Serial Parsing into 2 Arrays for Steppers on: October 15, 2012, 02:36:03 am
I figured out how to get the two needed integers to print within Max but I am still confused. ptr_stepperarray[0] seems like it is the holder of both incoming integers from the Serial Monitor but how can break it apart? If I were to run this code within MaxMSP or through the Arduino serial monitor and type two random integers (lets say 4, 123), I will get this

Number#1 -> 4
Number#1 -> 123

So by deduction it seems like the ptr_stepperarray[0] contains these two numbers but how can I parse it out so they are two separate int's? I just want each number, in this case 4 and 123, to be route individually if that is at all possible.

please need help!  smiley-cry


Code:

void loop()
{
  if( Serial.available())
  {
    char ch = Serial.read();
    if(ch >= '0' && ch <= '9') // is this an ascii digit between 0 and 9?
    {
      // yes, accumulate the value
      values1[stepper1index] = (values1[stepper1index] * 10) + (ch - '0');
      
    }
    else if (ch == '.')  // comma is our separator, so move on to the next field
    {
      if(stepper1index < NUMBER_OF_FIELDS_1-1)
      {
        stepper1index++;   // increment field index
        //Serial.println(stepper1index++);
      }
    }
    else
    {
      // any character not a digit or comma ends the acquisition of fields
      // in this example it's the newline character sent by the Serial Monitor
        
        
        
        int i;
      for(int i=0; i < 1; i++)
      {
          int a = values1[stepper1index];
          int b = values1[stepper1index++];    
          int stepperarray[] = {a, b};
          int *ptr_stepperarray = stepperarray;
          
          ptr_stepperarray[0] = ch;

          Serial.print("Number#1 - > ");
          Serial.println(ptr_stepperarray[0]);  
      
        }
               values1[i] = 0; // set the values to zero, ready for the next message    
stepper1index = 0;  // ready to start over
      }
    }
    }

13  Using Arduino / Programming Questions / Re: Serial Parsing into 2 Arrays for Steppers on: October 14, 2012, 10:45:59 pm
Forgot to mention that as you maybe saw in the code I need to convert ASCII to integers so it will interact with the steppers correctly. It was probably apparent but mainly mentioning since it is vital to track the stepper movements within Max.
14  Using Arduino / Programming Questions / Re: Serial Parsing into 2 Arrays for Steppers on: October 14, 2012, 10:44:23 pm
Will your input string 132, 293 contain spaces as well (after the comma?). You probably need to think of the number as the pattern <number><separator><number><end of line>.

Also, think of using a small structure that contains the numbers so that the array index remains the same

Code:
struct values
{
  int value1;
  int value2;
}

values v[NUMBER_OF_FIELDS];
you then access the individual elements as v.value1 and v.value2.

Fewer indices to kepe track of and a more logical grouping of values.

The string would be "0, 12" so 0, comma, space, 12. But now after reading the other reply I may just use a period. Thanks for the advice about the structs! I am fairly weak at working with structs, is it possible you could help me out or inform me with another example? This has been an experiment in how do I know and it seems that it may be very little  smiley-confuse
15  Using Arduino / Programming Questions / Re: Serial Parsing into 2 Arrays for Steppers on: October 14, 2012, 10:41:46 pm
Quote
(ex. 0, 23 or 132, 293)

whats the data format? is every other one going to list 2? or is it a chunk of 4 into list 1 then the next 4 into list two?

personally I would keep it all in a single array and stride the values

for(int i = 0, i < 5, i += 2)

would give you 0,2,4, and

for(int i = 1, i < 5, i+= 2)

would give you 1, 3

It would be so that in Max/MSP when I type in 0, 30 it will take the number before the comma and insert it into a list and the second number at the the comma do the same. I really don't want it to be like that but with Max/Arduino communication this is the easiest format, I could use a period too. But in general, 2 lists.
Pages: [1] 2