Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Desensitizing Joysticks (http://www.chiefdelphi.com/forums/showthread.php?t=24613)

deltacoder1020 01-02-2004 13:03

Re: Desensitizing Joysticks
 
Quote:

Originally Posted by KevinB
Looking back at my statement reminds me of why coding at midnight is bad. :D

hey, look at the post time on my reply ;)

WillyC 01-02-2004 13:07

Re: Desensitizing Joysticks
 
Quote:

Originally Posted by deltacoder1020
hey, look at the post time on my reply ;)

My most productive coding hours are between midnight and 3am, and I can't explain why....yawn....why I'm so tired today... :yikes:

thoughtful 01-02-2004 13:21

Re: Desensitizing Joysticks
 
That is very helpful file.

What i was thinking is, have a max change function in real-time like you mentioned.

Basically you jus need a variable that holds the current joystick input. For example if your joystick was at 135 and you pushed it to 250 all of a sudden, You can check you current motor output which was 135 and then current joystick input which is 250, now you keep adding a certain number lets say 10 to the motor output untill it reaches 250.

This is one way to do it, the other way is to subtract 250-135, you get 115 devide it by a number lets say 10 so you get 11.5 , now ur max change is 11.5 , add that 10 times to your motor output or until it reaches desired position, this way you will have variable max change function.

Joe Ross 01-02-2004 14:02

Re: Desensitizing Joysticks
 
Quote:

Originally Posted by KenWittlief
I dont understand how putting a deadband around 127 will make the joystick less sensitive

in fact, your bot is going to lurch when the joystick is moved just outside the deadband

But, your robot doesn't move when you give it a small value, because of friction and other factors. In '99 we did some tests with our robot, and you had to give it something to the effect of 145 to get it to move from a stop. So, we programmed in a deadzone from 117-137, and then starting at 138, we scaled the values from 145 to 254.

WillyC 01-02-2004 14:18

Re: Desensitizing Joysticks
 
Quote:

Originally Posted by Joe Ross
But, your robot doesn't move when you give it a small value, because of friction and other factors. In '99 we did some tests with our robot, and you had to give it something to the effect of 145 to get it to move from a stop. So, we programmed in a deadzone from 117-137, and then starting at 138, we scaled the values from 145 to 254.

Ahhh, good point Joe. Note though, that the nonlinear function I gave essentially has that deadband built in (very low response to joystick inputs around neutral), but it's a smooth and continous transition to the "on" state, instead of being abrupt. I guess once the bot is built up and you're testing it to see how much motor output is needed to start moving, you could tailor the transfer function a little to get it to "turn on" at that motor output. The smooth nature of the function takes care of the scaling from that point up to the max.


Quote:

Originally Posted by thoughtful
This is one way to do it, the other way is to subtract 250-135, you get 115 devide it by a number lets say 10 so you get 11.5 , now ur max change is 11.5 , add that 10 times to your motor output or until it reaches desired position, this way you will have variable max change function.

This works too. But I think you should be careful about remembering values from loop to loop and using them to calculate motor output. Suppose you're in the middle of changing the motor output as you suggest, but then the driver suddenly moves the stick full the other way. Now your math might suggest that the max change to the motor is huge, and you might get a big drive current spike as the motor responds. If you're going to do this, just be careful about how you write the calculation so that you don't over-juice the motor.

Scooter 02-02-2004 01:30

Re: Desensitizing Joysticks
 
What we use is a exponenetial function. This simply shifts the power curve out some while still retaining full power at the edges. Instead of it being completely linear, it follows a curve (that looks suspiciously like a cubic function). At 50% joystick travel, you may only have 33% motor output, but at 100% joystick travel, you have 100% motor output.

Another technique that I learned from flying R/C Heli's is to grip the joystick at the bottom with just a few fingers....This helps to make movements less extreme....they only downside is that it is a little tuffer to get to the buttons...The advantage is that the movement comes from the fingers instead of the arm and wrists, and it affords you alot more accuracy.

Bill

MichalSkiba 02-02-2004 21:53

Re: Desensitizing Joysticks
 
This is what I came up with during our team's meeting today after school:

/*
pwm is a jostick value, 0-254
pwm_in is the pwm_out of the default code
pwm_out is the new value going to the joysticks
null_zone_swing_fraction is the amount you'd want the joystick to move without the motors kicking in.
*/

pwm_out = (pwm_in / (1-null_zone_swing_fraction)) - null_zone_swing_fraction(1 - null_zone_swing_fraction)

So. Its quite simply a y = mx + b "transfer" function. enjoy.

MichalSkiba 02-02-2004 21:56

Re: Desensitizing Joysticks
 
Exponential Function: simple sin(x) function:

amplitude = 2 * 127 (pwm max)
period = 4 * 127

