|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||||
|
|||||
|
[FTC]: DC MotorEncoder Code
So in the instance of having servos, those servos have set positions you can send them to. What I want to do is tell a motor to go to specific encoder positions in robotC. I haven't the slightest clue how to begin doing that. My goal is to push a button and have an arm powered by a motor go to a certain position and stop or keep a low level of power to keep it locked in that position until the button isn't pressed.
Thank You. John Fogarty |
|
#2
|
||||
|
||||
|
Re: [FTC]: DC MotorEncoder Code
Here's one way to do it:
Have the motor move back until it hits a touch sensor. Set the input from the encoder as the zero position (store it in a variable) and move the motor forward to the encoder position you want, plus the zero value. We did this to align a dispenser tread on our old robot. If it doesn't rotate all the way around, you may not have to do this. |
|
#3
|
||||
|
||||
|
Re: [FTC]: DC MotorEncoder Code
Oh, actually, you could just reset the encoder using the software when it hits the touch sensor. Sorry, I'm a hardware guy. I was unsure about my last post, so I read our team's own tutorial on using them.
![]() http://say-watt.org/wp2/archives/391 |
|
#4
|
||||
|
||||
|
Re: [FTC]: DC MotorEncoder Code
Code:
nMotorEncoder[motorA] = 0;
wait1Msec(50);
nMotorEncoderTarget[motorA] = x; <- set this to the number of rotations the Motor Encoder needs to rotate
motor[motorA] = 100;
while ((nMotorRunState[leftMotor] != runStateIdle))
{
EndTimeSlice();
}
return;
|
|
#5
|
|||
|
|||
|
Re: [FTC]: DC MotorEncoder Code
another way thats a bit more direct but probably a little bit less reliable in terms of skidding:
Code:
motor[FL] = power;
motor[FR] = power;
motor[BL] = power;
motor[BR] = power;
while(nMotorEncoder[FL] < units){}
Stop(); // we wrote this function to set every motor to 0.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|