View Single Post
  #11   Spotlight this post!  
Unread 31-10-2013, 12:11
Domenic Rodriguez's Avatar
Domenic Rodriguez Domenic Rodriguez is offline
Registered User
FRC #0316 (LuNaTeCs)
Team Role: College Student
 
Join Date: Sep 2010
Rookie Year: 2011
Location: Grove City, PA
Posts: 213
Domenic Rodriguez has a spectacular aura aboutDomenic Rodriguez has a spectacular aura aboutDomenic Rodriguez has a spectacular aura about
Re: Encoders Programming

Looking at your other thread, I see you are using the AS5145B Magnetic Encoders, not the US Digital E4Ps. According to this page, these encoders output 1024 pulses per revolution, unlike the E4Ps which are only 360 pulses/revolution.

Have you looked at this page yet? It explains how quadrature encoders work, and gives some examples of how to use the WPILib Encoder class.

The constructor call is where you create the Encoder object, usually as an instance variable of your robot class. For example, to create an Encoder with the A channel in DIO 1, the B channel in DIO 2, counting the normal direction and 4X decoding, you would use this:
Code:
Encoder myEncoder = new Encoder(1, 2, false, EncodingType.k4X);
Here's a simple example of using encoders to drive a robot in autonomous: https://gist.github.com/DomenicP/7252269
__________________

LuNaTeCs - Learning Under Nurturing Adults Teaching Engineering Concepts and Skills - Small and Mighty!

FRC 316 LuNaTeCs - Student (2011-2014), Lead Programmer (2011-2014), Team Captain (2013-2014), Operator (2013), Drive Coach (2014), Mentor (2015-????)
'11 Philly Regional Finalists, '13 Chestnut Hill Finalists, '13 Lenape Champions, '13 Archimedes Division, '14 Chestnut Hill Champions, '14 Lenape Champions
FTC 7071 EngiNerds - Founding Advisor (2013-2014) | FRC 5420 Velocity - Founding Advisor (2015)
Grove City College Class of '18, Electrical/Computer Engineering (B.S.E.E)

Reply With Quote