I am using MPU 6050 to read accelerations. I am getting raw values of accelerations in three directions (x,y,z-axes) and angular velocities through gyro( 3 directions). A total of 6 values i am getting in my serial monitor at a speed of 9600 baud.
I am receiving the data of 100 readings per second. I want the data to be collected for the 20 seconds. It would be messy for me everything to copy paste the data of (201006 = 12000) every time into Excel Sheet.
My present code for this (taken from Jeff Rowberg)
So, i deleted the if loop and now. It works after this is deleted and I am getting the loop stopped. I want to know the meaning of this Millis and the code
if (millis() - start == 20000UL) while(1); // blocking while loop.
millis() is an internal clock in milliseconds since the Arduino started. By taking a timestamp (start) and comparint the current millis() against it I know if 20 secs (=200000 milliseconds) have passed.
The UL takes care that the compiler knows that the number is an unsigned long.
I want the program to be terminated after 20 seconds.
I want the data obtained from serial monitor to come into my excel sheet or matlab. ( avoiding the redundant work of copy paste )
Any other suggestions on this regard
You will not get any output any more after 20 seconds, that was your requirement 1.
You need to restart the sketch if you want more.
And yes it does not exit the loop, it just hangs in an endless while.
while(1); means while(true) do nothing as the ; is an empty statement.
For requirement 2, you should google for GoBetwino, that is a PC application that bridges between Arduino and any PC application. It really works good.
rdrprsdm:
2. I want the data obtained from serial monitor to come into my excel sheet or matlab. ( avoiding the redundant work of copy paste )
I use PLX/DAQ. It is a freebie Excel macro that gives a real-time graph or a direct feed into an Excel .csv file.
Also RealTerm writes comma separated .txt files with local timestamp that can be opened in Excel. I don't know what matlab is but it appears that RealTerm does.