Show Posts
Pages: [1] 2 3
1  Using Arduino / Sensors / Re: Data logger with accelerometer on: March 11, 2014, 10:23:17 am
Thanks for your answer, I`m using the ADXL377 of analog devices, it measures +-200G and I`m using this sketch.
Code:
#include <Wire.h>

#include <I2Cdev.h>

#include <ADS1115.h>

#include <SD.h>


 const int CS = 10;
 int pow_pin = 8;
 File logfile;
 unsigned long time = 0;
 ADS1115 adc;
 ADS1115 adc1(0x49);
 
void error(char *str)
{
  Serial.print("error");
  Serial.println(str);
}

void setup() {
  // open a serial connection
  Wire.begin();
  Serial.begin(38400);
  analogReference(EXTERNAL);
  Serial.println("Iniciando ads1115");
  adc.initialize();
  adc1.initialize();
  Serial.println("Probando coneccion ads");
  Serial.println(adc.testConnection() ? "ADS1115 connection successful" : "ADS1115 connection failed");
  Serial.println(adc1.testConnection() ? "ADS1115b connection successful" : "ADS1115 connection failed");
  Serial.println(" ");
 
  adc.setMode(ADS1115_MODE_CONTINUOUS);
  adc.setGain(ADS1115_PGA_6P144);
  adc.setRate(ADS1115_RATE_860);
 
  adc1.setMode(ADS1115_MODE_CONTINUOUS);
  adc1.setGain(ADS1115_PGA_6P144);
  adc1.setRate(ADS1115_RATE_860);
 
  pinMode(CS, OUTPUT);
  pinMode(pow_pin, OUTPUT);
  digitalWrite(pow_pin, HIGH);
 
  if(!SD.begin(CS))
  {
    Serial.println("Card Failure");
    return;
  }
  Serial.println("card initialized.");
 
  // create a new file
  char filename[] = "LOGGER00.TSV";
  for (uint8_t i = 0; i < 100; i++) {
    filename[6] = i/10 + '0';
    filename[7] = i%10 + '0';
    if (! SD.exists(filename)) {
      // only open a new file if it doesn't exist
      logfile = SD.open(filename, FILE_WRITE);
    }
   
    if (logfile) {
   logfile.print("Tiempo");
   logfile.print("\t");
   logfile.print("X");
   logfile.print("\t");
   logfile.print("Y");
   logfile.print("\t");
   logfile.print("Z");
   logfile.print("\t");
   logfile.print("X1");
   logfile.print("\t");
   logfile.print("Y1");
   logfile.print("\t");
   logfile.println("Z1");
   break;
  }
  }
 
  Serial.print("Logging to: ");
  Serial.println(filename);
}

void loop() {
 
  float zero_G_xcaja = 8473;
  float zero_G_ycaja = 8551;
  float zero_G_zcaja = 8570;
  float scale_xcaja = 35;
  float scale_ycaja = 35;
  float scale_zcaja = 37;
   
  float zero_G_xmov = 8504;
  float zero_G_ymov = 8533;
  float zero_G_zmov = 8508;
  float scale_xmov = 36;
  float scale_ymov = 36;
  float scale_zmov = 36;
 
  // change the resolution to 16 bits and read A0
  time = millis();
  int sensorOneCounts=adc.getConversionP0GND();
  delay(1);
  int sensorTwoCounts=adc.getConversionP1GND();
  delay(1);
  int sensorThreeCounts=adc.getConversionP2GND();
  delay(1); 
  int sensorOne1Counts=adc1.getConversionP0GND();
  delay(1);
  int sensorTwo1Counts=adc1.getConversionP1GND();
  delay(1);
  int sensorThree1Counts=adc1.getConversionP2GND();
 
  Serial.print("x :");
  Serial.print(sensorOneCounts);
  Serial.print("y :");
  Serial.print(sensorTwoCounts);
  Serial.print("z :");
  Serial.print(sensorThreeCounts);
  Serial.print("x1 :");
  Serial.print(sensorOne1Counts);
  Serial.print("y1 :");
  Serial.print(sensorTwo1Counts);
  Serial.print("z1 :");
  Serial.println(sensorThree1Counts);
 
  logfile.print(time);
  logfile.print("\t");
  logfile.print((sensorOneCounts - zero_G_xcaja) / scale_xcaja);
  logfile.print("\t");
  logfile.print((sensorTwoCounts - zero_G_ycaja) / scale_ycaja);
  logfile.print("\t");
  logfile.print((sensorThreeCounts - zero_G_zcaja) / scale_zcaja);
  logfile.print("\t");
  logfile.print((sensorOne1Counts - zero_G_xmov) / scale_xmov);
  logfile.print("\t");
  logfile.print((sensorTwo1Counts - zero_G_ymov) / scale_ymov);
  logfile.print("\t");
  logfile.println((sensorThree1Counts - zero_G_zmov) / scale_zmov);
  logfile.flush();
 
  delay(10);
}
2  Using Arduino / Sensors / Data logger with accelerometer on: March 11, 2014, 09:26:12 am
Hi, I`m working with analog sensors and I wish to know how can I filter my signal in order to get a more accurate readiing.
3  Products / Arduino Due / Re: Arduino Due and Sd shield on: June 14, 2013, 05:40:31 pm
Hi, no luck with that connection and the sketch, doesn anyone have any other idea?
4  Using Arduino / Project Guidance / Re: Datalogger adxl377 on: June 04, 2013, 05:17:27 pm
No, not in this one, but I have tryed after logfile.println(analogRead(A0)); puting thee logfile.close(); and the only result was only one line of data logged.
5  Using Arduino / Project Guidance / Re: Datalogger adxl377 on: June 04, 2013, 11:10:48 am
I have tryed that allready, in the the loop I open the file, write to it and the put the logfile.close(); but it only write one line of data.
6  Using Arduino / Project Guidance / Datalogger adxl377 on: June 03, 2013, 10:03:58 pm
Hey everyone, I`m doing a small datalogger with the adxl377 but when trying to log data to the sd card it`s no good.
Here is the sketch I`m using any sugestions or help are welcome and thanks

