|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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,};
Code:
if (IN_DEAD_ZONE(JOY_LEFT))
JOY_LEFT = STOP;
else
JOY_LEFT = lookup[JOY_LEFT];
Code:
LEFT_MOTOR = JOY_LEFT 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. |
|
#2
|
|||||
|
|||||
|
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. |
|
#3
|
||||
|
||||
|
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
|
|||
|
|||
|
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.
|
|
#5
|
||||
|
||||
|
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;
}
|
|
#6
|
||||
|
||||
|
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!
Last edited by Joel J : 21-01-2007 at 11:13. |
|
#7
|
||||
|
||||
|
Re: Mystery problem: exponential drive
Quote:
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. ![]() |
|
#8
|
||||
|
||||
|
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) ![]() |
|
#9
|
||||
|
||||
|
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).
Last edited by Joel J : 21-01-2007 at 11:47. |
|
#10
|
||||
|
||||
|
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. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |