View unanswered posts | View active topics It is currently Fri Apr 18, 2014 5:07 pm






Reply to topic  [ 4 posts ] 
No more "nPidUpdateInterval" in public RC2? 
Author Message
Rookie

Joined: Wed Jul 23, 2008 12:48 am
Posts: 19
Location: Germany
Post No more "nPidUpdateInterval" in public RC2?
I just updated to the latest version of RobotC (public RC2). Now, my formerly working code generates:

Quote:
**Error**:Undefined variable 'nPidUpdateInterval'. 'short' assumed.


At the line which includes the code:

Code:
nPidUpdateInterval = 10;


The variable can still be found in the pre-constructs at the left as well as in the help. Is this a bug or was it removed intentionally (just like the tMotor thing)?


Fri Aug 08, 2008 1:38 pm
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post Re: No more "nPidUpdateInterval" in public RC2?
The field is still there, but I believe has been renamed to xxxx.

But you should be aware of the following:
  • THe PID algorithms -- i.e. the PID constants -- were tuned to improve the PID performance. Motion is less jerky.
  • There's a nifty little sample program included to demonstate this. It's in the samples folder and has a name like "motor consistentcy". It draws a graph on the NXT LCD screen showing the movement of the motor vs time. You should also use this with the "NXT devices" debugger display which shows the "instantaneous" (or actual) power applied to the motors to obtain the PID managed speed.
  • If you're playing with the PID interval, you may also be interested in the "NXT devices" display -- with the "MORE" option clicked -- because it allows writing new values to the PID weighting factors. THese are not permanent changes, the factors are reset to default settings every time a new program is started. The capability was added primarily for the initial development and tuning of the PID algorithms.
  • There was a general cleanup of the ROBOTC user interface and the "PID interval" variable got moved into the new (and undocumented) "Super User" menu level. This is why it's not in the built-in documentation. It's a little tricky to get into "Super :downloading: User" menu level because it is not normally visible in the "Select User Level" menu. You have to select a check box in the "Preferences" setup to make the command visible; I think the check box is in the "Internal" tab. Once this check box is selected and you're already in "Expert mode" then the "Super User" selection will be visible.
  • The actual variable for the interval was renamed because there are now two variables for selecting the PID update interval. One is for the NXT motors. The second is for the new FTC motors that are connected via a HiTechnic motor controller. This is for the new FIRST FTC competition. The FTC motors needed a different update intervale because they have different characteristics and, more importantly, sit behind an I2C bus that is relatively slow to read/write to obtain encoders settings and set power.

Hope above has explained what's happened and how this came about.

But more importantly, I don't expect many users will want or should change the update interval. By default it is set to 25 milliseconds. [This is four times faster than the 100 milliseconds used in NXT-G firmware]. The PID factors are tuned for this setting. If the interval is changed, then the PID factors would also need to be adjusted.

ROBOTC firmware uses the PID interval variable to adjust for speed regulation. When moving to a specific target encoder position and the motor is close to the position, then ROBOTC firmware switches to a faster, and non-user modifyable, update rate.


Sun Aug 10, 2008 2:00 am
Profile
Rookie

Joined: Wed Jul 23, 2008 12:48 am
Posts: 19
Location: Germany
Post Re: No more "nPidUpdateInterval" in public RC2?
Thanks for the answer. This gives completely new insights into RobotC for me. Very interesting. I was using PidUpdateInterval because the motors run were very jerky when using low motor power such as 20%. There was also a topic around this forum, where this issue was discussed. In fact, when using the original NXT-G firmware I don't discover this jerkiness (at least not that much), so I was believing NXT-G is using a shorter interval anyway. I am wondering, what might cause this difference if the interval in NXT-G is really even four times longer?


Mon Aug 11, 2008 2:13 am
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post Re: No more "nPidUpdateInterval" in public RC2?
The jerkiness was related to the initial selection of the PID "factors". The PID "factors" are the constants that are multiplied by each of the P, I and D "errors" to determine the new power level. "P, I and D" and "Proportional, Integral and Derivative". They adjust the "sensitivity" of the motor speed control.

I encourage you to look at the sample program "NXT Motor Consistentcy vs Time V2" in the "Motors" sample folder. You don't need to understand the logic other than to adjust the motor that is being monitored. Also open the "NXT Devices" debugger window which has a column labelled "Speed" and a column labelled "PID"; "Speed" is the setting you've applioed. "PID" is the power level calculated by the PID algorithm to maintain this speed.

When you run the sample program, the NXT LCD display contains a histogram showing the instantaneous speed movement. It is almost a straight horizontal line with very ittle movement. In eariler versions, the histogram showed the "jerky" movement you've mentioned. Watching the "PID" column you can see the adjustments that are made to keep this constant speed.

If you apply some friction to the motor being moved, you can see the values in the "PID" column jump up as higher power level is used to maintain the constant speed.


Mon Aug 11, 2008 7:13 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 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.