Go to Post And (the video) didn't show how to do the "Charlie Brown". I still don't know how to do this... GAH!!!! - Elgin Clock [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 20-01-2007, 17:09
ida_noeman's Avatar
ida_noeman ida_noeman is offline
Registered User
AKA: phobbs
FRC #1719 (Umbrella Corp.)
Team Role: Mechanical
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Baltimore, MD
Posts: 129
ida_noeman is on a distinguished road
Mystery problem: exponential drive

Hi FIRST community. We decided to try out scaling our joysticks so that small, exact changes could be made using the middle parts of the joystick. To do this we used an exponential function model. We decided to use a lookup talbe, because we figured we had plenty of space, and we weren't sure whether the processor could do 4 of the calculations each loop without skipping a beat. However, the joysticks did not follow the model, as putting the joysticks full forward had the motors at stop, in addition to the middle and full back. The motors would only run when the joystick was not full forward, backward, or in the middle.
Anybody have any idea why? Is it fixable?
Thanks in advance.

--
Lemma 1: MOTOR_LEFT, JOY_LEFT are pound defined to you know what and DEAD_ZONE is to fix trim issues, by making some defined number (x2) of middle values of the joystick 127.
Lemma 2: "IN_DEAD_ZONE" is
#define IN_DEAD_ZONE(x) (x <= DEAD_ZONE + STOP && x>= STOP - DEAD_ZONE)
--

(At the beginning of user_routines.c)
Code:
rom const unsigned char [] lookup = {0, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 33, 36, 38, 41, 43, 45, 48, 50, 52, 54, 56, 58, 60, 62, 63, 65, 67, 68, 70, 72, 73, 75, 76, 77, 79, 80, 81, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 99, 100, 101, 101, 102, 103, 104, 104, 105, 105, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 112, 113, 113, 114, 114, 114, 115, 115, 115, 116, 116, 116, 116, 117, 117, 117, 118, 118, 118, 118, 119, 119, 119, 119, 119, 120, 120, 120, 120, 120, 121, 121, 121, 121, 121, 121, 122, 122, 122, 122, 122, 122, 122, 123, 123, 123, 123, 123, 127, 127, 131, 131, 131, 131, 131, 131, 132, 132, 132, 132, 132, 132, 132, 133, 133, 133, 133, 133, 133, 134, 134, 134, 134, 134, 135, 135, 135, 135, 135, 136, 136, 136, 136, 137, 137, 137, 138, 138, 138, 138, 139, 139, 139, 140, 140, 140, 141, 141, 142, 142, 142, 143, 143, 144, 144, 145, 145, 146, 146, 147, 147, 148, 149, 149, 150, 150, 151, 152, 153, 153, 154, 155, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 173, 174, 175, 177, 178, 179, 181, 182, 184, 186, 187, 189, 191, 192, 194, 196, 198, 200, 202, 204, 206, 209, 211, 213, 216, 218, 221, 223, 226, 229, 232, 235, 238, 241, 244, 247, 250, 254,};
(later, when assigning joysticks)
Code:
if (IN_DEAD_ZONE(JOY_LEFT))
            JOY_LEFT = STOP;
else
            JOY_LEFT = lookup[JOY_LEFT];
(etc for the rest of them.)
Code:
LEFT_MOTOR = JOY_LEFT
(etc.)


P.S. The reason that it jumps from 127 to 131 and 123 on each side is so we can adjust our deadzone to whatever we want, but then have a minimum output for the motor, something that will be detectable if we're not calibrated.
__________________
--
"Weeks of coding can save you hours of planning"
"If the code was hard to write, I'm dam well going to make it hard to read!"
  #2   Spotlight this post!  
Unread 20-01-2007, 23:59
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,756
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Mystery problem: exponential drive

Did you cut & paste directly from the code?
You have a syntax error at the end of your lookup table declaration.

DEAD_ZONE + STOP
and
STOP - DEAD_ZONE
need parentheses.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #3   Spotlight this post!  
Unread 21-01-2007, 00:08
6600gt's Avatar
6600gt 6600gt is offline
Registered User
AKA: Lohit
FRC #0226 (Hammerhead)
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Troy, MI
Posts: 221
6600gt is a jewel in the rough6600gt is a jewel in the rough6600gt is a jewel in the rough
Re: Mystery problem: exponential drive

You guys should watch what values are going to the pwms based on where the joystick is...use the printfs.
  #4   Spotlight this post!  
Unread 21-01-2007, 01:01
Jake M Jake M is offline
void* Jake;
FRC #1178 (DURT)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Missouri
Posts: 118
Jake M has a spectacular aura aboutJake M has a spectacular aura about
Re: Mystery problem: exponential drive

I'd say, if anything, there's a problem with how your logic string in IN_DEAD_ZONE() is being evaluated (use parenthases), or there's some other, small part of code somewhere else you don't know about, that's messing with those outputs. There might be something else modifying LEFT_MOTOR, after you set it to JOY_LEFT, and that would be overwriting everything.
__________________
Code:
void function(void)
 {
  function();
 }
  #5   Spotlight this post!  
Unread 21-01-2007, 11:05
ida_noeman's Avatar
ida_noeman ida_noeman is offline
Registered User
AKA: phobbs
FRC #1719 (Umbrella Corp.)
Team Role: Mechanical
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Baltimore, MD
Posts: 129
ida_noeman is on a distinguished road
Re: Mystery problem: exponential drive

Urm, we're actually using a method for deadzone, sorry 'bout that:

Code:
unsigned char Deadzone(unsigned char x) {
    if ( (x <= (STOP + DEADZONE)) && (x >= (STOP - DEADZONE)) )
        return STOP;
    else
        return x;
}
__________________
--
"Weeks of coding can save you hours of planning"
"If the code was hard to write, I'm dam well going to make it hard to read!"
  #6   Spotlight this post!  
Unread 21-01-2007, 11:10
Joel J's Avatar
Joel J Joel J is offline
do you..
no team
 
Join Date: May 2001
Rookie Year: 2000
Location: San Jose, CA
Posts: 1,445
Joel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond repute
Re: Mystery problem: exponential drive

What I like about a second or third order exponential, is that a deadband is included automatically. When I use an exponential on a drive, I usually comment out the deadband code, and let the function to the work. But then again, I just do something along the lines of "variable = SGN(variable)*variable*variable/127;" I don't use a LUT. Maybe if I wanted something a bit more specific? I understand the multiplications and divide chew up time, but bah!
__________________
Joel Johnson

Division By Zero (229) Alumni, 2003-2007
RAGE (173) Alumni, 1999-2003

Last edited by Joel J : 21-01-2007 at 11:13.
  #7   Spotlight this post!  
Unread 21-01-2007, 11:23
ida_noeman's Avatar
ida_noeman ida_noeman is offline
Registered User
AKA: phobbs
FRC #1719 (Umbrella Corp.)
Team Role: Mechanical
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Baltimore, MD
Posts: 129
ida_noeman is on a distinguished road
Re: Mystery problem: exponential drive

Quote:
Originally Posted by Joel J. View Post
What I like about a second or third order exponential, is that a deadband is included automatically.
I think you're mistaking 'exponential' for 'polynomial'.
The thing about a cubic function is that all but the center of the joystick will provide some power, but for most of it, not enough to get it moving.
That's why I used two exponentials and a dead zone.

__________________
--
"Weeks of coding can save you hours of planning"
"If the code was hard to write, I'm dam well going to make it hard to read!"
  #8   Spotlight this post!  
Unread 21-01-2007, 11:26
ida_noeman's Avatar
ida_noeman ida_noeman is offline
Registered User
AKA: phobbs
FRC #1719 (Umbrella Corp.)
Team Role: Mechanical
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Baltimore, MD
Posts: 129
ida_noeman is on a distinguished road
Re: Mystery problem: exponential drive

OK!!! So... it looks like that old inline function was the thing that was messing it up!

It works now. Feel free to copy the code and use it yourself (if that's within the bounds of the rules)
__________________
--
"Weeks of coding can save you hours of planning"
"If the code was hard to write, I'm dam well going to make it hard to read!"
  #9   Spotlight this post!  
Unread 21-01-2007, 11:42
Joel J's Avatar
Joel J Joel J is offline
do you..
no team
 
Join Date: May 2001
Rookie Year: 2000
Location: San Jose, CA
Posts: 1,445
Joel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond repute
Re: Mystery problem: exponential drive

Well, the code example I provided (and have usually used) is an x^2 exponential. I dropped my exponential equation into MATLAB, and verified that it gives a deadband of about 11 in the positive direction, and about 12 in the negative direction, which is about what I normally use as a deadband (10 in either direction).
__________________
Joel Johnson

Division By Zero (229) Alumni, 2003-2007
RAGE (173) Alumni, 1999-2003

Last edited by Joel J : 21-01-2007 at 11:47.
  #10   Spotlight this post!  
Unread 21-01-2007, 12:39
Joel J's Avatar
Joel J Joel J is offline
do you..
no team
 
Join Date: May 2001
Rookie Year: 2000
Location: San Jose, CA
Posts: 1,445
Joel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond repute
Re: Mystery problem: exponential drive

Ok, I saw your PM.. x^2 is a polynomial . I guess I can't use the term exponential control.
__________________
Joel Johnson

Division By Zero (229) Alumni, 2003-2007
RAGE (173) Alumni, 1999-2003
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
Mystery Sprockets aaeamdar General Forum 37 30-01-2007 00:54
tachometer mystery? Issues Motors 31 27-11-2005 20:44
Problem with drive train. Tton General Forum 2 12-02-2003 22:37
mystery icons Joe Johnson CD Forum Support 2 07-06-2001 22:09


All times are GMT -5. The time now is 19:13.

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