Go to Post There are two types of team members and mentors: Those who want to be FIRST, and those who want to be first. - Tetraman [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rating: Thread Rating: 30 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 16-02-2015, 18:47
seraine seraine is offline
Registered User
FRC #4693
 
Join Date: Sep 2013
Location: Minnesota
Posts: 4
seraine is an unknown quantity at this point
Using a rangefinder and a PID controller with a lift (Java)

We are attempting to use a rangefinder and a PIDController to set the height of our lift. Our lift has a winch that is only able to lift the elevator, and relies on gravity to pull the elevator down. When I currently test the code, I set the pidController to values between 0.1134 volts and 0.6048 volts, which correspond to ranges between 12 and 64 inches. These values have been verified by printing both the inches and volts output from the rangefinder.

If I set the PID controller to 0.1 volts, the winch spins in the wrong direction at a slow speed, and it slowly unspools the cable. If I set it to 0.2 volts, it also unspools in the wrong direction, just faster. As I increase the PID controller voltage setpoint, the speed it unspools increases.

What the controller should do is raise until the setpoint matches the voltage, and then maintain position, but it only unspools the wire at various speeds.

Does anyone have any idea what my problem is? Here is the code:

Code:
public class Robot extends IterativeRobot {

  Victor elevatorMotor;
  AnalogInput rangefinder;
  Joystick right;
  PIDController elevatorControl;

  double elevatorPoint = 0;

  public void robotInit() {
    
    elevatorMotor = new Victor(4);
    rangefinder = new AnalogInput(0);
    right = new Joystick(1);
    elevatorControl = new PIDController(0.5, 0.001, 0, rangefinder, elevatorMotor);
    elevatorControl.enable();

  }

  public void teleopPeriodic() {

    double range = (rangefinder.getVoltage()) / 0.00945;
    double volts = rangefinder.getVoltage();

    if (right.getRawButton(6) == true) {
      elevatorPoint = 0.1134;
    } else if (right.getRawButton(7) == true) {
      elevatorPoint = 0.2268;
    } else if (right.getRawButton(8) == true) {
       elevatorPoint = 0.3402;
    } else if (right.getRawButton(9) == true) {
       elevatorPoint = 0.4536;
    } else if (right.getRawButton(10) == true) { 
       elevatorPoint = 0.5670;
    } else if (right.getRawButton(11) == true) {
       elevatorPoint = 0.6048;
    }

    elevatorControl.setSetPoint(elevatorControl);

    Timer.delay(0.01);

  }

}
 


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 01:48.

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