Code:
#include <SD.h>


 const int CS = 10;
 File logfile;
 long idd = 0;
 long ids = 0;
 long idm = 0;
 long idh = 0;
 int set = 1;
 
void error(char *str)
{
  Serial.print("error");
  Serial.println(str);
}

void setup() {
  // open a serial connection
  Serial.begin(115200);
  pinMode(CS, OUTPUT);
 
  if(!SD.begin(CS))
  {
    Serial.println("Card Failure");
    return;
  }
  Serial.println("card initialized.");
 
  // create a new file
  char filename[] = "LOGGER00.TSV";
  for (uint8_t i = 0; i < 100; i++) {
    filename[6] = i/10 + '0';
    filename[7] = i%10 + '0';
    if (! SD.exists(filename)) {
      // only open a new file if it doesn't exist
      logfile = SD.open(filename, FILE_WRITE);
    }
   
    if (logfile) {
   logfile.print("Tiempo");
   logfile.print("\t");
   logfile.print("X");
   logfile.print("\t");
   logfile.print("Y");
   logfile.print("\t");
   logfile.println("Z");
   break;
  }
  }
 
  Serial.print("Logging to: ");
  Serial.println(filename);
}

void loop() {
 
  if (set == 1) {
    ids = ids + 1;
  }
 
  if (ids > 59) {
    ids = 0;
    idm = idm + 1;
  }
  if (idm > 59) {
    idm = 0;
    idh = idh + 1;
  }
 
  logfile.print(idh);
  logfile.print(idm);
  logfile.print(ids);
  logfile.print("\t");
  logfile.print(analogRead(A0));
  logfile.print(analogRead(A1));
  logfile.println(analogRead(A2));
 
  // change the resolution to 16 bits and read A0
  Serial.print("x :");
  Serial.print(analogRead(A0));
  Serial.print("y :");
  Serial.print(analogRead(A1));
  Serial.print("z :");
  Serial.println(analogRead(A2));
 
  delay(1000);
}

The Sd card Initialize ok but no datas transfered to it, the sensor works correctly and via the serial monitor I get data but no logging to the sd card
7  Products / Arduino Due / Re: Arduino Due and Sd shield on: May 31, 2013, 11:09:55 am
First of all thanks, and you are saying that I should connect the spi pins directly to the pins in my sd shield avoiding the original connections in the shield?
8  Products / Arduino Due / Arduino Due and Sd shield on: May 30, 2013, 03:33:01 pm
Hi everyone I`m trying to make a simple datalogger but with no successs, I have the arduino due and a sd module I have made the proper conections the following way:

Pin 8 = CS
3.3V = 3.3V Shield
GND = GND Shield
Miso = A25
Mosi = A26
SCK = A27

And I`m running the following sketch but the sd does not work

Code:
#include <SPI.h>

#include <SD.h>
 const int CS = 8;
 File logfile;
 
void error(char *str)
{
  Serial.print("error");
  Serial.println(str);
}

