Go to Post As guests in the city, we should make an effort to do some fundraising for the folks affected by the storm. Any ideas out there? - Jon236 [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 07-03-2015, 15:50
Omnicide Omnicide is offline
Registered User
FRC #1086
 
Join Date: Mar 2015
Location: Richmond, VA
Posts: 2
Omnicide is an unknown quantity at this point
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?
Reply With Quote
  #2   Spotlight this post!  
Unread 07-03-2015, 17:21
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,495
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
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.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
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 10:05.

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