Show Posts
Pages: [1]
1  International / Software / Re: Arduino Mini light on: November 19, 2013, 12:29:30 pm
Buenas,

Tengo la misma combinación. Arduino Mini ATmega 328 y el USB2SERIAL LIGHT y me da exactamente el mismo error.
Habéis podido solucionarlo.
En mi caso no dispongo del condensador de 100nF puede ser por esto? (ahora mismo no tengo condensadores de esa capacidad?
Ayuda por favor.
2  Using Arduino / Storage / Re: Read int values from the SD card on: February 14, 2013, 06:50:07 am
Thank you  johnwasser, for your reply and help. About your comment...
Quote
Are you sure you have to have every value in memory before you an do your calculations?
Really is not needed, I would explain you better the application and may be you can help me in found a solution.
The values stored in the file, "1.txt" (for example) are the values of the acceleration is x, y and z coordenates, once I storage this values (that don't have a fixed size) I need open this file and compound the resultant acceleration as ar=(ax^2+ay^2+az^2)^1/2; and calculate the integral of these points as v=time/2 (ar[i-1]+ar) newton rapson methode, and evaluate the maximun of this value V. For me is interesting evaluate storage all the values v for with a PC and Excel obtain the graphics.
I am thinking, and I hope that you can evaluate this possibility, use another file 1_v.txt when i storage all values of v and with this don't initializate any array, is possible this?
I am thinking in a code as this (in this I writte some doubts that I have):
Code:
File myFile = SD.open(nomfichero);
      if (myFile) {
        Serial.println(nomfichero);
        while (myFile.available()) {
          //Serial.write(myFile.read());
          int x = myFile.parseInt();
          int y = myFile.parseInt();
          int z = myFile.parseInt();
          File myfile2 = SD.open(nomfichero2,FILE_WRITE); //I DON'T KNOW IF I CAN OPEN AT THE SAME TIME TWO DIFFERENTS FILES.
          ar = sqrt((sq((x*0.007-3.6)) + sq(0.007*y-3.6) + sq(0.007*z-3.6)));// MY FUNCTION TRANSFER SENSOR
         myfile2.println(ar);                                        // I DON'T KNOW IF IS POSSIBLE PRINT A FLOAT VALUE IN THE SD.     
         myfile2.close();
         
    }// close the file:
          myFile.close();
         if (myFile2) {
              // CALCULATE THE INTEGRAL ECUATION AND FOUND THE MAX VALUE.
          }
      } else {
  // if the file didn't open, print an error:
      Serial.println("error opening test.txt");
      }
     }
3  International / Software / Duda con lectura de datos en Fichero SD on: February 12, 2013, 07:50:59 am
Buenas a todos,

Tengo un problema con una determinada aplicación que estoy realizando.
Por situar un poco la aplicación, cuando se pulsa un botón conectado a una determinada entrada digital, abro un fichero en la SD y comienzo la adquisición y guardado de datos que provienen de un sensor. La longitud de esta adquisición, depende del ensayo en cuestión.
El problema que encuentro es en la siguiente parte del código, con otra pulsación conectada a otra entrada digital, debo abrir el último fichero guardado y leer los datos adquiridos por el sensor, para realizar un determinado cálculo matemático con ellos. Los datos guardados están en enteros de la siguiente forma:

253;569;521
265;547;245
142;545;365
....

La idea que tengo es abrir el fichero y almacenar la primera columna de datos en un array x, la segunda en un array y y la tercera en un array z de la siguiente forma:
x = [253;265;142;....]; y =[569;547;545;....] y z=[521;245;365;...]

Estoy teniendo problemas con esta operación de almacenar en x, y y z los valores, el código que tengo implementado es el siguiente:
Defino las siguientes variables:
Code:
int i=0;
int x[]={};
int y[]={};
int z[]={};

Y dentro del loop cuando abro el fichero ....

Code:
File myFile = SD.open(nomfichero);
      if (myFile) {
        Serial.println(nomfichero);
        while (myFile.available()) {
          //Serial.write(myFile.read());
          int x = myFile.parseInt();
          int y = myFile.parseInt();
          int z = myFile.parseInt();
          x[i] = x;
          y[i] = y;
          z[i] = z;
          i=i+1;
    }// close the file:
          myFile.close();
          }
      } else {
  // if the file didn't open, print an error:
      Serial.println("error opening test.txt");
      }

