View Single Post
  #8   Spotlight this post!  
Unread 26-03-2008, 17:31
Glueeater Glueeater is offline
Registered User
no team
 
Join Date: Mar 2008
Rookie Year: 2007
Location: The Hood
Posts: 8
Glueeater is an unknown quantity at this point
Re: Controlling Motors More Accurately

Hmm. I don't think I follow?

Right now I have the aforementioned code running within a for loop..

Code:
 
float speed
int trps

-snip-

for enco == 0; enco < distance; enco = GetEncoder(1)
StartTimer(1)
-snip-
time = GetTimer(1)
rps = enco / time

If (rps <= 127)
speed = speed + .5

elseif (rps < trps)
speed = speed + 1

elseif (rps > trps)
speed = speed - 1

elseif (rps == trps)
speed = speed
The first If limits it to only go "forward." I think my main question now is if there is a way to more accurately control the speed than by integers. I think you referred to it overcompensating which is what I think it's doing, is there a way to solve that?

I start at a speed close to the target and it will vary around it, that should work, no?

By the way, I am not varying loads or anything. The servo will just run continously at its target speed.