Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Tweaking constants: any good way? (http://www.chiefdelphi.com/forums/showthread.php?t=27617)

wun 07-04-2004 22:40

Tweaking constants: any good way?
 
This year I was told that we would need some code to ramp up the speed, so if the driver jams the sticks forward or backward, the robot wont flip (as we are really top heavy). The actual code was easy, but what made it take forever was the tweaking.
Every time I would want to make a change, I would have to first change the #define statement, compile the code, then download the code.
Am I just ignorant, and there is an easy way to tweak constants in the code without having to compile/download it each time? (I know you cant change values of #define statements with out re-compiling... but you know what I mean).
The best thing I could think of was change the #define statements to variables, then assigning a button to increase/decrease them, but I never got around to coding it.

10intheCrunch 07-04-2004 22:44

Re: Tweaking constants: any good way?
 
That's pretty much all you can do. For more flexibility, maybe, you could use a steady analog input like the joystick wheel, or use buttons to switch between different constants that you want to test. Compile + download isn't *that* long, even if you have a bad computer. I would recommend, though, if you do have a slow comp, that you put the numbers into variables in the .c file instead of define's in the .h file, as changing a .h makes the MPLab recompile everything (otherwise f10 just recompiles files you have changed).

Bduggan04 07-04-2004 22:46

Re: Tweaking constants: any good way?
 
If you have one of the old joysticks, use one of the analog wheels as an input for the constant. You can adjust it so that its domain is less than 255. Use a dashboard to view the value of that wheel and change it permanently in the code. We use this to determine the position of our servos and pots for servo emulation.

wun 07-04-2004 22:51

Re: Tweaking constants: any good way?
 
Quote:

Originally Posted by 10intheCrunch
I would recommend, though, if you do have a slow comp, that you put the numbers into variables in the .c file instead of define's in the .h file, as changing a .h makes the MPLab recompile everything (otherwise f10 just recompiles files you have changed).

I am on a slow computer, but im also using gnu make with a custom makefile, so it never compiles more than it needs to.
I think I will get one of the grade 9ns who I am teaching to program to write something that uses the wheel...

10intheCrunch 07-04-2004 22:53

Re: Tweaking constants: any good way?
 
Would be pretty easy to do, just divide the wheel value by something decently large, or enough parts to test as many constants as you want, and run a switch statement on that number (or just plug it in to your variable) for testing. Use the program port + console window or the dashboard port for output.

Dave Scheck 08-04-2004 10:44

Re: Tweaking constants: any good way?
 
If you have two spare buttons (or two buttons that aren't needed to drive), map them so that one increments your parameter and the other decrements it. You could send that value to the OI through the user bytes so that you know what value you're using.

Be careful to put upper and lower bounds on the parameter so that you don't go from a value of 0 to 255 when decremented.


All times are GMT -5. The time now is 13:26.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi