![]() |
Joystick filtering gone horribly wrong...help!
Hey all,
I was asked to make the robot have a curved response in the drive motors, i.e. pushing the joysticks halfway gets you about quarter speed, but pushing them full gets you full speed. I was advised that this will make the drivers' jobs easier. However, it seems to be making my job more complicated...:p I have a basic lookup table solution in place right now...but it doesn't work. Ideally, I want to be able to input a number of points on the curve (right now, I have 7) and have the code extrapolate the points in between. I would be able to tweak this curve, adjust the constants in code, recompile, and blast the code down again to have filtered joysticks. Now, at this point in time, I am getting strange results. The code I have is trying to set outputs to values like 360-something or greater, and I can't figure out why (I know it's out of range. I know PWMs only go up to 254...). I am seeing this code get more and more complex, and I need some help implementing KISS in this situation. Here's the code I've got right now: Code:
unsigned char DRV_GetFilteredValue(unsigned char joystick)You don't even have to look at that code. I just need something that I can put in place to filter the joysticks. Thanks in advance for any help you can provide. And I'm willing to throw out the code I've got; I just need *something* to work. JBot |
Re: Joystick filtering gone horribly wrong...help!
Code:
} else if (temp_joystick < 0) {That's one of a few issues. I'm coding up an integer version right now. You need to have a power of two number of line points. They are assumed to be evenly spaced between 0 and 255. Code:
#define BITS_FOR_LOOKUP 3 // we're using the most significant 3 bits of the joystick value |
Re: Joystick filtering gone horribly wrong...help!
Your actually making it more complicated then you need to with a lookup table. Using a squaring function and some if statements you can get the curved response you want. Here's the code I used on our robot this year.
Code:
int linput; |
Re: Joystick filtering gone horribly wrong...help!
Quote:
Thanks for your help; I will try this. JBot BTW, dpick, nice sig. You should get yourself a disable switch, though; you can react fast enough to kill the 'bot if bad things happen...;-) |
Re: Joystick filtering gone horribly wrong...help!
Thanks for the advice : ) We actually have one I just can't find it in the giant box of electrical stuff.
|
Re: Joystick filtering gone horribly wrong...help!
http://www.chiefdelphi.com/forums/showpost.php?p=547561&postcount=9 And, as an example of the 255 value tables I talked about, here is the 255 value table currently on our robot.
Code:
rom const unsigned char expotable[255] = |
Re: Joystick filtering gone horribly wrong...help!
This is what Team 11 Came up with to put a curve on the joysticks..
Code:
int ramp_joystick(int value) |
Re: Joystick filtering gone horribly wrong...help!
Quote:
Cool stuff. Jacob |
Re: Joystick filtering gone horribly wrong...help!
We use excel. We use 3 points 0 127 to define one curve, and 3 points above 127 to define the 127 - 255 curve. Then you graph those points and have excel do a trendline and give you the equation.
Now you can just change your 3 datapoint values around and the trendline graph will automatically give you the new equation. You can either type the equation into excel and have it give you the values for a lookupt table (it becomes a simple copy/paste) or you can multiply the equation by 10, 100, or 1000 to remove the floats and simply use the equations with integer math in your program. Once you have the excel spreadsheet set up, it takes about 30 seconds to change the curves then update your program. |
| All times are GMT -5. The time now is 09:08. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi