Go to Post This game is absolutely *NOT* too difficult, but many teams will make it too difficult by biting off more than they can chew. - pfreivald [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 03-03-2011, 21:12
BigJ BigJ is offline
Registered User
AKA: Josh P.
FRC #1675 (Ultimate Protection Squad)
Team Role: Engineer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Milwaukee, WI
Posts: 945
BigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond repute
Rate-based PID feedback using PIDController and Encoder

Hi, our team is working on a PID feedback loop for our motors. Every example of code I could find was for distance-based PID feedback and we want to go off the rate of our encoders to modify the motor speed.

Here's an example of the code I've been trying. We use IterativeRobot.

In the constructor:

Code:
m_testEnc = new Encoder(ENC_A_CHANNEL, ENC_B_CHANNEL);
m_testEnc->SetPIDSourceParameter(Encoder::kRate);
m_testJag = new Jaguar(MOTOR_CHANNEL);
m_testPIDController = new PIDController(0.1, 0.1, 0.1, m_testEnc, m_testJag);
m_testEnc->SetDistancePerPulse(.00005);
m_testEnc->Start();
m_testPIDController->Enable();
EDIT: All variables are declared previously, all-caps variables are #defined.


In AutonomousPeriodic:


Code:
m_testPIDController->SetSetpoint(0.5);

SetDistancePerPulse is a dummy number, this is a motor on a piece of wood. We put it in there because it looked like the encoder rate needed it for some reason. The desired function of the code was to approach 0.5 motor speed and use PID feedback to stick there.

Here's what we've done so far:

Our initial assumption was that the PID loop would go off the rate of the encoder, and we were pleased to find that it was actually sending a motor value. However, the motor value went up straight past 0.5, and the error on the PIDController was only changed by the encoder rate changing. I tried setting the Setpoint in terms of the rate but that didn't work out at all. I'm confused as to what we're actually suposed to set the setpoint in terms of. I switched it back to 0.5 (half motor speed) and thought that the reason the value surpassed the value and kept going up was from one of the P, I, or D constants. I set I and D to zero, and then the value didn't change at all from loop to loop. I set only I to zero and the value still didn't change at all.

Any input, CD? At this point the only problem I can think of is from the SetDistancePerPulse dummy, even though we are using rate and not distance.

Thanks.

Last edited by BigJ : 03-03-2011 at 21:59.
Reply With Quote
  #2   Spotlight this post!  
Unread 05-03-2011, 19:06
BigJ BigJ is offline
Registered User
AKA: Josh P.
FRC #1675 (Ultimate Protection Squad)
Team Role: Engineer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Milwaukee, WI
Posts: 945
BigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond repute
Re: Rate-based PID feedback using PIDController and Encoder

We fixed our problem. We figured out that we needed GetRate to be -1.0 to 1.0 based on our desired max speed, so the DistancePerPulse was set to a number that made GetRate equal to 1.0 at our desired maximum motor speed.
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 13:32.

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