Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Coding a am-2816a motor encoder. (http://www.chiefdelphi.com/forums/showthread.php?t=143881)

FireAmpersand 02-15-2016 12:51 AM

Coding a am-2816a motor encoder.
 
Hi there. We want to use a encoder for our lifting motor on our robot and can't seem to figure it out. First off is the wires go back to the roboRIO or straight to the Talon srx (CAN). Secondly, how to we code it up so we get sensor feed back from the motor. Thanks in advance.

TimTheGreat 02-15-2016 01:36 AM

Re: Coding a am-2816a motor encoder.
 
Quote:

Originally Posted by FireAmpersand (Post 1540426)
First off is the wires go back to the roboRIO or straight to the Talon srx (CAN).

So the wires go to a talon Encoder Breakout board. You can find the wiring specifications on the andymark encoder description page.

In code, change the control mode of the motor
Code:

motor.changeControlMode(CANTalon.TalonControlMode.Position)
To get the sensor feedback you can view it in networktables by adding
Code:

motor.get()
and to set the motor to a certain encoder position

Code:

motor.set(int encValue)

FireAmpersand 02-15-2016 01:38 AM

Re: Coding a am-2816a motor encoder.
 
Sweet. And this follows PID control, correct?

FireAmpersand 02-15-2016 01:41 AM

Re: Coding a am-2816a motor encoder.
 
Also is the board needed, or can we go straight to the srx's pinout?

GeeTwo 02-15-2016 02:04 AM

Re: Coding a am-2816a motor encoder.
 
Quote:

Originally Posted by FireAmpersand (Post 1540445)
Also is the board needed, or can we go straight to the srx's pinout?

It is theoretically possible to go straight back to the SRX's pinout, but because of the fine pitch of those pins, it is preferable for most teams to use the breakout to get to a pin pitch solderable by regular humans.

FireAmpersand 02-15-2016 02:43 AM

Re: Coding a am-2816a motor encoder.
 
Ok thats good too know, its just that its week 6 and we don't want to wait on shipping

TimTheGreat 02-15-2016 10:16 AM

Re: Coding a am-2816a motor encoder.
 
Quote:

Originally Posted by FireAmpersand (Post 1540444)
Sweet. And this follows PID control, correct?

Yes. I forgot earlier but I think you have to set the PID before the motor will work. Generally only P is needed, but if it doesn't work too well increase I very very slightly (start at .002)

Code:

motor.setPID(P, I, D)

CyberTeam5713 02-15-2016 04:32 PM

Please Help
 
Down below is my code and we want the robot to drive with arcade with a xbox controller also plz help me to get it to turn. And we are using the standard wheels on the robot



package org.usfirst.frc.team5713.robot;

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Talon;



public class Robot extends IterativeRobot {
RobotDrive drive = new RobotDrive(1,2,3,4);
Joystick driveStick = new Joystick(0);
Joystick controlStick = new Joystick(1);
Talon frontLeft = new Talon(1);
Talon rearLeft = new Talon(2);
Talon frontRight = new Talon(3);
Talon rearRight = new Talon(4);

public void robotInit() {
drive = new RobotDrive(1,2,3,4);
driveStick = new Joystick(0);
controlStick = new Joystick(1);
frontLeft = new Talon(1);
frontLeft.enableDeadbandElimination(true);
frontLeft.set(+1.0);
rearLeft = new Talon(2);
rearLeft.enableDeadbandElimination(true);
rearLeft.set(-1.0);
frontRight = new Talon(3);
frontRight.enableDeadbandElimination(true);
frontRight.set(+1.0);
rearRight = new Talon(4);
rearRight.enableDeadbandElimination(true);
rearRight.set(-1.0);

public void teleopInit(){
drive = new RobotDrive(1,2,3,4);
driveStick = new Joystick(0);
controlStick = new Joystick(1);
frontLeft = new Talon(1);
frontLeft.enableDeadbandElimination(true);
frontLeft.set(-1.0);
rearLeft = new Talon(2);
rearLeft.enableDeadbandElimination(true);
rearLeft.set(+1.0);
frontRight = new Talon(3);
frontRight.enableDeadbandElimination(true);
frontRight.set(-1.0);
rearRight = new Talon(4);
rearRight.enableDeadbandElimination(true);
rearRight.set(+1.0);

}




public void teleopPeriodic() {
while (isOperatorControl() && isEnabled()) {
drive.setSafetyEnabled(true);


double joystickLeftY = driveStick.getRawAxis(2);
double joystickLeftX = driveStick.getRawAxis(1);
drive.arcadeDrive(joystickLeftY, joystickLeftX, true);
Timer.delay(0.01); } }

also our team is using standard wheels and we have the middle wheel and back wheel connected to drive train and the middle wheel has two motors and the same applies to the other middle wheel. for going forward and backward can someone plz help

TimTheGreat 02-15-2016 05:06 PM

Re: Please Help
 
Quote:

Originally Posted by CyberTeam5713 (Post 1540726)

Code:

package org.usfirst.frc.team5713.robot;

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.Talon;



public class Robot extends IterativeRobot {
RobotDrive drive;
Joystick driveStick;
Joystick controlStick;

public void robotInit() {

Talon frontLeft = new Talon(1);
Talon rearLeft = new Talon(2);
Talon frontRight = new Talon(3);
Talon rearRight = new Talon(4);
drive = new RobotDrive(1,2,3,4);
driveStick = new Joystick(0);
controlStick = new Joystick(1);

public void teleopInit(){
}

public void teleopPeriodic() {
drive.setSafetyEnabled(true);


double joystickLeftY = driveStick.getRawAxis(2);
double joystickLeftX = driveStick.getRawAxis(1);
drive.arcadeDrive(joystickLeftY, joystickLeftX, true); }


This should work.

CyberTeam5713 02-15-2016 05:13 PM

TimTheGreat
 
Thank You


All times are GMT -5. The time now is 08:02 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi