|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#12
|
|||
|
|||
|
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 |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Battlebots I.Q.- A serious threat to FIRST or a half thought up cheep copy? | Joe Matt | General Forum | 75 | 17-10-2005 20:43 |
| Fried program slots? | Jeff Waegelin | Programming | 18 | 19-03-2003 18:08 |
| Anyone looking for more program space? | archiver | 2001 | 13 | 24-06-2002 02:20 |
| robot control emulator for default or other program | CharlieWilken | Programming | 26 | 24-02-2002 02:36 |
| control program looping??? | ctartist236 | Programming | 1 | 08-02-2002 10:09 |