FIRST Tech Challenge Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

Stop 4 motors based on encoder counts even if only two have encoders (Archived)

Update: This example applies to the 2010 FTC competition software and may not be compatiblw with current competiton software. - Motor functions have changed.


4 motots 2 econders_snip.png

In this example we have two motors with encoders (Left Front Drive and Right Front Drive) and two motors that do not (Rear Left and Read Right).  In the outer while loop I simple tell the motors with encoders to move1000 encoder ticks.  In the inner loop I tell my other two motors to move and poll the encoders attached to Left Front Drive and Right Front Drive to see if they are still moving.  If they have stopped the output Move in Progress? from the Motor Status VI outputs a false.  I use this value to end my inner while loop and then immediately set the motor speed for Rear Left an Rear Right to 0, stopping the motors.

Mark
NI App Software R&D
Comments
Philbot
Active Participant
Active Participant
on

In your example, there is nothing to ensure that the Move Fixed Distance vi executes before the inner loop.  So it's possible that the move may not get started befotre the inner loop runs.  I would think that the pink NXT signal flow should be... From Reset encoder - Move fixed Distance and then into the inner loop (rather than being split before the Move Fixed Distance).

As a "conceptual example" this is probably then workable, but I suspect once the target disatnce has been reached, the four motors will be fighting against each other to hold the position.  The DC motor controllers seem to have a very small window for "in position" and they often oscillate around that goal.  I'd recommend adding a timeout to the inner loop to ensure that it doesn't sit there and oscillate for ever.

Get a life? This IS my life!
MarkBlack
Active Participant
Active Participant
on

I made some changes to this example for the 2010-2011 seasons based on Phil's feedback.  Namely I ensured the Moved Fixed distance VI executes before the inner while loop.  I also removed the type def controls for the named motors.  This will ensure the VI will not open broken.

Mark
NI App Software R&D
Contributors