Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   PID Controller help (http://www.chiefdelphi.com/forums/showthread.php?t=139375)

josephno1 18-11-2015 20:24

PID Controller help
 
So I followed the example on here.

http://wpilib.screenstepslive.com/s/...rs-pid-control

So this is what I got so far.

The PID Controller is plugged in on PWM port 0 and AnalogInput 2

How do I call this in the Robot.java and what do I do next?
I am using IterativeRobot

Code:

import edu.wpi.first.wpilibj.command.PIDSubsystem;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.SpeedController;
import edu.wpi.first.wpilibj.AnalogInput;
import edu.wpi.first.wpilibj.*;
/**
 *
 */
public class PIDWheel extends PIDSubsystem {
        SpeedController motor = new Talon(0);
        AnalogInput pot = new AnalogInput(2);
       
    // Initialize your subsystem here
    public PIDWheel() {
            super("Wheel", 1.0, 0.0, 0.0);
            setAbsoluteTolerance(0.2);
            getPIDController().setContinuous(false);
            LiveWindow.addActuator("Wheel", "PIDSubsystem Controller", getPIDController());
        // Use these to get going:
        // setSetpoint() -  Sets where the PID controller should move the system
        //                  to
        // enable() - Enables the PID controller.
    }
   
    public void initDefaultCommand() {
        // Set the default command for a subsystem here.
        //setDefaultCommand(new MySpecialCommand());
    }
   
    protected double returnPIDInput() {
        // Return your input value for the PID loop
        // e.g. a sensor, like a potentiometer:
        // yourPot.getAverageVoltage() / kYourMaxVoltage;
            return pot.getAverageVoltage();
    }
   
    protected void usePIDOutput(double output) {
            motor.pidWrite(output);
        // Use output to drive your system, like a motor
        // e.g. yourMotor.set(output);
    }
}



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

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