|
eaglestrike7339
Rookie
Joined: Wed Dec 17, 2008 11:34 am Posts: 6
|
 Encoder Problem
Hello RobotC community! I have a questions about the proper use of motor encoders. Our robot uses a tank drive system utilizing four motors, two hooked up to each port of the motor controller. Here is our problem. This should make it go forward and stop, correct? On ours, It runs forwards, backwards, turns around, and any other combination of the three you can think of. How sensitive are the encoders to installation? We believe we installed them right.... Thanks for any help you can give us,. Team 3216
|
|
Ford Prefect
Senior Roboticist
Joined: Sat Mar 01, 2008 12:52 pm Posts: 936 Location: a small planet in the vicinity of Beteigeuze
|
 Re: Encoder Problem
which ROBOTC version ?
can you post the whole code?
_________________ Ford Prefect
Never purchase release 1.x ! (ancient programmer's wisdom) "Don't argue with idiots. They'll drag you down to their level and then beat you with experience."
|
|
eaglestrike7339
Rookie
Joined: Wed Dec 17, 2008 11:34 am Posts: 6
|
 Re: Encoder Problem
Complete code, as requested. Running RobotC 1.46 for FTC (downloaded from FTC site, with 365 day trial)
#pragma config(Hubs, S1, HTMotor, HTServo, none, none) #pragma config(Sensor, S2, touch, sensorTouch) #pragma config(Sensor, S3, sonar, sensorSONAR) #pragma config(Sensor, S4, compass, sensorI2CHiTechnicCompass) #pragma config(Motor, mtr_S1_C1_1, leftDrive, tmotorNormal, PIDControl) #pragma config(Motor, mtr_S1_C1_2, rightDrive, tmotorNormal, PIDControl) #pragma config(Servo, servo1, leftElbow, tServoNormal) #pragma config(Servo, servo2, leftElbowAid, tServoNormal) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
//#include "JoystickDriver.c"
task main() {
/* Note: Multiply all speeds times -1 */ /*getJoystickSettings(joystick); //Update initial joystick/game values
while(joystick.StopPgm) //While the FMS says we're "disabled", keep looping { getJoystickSettings(joystick); //Update joystick/game values to see if enabled wait1Msec(50); //wait 50 milliseconds }*/ //both FTC motors, Drive Forward nMotorEncoder[leftDrive] = 0; //Reset the motor encoder nMotorEncoderTarget[leftDrive] = 2000; nMotorEncoder[rightDrive] = 0; //Reset the motor encoder nMotorEncoderTarget[rightDrive] = 2000; nxtDisplayTextLine(2, "Encoder Start "); motor[rightDrive] = 100; motor[leftDrive] = 100; while(nMotorRunState[leftDrive] != runStateIdle){wait1Msec(1);} nxtDisplayTextLine(2, "Encoder End ");
}
Thanks again to all, eagle Team 3216
|
|
Dick Swan
Creator
Joined: Fri Feb 09, 2007 9:21 am Posts: 613
|
 Re: Encoder Problem
I assume that you're using the 12V motors with the FTC kit. And that you have two motors connected to each of the ports on the HiTechnic motor controller -- one is equipped with a motor encoder and one is not. The most likely cause of the problems that you are experiencing is one of the following: - THe encoders are counting forward while the motor is moving in reverse. This is most easily fixed by reversing the two spade lug connecters to the motor
- The motor encoders are miswired with Encoder 0 connected as if it is motor 1 and Encoder 1 connected as if it is motor 0.
The first item is the most likely. Do the various wiring re-arrangements to connect above and see if the problem disappears.
|