View Single Post
  #12   Spotlight this post!  
Unread 23-06-2002, 22:23
archiver archiver is offline
Forum Archival System
#0047 (ChiefDelphi)
 
Join Date: May 2001
Location: Pontiac, MI
Posts: 21,214
archiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond repute
Re: Scaling Values in the Control Program

Posted by Mike Gray.

Engineer on team HOT from Huron Valley Schools sponsored by GM Milford Proving Ground.

Posted on 3/15/2000 11:08 AM MST


In Reply to: Scaling Values in the Control Program posted by Nate Smith on 3/15/2000 10:06 AM MST:



Nate:

Not sure exactly what you're after, so I'll discuss three methods:

1. If you want to scale the joystick variable linearly, use slope and intercept.

Example:

p1_y=p1_y / 2 + 64

This example assumes that you want to scale the variable to half-scale. You must add
64 counts so that 127 counts still represents center-stick. If you want 1/4 speed, simply
divide by 4 and add 96.

2. If you want to reduce the authority in one direction only, use the branch statement, and write a routine that scales the joystick variable (as above) only when the raw variable is in a particular range.

3. If you just want to limit the reverse speed, simply clamp the joystick variable at some minimum or maximum value.

Example:

p1_y=p1_y min 50

This example assumes that zero counts is full reverse (depends upon motor polarity). Experiment with the minimum value. Use the MAX function if 255 counts is full reverse.

Example:

p1_y=p1_y max 200

You can combine these two techniques, scaling and clamping in the same line of code:

Example:

p1_y=p1_y / 2 + 64 min 32 max 160

If you are using a single joystick to control both traction motors, you will find it VERY beneficial to leave the y-axis alone, but scale the x-axis. You then have full authority fore-and-aft, but reduced authority when turning. Much more controllable.

When scaling, remember: power=I squared R. Its always best to optimize the mechanical features so that you make use of all the motor's potential (times a safety factor) before making software tweaks.

Non-linear scaling is much more complex, and not recommended unless you have a rotating member working against gravity. If that is the case, take a look at SIN and COS functions. Hope some of this helps!

Mike Gray

: Does anybody out there have a foolproof way to scale down values in the control program? Whenever i try it, using different scaling constants for forward and reverse(scaling joystick inputs), I always seem to lose part of the range completely. Help!

: Nate


__________________
This message was archived from an earlier forum system. Some information may have been left out. Start new discussion in the current forums, and refer back to these threads when necessary.