Go to Post Someone Photoshopping Heidi...............now there's a switch! - Jay H 237 [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 26-01-2012, 20:36
msk msk is offline
Registered User
FRC #2177
 
Join Date: Jan 2009
Location: Minnesota
Posts: 4
msk is an unknown quantity at this point
speed adjustment with PID controllers

So we can properly adjust the speed of a motor using encoder feedback when everything except that one motor and its corresponding encoder and PIDController is commented out. We can get the left front motor and left back motor to work separately, but when we try to get them to work together, both motors alternate running full speed forward and full speed backward, no matter what the joystick input is.

How can we get both motors to work simultaneously with PID?

(Yes, I know it's strange to operate to operate two motors on the same side with two different joysticks, but we're just trying to test the encoders.)


public class Mechanum
{
SpeedController frontLeftMotor;
SpeedController rearLeftMotor;

private final Encoder frontLeft = new Encoder(6,7);
private final Encoder backLeft = new Encoder(8,9);

private final double Kp = 1.0;
private final double Ki = 0.0;
private final double Kd = 0.0;

private PIDController leftFrontPID;
private PIDController leftBackPID;

public Mechanum
{
frontLeftMotor = new Jaguar(1);
rearLeftMotor = new Jaguar(2);

frontLeft.setDistancePerPulse(0.067631);
backLeft.setDistancePerPulse(0.067631);

frontLeft.start();
backLeft.start();

frontLeft.setPIDSourceParameter(Encoder.PIDSourceP arameter.kRate); backLeft.setPIDSourceParameter(Encoder.PIDSourcePa rameter.kRate);

leftFrontPID = new PIDController(Kp, Ki, Kd, frontLeft, frontLeftMotor);
leftBackPID = new PIDController(Kp, Ki, Kd, backLeft, rearLeftMotor);

leftFrontPID.enable();
leftBackPID.enable();

leftFrontPID.setInputRange(-1.0, 1.0);
leftBackPID.setInputRange(-1.0, 1.0);

public void driveWithEncoders()
{
leftFrontPID.setSetpoint(rightStick.getY());
leftBackPID.setSetpoint(leftStick.getY());

}

}
}
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 22:22.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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