Changing PID parameters on the fly.

More
29 Apr 2013 02:49 #33349 by mariusl
Hi All,
I would like to know if there is a way to change the PID parameters on the fly. I would like to select a parameter set from a drop down list and apply them to the PID parameters. Is this possible and if so, any ideas please?

Regards
Marius


www.bluearccnc.com

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

More
29 Apr 2013 06:40 #33357 by andypugh

I would like to know if there is a way to change the PID parameters on the fly.

If the PID parameters exist as entries in the INI file, and are then linked to the PID component in the HAL file, then the Machine->Calibration menu item can pick them up, and allows you to experiment with values. You can then, optonally, save the new values back to the INI.
If your values are hard-coded in the HAL file, then you can still change them on the fly from the command line, with
halcmd setp pid.0.Pgain 1024.5
You can also do the same thing from the Machine->Show Hal Configuration dialog. (but the command line is actually easier as you have tab-completion and up-arrow history)

I think the "Machine Calibration" menu option is what you want, though.

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

More
29 Apr 2013 13:18 #33363 by mariusl
Thanks Andy,
I want to let the operator choose from a drop down box. He wont know the PID settings but he will choose an option from which I must set the PID parameters to a pre-determined value.
The machine does not have a fixed mechanical X axis. The material is pulled through the machine and this is the X axis. Some pieces weigh as little as 20 kg and other as much as a ton. So the machine is not optimally tuned for all situations. I would like to change the PID settings to match at least a specific weight range.

So what I am really stuck wit is how to set the parameters to a value when the operator selects an option on the screen. If that makes sense?

Regards
Marius


www.bluearccnc.com

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

More
29 Apr 2013 19:03 #33381 by andypugh

I want to let the operator choose from a drop down box. He wont know the PID settings but he will choose an option from which I must set the PID parameters to a pre-determined value.


I think this requires a HAL module that I never finished.

In my day-job we often have situations like this. One PID controller I calibrate has so many other dependencies that the P term is derived by multiplying together the output of two 3D maps, and the I term is the product of three 3D maps.

What should suffice in your case is a simple curve extrapolator.

So, the operator can select the workpiece mass, and then the lookup table will select suitable P I and D terms.

I will have a look at how far along my HAL component got tonight, but you would have something like
loadrt lincurve count=3
...
setp lincurve.0.x1 0
setp lincurve.0.x2 20
setp lincurve.0.x3 100
....
setp lincurve.0.y1 30
setp lincurve.0.y2 20
...
setp lincurve.1.x1 0
...
...
net part-mass pyvcp.part-mass =>  lincurve.0.x-val 
net computed-P lincurve.0.out-rw =>  pid.0.Pgain

(the rw is because, incovenieniently, the Pgain pins are bidirectional, so the component probably needs to offer both conventional and rw outputs)

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

More
29 Apr 2013 20:00 #33390 by mariusl
Thanks Andy, looking forward to seeing your component.

Regards
Marius


www.bluearccnc.com

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

More
30 Apr 2013 06:16 - 30 Apr 2013 06:16 #33413 by andypugh

Thanks Andy, looking forward to seeing your component.


Here it is, do you know how to compile/install with comp?
component lincurve "one-dimensional lookup table";
description """Performs a 1-dimensional lookup and interpolation. The x-val
parameters must be monotonic, though identical adjacent values are allowed.
(for example 0,0,0,10) for a 4-element curve. For input x less than the lowest
xval the y-val of the lowest is returned. For x greater than the largest x-val 
the yval corresponding to x-max is returned (ie, no extrapolation is performed.
""";

param rw float y-val##[16 : personality] "output values";
param rw float x-val##[16 : personality] "input values";

pin in float x "The input value";
pin out float y "The output value";
pin io float y-rw "The output value, compatible with PID gains";

variable unsigned i = 0;

author "andy pugh";
license "GPL";

function _;

;;

FUNCTION(_){
    double f;
    if (x >= x_val(personality-1)) {
        y = y_val(personality-1);
        return;
    }
    if (x <= x_val(0)) {
        y = y_val(0);
        return;
    }
    while (x > x_val(i+1)) { i++;}
    while (x < (x_val(i))) { i--;}
    
    f = (x - x_val(i))/(x_val(i+1)-x_val(i));
    y = y_val(i) + f * (y_val(i+1) - y_val(i));
    y_rw = y;
}

The x and y axis values are actually parameters called things like lincurve.0.x-val00, lincurve.0.x-val01 and so on.

To load three instances, with 4 axis points each, use
loadrt lincurve count=3 personality=4,4,4
Attachments:
Last edit: 30 Apr 2013 06:16 by andypugh.

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

More
30 Apr 2013 12:22 #33424 by mariusl
Andy,
Wow magic stuff man. Yes I know how to handle components. Done a few myself. I tend to use components rather that Ladder Logic.
I will implement this into the machine design and test. It will take some time to complete but I will report back.
Thanks a lot for your support man.

Regards
Marius


www.bluearccnc.com

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

Time to create page: 0.174 seconds
Powered by Kunena Forum