Differents PID´s for differents velocities

More
10 Sep 2013 19:12 #38609 by casetero
Maybe something wrong with the personality of the variables or of the pins??

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

More
10 Sep 2013 19:15 #38610 by casetero
This is the lincurve.comp im trying to 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;
}

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

More
11 Sep 2013 00:35 - 11 Sep 2013 01:02 #38636 by andypugh

a, b = f.split("\n;;\n", 1)


I have a theory. I think that it is not finding the pattern \n;;\n because your file has been transferred via windows and has windows-style line endings.

I think that there is an option in gedit to change the line endings. Or deleting and retyping the three lines around the ;; might do the trick.

<EDIT>

I just tried passing a working file through Windows and that is exactly the effect I saw.

I would suggest that this counts as a bug in "comp". It could at least give a clearer error message.
Last edit: 11 Sep 2013 01:02 by andypugh.

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

More
11 Sep 2013 01:08 #38638 by andypugh
And the solution…..

Open the file in gedit, select "save as" and at the bottom of the save-as dialog there is an option to choose line-endings.
Select "Unix/Linux" and then OK, then "Yes" to over-write the existing file.

That looks like it should do the trick.
The following user(s) said Thank You: casetero

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

More
11 Sep 2013 01:55 #38640 by casetero
Hi,

For sure is that the reason :lol: , i didnt have internet in the computer of the machine, and downloaded it in windows.

This morning i linked a wifi usb to ubuntu so now i have internet in the computer of the machine, and can download the component directly in linux.

Tomorrow i will try.

Thank you very much Andy.

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

More
11 Sep 2013 13:51 #38654 by casetero
Hi,

You were right Andy.

I have just compiled and installed just downloading under linux.

Now i have to investigate how to use it. Any example??

Thank you.

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

More
11 Sep 2013 16:00 #38660 by casetero
Andy,

Im trying to undestand how it works, but i´m lost.

How can i link the velocity of the axis ( F value in G-code) to the lincurve.0.x-val ??

I suposse this is the parameter which i have to link to the F value.

What i want to do is that Pgain get controlled by this equation:

Pgain ( F) = F/100 +5

This means that:

when F (velocity of work of the axis) is 100, Pgain will be 6

when F is 200, Pgain will be 7

when F is 300, Pgain will be 8

....

Is the way to do it with lincurve??

Thank you.

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

More
11 Sep 2013 17:22 - 11 Sep 2013 17:23 #38665 by andypugh

Im trying to undestand how it works, but i´m lost.

When you figure it out, is it possible that you can consider what the manual page should say?
man lincurve (if you haven't already)
I think it is perfectly clear, but nobody else who has tried to use it has been able to make any sense of it.

How can i link the velocity of the axis ( F value in G-code) to the lincurve.0.x-val

You need to use the axis.0.joint-vel-cmd pin: www.linuxcnc.org/docs/html/man/man9/motion.9.html
net x-vel axis.0.joint-vel-cmd  => lincurve.0.in
Then link the pid gain to the output
net x-pgain lincurve.0.out-io => pid.0.Pgain
(I am not 100% certain where you are getting the lincurve.comp file from, the pin names don't seem to exactly match the code you had earlier.
To make 100% sure that you are using a compatible version of lincurve, use the file version here: git.linuxcnc.org/gitweb?p=linuxcnc.git;a...hb=refs/heads/master )

What i want to do is that Pgain get controlled by this equation:
Pgain ( F) = F/100 +5

lincurve can be seen as a graph, where you define the (x,y) coordinates and then the component picks a y for a supplied x.
I think that the axis velocity pin can go negative, and there is no hardship in assuming that it can.
So, we will use a 4-point graph and set it up for a Pgain of 5 from -6 to +6 mm/min and then 5X speed up to 600mm/min.
But, note that the values in HAL are mm/second so we need to use different x-axis values
loadrt lincurve count=4 personality=4,4,4
setp lincurve.0.x-val-00 -10.0
setp lincurve.0.x-val-01 -0.1
setp lincurve.0.x-val-02 +0.1
setp lincurve.0.x-val-03 +10.0

setp lincurve.0.y-val-00 11.0
setp lincurve.0.y-val-01 5.0
setp lincurve.0.y-val-02 5.0
setp lincurve.0.y-val-03 11.0

To get more finesse you might want to add more points. For a Z-axis you might want to make the curve non-symmetrical to compensate for the Z axis weight.
Halscope should be able to watch the lincurve.N.out pin (but not the out-rw pin) to allow you to monitor the output.
Last edit: 11 Sep 2013 17:23 by andypugh.
The following user(s) said Thank You: casetero

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

More
12 Sep 2013 18:17 #38692 by casetero
Hi Andy,

What a wonderfull component!

It works great.

Now i understand crearly the man page. My english is very poor, and my knowledge about linuxcnc is poor too. But maybe if you add and example like the one in this post in the man page would help to understand it. Indeed is very simple, but things like personality´s made me wrong to understood it.

I suposse that the correct thread to link is the same as the pid is linked to, am i wrong??

Lots of thanks to you!!

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

More
12 Sep 2013 18:51 #38694 by andypugh

I suposse that the correct thread to link is the same as the pid is linked to, am i wrong??


No, quite correct. It needs to go in the slow thread where floating-point maths is possible.
(And there is no need to have it in a fast thread, the required value will only change slowly)

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

Time to create page: 0.082 seconds
Powered by Kunena Forum