Find components source code.

More
06 Mar 2018 13:24 #107032 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

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

More
06 Mar 2018 13:53 #107033 by andypugh
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.
The following user(s) said Thank You: Patrik T

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

More
09 Mar 2018 20:41 #107172 by Patrik T
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:
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.171 seconds
Powered by Kunena Forum