View Single Post
  #1   Spotlight this post!  
Unread 27-12-2009, 00:45
buddyb's Avatar
buddyb buddyb is offline
Registered User
FRC #1885 (ILITE)
Team Role: Programmer
 
Join Date: Dec 2009
Rookie Year: 2008
Location: Haymarket, VA
Posts: 65
buddyb has a spectacular aura aboutbuddyb has a spectacular aura aboutbuddyb has a spectacular aura about
Re: [FTC]: Breaking DC Gearboxes Fix

Quote:
Originally Posted by Don Rotolo View Post
Good info, thanks.

A better design would account for the possibility of overflows and handle them gracefully, instead of allowing them to wrap like that.
Yeah. If you really need the PID control, though, maybe you could make a function to unset it, set the encoder values to 0, wait 10MS (for the changes to reflect in the hardware), then re-set the PID control?

It's the only thing I can think of doing; I don't really want to test it that badly, though. Sorry.

Quote:
Originally Posted by ethan_orion View Post
any suggestions (or example code) on how to achieve this slow down in labview?

thanks.
It's been quite a while since I've used LabVIEW, so, I'll try the best I can to recommend how to code it. If anyone wants to suggest something different, feel free.

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
I hope this helps! If not, I can try to make something in LabVIEW up when I am allowed back in to School (around January 5th), and if you have any questions, feel free to post back here, or contact me directly.

Best of luck,
Buddy
__________________
FRC - Team 1885 - Programmer.
Reply With Quote