Thread: autonomous mode
View Single Post
  #6   Spotlight this post!  
Unread 31-01-2007, 14:41
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: autonomous mode

Quote:
Originally Posted by mluckham View Post
You could try something simple like this, to basically ignore the values near the centre of travel:

Code:
if ((joy >= 120) && (joy <= 140))  joy = 127;
This is a good idea, but I would propose the following enhancement to make it a little more flexible
Code:
#define JOYSTICK_DEADZONE   5
...
if((joy >= (127 - JOYSTICK_DEADZONE)) && (joy <= (127 + JOYSTICK_DEADZONE)))
{
  joy = 127;
}
Then, to extend that even further, you could create a macro so that you could apply deadzones whenever you needed to.
Code:
#define JOYSTICK_DEADZONE   5

#define DEADZONE(input, dz) (if(((input) >= (127 - (dz))) && ((input) <= (127 + (dz)))) (input) = 127;)

...

DEADZONE(joy1, JOYSTICK_DEADZONE)
DEADZONE(joy2, JOYSTICK_DEADZONE)
Notice that the lines that "call" the macto don't have semicolons. This is because there is a terminating semicolon at the end of the macro itself.
Quote:
Originally Posted by seanl
1. where do i splice in the code you gave me i was looking through the code i cant see where to put it.
Well, if you think about this logically, your outputs (pwm/relay/analog/digital outs) are based on your inputs, so it makes sense that deadzone code would be placed somewhere after the inputs are read, but before the outputs are written. Depending on how your inputs map to outputs, you may have intermediate calculations. It would then make sense to place your deadzone code before those calculations. When in doubt, take a deep breath and think through the problem. Programming is about thinking logically. Go step by step and you'll figure it out.
Quote:
Originally Posted by seanl
2. do i connect the user interface to my computer for running the labview program.
I don't know anything about the way that labview works. Hopefully someone else can answer that question.