View unanswered posts | View active topics It is currently Thu Aug 28, 2014 11:31 pm






Reply to topic  [ 4 posts ] 
Encoder Problem 
Author Message
Rookie

Joined: Wed Dec 17, 2008 11:34 am
Posts: 6
Post 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.

Code:
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 ");


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


Thu Dec 18, 2008 11:46 am
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: Encoder Problem
which ROBOTC version ?

can you post the whole code?

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Thu Dec 18, 2008 3:51 pm
Profile
Rookie

Joined: Wed Dec 17, 2008 11:34 am
Posts: 6
Post 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


Fri Dec 19, 2008 10:54 am
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 615
Post Re: Encoder Problem
eaglestrike7339 wrote:
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.
<<snip>>
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....
Team 3216

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:
  1. 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
  2. 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.


Mon Dec 22, 2008 1:47 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.