View unanswered posts | View active topics It is currently Wed Jul 23, 2014 12:31 am






Reply to topic  [ 1 post ] 
Macro functions and Motor precision/timing 
Author Message
Rookie

Joined: Fri Jan 15, 2010 8:22 pm
Posts: 1
Post Macro functions and Motor precision/timing
Hello everyone!

I would like to be able to create a code that allows my robot to perform multiple actions with the click of a single button. Along with that, i would like for my motors to be able to turn a specified amount during the command. I originally started with something along the lines of this:
Code:
if (//button one is pressed)
{
motor[motorA] = 100; //Motor at full power
wait1msec(60); //Allow the motor to turn for 60 milliseconds
}


but to my surprise when i pressed the button, the length of the spin was actually determined by the time I held down the button and was extremely inconsistant. If i pressed like normal the motor would spin for x long, but if i pressed it unrealisticly fast it would spin for x-y long...

I figured this was because the computer was executing the commands faster than i could move my finger, so the code was actually executing more than once. To combat this, i added:
Code:
motor[motorA] = 100; //Motor at full power
wait1msec(60); //Allow the motor to turn for 60 milliseconds
motor[motorA] = 0; //Turn off motor
wait1msec(100); //Give controller time to release button


I hoped, in vain, that the extra wait1msec would give the user time to press and release the button, but the effect was actually far more different... Instead the motor continued to spin the extra 100 milliseconds...


Is there a way to make the motor spin a certain amount in a given time with the use of a single button? Or better yet, do the HiTechnic DC motors have encoders i can use to specify the degree of the turn? (I know the servos do, but one of my senior club members told me the DC motors did not)

Thank you in advance!


Fri Jan 15, 2010 9:08 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

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.