View unanswered posts | View active topics It is currently Wed Sep 23, 2020 3:53 pm






Reply to topic  [ 2 posts ] 
how to AddToDatalog() negative int 
Author Message
Rookie

Joined: Sun Mar 22, 2009 5:19 am
Posts: 6
Post how to AddToDatalog() negative int
I suffer with AddToDatalog () with logging negative Int values.

When trying to store float multiplied by 100 with code:

float Angle;
Angle = SensorRaw[gyro] - offset;
AddToDatalog(1, 100 * Angle);


I get the result of type:
...
129, 48
129, 14
129, 14
129, 0
129, 0
129, 65526
129, 65526
129, 65513
129, 65513
129, 65502
129, 65502
129, 65495
129, 65495
129, 65496

...

Where the Red marked values are for negative angle values ...

I tried using:

Int16 signedInt = (Int16)UInt16.Parse(dataPointValue);

but nothing helps...

best regards,
Maciej


Fri Feb 05, 2010 4:03 pm
Profile
Rookie

Joined: Sun Dec 27, 2009 2:58 pm
Posts: 6
Post Re: how to AddToDatalog() negative int
sekai,

RobotC will never record your negative values with the "-" sign. So before you can process to values in the data log, you have to convert them to a signed 16 bit integer. The code you presented is written in C# and if you're doing your processing in C# then that will handle it for you. If you're not processing your data with C# and are using a spreadsheet application or something else, you'll need to refer to the documentation on how to do explicit casts.

That being said, I think I can solve your problem. I've written an application that will convert the datalog values to negative numbers for you, as well as transpose the vertical data set into columns representing each data point. So if you record 3 data points per loop, my application will give you three columns so that you can properly graph the data in a spreadsheet application. The application will look for CSV files in the same directory it is ran from and ask you how many rows you'll be transposing. So given the above example, you would type 3 when prompted. This will transpose the data in the CSV file and append the word "Transposed" to the end of the filename (so it won't be processed again).

Please let me know if this solves your issue.

P.S. You'll need the .NET Framework 3.5 SP1 installed to use the application.


Attachments:
File comment: Transposer
Transposer.zip [3.27 KiB]
Downloaded 361 times
Sat Feb 13, 2010 3:48 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 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.