|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Calibration/Zeroing of Joystick
We are trying to use a different joystick then what came in the kit. Its center is not at (127, 127). We need a way to center. Right now, we have a button that is not on the joystick wired up so that we can press it and it will then be calibrated. We don't have the code to do this. Our code right now will add a constant (either pos. or neg) to the joystick values which would then in theory have the joystick centered. The problem comes in getting that constant. How can we keep a constant wth the looped structure of the FRC code? We have tried putting it in User_Initialization and also at the spot that where the inputs are mapped to the drive PWMs. Any help would be appreciated.
archimedes, Wyoming Aftershock |
|
#2
|
|||
|
|||
|
Re: Calibration/Zeroing of Joystick
If you button is NOT coded, that isnt too bad. Just dont touch the joystick and let it center itself and push the button. Code would be something like:
if (switchname) { consty=p1_y-127; constx=p1_x-127; } and then modify the drive code so it takes pwmxx= LimitMix((p1_y-consty)+(p1_x-constx)-127); Good Luck |
|
#3
|
|||
|
|||
|
Re: Calibration/Zeroing of Joystick
That is basicly what I have already programmed in. The problem is keeping that constant throughout the loop or getting it assigned. When I put code like that in our program, the offset, constatn, whatever you want to call it, is not right and it doesn't work. Where do we define our variables and assign to them so that they are trully global?
archimedes |
|
#4
|
|||
|
|||
|
Re: Calibration/Zeroing of Joystick
Just thought of something else.
What you can do is take out your offset code (and unplug any motor PWM cables!) and map p1_y and p1_x (or whatever) to individual PWM(1-16). Then open up IFI Dashboard and see how far off you are, and just code the number into your initialization at the top of user_routines.c so you could just have char xoffset= 7 or whatever it is, just make sure in your pwm mixing code you add or subtract accordingly. Also, if you post code, I or somebody else can look at it and see if there is anything throwing you off. I also recommend programming deadbands so that your joystick doesnt output anything but 127 for the first few values of x and y. Oh yea, there is also a thing you can do to calibrate your speed controllers to your joystick. I am not sure how to do this, but I know there is a post on it. This may fix your centering problems, and should give you full range on your stick instead of the (most likely) shortened range that it would have otherwise Good luck |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Tri-axis Analog Joystick | KVermilion | Control System | 5 | 19-01-2005 00:24 |
| Changing 1 joystick code to 2 (rookie team) | Brawler006 | Programming | 5 | 20-02-2004 17:00 |
| robot goes haywire with the one joystick default code | Miles | Programming | 7 | 24-01-2003 14:58 |
| joystick problem | archiver | 2000 | 12 | 23-06-2002 23:08 |
| switching joystick axis????? | team222badbrad | Technical Discussion | 9 | 16-01-2002 23:07 |