|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Re: Encoder
My team uses jaguars, but the code might be similar. What language do you program in?
|
|
#2
|
|||
|
|||
|
Re: Encoder
java
|
|
#3
|
|||
|
|||
|
Re: Encoder
What our electrical team did was they wired optical encoders onto the axel and into the jag. Inside of the DriveTrain subsystem, I called a method on each of the jags to inform them that they have encoders. That portion of code looked like this:
Quote:
Quote:
I wouldn't know without looking at the javadocs, but if I were to make an educated guess I would say that setting up encoders would be similar to this but with talons instead of jaguars. |
|
#4
|
|||
|
|||
|
Re: Encoder
ok what kind of encoders did you get and how did you attach them.
|
|
#5
|
|||
|
|||
|
Re: Encoder
What do you plan to use the encoders for? Making sure both wheels turn at the same speed or are you using it for finding out how far you have driven?
|
|
#6
|
|||
|
|||
|
Re: Encoder
We used optical encoders, I'd have to ask the electrical folks for more details. I'm working on incorporating them into autonomous mode.
|
|
#7
|
|||
|
|||
|
Re: Encoder
both but mainly distance.
|
|
#8
|
|||
|
|||
|
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
}
|
|
#9
|
|||||
|
|||||
|
Re: Encoder
The encoders should be connected to DIOs, not PWM ports!
|
|
#10
|
||||
|
||||
|
Re: Encoder
Yes, I agree, that diagram can be misleading out of context. The "PWM" in the diagram refers to the use of PWM cable/connectors.
In context (i.e. on the web page where the diagram came from) it explicitly says to connect the cable to DIO ports. |
|
#11
|
|||
|
|||
|
Re: Encoder
is there any reason why i wouldnt get an accurate reading from the encoders?
|
|
#12
|
||||
|
||||
|
Re: Encoder
Quote:
|
|
#13
|
||||
|
||||
|
Re: Encoder
Quote:
We should have added encoders a while ago before bag & tag, but since we didn't we will be adding them during the 6-hour robot access period the week of our first district event. Currently our autonomous modes are based on a timer which isn't very accurate or predictable. |
|
#14
|
||||
|
||||
|
Re: Encoder
Quote:
|
|
#15
|
||||
|
||||
|
Re: Encoder
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|