Skip to content
Open
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
4 changes: 3 additions & 1 deletion src/emc/ini/inijoint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ static int loadJoint(int joint, const IniFile &ini)
bool ignore_limits = ini.findBoolV("HOME_IGNORE_LIMITS", jointSection, false);
bool volatile_home = ini.findBoolV("VOLATILE_HOME", jointSection, false);
bool locking_idxer = ini.findBoolV("LOCKING_INDEXER", jointSection, false);
bool home_dogbone = ini.findBoolV("HOME_DOGBONE", jointSection, false);
int abs_encoder = ini.findIntV("HOME_ABSOLUTE_ENCODER", jointSection, 0, 0, 2);

// Sequence defaults to an unrealizable and positive sequence so that
Expand All @@ -162,7 +163,8 @@ static int loadJoint(int joint, const IniFile &ini)
sequence,
volatile_home,
locking_idxer,
abs_encoder)) {
abs_encoder,
home_dogbone)) {
print_dbg_config("emcJointSetHomingParams");
return -1;
}
Expand Down
3 changes: 2 additions & 1 deletion src/emc/motion/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,8 @@ void emcmotCommandHandler_locked(void *arg, long servo_period)
emcmotCommand->latch_vel,
emcmotCommand->flags,
emcmotCommand->home_sequence,
emcmotCommand->volatile_home
emcmotCommand->volatile_home,
emcmotCommand->home_dogbone
);
break;

Expand Down
70 changes: 64 additions & 6 deletions src/emc/motion/homing.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ typedef enum {
HOME_LOCK,// 22
HOME_LOCK_WAIT,// 23
HOME_FINISHED,// 24
HOME_ABORT// 25
HOME_ABORT,// 25
HOME_DOGBONE_SLOW_START,// 26
HOME_DOGBONE_SLOW_WAIT// 27
} home_state_t;

// local per-joint data (includes hal pin data)
Expand All @@ -122,6 +124,7 @@ typedef struct {
int home_sequence; // intfc, updateable
bool volatile_home; // intfc
bool home_is_synchronized;
bool home_dogbone;
} home_local_data;

static home_local_data H[EMCMOT_MAX_JOINTS];
Expand Down Expand Up @@ -521,6 +524,7 @@ static int base_homing_init(int id,
H[i].home = 0;
H[i].home_flags = 0;
H[i].home_sequence = 1000; //startup: unrealizable, positive seq no.
H[i].home_dogbone = 0;
H[i].volatile_home = 0;
}
return 0;
Expand Down Expand Up @@ -625,7 +629,8 @@ static void base_set_joint_homing_params(int jno,
double home_latch_vel,
int home_flags,
int home_sequence,
bool volatile_home
bool volatile_home,
bool home_dogbone
)
{
H[jno].home_offset = offset;
Expand All @@ -636,6 +641,7 @@ static void base_set_joint_homing_params(int jno,
H[jno].home_flags = home_flags;
H[jno].home_sequence = home_sequence;
H[jno].volatile_home = volatile_home;
H[jno].home_dogbone = home_dogbone;
update_home_is_synchronized();
}

Expand Down Expand Up @@ -846,7 +852,52 @@ static int base_1joint_state_machine(int joint_num)
}
}
break;

case HOME_DOGBONE_SLOW_START:
if (joint->free_tp.active) {
H[joint_num].pause_timer = 0;
break;
}

if (H[joint_num].pause_timer < (HOME_DELAY * servo_freq)) {
H[joint_num].pause_timer++;
break;
}

H[joint_num].pause_timer = 0;

if (!home_sw_active) {
rtapi_print_msg(RTAPI_MSG_ERR,
_("Dogbone: switch lost before slow phase j=%d"),
joint_num);
H[joint_num].home_state = HOME_ABORT;
immediate_state = 1;
break;
}

/* Continue SAME direction, but slower */
double vel = H[joint_num].home_latch_vel;

if (H[joint_num].home_search_vel < 0)
vel = -fabs(vel);
else
vel = fabs(vel);

home_start_move(joint, vel);

H[joint_num].home_state = HOME_DOGBONE_SLOW_WAIT;
break;
case HOME_DOGBONE_SLOW_WAIT:
if (!home_sw_active) {
joint->free_tp.enable = 0;

/* latch position at falling edge */
H[joint_num].home_state = HOME_SET_SWITCH_POSITION;
immediate_state = 1;
break;
}

ABORT_CHECK(joint_num);
break;
case HOME_INITIAL_BACKOFF_START:
/* This state is called if the homing sequence starts at a
location where the home switch is already tripped. It
Expand Down Expand Up @@ -927,8 +978,13 @@ static int base_1joint_state_machine(int joint_num)
if (home_sw_active) {
/* yes, stop motion */
joint->free_tp.enable = 0;

