|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: [FTC]: Breaking DC Gearboxes Fix
Quote:
It's the only thing I can think of doing; I don't really want to test it that badly, though. Sorry. Quote:
![]() I will assume that you can get this set up so that the revving down can run as a second task, of sorts. If not, I can try to find some examples online, if you would like. We first need to do some set-up, though. Create a new boolean variable for the action you want to trigger the revving up and down with (likely a button). For each motor you want to rev down, create a number value that will contain its current power. Every place you set that motor's power, have it update the corresponding motor power variable to reflect the new power. So, if you have Button 2 to set the motor's power to 75, have button 2 also set your custom Button 2 Power variable to 75. Now that we're done with that, we can begin making the task. Have an infinite (while) loop as the 'body' of the task; we want this monitoring the robot the whole time. Inside of it, add a switch statement, and have it check the Button X Pressed boolean you made earlier. If the condition is FALSE, have it wait 30MS (If it doesn't wait, bad things may happen). If the condition is TRUE, have it begin another while loop. We want this loop to run until all motors we want to rev to 0 power are at 0. So, it would be until Motor 1 Power = 0 and Motor 2 Power = 0, etc. Now, inside of the loop you've just created, have another switch statement for each motor you want to rev down (so, if you had two motors, you'd have two more switch statements). In these switch statements, we'll want to check to see whether each motor's power is within 10 of 0. So, we'd take the absolute power of the motor value, and see if it's less than or equal to 10. If this is true, we want to set the motor's power VARIABLE to 0. (not the motor yet) If it's false, however, you need to make *another* switch statement. [Fun, isn't it?] Have it check to see whether the motor power is positive or negative (using the variables we created earlier). If the power is positive, subtract 5 from the variable. (skip setting the motor for now). Otherwise, add 5 to the variable. Now, get out of both of the switch statements we just created (so we're in the loop that checks to see if the powers are not equal to 0). In here, set the motor's powers to the variables. In my messed up form of pseudocode, it will look a bit like this: Code:
while(1>0):
Is button x pressed?
YES:
while(Motor A Power [variable] is not 0):
Is |Motor A Power [variable]| < 10?
YES:
Set Motor A Power [variable] to 0.
NO:
Is Motor A Power < 0?
YES:
Add 5 to Motor A Power [variable]
NO:
Subtract 5 from Motor A Power [variable]
Set Motor A Power [actual motor power] to Motor A Power [variable]
NO:
wait 30MS
![]() Best of luck, Buddy |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [FTC]: FTC Futures Forum at FTC World Championship | gdo | FIRST Tech Challenge | 0 | 08-04-2009 18:46 |
| [FTC]: FTC]: FTC Champ Tournament - Ontario (Scoring Breakdown) | Mr. Lim | FIRST Tech Challenge | 2 | 03-03-2008 11:54 |
| [FTC]: [FTC]: Ontario Provincial FTC Start/End Times | cbhl | FIRST Tech Challenge | 8 | 16-12-2007 13:37 |
| FP burning out | Max Lobovsky | Motors | 6 | 24-02-2004 07:52 |
| Burning IR sensors | LittleProton | Electrical | 5 | 06-02-2004 09:02 |