Hi im Joe from team 2170
i am having trouble auto calibrating our robot
can someone please tell me how i would?
Um…
What are you calibrating?
If you mean joysticks…
Plug your OI into a laptop via serial connection (Use the Dashboard port on the OI).
Then, open IFI Dasboard. Make sure your jumper is set to OI DATA (if it’s on RC DATA, move it to OI DATA)
Play with the trims until p1_x, p1_y, p2_x, p2_y… etc are all set (to 127)
If you are talking about joysticks we usually just put the robot up on bricks or the carts so we can see how much we have to calibrate them.
yea i mean joysitcks…but how can i program the robot so when i hit a button it auto calibrates?
I don’t know what you mean. Can you give more detail about what button you are talking about, and what you want to happen when the button is pressed? Please explain it without using the words “auto calibrate”.
Well, if you add code that sets the current value as the neutral (127) value, then you can “autocalibrate”, or at least kinda autocalibrate.
You can write a relatively simple algorithm that keeps watching for higher highs and lower lows and calculates the midpoint (average) value and watches how much displacement there is above and below this midpoint to scale whatever your joystick input is.
However, if you don’t trim the joysticks, you could have a lot of meaningless joystick travel, such as the last 15 degrees of travel all being ‘255’.
-q
I’m not sure if this is what your looking for but you could set it so that when you press the triggers it sets the joysticks to 127. Then instead of messing with the calibration wheels, you would press the triggers and it would set it to 127, 127. I’m not sure exactly how you would go about doing this but it would probably start with an if statement similiar to this
if(trig_sw==1)
I’m sorry if this isn’t that much help. It’s my first year in FIRST and I began programming over the summer
I think i understand what you talking about:
You would need to set a code that would record ans store values given by the joysticks in a sequence:
- you would have to get the manual trim as close as possible then make it so their is no way the manual trim can move.
- your code would need something to trigger the code such as a switch and then have it run so the you have it scan for ranges that could be the max, min, neutral .
-max would be the highest value recorded
-min would be the lowest value recorded
-neutral would probably be what the code would read first when no one is touching the stick.
~now i don’t know alot of code but i know logically it would work but since my team refuses to do it i hope someone out there will finish this.
After thinking about this I think I have your code.
if(trig_sw==1)
x1==127
y1==127
x2==127
y2==127
This should be it. Although you still want to check the variables
x1,x2,y1,y2 are supposed to be the joystick direction.
All this would do is set the joystick values to 127 for execution of the code loop. To have it really calibrate you need to store the offset from 127 into a variable and then have the code add/subtract it each time.
Jamie, I don’t think that’s what he’s talking about. If you did something like that at the beginning of you default routine, then you’d have your joysticks zeroed while you held down the trigger, but you’d never be able to move.
You could do this pretty simply with code along these lines:
//Definitions
signed char p1_x_off = 0;
signed char p1_y_off = 0;
//Code somewheres at the top of your default routine before you use p1_x, etc. for anything useful:
if (p1_top == 1)
{
p1_x_off = 127 - p1_x;
p1_y_off = 127 - p1_y;
}
p1_x = Limit_Mix(2000 + p1_x + p1_x_off);
p1_y = Limit_Mix(2000 + p1_y + p1_y_off);
And then you’d be able to virtually offset your joysticks back to center. Sort of. As QBranch has said, if you actually do this, then the effective range of your joystick is reduced by however wrong you were when you calibrated. for example:
Joystick center starts at:
p1_x = 147
You "calibrate" so:
p1_off = -20
Here, then are some typical joystick values
and how they'd come out in your code:
p1_x 147 127 0 20 254
p1_x + off 127 107 -20 0 234
Limit_Mix'd 127 107 0 0 234
Notice how actual values between 0 and 20 look like 0 to your code. Notice also how your code will now never see anything higher than 234. These sort of limits that come from this “calibration” are why you always see teams fiddling with trim dials as opposed to using code like this. It might be a little more time consuming and troublesome, but it just works better.
I wrote a simple calibration helper using easyC pro using the display on the OI because hooking up the laptop to dashboard between matches gets old fast.
The code is something like: if joy1 >= 230 { SetUserDisplay = joy2; } (and visa versa). Basically, you disable the robot and push the joystick you aren’t calibrating all the way up. The user diplay on the OI then displays the opposite joystick’s value (0-255). Adjust the trim until it gets as close as possible to 127, rinse, repeat with the other joystick, and you’re good to go.
thx for all the help and input…i will try this asap at our Hartford Regional thursday-saturday…