void setup() {
  // open a serial connection
  Serial.begin(115200);
  SPI.begin(8);
  pinMode(CS, OUTPUT);
 
  if(!SD.begin(CS))
  {
    Serial.println("Card Failure");
    return;
  }
  Serial.println("card initialized.");
 
  // create a new file
  char filename[] = "LOGGER00.TSV";
  for (uint8_t i = 0; i < 100; i++) {
    filename[6] = i/10 + '0';
    filename[7] = i%10 + '0';
    if (! SD.exists(filename)) {
      // only open a new file if it doesn't exist
      logfile = SD.open(filename, FILE_WRITE);
    }
  }
 
  if (! logfile) {
    error("couldnt create file");
  }
 
  Serial.print("Logging to: ");
  Serial.println(filename);
}

void loop() {
 
  // change the resolution to 16 bits and read A0
  analogReadResolution(12);
  Serial.print("x :");
  Serial.print(analogRead(A0)); 
  Serial.print("y :");
  Serial.print(analogRead(A1));
  Serial.print("z :");
  Serial.println(analogRead(A2));
 
 
  logfile.print(A0);
  logfile.print(A1);
  logfile.println(A2);
 

  // a little delay to not hog serial monitor
  delay(10);
}

Can anyone help me with this?
9  Using Arduino / Sensors / Re: ADXL377 on: May 22, 2013, 04:13:08 pm
The thing is that this device is going to be inside a racecar, so I don`t know when a peak or an incident is going to happen, all the data collected is going to be writen to a sd card to read it after.
10  Using Arduino / Sensors / Re: ADXL377 on: May 22, 2013, 03:32:04 pm
Here it is

Code:
void setup() {
  // open a serial connection
  Serial.begin(115200);
  analogReadResolution(12); //setea maxima resolucion al adc
}

void loop() {
 
  Serial.print("x :");
  Serial.print(analogRead(A0)); 
  Serial.print("y :");
  Serial.print(analogRead(A1));
  Serial.print("z :");
  Serial.println(analogRead(A2));
 
  delay(10);

  // a little delay to not hog serial monitor

}
11  Using Arduino / Sensors / Re: ADXL377 on: May 22, 2013, 02:44:41 pm
No, just the top peak, with this value and the total mass of the object I can easily get the total force produced on the impact.

I`m doing some math and with 3.3 V my sensitivity is 7.15mV/G so I will put all this in a formula in order to get g results in the serial monitor, I have also set the baudrate higher and set the delay in 10.

Do you have any other sugestion?

I appreciate your help, thanks very much
12  Using Arduino / Sensors / Re: ADXL377 on: May 22, 2013, 01:29:11 pm
First thank you for answering, and what I need to do is register peaks, like in car crash, so thats the reazon I need the sample rate so high, and the using the code I posted I get the following readings

x= 2056
y= 2076
z= 2088

is this ok, in the analog devices page it says that the sensor is set to give 0g at half the mV given to the adxl377 so in this case it would be 4094/2 = 0G right? But doing some math, 1g would be aproximatly 2056, now, my sensor shoul give me in theory this:

x= 2047
y= 2047
z= 2056
I`m right about this or I`m having some error?
13  Using Arduino / Sensors / Re: ADXL377 on: May 22, 2013, 11:57:51 am
It is for measuring peaks, and the software issues are prety much solved I just wanted to know if anyone had anprevious experience with this sr in particular, I`m usingthe following sketch:

Code:
void setup() {
  // open a serial connection
  Serial.begin(9600);
}

void loop() {
 
  // change the resolution to 16 bits and read A0
  analogReadResolution(16);
  Serial.print(", 16-bit : ");
  Serial.print("x :");
  Serial.print(analogRead(A0)); 
  Serial.print("y :");
  Serial.print(analogRead(A1));
  Serial.print("z :");
  Serial.println(analogRead(A2));

  // a little delay to not hog serial monitor
  delay(100);
}

Is there anything I can do here to improve the results?
14  Using Arduino / Sensors / Re: ADXL377 on: May 22, 2013, 10:36:09 am
It is for extreme G readindgs, I expect to get values for 150 G
15  Using Arduino / Sensors / ADXL377 on: May 21, 2013, 08:52:47 pm
Hi everyone, I`m doing a datalogger with the adxl377 accelerometer and the arduino due and I was wondering if anyone have used this sensor, I choosed the Arduino due since it has 12 bits of resolution, so my question is which readingns should I have on the serial monitor, and how can I refine my readings
Pages: [1] 2 3