Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Encoder Help (http://www.chiefdelphi.com/forums/showthread.php?t=90086)

normpearii 25-01-2011 16:35

Encoder Help
 
We are having trouble getting our motors to go forward for 10 ticks of our encoders; this is how we are testing out encoder code to make sure it works.

MyRobot.cpp (Simple Template)
Our Declaration
Code:

Encoder encoderR;
Encoder encoderL;
double dblRight;

Our Init
Code:

encoderR(13,12),
encoderL(10,11)

Our Autonomous drive code
Code:

encoderR.Start();
encoderL.Start();
dblRight=encoderR.GetDistance();

if(dblRight>-10)
{
myRobot.Drive(0.5, 0.0);       
dblRight=encoderR.GetDistance();
}
                               
else if(dblRight<=-10)
{
myRobot.Drive(0.0, 0.0);       
dblRight=encoderR.GetDistance();
}


1jbinder 25-01-2011 19:26

Re: Encoder Help
 
We can't help you if you can't describe the problem. Also, ten ticks is a very small distance. Like a 30th of a rotation.
Julian Binder

jwakeman 25-01-2011 19:57

Re: Encoder Help
 
You will need to set SetDistancePerPulse with the proper value if you want to use GetDistance(). Maybe you did and just didn't show it here. If you just want ten ticks tho maybe you should use GetRaw()


All times are GMT -5. The time now is 17:48.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi