PID problem with 'D' in ver 2.5 & 2.5.1

More
21 Aug 2012 02:06 - 21 Aug 2012 02:06 #23455 by joekline9
From joekline9. Joe Kline 8/20/2012
Hello,
I am new to forum so I hope I am putting this post in the proper place.
I recently converted two large servo driven milling machines from my old DOS based system to Linuxcnc 2.5 and 2.5.1
I have a desktop mill for testing, It is running Linuxcnc 2.4.

in Linuxcnc ver 2.5 & 2.5.1 the D in pid is not working.
It was ok in 2.4 but in 2.5 it is very flakey.
I found the problem in the source code.
component pid.c Line 353 needs to be like line 309 in ver 2.4

ver 2.4
line 309
/* calculate derivative term */
*(pid->error_d) = (tmp1 - pid->prev_error) * periodrecip;
pid->prev_error = tmp1;
/* apply derivative limits */


ver 2.5
line 353
/* and calculate derivative term as difference of derivatives */
*(pid->error_d) = *(pid->commandv) - *(pid->feedbackv);
pid->prev_error = tmp1;
/* apply derivative limits */

Please inform me as to the correct way to rectify this problem.
Last edit: 21 Aug 2012 02:06 by joekline9.

Please Log in or Create an account to join the conversation.

More
21 Aug 2012 02:30 #23457 by PCW
Can you post your hal file?

Please Log in or Create an account to join the conversation.

More
21 Aug 2012 10:48 #23467 by BigJohnT
Here is the description of that commit

Wed, 27 Oct 2010 09:37:24 -0500 (09:37 -0500)
One problem frequently identified with pid is that the D term is
excessively noisy due to quantization (particularly of feedback position).

Introduce command-deriv and feedback-deriv pins. These can be connected
to some (hopefully superior) source of the derivative. For example, a
system with an analog tach signal in hal could use that value for
feedback-deriv. It also becomes easier to test different derivative
computation functions, such as explicit smoothing of the D term or
the five-point method mentioned on wikipedia
en.wikipedia.org/wiki/Numerical_differen...Higher_order_methods

Zero, one, or both of the -deriv pins may be connected. When a -deriv
pin is not connected, the related value input is computed by the
traditional two-point difference method. This means that when neither
pin is connected the behavior is the same as before (except for rounding
differences).


John

Please Log in or Create an account to join the conversation.

More
21 Aug 2012 11:12 #23468 by andypugh

When a -deriv pin is not connected, the related value input is computed by the traditional two-point difference method.

I seem to recall that Jepler did something a but cunning to work out if the pin was connected or not.
Perhaps that cleverness has been broken, or was never as clever as it looked?

Please Log in or Create an account to join the conversation.

More
21 Aug 2012 11:24 #23469 by BigJohnT
This is the diff... and it is beyond my level of cleverness.
-    /* calculate derivative term */
-    *(pid->error_d) = (tmp1 - pid->prev_error) * periodrecip;
+    /* compute command and feedback derivatives to dummysigs */
+    *(pid->commandvds) = (command - pid->prev_cmd) * periodrecip;
+    *(pid->feedbackvds) = (feedback - pid->prev_fb) * periodrecip;
+    /* and calculate derivative term as difference of derivatives */
+    *(pid->error_d) = *(pid->commandv) - *(pid->feedbackv);

John

Please Log in or Create an account to join the conversation.

More
21 Aug 2012 11:47 #23471 by andypugh
Some explanation here:
thread.gmane.org/gmane.linux.distributio...evel/3615/focus=3632

The derivative value calculated the old-fashioned way is written to a shared-memory address that he unconnected feedback-deriv pin was allocated when first created.
If that pin is netted to a signal in HAL then it will move to a different point in shared-memory. So the value will still be written to there, but not used.

Please Log in or Create an account to join the conversation.

More
21 Aug 2012 13:28 - 21 Aug 2012 13:30 #23474 by PCW
Can you please post your hal file?
Last edit: 21 Aug 2012 13:30 by PCW.

Please Log in or Create an account to join the conversation.

More
21 Aug 2012 13:52 #23476 by Todd Zuercher
I believe the reason someone asked for you to post your Hal file is because, if you used PNConf to configure yours, there is/was a bug that caused it not to connect the velocity feedback pin correctly, essentially canseling out the D term.

Please Log in or Create an account to join the conversation.

More
21 Aug 2012 13:57 - 21 Aug 2012 13:59 #23477 by PCW
Yes theres that and the fact I just verified that the PID comp works correctly with both connected and unconnected feedback-deriv, at least with my 2.5.1 setup and hal file
Last edit: 21 Aug 2012 13:59 by PCW.

Please Log in or Create an account to join the conversation.

More
21 Aug 2012 16:51 #23500 by joekline9
Here is one of my hal files. Originally created with pncconf in ver 2.5

File Attachment:

File Name: HTS_Hillyer.hal
File Size:16 KB
Attachments:

Please Log in or Create an account to join the conversation.

Time to create page: 0.090 seconds
Powered by Kunena Forum