View unanswered posts | View active topics It is currently Sat Oct 25, 2014 12:03 pm






Reply to topic  [ 8 posts ] 
PID not working, sometimes. 
Author Message
Rookie

Joined: Sun Nov 16, 2008 3:07 pm
Posts: 45
Post PID not working, sometimes.
We are having trouble that PID is not working sometimes.

I strongly believe in some cases, the control is open loop, even though the checkboxes and Pragma says PID control should be on.

By some cases, I mean that when I downloaded the program the first time after enabling PID, it worked great. Then I changed some stuff and downloaded again, and now the motor doesn't move with a
motor[x] = 10;
command.

If I change it to
motor[x] = 30;
it moves.

I believe this adjustment of power value to get it to move is exactly what we should expect when the PID box is checked for the motor (and sometimes I get that).

The kids at school first reported this on Friday, and I dismissed it as sun spots or bad hands or something, but on a totally different robot and computer and NXT, it is happening to me today and since it is dark, it can't be sun spots, and my hands are just fine.

Any thoughts?

Here is the program, and motorFork is the offending one.
(note only one channel on that controller is in use).
2.26 Beta.

#pragma config(Hubs, S1, HTMotor, HTMotor, none, none)
#pragma config(Motor, motorA, motorConveyTread, tmotorNormal, PIDControl, encoder)
#pragma config(Motor, motorB, motorConveyWheel, tmotorNormal, PIDControl, encoder)
#pragma config(Motor, mtr_S1_C1_1, motorRight, tmotorNormal, openLoop)
#pragma config(Motor, mtr_S1_C1_2, motorLeft, tmotorNormal, openLoop, reversed)
#pragma config(Motor, mtr_S1_C2_1, motorF, tmotorNormal, openLoop)
#pragma config(Motor, mtr_S1_C2_2, motorFork, tmotorNormal, PIDControl, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#include "joystickdriver.c"

task main()
{
while (true)
{
getJoystickSettings(joystick);

if (joy1Btn(4))
{
// forklift up
motor[motorFork] = 30;

}
else if (joy1Btn(2))
{
// forklift down
motor[motorFork] = -10;
}
else
{
// forklift off
motor[motorFork] = 0;
}

if (joy1Btn(3))
{
// conveyer in
motor[motorConveyTread] = 30;
motor[motorConveyWheel] = 30;
}
else if (joy1Btn(1))
{
// conveyer out
motor[motorConveyTread] = -30;
motor[motorConveyWheel] = -30;
}
else
{
// conveyer off
motor[motorConveyTread] = 0;
motor[motorConveyWheel] = 0;
}

// tank style steering (yuck, but easier to code)
if (joystick.joy1_y1 < 15 && joystick.joy1_y1 > -15)
{
// practically off. hold still
motor[motorLeft] = 0;
}
else
{
motor[motorLeft] = joystick.joy1_y1/2;
}

if (joystick.joy1_y2 < 15 && joystick.joy1_y2 > -15)
{
// practically off. hold still
motor[motorRight] = 0;
}
else
{
motor[motorRight] = joystick.joy1_y2/2;
}

wait1Msec(10);
}
}


Sun Jan 09, 2011 11:44 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: PID not working, sometimes.
We don't use the built-in PID. We have our own PID library. However I can share my experience on PID programming. My experience told me that anything below 30% power may not reliably start a motor moving depending on the load on the motors. Also, if you are almost to your target, the PID error is small, the resulting PID output will be small enough that the motor may stop moving causing it to have a "steady state error" (i.e. never quite reach the target). This could be compensated with a non-zero Ki (integral term of PID). The error will be integrated in time to boost the output power.
In short, I don't recommend applying motor power below 30%.


Sun Jan 09, 2011 11:58 pm
Profile
Rookie

Joined: Sun Nov 16, 2008 3:07 pm
Posts: 45
Post Re: PID not working, sometimes.
hmmm.

Do you think kI might be 0 in the built in motor control PID? That would certainly explain what we are seeing when it doesn't work, although doesn't explain why it worked sometimes and not others. (i.e. worked great, controlling accurately to speed, vs. not moving at all, just making a groaning noise).

Is there a way to find out what the PID parameters are that are in play? Does RobotC always set them the same in the HiTechnic controller?

It really feels like the NXT neglected to tell the HiTechnic controller to close the loop.


Mon Jan 10, 2011 2:26 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: PID not working, sometimes.
The built-in PID is opaque to us. We don't understand it. That's why we did our own PID so we can tune our own PID constants.


Mon Jan 10, 2011 3:19 pm
Profile
Rookie

Joined: Wed Feb 24, 2010 11:43 pm
Posts: 34
Post Re: PID not working, sometimes.
This is the same problem that we reported in a different thread (http://www.robotc.net/forums/viewtopic.php?f=52&t=2868)

The problem is almost certainly that you are shutting off the 12V between downloads. Basically, here's what we've figured out: the built in PID is stored in the HiTechnic controllers. PID is only enabled if it is enabled in the program that initializes the controllers. That initialization is lost if the 12V goes off. But, the communication board in the HiTechnic controller doesn't report a loss of the 12V as a reset required to the NXT, and thus the PID is not re-initialized when power is recovered.

I also would not be surprised to find out that this is a big cause of the problems that have been reported with Samantha. If 12V is dropped momentarily, or the I2C link is broken momentarily, and the program is active, the controllers do not always seem to recover communication to the NXT. Thus, the controllers keep doing the last thing they were told...

Our solution is to make SURE that all connections are as good as they can be, and to ALWAYS make sure that if the 12V gets turned off (even if just for a reset), that the NXT gets rebooted as well.

It is not a good solution, but the fix really probably needs to be a combination of HiTechnic updating their firmware and RobotC handling the loss of I2C and subsequent recovery a bit better.


Tue Jan 11, 2011 7:38 pm
Profile
Rookie

Joined: Sun Nov 16, 2008 3:07 pm
Posts: 45
Post Re: PID not working, sometimes.
OK,
I think you are on to something here.

PID Working
Power Off 12V
Power On 12V
PID No Working
Stop Program
Start Program
PID No Working

Power off NXT
Power On NXT

Start program again.

PID Working.

Your question in the other thread seems pertinent: Can we force a send of the I2C messages to set up the Motor Controllers again, since it seems to get skipped in some cases?
(and why doesn't it happen at the beginning of the program?).


Thu Jan 20, 2011 9:26 pm
Profile
Rookie

Joined: Sun Dec 05, 2010 11:58 am
Posts: 28
Post Re: PID not working, sometimes.
MHTS wrote:
The built-in PID is opaque to us. We don't understand it. That's why we did our own PID so we can tune our own PID constants.

The built in PID operates on the motor controllers themselves, whereas any PID you make would run on the NXT.
Wouldn't this give you a much slower response time?


Wed Mar 02, 2011 9:33 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3227
Location: Rotterdam, The Netherlands
Post Re: PID not working, sometimes.
Nah, not necessarily. The built-in PID only regulates every 25ms or so, so plenty of time for that to be done on the NXT.

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Thu Mar 03, 2011 3:09 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.