/* go to next step */
H[joint_num].home_state = HOME_SET_COARSE_POSITION;
if (H[joint_num].home_dogbone) {
H[joint_num].home_state = HOME_DOGBONE_SLOW_START;
} else {
H[joint_num].home_state = HOME_SET_COARSE_POSITION;
}
immediate_state = 1;
break;
}
Expand Down Expand Up @@ -1475,7 +1531,8 @@ void set_joint_homing_params(int jno,
double home_latch_vel,
int home_flags,
int home_sequence,
bool volatile_home
bool volatile_home,
bool home_dogbone
)
{ base_set_joint_homing_params(jno,
offset,
Expand All @@ -1485,7 +1542,8 @@ void set_joint_homing_params(int jno,
home_latch_vel,
home_flags,
home_sequence,
volatile_home);
volatile_home,
home_dogbone);
}
void update_joint_homing_params(int jno,
double offset,
Expand Down
3 changes: 2 additions & 1 deletion src/emc/motion/homing.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ void set_joint_homing_params(int jno,
double home_latch_vel,
int home_flags,
int home_sequence,
bool volatile_home
bool volatile_home,
bool home_dogbone
);

// updateable interface params (for inihal pin changes typically):
Expand Down
2 changes: 2 additions & 0 deletions src/emc/motion/motion.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ extern "C" {
int home_sequence; /* order in homing sequence */
int volatile_home; /* joint should get unhomed when we get unhome -2
(generated by task upon estop, etc) */
int home_dogbone; /* Use dogbone homing, fast initial search, slow until switch
release, and no change of direction */
double minFerror; /* min following error */
double maxFerror; /* max following error */
int wdWait; /* cycle to wait before toggling wd */
Expand Down
2 changes: 1 addition & 1 deletion src/emc/nml_intf/emc.hh
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ extern int emcJointSetHomingParams(int joint, double home, double offset, double
double search_vel, double latch_vel,
int use_index, int encoder_does_not_reset, int ignore_limits,
int is_shared, int home_sequence, int volatile_home, int locking_indexer,
int absolute_encoder);
int absolute_encoder, int home_dogbone);
extern int emcJointUpdateHomingParams(int joint, double home, double offset, int sequence);
extern int emcJointSetMaxVelocity(int joint, double vel);
extern int emcJointSetMaxAcceleration(int joint, double acc);
Expand Down
1 change: 1 addition & 0 deletions src/emc/nml_intf/emc_nml.hh
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ class EMC_JOINT_SET_HOMING_PARAMS:public EMC_JOINT_CMD_MSG {
int volatile_home;
int locking_indexer;
int absolute_encoder;
int home_dogbone;
};

class EMC_JOINT_HALT:public EMC_JOINT_CMD_MSG {
Expand Down
3 changes: 2 additions & 1 deletion src/emc/task/emctaskmain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,8 @@ static int emcTaskIssueCommand(NMLmsg * cmd)
set_homing_params_msg->home_sequence,
set_homing_params_msg->volatile_home,
set_homing_params_msg->locking_indexer,
set_homing_params_msg->absolute_encoder);
set_homing_params_msg->absolute_encoder,
set_homing_params_msg->home_dogbone);
break;

case EMC_JOINT_SET_FERROR_TYPE:
Expand Down
8 changes: 5 additions & 3 deletions src/emc/task/taskintf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ int emcJointSetHomingParams(int joint, double home, double offset, double home_f
double search_vel, double latch_vel,
int use_index, int encoder_does_not_reset,
int ignore_limits, int is_shared,
int sequence,int volatile_home, int locking_indexer,int absolute_encoder)
int sequence,int volatile_home, int locking_indexer, int absolute_encoder,
int home_dogbone)
{
#ifdef ISNAN_TRAP
if (std::isnan(home) || std::isnan(offset) || std::isnan(home_final_vel) ||
Expand All @@ -301,6 +302,7 @@ int emcJointSetHomingParams(int joint, double home, double offset, double home_f
emcmotCommand.flags = 0;
emcmotCommand.home_sequence = sequence;
emcmotCommand.volatile_home = volatile_home;
emcmotCommand.home_dogbone = home_dogbone;
if (use_index) {
emcmotCommand.flags |= HOME_USE_INDEX;
}
Expand Down Expand Up @@ -335,9 +337,9 @@ int emcJointSetHomingParams(int joint, double home, double offset, double home_f
int retval = usrmotWriteEmcmotCommand(&emcmotCommand);

if (emc_debug & EMC_DEBUG_CONFIG) {
rcs_print("%s(%d, %.4f, %.4f, %.4f, %.4f, %.4f, %d, %d, %d, %d, %d) returned %d\n",
rcs_print("%s(%d, %.4f, %.4f, %.4f, %.4f, %.4f, %d, %d, %d, %d, %d, %d) returned %d\n",
__FUNCTION__, joint, home, offset, home_final_vel, search_vel, latch_vel,
use_index, ignore_limits, is_shared, sequence, volatile_home, retval);
use_index, ignore_limits, is_shared, sequence, volatile_home, home_dogbone, retval);
}
return retval;
}
Expand Down
6 changes: 4 additions & 2 deletions src/hal/components/homecomp.comp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ void set_joint_homing_params(int jno,
double home_latch_vel,
int home_flags,
int home_sequence,
bool volatile_home
bool volatile_home,
bool home_dogbone
)
{
base_set_joint_homing_params(jno,
Expand All @@ -323,7 +324,8 @@ void set_joint_homing_params(int jno,
home_latch_vel,
home_flags,
home_sequence,
volatile_home);
volatile_home,
home_dogbone);
}
void update_joint_homing_params(int jno,
double offset,
Expand Down
Loading