Ok new FIRST programmer here…where are we allowed to insert code. For example, we want to change the sensitivity of our joy stick drive by using an array (we think). Does this go in user_routines.c ? and if so, does it matter where?
You put your actual code to drive the robot in user_routines.c, in the Default_Routine function. Using some math functions you should be able to change the sensitivity of the joystick.
Yeah, what he said. You are going to want to study it some because the default code uses somthing called limit mix at least for the one joystick drive. I forget what it does but I think it had something to do with making sure that your pwm values did not exceed 255 or go below 0. Or something.
Files that you aren’t supposed to modify are clearly labeled in the comments at the top of said files. The most common places of adding code are in user_routines.c (usually for driver code), and user_routines_fast.c (for autonomous, and processing interrupts and the like). In these files, you will find a comment to the effect of:
/*Add your code here.*/
If you put your code there, you are much more likely to get the results you expect.
What the limit mix functions do is take the values of the x and y axis of the joystick, and convert them to the numbers that you would want the motors to do. It’s just a little bit of math.
Yep… using a math formula is a much better idea than using a lookup table, which would be horribly inefficient with the limited resources we have. See this post for one example.
Thanks everyone! Yeah I put in an array table but thinking about using a log formula instead. I keep getting an error when building -
MPLINK 3.90 Linker
Error - section ’ .idata_user_routines.o’ can not fit the section. Section ’ .idata_user_routines.o’ length=0x0000020c
Errors :1
if your array table does not change you could dosomething like:
rom const char myArray[2] = {1, 2};
the problem is you don’t have enough memory in RAM for whatever array you have.
note: ya can’t change it if its rom
and another: go to http://www.chiefdelphi.com/forums/showthread.php?t=33359 for more info
I disagree.
Depends on how complex the math is I guess, but using ROM to store your loo up table yields pretty fast results.