View unanswered posts | View active topics It is currently Wed Jul 30, 2014 9:32 am






Reply to topic  [ 8 posts ] 
Novice datalogging questions 
Author Message
Novice

Joined: Thu Apr 17, 2008 6:04 am
Posts: 70
Location: Plymouth, Indiana, USA
Post Novice datalogging questions
Hello, I'm a novice so don't get too technical on me. :D
Using RobotC for NXT.
I've been trying to learn about data logging and have a few questions.
1) The sample data logging program (NXT Datalog Test) had a couple of lines that I've been able to delete with seemingly no effects. They are:
#pragma platform(NXT)
const int kDatalogSize = 2000; (When I delete this I also put a value where ever kDatalogSize was before).

Are these lines not needed at all or is deleting them creating unseen problems? Also what does "const" stand for?

2) The variables listed in the datalogging window are BAD63(3), BAD63(4), .... Is this normal or is something "bad"? Why doesn't the variable name match the one from the program?

3) What does "AddtoDatalogEnhaced" do and what's the format for using it? It pops up when typing commands but I can not find any documentation on it.

4) How can I datalog more than one variable at a time? For example: Say I have variables x, y, and z that are changing with each run through a loop. How can I datalog those values? Is my only choice doing an "AddtoDatalog" in sequence and then sort them out in a spreadsheet to get it into columns?

Thanks for any answers,

Dad (Dave) and Adam

_________________
Dad (Dave) and Adam


Last edited by Dad and Adam on Wed Jun 04, 2008 5:12 am, edited 1 time in total.



Sat May 31, 2008 7:58 am
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post 
THe advantage of using the datalog over logging to a NXT flash file is that the datalog points are stored in RAM. Whenever a "sector" (256 bytes) is writtent to flash the NXT CPU is stalled for the 3 to 6 milliseconds it takes to erase and write the flash.

ROBOTC runs on many platforms / CPUs. They don't all support the data log capabilities. The "#pragam platform(NXT)" tells the compiler that a program is written for the NXT platform. If you inadvertently tried to use it on a different platform you'd get a compiler error message. If all you have is the NXT, then you can safely remove this from your program.

"const int kDatalogSize = 2000;" defines a "constant" variable. Constant variables can only be read and not written. If they are scalar variables (i.e. not an array and not a structure) then they do not require RAM memory, it's the same as using a numeric constant in your program. Defining a "const int" variable generally helps in "documenting" your program.

Similarly you may want to use "const tMotors leftMotor = motorA;" in your program rather than using the generic value of "motorA". "leftMotor" is a more meaningful / understandable term. Assuming, of course, that this is the left motor on your robot. :D


Wed Jun 04, 2008 4:55 am
Profile
Novice

Joined: Thu Apr 17, 2008 6:04 am
Posts: 70
Location: Plymouth, Indiana, USA
Post Re: Novice datalogging questions
Dad and Adam wrote:
2) The variables listed in the datalogging window are BAD63(3), BAD63(4), .... Is this normal or is something "bad"? Why doesn't the variable name match the one from the program?

3) What does "AddtoDatalogEnhaced" do and what's the format for using it? It pops up when typing commands but I can not find any documentation on it.

4) How can I datalog more than one variable at a time? For example: Say I have variables x, y, and z that are changing with each run through a loop. How can I datalog those values? Is my only choice doing an "AddtoDatalog" in sequence and then sort them out in a spreadsheet to get it into columns?

Dad (Dave) and Adam


Thanks for the reply Dick. That answers my first question very well.

Does anyone have any feedback on any of the other three questions?

Thanks again,
Dad and Adam

_________________
Dad (Dave) and Adam


Wed Jun 04, 2008 5:12 am
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post 
The ROBOTC firmware is also used by the ROBOLAB programming environment. For legacy reasons the datalogigng support is backwards compatible with it. This is the root cause of the "BAD63" display.

Datalog entries are three bytes. One byte identifies the "source" of the datapoint and two bytes contain the value. The original (i.e. years ago) ROBOLAB system only had space for 32 variables. So the "source" byte was divided into a 3-bit and 5-bit field. the 3-bit field indicated the type of source (user variable, sensor variable, timer, constant, motor power level, ...) and the 5-bit field (i.e. 0 to 31) the "index" for that source.

One byte is not enough to unique address the source. It takes three bytes -- one for the source type and two bytes for index. The "BAD63" code is coming from a datalog entry that simply couldn't be comrpessed into the one byte field.

For now, the quick fix to log multiple data points is to ensure that the variables you are logging fit in the 1-byte format. You can achieve this by declaring these variables at the beginning of your program as memory allocation for global variable starts with the variables declared first. Then the display in the datalog will look like "Gnn" where "G" indicates a global variable and "nn" is the address of the global -- sorry it does not automatically convert these to the actual variable name declared in your program.

In the future I will add a new "addToDatalog" function that will allow you to explicitly set the value of the first byte of the entry rather than have it automatically created from the variable address. This will achieve what you desire.

You can datalog multiple points as follows:

int nDataSet1; // Put declaration at front of program
int dDataSet2; // Use whatever variable name you want
int nDataSet3;

. . .
// Within your program, use the following

addToDatalog(nDataSet1);
...
addToDatalog(nDataSet2);
...
etc


Wed Jun 04, 2008 5:41 am
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post 
Regarding multiple columns for data sets. Right now there is just one column of data. I will look into an alternative format that uses multiple colums for data sets.

However, it is not scheduled aor committed. So, sometime in the fall at best.


Wed Jun 04, 2008 12:14 pm
Profile
Novice

Joined: Thu Apr 17, 2008 6:04 am
Posts: 70
Location: Plymouth, Indiana, USA
Post 
I finally got some time to play with this. I was able to get two variables datalogged with each run through a loop but I had some difficultly. I had to add a 10 milisec wait between each "AddToDatalog". If I didn't have the wait the program would hang itself after about a dozen loops. Sometimes the motors would go crazy, sometimes they would just stop. The Stop bottom (on the brick or RobotC screen) would not work once it was hung. Removing the batteries seemed to be the only way to clear it.
Once I added the slight wait between the AddToDatalogs everything was back to working fine. The wait may be able to be shorter, 10 millisec was just the first thing I tried.
Below is some of the code. The datalogged variables Xpos and Ypos are only used for datalogging and not not used anywhere else in the program.
task main()
{
int Xpos;
int Ypos;

Some code that loops while running two motors

Xpos = 35 + xcount;
Ypos = 10 + ycount;
AddToDatalog(Xpos);
wait1Msec(10);
AddToDatalog(Ypos);


Is adding a delay typical when datalogging more than one variable?
I tried a practice program that was just a loop (no motors) that datalogged three variables and it worked fine without needing a delay between the AddToDatalogs.

Also the datalogging window still lists the variables as "Bad63(index number)" They will be easy to sort in Excel due to the index numbers. Any idea why I didn,t get the expected G(index number) format?

Thanks for adding to my understanding,
Dad and Adam

_________________
Dad (Dave) and Adam


Sat Jun 07, 2008 8:10 am
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post 
You should not have to add the wait.

Send me your coimplete source code file (to dickswan@sbcglobal.net) and I will debug the error.

I'll also look at the display indicator for "BAD" as well.


Sat Jun 07, 2008 9:38 am
Profile
Novice

Joined: Thu Apr 17, 2008 6:04 am
Posts: 70
Location: Plymouth, Indiana, USA
Post 
My code ran fine for Dick on version 1.38 without needing the delays between AddToDatalogs.
He returned the code to me after making some nice improvments. I was using version 1.10. The improved code still had the same problems when ran with 1.10 (locking up and listing "Bad63" as the datalogged variable name). I updated to version 1.38 Beta and both problems went away
(No locking up and Datalogged variables are now listed as Gnn).

Thanks Dick,

Dad (Dave) and Adam

_________________
Dad (Dave) and Adam


Sun Jun 08, 2008 4:33 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.