![]() |
Using Encoder to Drive a Certain Distance
Hi I am looking for some resources and places to get start to use one encoder to drive a certain distance during autonomous. I found this link http://wpilib.screenstepslive.com/s/...or-other-shaft. It has been slightly helpful with understanding how the encoder works and got me started. Here's what I have so far. Our team will be getting a second encoder soon, I hope I can still get this working with just the one encoder for now. Thanks!
Code:
public class Robot extends IterativeRobot { |
Re: Using Encoder to Drive a Certain Distance
Remember to use the encoder reset, and start function when initializing (This was a mistake my team made when first getting into them). It looks as though you have all you need other than that though. Just use if statements to progress through your autonomous when target distances are met. best of luck
Also, be careful about what encoders you use. The standard andymark encoders are very... finicky. Make sure if you use them, you don't EVER have to disassemble the drive system. (don't take them off) |
Re: Using Encoder to Drive a Certain Distance
Quote:
For example if I were to calculate the circumference of the wheel (in inches). Then divide the circumference of the wheel by the number of pulses in a full revolution (which is 1440 I think if I am using x4 encoding). Then set the distance per pulse to the circumference/number of pulses in one revolution would it make one full revolution move the robot one inch? Sorry if this is not clear enough I can try to clarify if it makes zero sense. |
Re: Using Encoder to Drive a Certain Distance
Quote:
Code:
//Encoder Distance Constants |
Re: Using Encoder to Drive a Certain Distance
Quote:
|
Re: Using Encoder to Drive a Certain Distance
Quote:
Quote:
|
Re: Using Encoder to Drive a Certain Distance
Quote:
http://www.andymark.com/AM14U3-p/am-14u3.htm Update: Just tested the code and I the number I was getting from the encoder very off. I was trying to travel 36 inches but at the 36 inch mark the encoder is reading about 1.26. This is the manual to the drive train we are using currently just to get things rolling. If you jump to page 4 it will tell you the gear ratio specifics. We are using the included 4 inch wheels. http://files.andymark.com/AM14U_Asse...structions.pdf I am having a hard time finding the exact model of encoder we are using. It is very similar to this: http://www.andymark.com/product-p/am-3132.htm It's just an optical encoder that we got in 2014. Here is snippets of the code everything that I am doing with the encoder is included below. Code:
|
| All times are GMT -5. The time now is 10:24. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi