View Single Post
  #4   Spotlight this post!  
Unread 02-04-2012, 15:26
Jay Meldrum's Avatar
Jay Meldrum Jay Meldrum is offline
Registered User
FRC #0067 (H.O.T.)
Team Role: Engineer
 
Join Date: Jan 2012
Rookie Year: 2003
Location: Michigan
Posts: 42
Jay Meldrum has much to be proud ofJay Meldrum has much to be proud ofJay Meldrum has much to be proud ofJay Meldrum has much to be proud ofJay Meldrum has much to be proud ofJay Meldrum has much to be proud ofJay Meldrum has much to be proud ofJay Meldrum has much to be proud ofJay Meldrum has much to be proud of
Re: Encoder for Rpm help!

If you are using a digital I/O/PWM encoder here is an example of code.

(Note: we use pointers)

Code:
class BuiltinDefaultCode : public IterativeRobot
{
        
        //Declare Encoders
        Encoder *m_Encoder1;

public:

        BuiltinDefaultCode(void)
        {
                //Initialize encoders
                m_Encoder1 = new Encoder(1, 2, true);
                m_Encoder1 -> SetDistancePerPulse(1);
                m_Encoder1 -> SetMaxPeriod(1.0);
                m_Encoder1 -> Start();

                double m_Encoder1Distance;
                double m_Encoder1Rate;

		void TeleopSensorUpdater(void)
		{
			m_Encoder1Distance = m_Encoder1 -> GetDistance();  //Returns the amount of counts since the last reset
                        m_Encoder1Rate = m_Encoder1 -> GetRate();  //Returns the rate in pulses/second
		}
       }
}
__________________
2012-2015 - FRC 67 - Programming/Controls Lead Mentor
2003-2005 - FRC 857 - Driver

Check us out at http://www.hotteam67.org
Previous year design docs, programming tutorials, and more!

Last edited by Jay Meldrum : 02-04-2012 at 15:30.
Reply With Quote