Graphing Variables in RobotC

My team’s programmers have been working with jpearman’s TBH code (thanks for that code, Mr. Pearman), and we would like to create a graph displaying the rotational velocity of the flywheel motors in ticks/20 ms cycle. We use RobotC. Does anyone know how to do this?

You can print values to the debug stream like this:


int velocity; //variable to store velocity of flywheel
clearDebugStream(); //clears debug stream at beginning of the program

while(true)
{
    //do stuff to run flywheels
    velocity = 100; //just an example, you'd need to calculate the velocity yourself
    writeDebugStreamLine("Velocity: %f", velocity);
    wait1Msec(20);
}

The %f just determines how to format the value you give the function and tells the function to replace “%f” with whatever value you give it. Once the program is running, it will start writing values to the debug stream, which you can view if you go to ROBOT > DEBUGGER WINDOWS > DEBUG STREAM.

Then you can copy those values and paste them into your favorite spreadsheet/graphing program. If you formatted things nicely like I like to do (each line will say “Velocity: 100”), then you can use find and replace to get rid of the "Velocity: ". Hope you find this helpful.

One way you could do this is to write the data to the debug screen debugger window and then export that data to excel…

I was going to write an example, but you beat me to it @Bpalms! :smiley:

Hahaha. At least with the new forum update it pops up while you’re writing the post, right? That way you don’t waste time writing a post which has already been written.

Yeah, I have written at least a few examples only to post them seconds after someone else :stuck_out_tongue:

Thanks for the help, everybody. I definitely like the new look of this forum, and the new features like updating while writing posts and saving drafts.

One thing I found extremely useful for live tuning PID was the BNS bluetooth library and a 9$ hc05. I could live print and graph any variables to my phone. Obviously illegal for competition but extremely useful for debugging and tuning. Example below of me tuning drive straight PID and stay pointing straight. The second one looks really poor but that is just because it is zoomed in so much. It never drifted more than 2 or 3 degrees from desired angle.