kay guys i need help big time, i have been trying to get my robot to drive 100 tick and then stop using encoders on my 2 front wheels (some images in the link here: https://vexforum.com/t/17c-dr4b-preview/28083/1 )
I have tried using while and if/else loops to get it to work but have not gotten anywhere in the hours that I have tried.
if anyone wouldn’t mind checking out my Easy C program that would be awesome, cause i have my competition in a week lol.
Well, there really is no code in that project trying to drive forward 100 ticks.
100 ticks is a short distance, 2-3 inches usually (depends on gearing etc.)
The general form of code to do this type of thing is.
// Drive forwards 1000 counts - assumes the encoder count increases as you drive forward
PresetQuadEncoder ( 3 , 4 , 0) ;// Set encoder back to 0
while ( GetQuadEncoder( 3, 4 ) < 1000 )
{
AUTO_Drive_foraward ( ) ;
Wait ( 25 ) ;
}
// Stop the drive - you need to make this user function, send 0 to all motors
AUTO_Drive_Stop ( ) ;
If the encoder count decrements when going forwards then swap the two encoder cable digital ports (ie. rewire them on the cortex).
If not you can always take away the if encoder==1 and replace it with the smart task block i mentioned earlier and put auto drive stop under the smart task block.