using easyC to give more control to the joysticks

I have two ideas:

  1. make the input and output relationship a cubic function - no clue how to do that tho i would prefer a look up table to save processing power…

  2. use a divide function when a button is held down to give control - i am confused since 127 would not be 127 and things could go wrong…i don’t know how to spread out the limited output over the whole joystick axis with 127 still being 127…

P.S. If you could leave your email, so that I could ask some more newbie question…that would be much appreciated :smiley:

I apologize in advance because my knowledge of EasyC functions is limited. In both cases I think you should use the FourWheelDrive() or TwoWheelDrive() functions (depending on what you are using). The you can use the Drive(int speed, int direction) function to control the robot. Keep in mind that Drive how drive works

one way to create a lookup table is to declare the table:

rom const char lookup[256] = { 0th char, ..., 255th char};

then in your Drive function:

Drive(lookup[y-axis of joystick], lookup[x-axis of joystick]);

Normal C is centered around 127, so you would have to calculate an offset to bring it back to 127 center. For example: 127/2 = 63, 127 -63 = 64, so: (new joy axis)= (old joy axis)/2 +64;

However since EasyC’s Drive is centered around 0, you can just:

Drive((y-axis of joystick-127)/(factor), (x-axis of joystick-127)/(factor));

And enclose it in a if (button pressed) statement.

I hope this helps. There may be a few minor difficulties with EasyC. I am trying to learn EasyC this year for Team 1495, but I don’t have my own license. I’ll PM you an email address.

1075 has implemented a cubic function based drive for several years. Well, not so much cubic as sticking the positive and negative quadratic functions together, but you get the idea.

Well, I’ve pasting this everywhere, so it might as well be here as well:

long ramping (unsigned char ramp)
{
    long answer = 0;
    answer =  ((long)ramp - 127);
    answer = ((answer) * (answer) * (answer));
    answer = ((answer) / (128 * 128));
    answer = (answer) + (127);
    return answer;
}

However, you don’t need to subtract 127 and then add it again unless your drive is centered around 127. Here’s a graph of joystick input versus PWM value. Is that what you intended?

http://www.chiefdelphi.com/forums/attachment.php?attachmentid=6109&d=1201127844

And in previous years we have used a ‘half inputs’ button. Just subtract 127 before halving and add it back later. (Assuming neutral is 127) It works fairly well when you need precision, but no one ever remebered to use it. Maybe with decent driver training.

Well, I’ve pasting this everywhere, so it might as well be here as well:

Code:

long ramping (unsigned char ramp)
{
long answer = 0;
answer = ((long)ramp - 127);
answer = ((answer) * (answer) * (answer));
answer = ((answer) / (128 * 128));
answer = (answer) + (127);
return answer;
}

However, you don’t need to subtract 127 and then add it again unless your drive is centered around 127. Here’s a graph of joystick input versus PWM value. Is that what you intended?

http://www.chiefdelphi.com/forums/at...9&d=1201127844

And in previous years we have used a ‘half inputs’ button. Just subtract 127 before halving and add it back later. (Assuming neutral is 127) It works fairly well when you need precision, but no one ever remebered to use it. Maybe with decent driver training.

so “ramping” and “answer” are variables along with “ramp”?
I don’t get "long ramping (unsigned char ramp)
Also if i typed the code u posted into easyC along with some other blocks, will it work?
Thanks

Alright, I guess EasyC doesn’t use function syntax like that. Sorry, I’m really not familiar with it.

In the code given, only ‘answer’ and ‘ramp’ are variables. The function’s name is ‘ramping.’ When you call ramping(ramp) where var is an unsigned char, it returns the long ‘answer.’ This would be how to use it in any code, I guess:

answer = ((long)ramp - 127);
answer = ((answer) * (answer) * (answer));
answer = ((answer) / (128 * 128));
answer = (answer) + (127);

Just make sure to change ‘answer’ to whatever variable name you are using for your joystick(s) in values. Just use this on all of your joystick inputs before assigning the PWMs. That should work, maybe somebody more knowledgable in EasyC could help you better.