Go to Post The Robot Alliance Project is perpetrating the government shutdown? I KNEW robots would take over the world! - BBray_T1296 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 24-01-2008, 22:40
Neurovirus Neurovirus is offline
Registered User
FRC #0224
 
Join Date: Jan 2008
Location: Piscataway
Posts: 13
Neurovirus is an unknown quantity at this point
Question 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
  #2   Spotlight this post!  
Unread 25-01-2008, 00:16
The Lucas's Avatar
Happy Birthday! The Lucas The Lucas is offline
CaMOElot, it is a silly place
AKA: My First Name is really "The" (or Brian)
FRC #0365 (The Miracle Workerz); FRC#1495 (AGR); FRC#4342 (Demon)
Team Role: Mentor
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Dela-Where?
Posts: 1,564
The Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond repute
Send a message via AIM to The Lucas
Re: using easyC to give more control to the joysticks

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

Quote:
Originally Posted by WPILIB documentation
// Drive functions that are based on motor and direction values ranging from:
// -127 - +127 for full backwards to full forwards
// -127 - +127 for full right to full left turns (see Drive function)
Quote:
Originally Posted by Neurovirus View Post
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...
one way to create a lookup table is to declare the table:
Code:
rom const char lookup[256] = { 0th char, ..., 255th char};
then in your Drive function:
Code:
Drive(lookup[y-axis of joystick], lookup[x-axis of joystick]);
Quote:
Originally Posted by Neurovirus View Post
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...
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:
Code:
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.
__________________
Electrical & Programming Mentor ---Team #365 "The Miracle Workerz"
Programming Mentor ---Team #4342 "Demon Robotics"
Founding Mentor --- Team #1495 Avon Grove High School
2007 CMP Chairman's Award - Thanks to all MOE members (and others) past and present who made it a reality.
Robot Inspector
"I don't think I'm ever more ''aware'' than I am right after I burn my thumb with a soldering iron"

Last edited by The Lucas : 25-01-2008 at 00:19.
  #3   Spotlight this post!  
Unread 25-01-2008, 00:52
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Re: using easyC to give more control to the joysticks

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.
  #4   Spotlight this post!  
Unread 25-01-2008, 15:40
psy_wombats's Avatar
psy_wombats psy_wombats is offline
Registered User
AKA: A. King
FRC #0467 (Duct Tape Bandits)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Shrewsbury MA
Posts: 95
psy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura about
Re: using easyC to give more control to the joysticks

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.

Last edited by psy_wombats : 25-01-2008 at 15:47.
  #5   Spotlight this post!  
Unread 26-01-2008, 18:30
Neurovirus Neurovirus is offline
Registered User
FRC #0224
 
Join Date: Jan 2008
Location: Piscataway
Posts: 13
Neurovirus is an unknown quantity at this point
Re: using easyC to give more control to the joysticks

Quote:
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
  #6   Spotlight this post!  
Unread 26-01-2008, 18:38
psy_wombats's Avatar
psy_wombats psy_wombats is offline
Registered User
AKA: A. King
FRC #0467 (Duct Tape Bandits)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Shrewsbury MA
Posts: 95
psy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura about
Re: using easyC to give more control to the joysticks

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:

Code:
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.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Single Click On/Off Using the Trigger in EasyC IraJason Programming 15 01-06-2007 11:37
Using a computer to control the pic mikesown Programming 6 13-09-2005 19:13
Using the edu--erm, Robovation for more info? Billfred Control System 8 18-07-2004 21:50
reworking radio control for joysticks ajlapp Electrical 5 05-12-2003 17:38
Are we Using the Same control boards as last year? archiver 2000 5 24-06-2002 00:04


All times are GMT -5. The time now is 23:17.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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