Find components source code.
06 Mar 2018 13:24 #107032
by Patrik T
Find components source code. was created by Patrik T
Hi
I want to set the limit2 components maxv parameter as a pin. If I find the source I can just change the parameter to a pin and save the work of making a component from scratch. I have searched but my Google fu is inadequate to this task. Could someone tell me how to find the components source code.
Thanks
I want to set the limit2 components maxv parameter as a pin. If I find the source I can just change the parameter to a pin and save the work of making a component from scratch. I have searched but my Google fu is inadequate to this task. Could someone tell me how to find the components source code.
Thanks
Please Log in or Create an account to join the conversation.
06 Mar 2018 13:53 #107033
by andypugh
Replied by andypugh on topic Find components source code.
The comps are in src/hal/components
github.com/LinuxCNC/linuxcnc/blob/master...mponents/limit2.comp
And the maxv _is_ a pin, at least in Master, so you could just
sudo halcompile --install limit2.comp
with that file.
github.com/LinuxCNC/linuxcnc/blob/master...mponents/limit2.comp
And the maxv _is_ a pin, at least in Master, so you could just
sudo halcompile --install limit2.comp
with that file.
The following user(s) said Thank You: Patrik T
Please Log in or Create an account to join the conversation.
09 Mar 2018 20:41 #107172
by Patrik T
Replied by Patrik T on topic Find components source code.
Thanks, I do not use Master. I do not know what the advantages of Master are.
The limit2 code did not compile immediately so i modified it to this:
The limit2 code did not compile immediately so i modified it to this:
component mylimit2;
pin in float in;
pin out float out;
pin in float min = -1e20;
pin in float max = 1e20;
pin in float maxv = 1e20;
param rw float threadfreq = 1000.0f;
///////////////////////////////////////////////////////////////7
function _;
license "GPL"; // indicates GPL v2 or later
;;
///////////////////////////////////////////////////////////////
double old_out = 0.0f;
#ifndef clamp
static inline double clamp(double v, double sub, double sup) {
if(v < sub) return sub;
if(v > sup) return sup;
return v;
}
#endif
///////////////////////////////////////////////////////////////
FUNCTION(_)
{
double tmp = in;
double maxdelta = maxv / threadfreq;
tmp = clamp(tmp, old_out - maxdelta, old_out + maxdelta);
tmp = clamp(tmp, min, max);
old_out = tmp;
out = tmp;
}
Please Log in or Create an account to join the conversation.
Time to create page: 0.058 seconds