Thread: Encoder
View Single Post
  #11   Spotlight this post!  
Unread 18-02-2015, 13:53
nickmcski nickmcski is offline
Registered User
AKA: Nicholas McCurry
FRC #1482 (Grandin Ghosts)
Team Role: Alumni
 
Join Date: Nov 2012
Rookie Year: 2012
Location: Canada
Posts: 112
nickmcski has a spectacular aura aboutnickmcski has a spectacular aura aboutnickmcski has a spectacular aura about
Re: Encoder

These are the encoders our team purchased http://www.andymark.com/product-p/am-0180.htm and they are working extremely well for us. One thing we want to try is wiring them directly up to our talons (You can only do this if you have the talon SRX's).

If you cant wire them up to the talons then wire them up to the roboRIO, our team accomplished this by cutting up 2 unneeded PWM cables. We wired the cables like so:


(This image is not mine, I just found it online)

Then we programmed them link this
Code:
	Encoder encoderleft; //Declare the encoders so they are accessible in all methods 
	Encoder encoderright;

	public void robotInit() {
		encoderleft = new Encoder(0, 1); //Initalize the encoder, A channel is plugged into DIO 0, B channel DIO 1.
		encoderright = new Encoder(2, 3);

		encoderleft.setDistancePerPulse(0.11); //did some math to calculate that for 1 pulse the robot moved 0.11 of an inch (Will be different for other robots) 
		encoderright.setDistancePerPulse(0.11);
	}

	public void autonomousPeriodic() {
		double distance = (encoderleft.getDistance() + encoderright.getDistance()) /2; //Find the distance robot has travled based off of the average of the 2 encoders. 
		


		//Code to make your robot move off of the encoder values here
	}
Reply With Quote