Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
310 changes: 155 additions & 155 deletions src/hal/components/carousel.comp

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions src/hal/components/corexy_by_hal.comp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// Based on a forum posting by nbremond
component corexy_by_hal "CoreXY kinematics";

pin in float alpha_fb"typ: feedback from alpha motor controller";
pin in float beta_fb "typ: feedback from beta motor controller";
pin in real alpha_fb"typ: feedback from alpha motor controller";
pin in real beta_fb "typ: feedback from beta motor controller";

pin in float j0_motor_pos_cmd"typ: from joint.0.motor-pos-cmd";
pin in float j1_motor_pos_cmd"typ: from joint.1.motor-pos-cmd";
pin in real j0_motor_pos_cmd"typ: from joint.0.motor-pos-cmd";
pin in real j1_motor_pos_cmd"typ: from joint.1.motor-pos-cmd";

pin out float j0_motor_pos_fb"typ: to joint.0.motor-pos-fb";
pin out float j1_motor_pos_fb"typ: to joint.1.motor-pos-fb";
pin out real j0_motor_pos_fb"typ: to joint.0.motor-pos-fb";
pin out real j1_motor_pos_fb"typ: to joint.1.motor-pos-fb";

pin out float alpha_cmd"typ: command to alpha motor";
pin out float beta_cmd "typ: command to beta ts motor";
pin out real alpha_cmd"typ: command to alpha motor";
pin out real beta_cmd "typ: command to beta ts motor";