El problema que tengo es en x, y y z se me escriben los mismos valores esto es :
x[1]=521;y[1]=521;z[1]=521
x[2]=245;y[1]=245;z[1]=245 .....

Puede alguien decirme por que ocurre esto?
Se puede mejorar o robustecer esta parte de código?
Agradecería cualquier ayuda al respecto...
Un saludo.
4  Using Arduino / Storage / Re: Read int values from the SD card on: February 12, 2013, 06:58:38 am
The problem with the initialize the arrays values is that I don't know the size of these vectors, because depending of the test measurements you can have differents size vectors.
Is possible that I can do it a very great initialitation as:
Code:
for (i=0;1<100000;i++){
ax[i]=0;
ay[i]=0;
az[i]=0;
}
Is it possible or it's a crazy solution?
Thanks and regards.
5  Using Arduino / Storage / Re: Read int values from the SD card on: February 11, 2013, 10:39:14 am
Thank you, Johnwasser I didn't know the function parsein(), really interesting!.
I think that I complete the code:

In the setup ...
Code:
int i=0;
int ax[]={};
int ay[]={};
int az[]={};

and in the loop ....
Code:
  File myFile = SD.open(nomfichero);
      if (myFile) {
        Serial.println(nomfichero);
        while (myFile.available()) {
          //Serial.write(myFile.read());
          int x = myFile.parseInt();
          int y = myFile.parseInt();
          int z = myFile.parseInt();
          ax[i] = x;
          ay[i] = y;
          az[i] = z;
          i=i+1;
    }// close the file:
          myFile.close();
          i=0;
          for (i=0;i<10;i++){
          int value = az[i];
            Serial.println(value);
          }
      } else {
  // if the file didn't open, print an error:
      Serial.println("error opening test.txt");
      }
     }

Why I obtain the same values in the ax, ay and az dates?
How I can see in the Serial the values of the all the arrays for evaluate if the arrays is generated OK?

Thank you very much another time.
Regards.
6  Using Arduino / Storage / Read int values from the SD card on: February 11, 2013, 09:23:25 am
Dear all,
I have a problem with a program that I am developing I am using and Arduino Ethernet Shield with the  incorporated SD.
In the program, I storage in the SD card some values of the an accelerometer, the number of these values are aleatory depending of the test duration. The values are properly storage in a file.
After of this storage, I need verify the values stored for do it I need open the file and read these values.

The opened file has the next values:
192.txt
705;546;437
426;402;385
307;291;303
257;245;254
232;225;230
221;218;221
216;214;216
215;214;415
221;222;223
224;225;226
228;229;229

I would like, storage in a first array ax the first colum, in the ay the second and in the az the last column of values. I need do it some matematics calculus with these arrays.

By the moment, I has the next code opening the file but I have really problems in storage the values as I comment previously.
Code:
File myFile = SD.open(nomfichero);
      if (myFile) {
        Serial.println(nomfichero);
       while (myFile.available()) {
          Serial.write(myFile.read());
         }// close the file:
          myFile.close();
          } else {
  // if the file didn't open, print an error:
      Serial.println("error opening test.txt");
      }

I read in some foros that exist the function strocke and atof but I don't know how this functions operate.

I am very thankfully some ideas about my problems.

Thanks and regards.
7  Using Arduino / Programming Questions / Write analog value in SD on: January 30, 2013, 10:15:33 am
Hello to all.

I have a problem with a program that I am doing. I am read an analog value and I want to writte this value in a file in the SD. The problem is that this value is write as int ( 283 for example) and I want see this value in float (1.38).
I am using this code but I can not storage this value in float.

 File myfile = SD.open(nomfichero,FILE_WRITE);                    
    if (myfile){                                                      
    
      String dataString = "";                                          
      for (int analogPin = 0; analogPin < 1; analogPin ++){            
        float sensor = analogRead(analogPin)*(5,0 / 1023,0);                            
        char sensor2 = sensor;
        dataString += String(sensor2);                               
        if (analogPin < 2){                                           
        dataString += ",";                                          
        }
      }
 
      myfile.println(sensor);    
      myfile.close();

I am very thank fully if somebody could help me.

Thanks !!!
Pages: [1]