View Single Post
  #3   Spotlight this post!  
Unread 12-02-2014, 17:48
irvingc irvingc is offline
Registered User
FRC #0948 (Newport Robotics Group)
Team Role: Leadership
 
Join Date: Jan 2014
Rookie Year: 2011
Location: Bellevue, WA
Posts: 31
irvingc is on a distinguished road
Re: motor encoder java

Quote:
Originally Posted by Maxchrist View Post
we are trying to sense position. we have it on an a and b channel plugged into the digital i/0 on port 1 and 2.
This is not the proper wiring to use the encoder as an absolute sensor (position). Refer to the last section of Joe Ross's link.


[ edit ]
Provided you do want to use it as a quadrature, though, you would first create a new Encoder object:
Code:
Encoder encoder = new Encoder(aChannel, bChannel);
Then enable it:
Code:
encoder.start();
Then, you would read it like so:
Code:
encoder.getDistance();
Depending on the application, you may also want to calibrate the distance per pulse:
Code:
encoder.setDistancePerPulse(someConstant);

Last edited by irvingc : 12-02-2014 at 17:56.
Reply With Quote