How to stop and save data on arduino board

I have an accelerometer and I want to save the data collected by the accelerometer in my arduino board.

also have my arduino board stop collecting data after some time.

How much data?

Maybe the EEPROM would do the job.

im just running the accelerometer and I want to save the data in maybe excel and graph x y and z versus time. I have downloaded PLX-DAQ. i was thinking of saving it on flash? where can i find codes to do that?

here is the website. http://www.parallax.com/ProductInfo/Microcontrollers/PLXDAQDataAcquisitiontool/tabid/393/Default.aspx

[u]How much data[/u]?

Flash is program memory - difficult to use from a running progam without re-writing the bootloader.

If you are sending data over the serial port to a PC running Excel, why do you need to save it, too?

beacuse I need to save the results and the graph for analysis I am trying to measure the direction, velocity, and distance traveled.

Flash is program memory - difficult to use from a running progam without re-writing the bootloader.

What does the bootloader have to do with this?

Don

Can't you save it in Excel, if you are sending the data to excel?

You could use an SD card, if you want to save the data on the Arduino.

I am a noobie and I found a code to send data to excel and then graph the data. my accelerometer keeps on collecting data, how can I make it stop collecting after some time?

my computer is not finding a program to open the example XL test for the gobetwino program.

this is what I have so far

int CS_pin = 9; //Chip select input; active low
int CLK_pin = 10; // Clock input
int DIO_pin = 11; // Data to/from the modual

int aX = 0;
int aY = 0;
int aZ = 0;

//// FUNCTIONS
void StartBit() { //declaring a function, funtion follows;
pinMode(DIO_pin, OUTPUT); //sets DIO_pin as output
digitalWrite(CS_pin, LOW); //sets CS_pin off
digitalWrite(CLK_pin, LOW); //Sets CLS-pin off
delayMicroseconds(1); //delay for 1 microsecond
digitalWrite(DIO_pin, HIGH); //Dio_pin On
digitalWrite(CLK_pin, HIGH); //CLK-pin on
delayMicroseconds(1); //delay for 1 microsecond

}

void ShiftOutNibble(byte DataOutNibble)
{
for(int i = 3; i >= 0; i–) //Loop, starts at 3, if it is greater than O then it subtracts 1 and starts the same loop over, if it is less than ) then goes to next step.
{
digitalWrite(CLK_pin, LOW); //CLK_pin off
// set DIO first
if ((DataOutNibble & (1 << i)) == (1 << i)) { // DataOutNibble AND 1 x 2^i Equals 1 x 2^i ?
digitalWrite(DIO_pin, HIGH);
}
else {
digitalWrite(DIO_pin, LOW);
}
// with CLK rising edge the chip reads the DIO from arduino in
digitalWrite(CLK_pin, HIGH);
// data rate is f_clk 2.0 Mhz → 0,5 micro seeconds
delayMicroseconds(1); // :slight_smile: just nothing
}
}

void SampleIt() {
digitalWrite(CLK_pin, LOW);
delayMicroseconds(1);
digitalWrite(CLK_pin, HIGH);
delayMicroseconds(1);

pinMode(DIO_pin, INPUT);
digitalWrite(CLK_pin, LOW);
delayMicroseconds(1);
digitalWrite(CLK_pin, HIGH);
if (digitalRead(DIO_pin)== LOW) {
// Blink LED because ok
}
}

byte ShiftInNibble() {
byte resultNibble;
resultNibble = 0;

for(int i = 3 ; i >= 0; i–) { // from bit 3 to 0
// The chip Shift out results on falling CLK
digitalWrite(CLK_pin, LOW);
delayMicroseconds(1); // :slight_smile: just nothing
if( digitalRead(DIO_pin) == HIGH) { // BIT set or not?
resultNibble += 1 << i; // Store 1 x 2^i in our ResultNibble
}
else {
resultNibble += 0 << i; // YES this is alway 0, just for symetry :wink:
}
digitalWrite(CLK_pin, HIGH);
//delayMicroseconds(1); // :slight_smile: just nothing
}
return resultNibble;
}

void EndBit() {
digitalWrite(CS_pin, HIGH);
digitalWrite(CLK_pin, HIGH);
}

int GetValue(byte Command) { // x = B1000, y = B1001, z = B1010
int Result = 0;
StartBit();
ShiftOutNibble(Command);
SampleIt();
Result = 2048 - ((ShiftInNibble() << 8) + (ShiftInNibble() << 4) + ShiftInNibble());
EndBit();

return Result;
}

//// SETUP
void setup() {
Serial.begin(115200);
pinMode(CS_pin, OUTPUT);
pinMode(CLK_pin, OUTPUT);
pinMode(DIO_pin, OUTPUT);
// initialize device & reset
digitalWrite(CS_pin,LOW);
digitalWrite(CLK_pin,LOW);
delayMicroseconds(1);
digitalWrite(CS_pin, HIGH);
digitalWrite(CLK_pin,HIGH);
}

//// LOOP
void loop() {

aX = GetValue(B1000);
aY = GetValue(B1001);
aZ = GetValue(B1010);

Serial.print(aX);
Serial.print(" “);
Serial.print(aY);
Serial.print(” “);
Serial.print(aZ);
Serial.println(”");
delay(1000); // loop every 100 times per sec.
}

my accelerometer keeps on collecting data, how can I make it stop collecting after some time?

The accelerometer does not collect data. It outputs data. The Arduino collects it, and sends it to the serial port.

If the Arduino were to stop sending the data to the serial port, which it could do after any amount of time, what should it do, instead? When would you want it to resume sending data, if ever?

I am just trying to have it send data to excel and graph X(t), Y(t), and z(t). I have been trying to figure out how to use gobetwino to help me do that but because I am new to programing Iam having trouble finding how to do it.

Hi Katerina.

Maybe i can help with GoBetwino.

Important stuff with GoBetwino is:

1) Configure serial port in the settings menu, make sure you are using the correct serial port, and the same Baud rate as setup in your Arduino code.

2) Do not use GoBetwino and the Arduino IDE serial monitor at the same time, this won't work.

3) Read the "How to use sample code" document. It explains how to use the XL sample. Try to get this code to work first, this will give you a good starting point for using GoBetwino with your own project.

4) Feel free to ask any questions in this thread, i will follw it.

EDIT: When sending data to Excel from Arduino, with GoBetwino try not to send data too fast / frequently, GoBewtino and Excel needs a little time to handle the data.

Flash is program memory - difficult to use from a running progam without re-writing the bootloader.
What does the bootloader have to do with this?

Only code executing from the boot loader section of memory can write to program memory (including itself), so although it is possible to self-modify program memory, you’d have to write your own code into the area currently occupied by the boot loader to allow yourself to do this.

Again, if you have to ask the question, you’re probably nowhere near ready to do it yourself.

Note, however, that flash memory has a poorer erase/write cycle spec than the EEPROM, only 10 000 cycles guaranteed.