Differents PID´s for differents velocities
Please Log in or Create an account to join the conversation.
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.
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.
Please Log in or Create an account to join the conversation.
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.
Please Log in or Create an account to join the conversation.
For sure is that the reason , 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.
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.
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.
When you figure it out, is it possible that you can consider what the manual page should say?Im trying to undestand how it works, but i´m lost.
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.
You need to use the axis.0.joint-vel-cmd pin: www.linuxcnc.org/docs/html/man/man9/motion.9.htmlHow can i link the velocity of the axis ( F value in G-code) to the lincurve.0.x-val
net x-vel axis.0.joint-vel-cmd => lincurve.0.in
net x-pgain lincurve.0.out-io => pid.0.Pgain
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 )
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.What i want to do is that Pgain get controlled by this equation:
Pgain ( F) = F/100 +5
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.
Please Log in or Create an account to join the conversation.
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.
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.