![]() |
Encoders
I got the Ultrasonics working, But can someone help me with programming encoders.
I understand how they work, But I don't understand how to program them so they will track the motor to a certain spot then return to the starting spot. Calvin |
Re: Encoders
What you need to do is to make a program that makes the robot go in whatever direction you wish UNTIL a certian number of encoder clicks is reached. For example, if you wanted to go five rotations of the wheel forward, then you would tell the robot to go forward until the encoder count reached 450 clicks (90 clicks per rotation * 5 rotations). In order to go back the same ammount, you have to preset the encoder to zero (the Vex encoders don't know whether you are going backwards or forwards) and set the motor to go backwards until it reads another 450 clicks (using the example above).
If you want to see how many clicks it is to a certian spot, download the "ENCODERTEST" program from the test code folder. Then, bring up the terminal window and see what the reading is once you reach a certian spot. If you need help specificaly about the encoder blocks, take a look in the help file which explains them very nicely. I hope this helps you, but if it dosen't, come on back and I'm sure someonw can help you. :) |
Re: Encoders
Quote:
Thats my problem, How do you tell the motor to go forward say 90 clicks? Is this how: Begin - Start Encoder - Get encoder - motor module clockwise If -encoder ==90 - stop motor. Is this correct? and how do you reverse it? I'm sorry I'm really lost. Thanks for your help. Calvin |
Re: Encoders
On the topic of Encoders, would it be possible to use a grayhill op encoder on a vex system? If i recall correctly the grayhills run on 5v and just use an interupt port on the full size controller.
As the ports are the same (i believe but i have not found a pin out or anything to tell me if they are exactly alike) so i think it is possible. The reason is our team has several older grayhills around and none of the vex encoders. As i am doing vex as a class and focusing on the programming aspect i would like to know if the sensors could be made to work for vex as well. The same question also goes for pots. As for easyC im not very sure. I prefer to write the code by hand as i find it faster and more open ended. |
Re: Encoders
The Greyhills encoders would work with easyC but would only count up and not up and down.
|
Re: Encoders
How do you tell an encoder, How many clicks you want the motor to turn?
|
Re: Encoders
Since they would work in easyC it is valid to assume that it would also work in normal C. correct?
|
Re: Encoders
Quote:
Really, this is a job that is better suited for a stepper motor (which are currently illegal in FIRST). The Grayhills and Kevin's code can be made to simulate this sort of behaviour quite effectively, though. |
Re: Encoders
Quote:
The encoders do not detect direction. So no matter what way it moves, the value will increase. Depending on how your code is set up, to reverse it, you have two choices. 1) reverse the motor direction and keep counting the encoder until it hits 180. Then stop. 2) reset the encoder and in a separate loop, do the same thing as forward, except you need to reverse the motor direction. Try this... create a variable, count = 0 Start Encoder While (count <= 90) Set motor forward Set motor to neutral Stop Encoder Start Encoder While (count <= 90) Set motor reverse Set motor to neutral |
| All times are GMT -5. The time now is 03:17. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi