|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools |
Rating:
|
Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: [FTC]: Spin Motor Wind Down: Programming
Quote:
if(joystick1.joy_y1 == 0 && motorspeed > 0) { x = x + 1; if(x=1000){x = 0; motorspeed = motorspeed - 1;} motor[shooter] = motorspeed; } if(joystick1.joy_y1 != 0){motor[shooter] = ((joystick1.joy_y1 * 100) / 127);} or if your using a button if(joy1Btn(1) == 0 && motorspeed > 0) { x = x + 1; if(x=1000){x = 0; motorspeed = motorspeed - 1;} motor[shooter] = motorspeed; } if(joy1Btn(1) ==1){motor[shooter] = 100;} that should work much better |
|
#2
|
|||
|
|||
|
Re: [FTC]: Spin Motor Wind Down: Programming
jamie_1930:
Yes, that should do the trick as well. You'd need to add a little more code to reset your runtime counter (x) once it hits 1000 or if the launcher is reactivated and do some testing to find the optimal limit. Even though it is just sample code, a team using the analog sticks would need to also compensate for a deadzone in your first example. One last note on this is that my students observed a difference in how smoothly the shooter mechanism came to a stop depending upon whether or not they floated the motors. If braking was enabled (the default) then the mechanism would slow down until about 20% power and still stop fairly hard due to the motor attempting to brake (maintain speed) at low power and not overcoming the torque to keep driving the gears. If they floated the motors first, then the mechanism would slow down nice and smooth all the way using its own momentum. Test and experiment; YMMV. EricVanWyk: ROBOTC makes it easy to spin up separate threads (tasks for the NXT) where you can use wait statements without pausing your primary control loop code (located in the main task). In this model, you shouldn't care how fast the processor can execute your primary control loop and have to guess a counter limit, because you can explicitly set how many milliseconds you want to wait between stepping up or down power to a motor in a separate task. No guessing and the code will be much more optimized anyway. Yes, ROBOTC supports floating point calculations. Last edited by l0jec : 12-11-2009 at 08:28. Reason: Combine answers to single post |
|
#3
|
|||
|
|||
|
Re: [FTC]: Spin Motor Wind Down: Programming
we had the same problem. however since we found out how much damage it can cause on the motors the hard way at a competition, we did a quick and dirty fix. we set it to an idle speed. this way the motors always ran. sped up nicely, and slowed down nicely.only down side was everyone thought we did something wrong in the code, and it would occasionally spew out a ball or two because we had the idle speed to high.
i think the nicest solution would be to turn of the brakes on the motors some how. although i don't know how you would do that. |
|
#4
|
|||
|
|||
|
Re: [FTC]: Spin Motor Wind Down: Programming
Quote:
Code:
//float motors bFloatDuringInactiveMotorPWM = true; //brake motors bFloatDuringInactiveMotorPWM = false; |
|
#5
|
|||
|
|||
|
Re: [FTC]: Spin Motor Wind Down: Programming
we tried that. the motors did some very odd things. the motors pretty much went haywire when we did this.
but we don't really want to turn off the brakes for all the motors. is there a way to set just 2 motors to float like in NXTG? |
|
#6
|
|||
|
|||
|
Re: [FTC]: Spin Motor Wind Down: Programming
Your experience seems to match ours. One of my students came up with a possible fix (*hack*) which appeared to prevent their drive motors from flipping out when they wanted to coast their shooter motors. I'll check with him to see what it was and if it is a viable workaround; if it is, we'll post it.
|
|
#7
|
|||
|
|||
|
Re: [FTC]: Spin Motor Wind Down: Programming
thanks. that would help a lot.
in the mean time something like this might help for anyone else trying to keep there motors alive: Code:
int motorSpeed = 100;
void powerDown()
{
if(time10[T1] > 10 && motorSpeed > 10)
{
time10[T1] = 0;
motorSpeed --;
}
else
{
motorSpeed = 0;
}
motor[shooter] = motorSpeed;
}
Last edited by clwilligham : 16-11-2009 at 17:15. |
|
#8
|
|||
|
|||
|
Re: [FTC]: Spin Motor Wind Down: Programming
I talked with the student who had come up with a potential workaround. It sounds like he was adjusting the bFloatDuringInactiveMotorPWM before setting any motor speed. The reported observation was that the bFloatDuringInactiveMotorPWM was only read/applied when setting the power to a motor, not after. So if you wanted to only coast a single motor, you had to set bFloatDuringInactiveMotorPWM to true just before setting the power on that specific motor and then set it back to false before updating any other motors. Any other motors with power already set when the flag is changed do not get affected.
The biggest challenge I see with this type of workaround (assuming it works at all) is if you are setting motor outputs from different tasks. I did not test this myself, but wanted to pass it along as promised. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Wind River License Server Down? | keericks | C/C++ | 4 | 19-06-2009 20:02 |
| [FTC]: January Run Down and New FTC Pictures | ttldomination | FIRST Tech Challenge | 6 | 04-02-2009 13:18 |
| Driver Station Watch Dog / Motor Won't Spin Issue | RMiller | FRC Control System | 5 | 20-01-2009 09:58 |
| Motor Spin Direction | archiver | 2000 | 6 | 23-06-2002 23:43 |
| How Many RPM does a Fisher-Price Motor Spin At? | archiver | 2000 | 7 | 23-06-2002 23:22 |