function _;
description """
Expand Down Expand Up @@ -57,10 +57,10 @@ author "Dewey Garrett based on forum post from nbremond";
FUNCTION(_) {

// forward kinematics (j0==x,j1==y from motor positions):
j0_motor_pos_fb = alpha_fb + beta_fb;
j1_motor_pos_fb = alpha_fb - beta_fb;
j0_motor_pos_fb_set(alpha_fb + beta_fb);
j1_motor_pos_fb_set(alpha_fb - beta_fb);

// inverse kinematics (motor positions from j0==x,j1==y):
alpha_cmd = 0.5*(j0_motor_pos_cmd + j1_motor_pos_cmd);
beta_cmd = 0.5*(j0_motor_pos_cmd - j1_motor_pos_cmd);
alpha_cmd_set(0.5*(j0_motor_pos_cmd + j1_motor_pos_cmd));
beta_cmd_set(0.5*(j0_motor_pos_cmd - j1_motor_pos_cmd));
}
24 changes: 12 additions & 12 deletions src/hal/components/differential.comp
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@

component differential "kinematics for a differential transmission";

pin in float roll-cmd "position command for roll (in degrees)";
pin in float pitch-cmd "position command for pitch (in degrees)";
pin in real roll-cmd "position command for roll (in degrees)";
pin in real pitch-cmd "position command for pitch (in degrees)";

pin out float roll-fb "position feedback for roll (in degrees)";
pin out float pitch-fb "position feedback for pitch (in degrees)";
pin out real roll-fb "position feedback for roll (in degrees)";
pin out real pitch-fb "position feedback for pitch (in degrees)";

pin out float motor0-cmd "position command to motor0 (based on roll & pitch inputs)";
pin out float motor1-cmd "position command to motor1 (based on roll & pitch inputs)";
pin out real motor0-cmd "position command to motor0 (based on roll & pitch inputs)";
pin out real motor1-cmd "position command to motor1 (based on roll & pitch inputs)";

pin in float motor0-fb "position feedback from motor0";
pin in float motor1-fb "position feedback from motor1";
pin in real motor0-fb "position feedback from motor0";
pin in real motor1-fb "position feedback from motor1";

option period no;
function _;
Expand All @@ -37,9 +37,9 @@ author "Sebastian Kuzminsky";
;;

FUNCTION(_) {
motor0_cmd = roll_cmd + pitch_cmd;
motor1_cmd = roll_cmd - pitch_cmd;
motor0_cmd_set(roll_cmd + pitch_cmd);
motor1_cmd_set(roll_cmd - pitch_cmd);

roll_fb = (motor0_fb + motor1_fb)/2;
pitch_fb = (motor0_fb - motor1_fb)/2;
roll_fb_set((motor0_fb + motor1_fb)/2);
pitch_fb_set((motor0_fb - motor1_fb)/2);
}
42 changes: 21 additions & 21 deletions src/hal/components/gantry.comp
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
******************************************************************************/

component gantry "LinuxCNC HAL component for driving multiple joints from a single axis.";
pin out float joint.##.pos-cmd [7 : personality] "Per-joint commanded position";
pin in float joint.##.pos-fb [7 : personality] "Per-joint position feedback";
pin in bit joint.##.home [7 : personality] "Per-joint home switch";
pin out float joint.##.offset [7 : personality] "(debugging) Per-joint offset value, updated when homing.";
pin in float position-cmd "Commanded position from motion";
pin out float position-fb "Position feedback to motion";
pin out bit home "Combined home signal, true if all joint home inputs are true.";
pin out bit limit "Combined limit signal, true if any joint home input is true.";
pin in float search-vel "HOME_SEARCH_VEL from INI file";
pin out real joint.##.pos-cmd [7 : personality] "Per-joint commanded position";
pin in real joint.##.pos-fb [7 : personality] "Per-joint position feedback";
pin in bool joint.##.home [7 : personality] "Per-joint home switch";
pin out real joint.##.offset [7 : personality] "(debugging) Per-joint offset value, updated when homing.";
pin in real position-cmd "Commanded position from motion";
pin out real position-fb "Position feedback to motion";
pin out bool home "Combined home signal, true if all joint home inputs are true.";
pin out bool limit "Combined limit signal, true if any joint home input is true.";
pin in real search-vel "HOME_SEARCH_VEL from INI file";
function read "Update position-fb and home/limit outputs based on joint values.";
function write "Update joint pos-cmd outputs based on position-cmd in.";
description """
Expand Down Expand Up @@ -81,38 +81,38 @@ When a joint home switch trips, the commanded velocity will drop immediately fro
license "GPL";
author "Charles Steinkuehler";
option period no;
variable float offset[7] = 0.0;
variable float prev_cmd = 0.0;
variable rtapi_real offset[7] = 0.0;
variable rtapi_real prev_cmd = 0.0;
variable int fb_joint = 0;
variable int latching = 0;
;;
FUNCTION(read) {
int i=1;

// First (or only) joint
home=joint_home(0);
limit=joint_home(0);
home_set(joint_home(0));
limit_set(joint_home(0));

// All other joints, if configured
while (i < personality) {
// Check to see if machine is in latching state
if(latching==0)
{
// Don't assert home until all joints hit their home switches
home &= joint_home(i);
home_set(home && joint_home(i));
}
else
{
// Don't release home until all joints have backed off their
// home switches
home |= joint_home(i);
home_set(home || joint_home(i));
}

// Remember the home state for next time
latching=home;

// Limit is always asserted if any home switch is asserted
limit |= joint_home(i);
limit_set(limit || joint_home(i));
i++;
}

Expand All @@ -123,19 +123,19 @@ FUNCTION(read) {
if ((joint_home(fb_joint) == 1) && (home == 0)) {
for (i=0; i < personality; i++) {
if (joint_home(i) == 0) {
position_fb = joint_pos_fb(i) + offset[i];
position_fb_set(joint_pos_fb(i) + offset[i]);
fb_joint = i;
break;
}
}
} else {
position_fb = joint_pos_fb(fb_joint) + offset[fb_joint];
position_fb_set(joint_pos_fb(fb_joint) + offset[fb_joint]);
}
}

FUNCTION(write) {
int i;
float delta;
rtapi_real delta;

// Determine if we're moving in the same direction as home search

Expand Down Expand Up @@ -164,8 +164,8 @@ FUNCTION(write) {

// Update each joint's commanded position
for (i=0; i < personality; i++) {
joint_pos_cmd(i) = position_cmd - offset[i];
joint_offset(i) = offset[i];
joint_pos_cmd_set(i, position_cmd - offset[i]);
joint_offset_set(i, offset[i]);
}
}

119 changes: 60 additions & 59 deletions src/hal/components/histobins.comp
Original file line number Diff line number Diff line change
Expand Up @@ -42,36 +42,36 @@ Additional output statistics pins:
The method input pin selects an alternate variance calculation.

Maintainers note: hardcoded for MAXBINNUMBER==200
""";

pin in u32 pintype;
pin in float input;
pin in s32 input_s32;
pin in u32 input_u32;
pin in bit input_bit;

pin in u32 nbins = 20; // must be < MAXBINNUMBER
pin in float binsize = 1;
pin in float minvalue = 0;

pin in s32 index; // use s32 to avoid 0x hex display in hal
pin out s32 check; // use s32 to avoid 0x hex display in hal
pin in bit reset;
pin in bit method;

pin out bit input_error;
pin out float binvalue;
pin out float pextra;
pin out float nextra;
pin out float input_min;
pin out float input_max;

pin out u32 nsamples;
pin out float variance;
pin out float mean;
"""; //" To make vim happy in syntax=c mode

pin in ui32 pintype;
pin in real input;
pin in si32 input_s32;
pin in ui32 input_u32;
pin in bool input_bit;

pin in ui32 nbins = 20; // must be < MAXBINNUMBER
pin in real binsize = 1;
pin in real minvalue = 0;

pin in si32 index; // use s32 to avoid 0x hex display in hal
pin out si32 check; // use s32 to avoid 0x hex display in hal
pin in bool reset;
pin in bool method;

pin out bool input_error;
pin out real binvalue;
pin out real pextra;
pin out real nextra;
pin out real input_min;
pin out real input_max;

pin out ui32 nsamples;
pin out real variance;
pin out real mean;

// user may interrogate availablebins to determine this compiled-in limit
pin out s32 availablebins = 200; //MAXBINNUMBER
pin out si32 availablebins = 200; //MAXBINNUMBER

option period no;
function _;
Expand All @@ -80,31 +80,31 @@ variable int bin[200]; // MAXBINNUMBER
variable int first = 1;
variable unsigned last_nbins = 0;

variable hal_float_t maxvalue;
variable rtapi_real maxvalue;

variable hal_float_t last_binsize = 0;
variable hal_float_t last_minvalue = 0;
variable rtapi_real last_binsize = 0;
variable rtapi_real last_minvalue = 0;

variable hal_float_t sum;
variable hal_float_t sq_sum;
variable hal_float_t m2;
variable rtapi_real sum;
variable rtapi_real sq_sum;
variable rtapi_real m2;

license "GPL";
author "Dewey Garrett";
;;

hal_float_t invalue;
rtapi_real invalue;
unsigned i;
int idx;
check = index;
check_set(index);
if ( (nbins > (unsigned)availablebins)
|| (nbins < 1)
) {
input_error = 1;
check = index; // allow continue with no updates
input_error_set(1);
check_set(index); // allow continue with no updates
return;
}
input_error = 0;
input_error_set(0);
if (reset) {first = 1;}

//pintype "0:float, 1:s32, 2:u32 3:bit";
Expand All @@ -123,56 +123,57 @@ if ( first
) {
maxvalue = minvalue + nbins * binsize;
first = 0;
pextra = 0; nextra = 0;
pextra_set(0);
nextra_set(0);
for (i = 0; i < nbins; i++) {
bin[i] = 0;
}
nsamples = 0;
mean = 0;
nsamples_set(0);
mean_set(0);
sum = 0;
sq_sum = 0;
variance = 0;
input_min = 1e99; //dng
input_max = -1e99; //dng
variance_set(0);
input_min_set(1e99); //dng
input_max_set(-1e99); //dng
m2 = 0;
} else {

if (invalue < minvalue) {
nextra++;
nextra_set(nextra + 1);
} else if (invalue > maxvalue) {
pextra++;
pextra_set(pextra + 1);
} else {
idx = (invalue - minvalue)/binsize;
bin[idx]++;
}
}

check = index; // user should verify check==index for reading values
check_set(index); // user should verify check==index for reading values
// -1 value indicates illegal index
if (index < 0) {
binvalue = -1;
binvalue_set(-1);
} else if (index < (int)nbins) {
binvalue = bin[index];
binvalue_set(bin[index]);
} else {
binvalue = -1;
binvalue_set(-1);
}

if (invalue < input_min) input_min = invalue;
if (invalue > input_max) input_max = invalue;
if (invalue < input_min) input_min_set(invalue);
if (invalue > input_max) input_max_set(invalue);

nsamples++;
nsamples_set(nsamples + 1);
if (nsamples >= 2) {
if (method == 0 ) {
hal_float_t delta;
rtapi_real delta;
delta = invalue - mean;
mean = mean + delta / nsamples;
mean_set(mean + delta / nsamples);
m2 = m2 + delta * (invalue - mean);
variance = m2/(nsamples - 1);
variance_set(m2/(nsamples - 1));
} else {
sum += invalue;
sq_sum += invalue * invalue;
variance = (sq_sum - (sum * sum)/nsamples)/(nsamples -1);
mean = sum/nsamples;
variance_set((sq_sum - (sum * sum)/nsamples)/(nsamples -1));
mean_set(sum/nsamples);
}
}

Expand Down
Loading
Loading