make sure, as i forgot to in my previous post (above):

pwm = pwm - 127;

That way the origin is the middle of the null zone. makes for nice calculations.

Mark McLeod 03-02-2004 09:13

Re: Desensitizing Joysticks
 
Quote:

Originally Posted by Joe Ross
But, your robot doesn't move when you give it a small value, because of friction and other factors. In '99 we did some tests with our robot, and you had to give it something to the effect of 145 to get it to move from a stop. So, we programmed in a deadzone from 117-137, and then starting at 138, we scaled the values from 145 to 254.

The motors have gained more power since '99.
The new drills introduced last year have almost no delay at low power values.

The deadstick area is still nice, but you also need to scale the output rather than start at 138.

Ryan M. 03-02-2004 09:20

Re: Desensitizing Joysticks
 
You could use low pass filter. I'm at school right now and don't have access to what I've written, but I'll try to post it when I get home.

WillyC 03-02-2004 09:47

Re: Desensitizing Joysticks
 
This is what I love about programming...there are so many different ways to solve the same problem. All of these are nest ideas. Good luck everyone!

Ryan M. 03-02-2004 14:47

Re: Desensitizing Joysticks
 
I've posted the low pass filter on the white pages. It's called low pass filter. (Duh! :))

An example usage:
Code:

...
pwm01 = rampPWM(pwm01, where_we_want_it, 6, 5);
...

Basically, you call this function with what your current speed is, where you want it to be, how fast you want it to get there (higher numbers are faster), and how large you want the dead zone to be (i.e. if the joystick is at 129, you probably want to be at 127. You can set how far from 127 it will be corrected with this param.). It returns what value you should set the PWM to next.

By calling this function multiple times you get a nice gradual increase in output values, so if you move the joystick as fast as you can in circles, very little of that will be picked up. How sensitive it is to input is set by you. The exact equation for finding what to set sensitivity to:
255
-------------- = t
(1000/26.2)*s

t is time in this equation. deterimine what time (in seconds) you think is best for it to be able to go from full reverse to full forward and plug that equation. Solve and use that as your input to the function, ignoring any decimal portion. For instance, if t = 1 sec, then s = 6.

Note that the equation assumes it is being called every 26.2 ms.

Post again if you have any questions about the code or if you'd like to comment on it.

PS I had to re-write it because somebody took my disk that I had that on, so it hasn't been complied. It should be right, though. :)

Chris Hibner 03-02-2004 17:00

Re: Desensitizing Joysticks
 
Beware of low pass filters. We used an LPF on the joystick once and we decided that we didn't like using it. Under acceleration, it's fine, but under stopping, it's not so good. To make the story short, it will cause you to overshoot (because it ramps down your input just like it ramps it up). You can try some funky "if increasing do this, if decreasing do that" logic, but I really don't think it's worth it.

Also, the deadbands that have been described here are discontinuous deadbands, which are generally considered "hack" deadbands in the controls world (due to their abrupt change at the deadzone point). For a continuous deadzone (more commonly used), do this:

DeadZone = 15; // Calibration parameter
if (Joy > (127-DeadZone) && Joy < (127+DeadZone)) Joy = 127;
else if (Joy <= (127-DeadZone)) Joy += DeadZone;
else Joy -= DeadZone;

Ryan M. 03-02-2004 18:25

Re: Desensitizing Joysticks
 
Thanks for the warnings.

bob1million 03-02-2004 20:02

Re: Desensitizing Joysticks
 
Quote:

Originally Posted by WillyC
I've got to agree with Ken on this one. This deadband approach will make the joysticks more sensitive, because the motor output is proportional to the joystick deflection. If you ignore the stick input unless it's greater than 135 or less than 119, then as the stick moves out of the deadband and starts the motor moving, the motor's smallest non-zero speed is even faster than without the deadband. The result will be jerkiness as the bot starts moving.

Ken's solution sounds good, and is obviously more efficient than what I'm about to suggest here. I haven't tried my idea on the bot yet, and I'm a little sketchy about putting a lookup table of any size into the user routine because I don't want to slow it down too much. But here's the principle: make a slightly non-linear lookup table to de-emphasize the stick input near neutral, but not near the max/min. I've attached an example of the kind of curve I'm thinking of. Notice that near 127, it "dumbs down" the stick input to drive the motors slower and make the sticks less sensitive, but near the high or low end of the input it looks almost linear to make the driveability at high speeds feel pretty normal.

Try it out and let me know what you think! Like I said, I haven't tried this on the bot yet...

EDIT: I just changed the .xls to a zipped up .xls.

This works great on our bot, everyone from SWVGS Maximus thanks you.
We used a switch statement and it did not slow down anything. It is a big improvement from what we had. :)


All times are GMT -5. The time now is 05:21.

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