Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   PID help (http://www.chiefdelphi.com/forums/showthread.php?t=135548)

Omnicide 03-07-2015 03:50 PM

PID help
 
I've been trying to get a PID working for our elevator and I've gotten no feedback at all (No error either)
My code for the PID is as follows:
Elevatorpid1 = new PIDController(1,1,1,potOne,elevating_motor1);
Elevatorpid1->SetInputRange(19,50);
Elevatorpid1->SetOutputRange(1,-1);
//Range is 1 to -1 because motor is inverted
Elevatorpid1->SetSetpoint(35);
Elevatorpid2 = new PIDController(1,1,1,potOne,elevating_motor2);
Elevatorpid2->SetInputRange(19,50);
Elevatorpid2->SetOutputRange(-1,1);
Elevatorpid2->SetSetpoint(35);

I use 2 different motors for the elevator, so I'm using 2 PIDControllers, which may be the wrong way. potOne is an AnalogInput (uses a potentiometer)
Later on in the code, I enable it with this:
Elevatorpid1->Enable();
Elevatorpid2->Enable();


the method Elevatorpid1->Get() always returns 0.000.
Where did I go wrong?

GeeTwo 03-07-2015 05:21 PM

Re: PID help
 
If, as it appears, you always use the same set point for both, you can either use two PIDcontrollers as you did, or create a virtual motor controller that actually sets both motor speeds from a single set() method. If these two motors are on the same gearbox and the controllers are set to coast, this second technique can also be used to reduce the size of the deadband; if below the usual deadband value, set one motor at zero and the other at twice the normally desired value.

At startup, assuming that the piece isn't moving, both I and D are zero, so the only way that get() should return zero is either if you are at the setpoint of 35, or if there is some sort of error/out of bounds issue.

If this is not the case, you should try printing the output of getError(), which will return the difference between the sensor output and the setpoint (35). If this value is not very close to zero, perhaps your tolerance is set too high. If it is zero or close to it, but your actuator is not in the correct speed/location, you should probably check the output values from the sensor; it may have gotten mechanically disconnected or otherwise always be reporting a number near 35.

Also, is 19 to 50 really the valid range of the potentiometer output? Out of context it seems peculiar, though perhaps it makes sense in your context.


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

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