Spindles: Make spindle velocity limits and plus/minus increments
INI-config items. Signed-off-by: andypugh <andy@bodgesoc.org>
This commit is contained in:
parent
14a02d19b0
commit
3d005f685d
12 changed files with 374 additions and 38 deletions
|
|
@ -284,17 +284,22 @@ On multi spindle machine there will be entries for each spindle number. Qtvcp on
|
||||||
* 'DEFAULT_SPINDLE_SPEED = 100' - The default spindle RPM when the spindle
|
* 'DEFAULT_SPINDLE_SPEED = 100' - The default spindle RPM when the spindle
|
||||||
is started in manual mode. if this setting is not present, this
|
is started in manual mode. if this setting is not present, this
|
||||||
defaults to 1 RPM for AXIS and 300 RPM for gmoccapy.
|
defaults to 1 RPM for AXIS and 300 RPM for gmoccapy.
|
||||||
|
- deprecated - use the [SPINDLE_n] section instead
|
||||||
|
|
||||||
* 'DEFAULT_SPINDLE_0_SPEED = 100' - The default spindle RPM when the spindle
|
* 'DEFAULT_SPINDLE_0_SPEED = 100' - The default spindle RPM when the spindle
|
||||||
is started in manual mode. On multi spindle machine there will be entries for each spindle number. Qtvcp only
|
is started in manual mode. On multi spindle machine there will be entries for each spindle number. Qtvcp only
|
||||||
|
- deprecated - use the [SPINDLE_n] section instead
|
||||||
|
|
||||||
* 'SPINDLE_INCREMENT = 200' - The increment used when clicking increase/decrease buttons Qtvcp only
|
* 'SPINDLE_INCREMENT = 200' - The increment used when clicking increase/decrease buttons Qtvcp only
|
||||||
|
- deprecated - use the [SPINDLE_n] section instead
|
||||||
|
|
||||||
* 'MIN_SPINDLE_0_SPEED = 1000' - The minimum RPM that can be manually selected.
|
* 'MIN_SPINDLE_0_SPEED = 1000' - The minimum RPM that can be manually selected.
|
||||||
On multi spindle machine there will be entries for each spindle number. Qtvcp only
|
On multi spindle machine there will be entries for each spindle number. Qtvcp only
|
||||||
|
- deprecated - use the [SPINDLE_n] section instead
|
||||||
|
|
||||||
* 'MAX_SPINDLE_0_SPEED = 20000' - The maximum RPM that can be manually selected.
|
* 'MAX_SPINDLE_0_SPEED = 20000' - The maximum RPM that can be manually selected.
|
||||||
On multi spindle machine there will be entries for each spindle number. Qtvcp only
|
On multi spindle machine there will be entries for each spindle number. Qtvcp only
|
||||||
|
- deprecated - use the [SPINDLE_n] section instead
|
||||||
|
|
||||||
* 'PROGRAM_PREFIX = ~/linuxcnc/nc_files' - The default location for g-code
|
* 'PROGRAM_PREFIX = ~/linuxcnc/nc_files' - The default location for g-code
|
||||||
files and the location for user-defined M-codes. This location is searched
|
files and the location for user-defined M-codes. This location is searched
|
||||||
|
|
@ -1585,6 +1590,43 @@ image::images/encoder-scale.png[align="center"]
|
||||||
than the joint MAX_VELOCITY. Subsequent testing has shown that use of
|
than the joint MAX_VELOCITY. Subsequent testing has shown that use of
|
||||||
STEPGEN_MAXVEL does not improve the tuning of stepgen's position loop.
|
STEPGEN_MAXVEL does not improve the tuning of stepgen's position loop.
|
||||||
|
|
||||||
|
[[sec:spindle-section]](((INI File, SPINDLE Section)))
|
||||||
|
|
||||||
|
=== [SPINDLE_<num>] Section
|
||||||
|
The <num> specifies the spindle number 0 ... (num_spindles-1)
|
||||||
|
The value of 'num_spindles' is set by [TRAJ]SPINDLES=
|
||||||
|
|
||||||
|
* 'MAX_VELOCITY = 20000'
|
||||||
|
The maximum spindle speed (in rpm) for the specified spindle. Optional.
|
||||||
|
|
||||||
|
* 'MIN_VELOCITY = 3000'
|
||||||
|
The minimum spindle speed (in rpm) for the specified spindle. Optional.
|
||||||
|
Many spindles have a minimum speed below which they should not be run.
|
||||||
|
Any spindle speed command below this limit will be /increased/ to this
|
||||||
|
limit.
|
||||||
|
|
||||||
|
* 'MAX_REVERSE_VELOCITY = 20000'
|
||||||
|
This setting will default to MAX_VELOCITY if omitted. It can be used
|
||||||
|
in cases where the spindle speed is limited in reverse. Set to zero
|
||||||
|
for spindles which must not be run in reverse.
|
||||||
|
In this context "max" refers to the abslute magnitude of the spindle
|
||||||
|
speed.
|
||||||
|
|
||||||
|
* 'MIN_REVERSE_VELOCITY = 3000'
|
||||||
|
This setting is equivalent to MIN_VELOCITY but for reverse spindle
|
||||||
|
rotation. It will default to the MIN_VELOCITY if omitted.
|
||||||
|
|
||||||
|
* 'HOME_SEARCH_VELOCITY = 100' - FIXME: Spindle homing not yet working
|
||||||
|
Sets the homing speed (rpm) for the spindle. The spindle will rotate
|
||||||
|
at this velocity during the homing sequence until the spindle index
|
||||||
|
is located, at which point the spindle position will be set to zero.
|
||||||
|
Note that it makes no sense for the spindle home position to be any
|
||||||
|
value other than zero, and so there is no provision to do so.
|
||||||
|
|
||||||
|
* 'HOME_SEQUENCE = 0' - FIXME: Spindle homing not yet working
|
||||||
|
Controls where in the general homing sequence the spindle homing
|
||||||
|
rotations occur. Set the HOME_SEARCH_VELOCITY to zero to avoid spindle
|
||||||
|
rotation during the homing sequence
|
||||||
|
|
||||||
[[sec:emcio-section]](((INI File, EMCIO Section)))
|
[[sec:emcio-section]](((INI File, EMCIO Section)))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -314,6 +314,7 @@ HEADERS := \
|
||||||
emc/ini/emcIniFile.hh \
|
emc/ini/emcIniFile.hh \
|
||||||
emc/ini/iniaxis.hh \
|
emc/ini/iniaxis.hh \
|
||||||
emc/ini/inijoint.hh \
|
emc/ini/inijoint.hh \
|
||||||
|
emc/ini/inispindle.hh \
|
||||||
emc/ini/initraj.hh \
|
emc/ini/initraj.hh \
|
||||||
emc/ini/inihal.hh \
|
emc/ini/inihal.hh \
|
||||||
emc/kinematics/cubic.h \
|
emc/kinematics/cubic.h \
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
#include "rtapi.h"
|
#include "rtapi.h"
|
||||||
#include "inihal.hh"
|
#include "inihal.hh"
|
||||||
#include "iniaxis.hh"
|
#include "iniaxis.hh"
|
||||||
|
#include "inispindle.hh"
|
||||||
|
|
||||||
static int debug=0;
|
static int debug=0;
|
||||||
static int comp_id;
|
static int comp_id;
|
||||||
|
|
|
||||||
128
src/emc/ini/inispindle.cc
Normal file
128
src/emc/ini/inispindle.cc
Normal file
|
|
@ -0,0 +1,128 @@
|
||||||
|
/********************************************************************
|
||||||
|
* Description: inispindle.cc
|
||||||
|
* INI file initialization routines for spindle NML
|
||||||
|
*
|
||||||
|
* Derived from a work by Fred Proctor & Will Shackleford
|
||||||
|
*
|
||||||
|
* Author: Andy Pugh
|
||||||
|
* License: GPL Version 2+
|
||||||
|
* System: Linux
|
||||||
|
*
|
||||||
|
* Copyright (c) 2021 All rights reserved.
|
||||||
|
*
|
||||||
|
* Last change: created 30/12/21
|
||||||
|
********************************************************************/
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdio.h> // NULL
|
||||||
|
#include <stdlib.h> // atol(), _itoa()
|
||||||
|
#include <string.h> // strcmp()
|
||||||
|
#include <ctype.h> // isdigit()
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include "emc.hh"
|
||||||
|
#include "rcs_print.hh"
|
||||||
|
#include "emcIniFile.hh"
|
||||||
|
#include "inispindle.hh" // these decls
|
||||||
|
#include "emcglb.h" // EMC_DEBUG
|
||||||
|
#include "emccfg.h" // default values for globals
|
||||||
|
|
||||||
|
#include "inihal.hh"
|
||||||
|
|
||||||
|
extern value_inihal_data old_inihal_data;
|
||||||
|
|
||||||
|
/*
|
||||||
|
loadSpindls(int spindle)
|
||||||
|
|
||||||
|
Loads ini file params for the specified spindle
|
||||||
|
spindle max and min velocities
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int loadSpindle(int spindle, EmcIniFile *spindleIniFile)
|
||||||
|
{
|
||||||
|
int num_spindles = 1;
|
||||||
|
char spindleString[11];
|
||||||
|
double max_pos = 1e99;
|
||||||
|
double max_neg = 0;
|
||||||
|
double min_pos = 0;
|
||||||
|
double min_neg = -1e99;
|
||||||
|
int home_sequence = 0;
|
||||||
|
double search_vel = 0;
|
||||||
|
double home_angle = 0;
|
||||||
|
double increment = 100;
|
||||||
|
double limit;
|
||||||
|
|
||||||
|
spindleIniFile->EnableExceptions(EmcIniFile::ERR_CONVERSION);
|
||||||
|
|
||||||
|
if (spindleIniFile->Find(&num_spindles, "SPINDLES", "TRAJ") < 0){
|
||||||
|
num_spindles = 1; }
|
||||||
|
if (spindle > num_spindles) return -1;
|
||||||
|
|
||||||
|
snprintf(spindleString, sizeof(spindleString), "SPINDLE_%i", spindle);
|
||||||
|
|
||||||
|
// set max positive speed limit
|
||||||
|
if (spindleIniFile->Find(&limit, "MAX_VELOCITY", spindleString) == 0){
|
||||||
|
max_pos = limit;
|
||||||
|
min_neg = limit;
|
||||||
|
}
|
||||||
|
// set min positive speed limit
|
||||||
|
if (spindleIniFile->Find(&limit, "MIN_VELOCITY", spindleString) == 0){
|
||||||
|
min_pos = limit;
|
||||||
|
max_neg = limit;
|
||||||
|
}
|
||||||
|
// set min negative speed limit
|
||||||
|
if (spindleIniFile->Find(&limit, "MIN_REVERSE_VELOCITY", spindleString) == 0){
|
||||||
|
max_neg = -1.0 * fabs(limit);
|
||||||
|
}
|
||||||
|
// set max negative speed limit
|
||||||
|
if (spindleIniFile->Find(&limit, "MAX_REVERSE_VELOCITY", spindleString) == 0){
|
||||||
|
min_neg = -1.0 * fabs(limit);
|
||||||
|
}
|
||||||
|
// set home sequence
|
||||||
|
if (spindleIniFile->Find(&limit, "HOME_SEQUENCE", spindleString) == 0){
|
||||||
|
home_sequence = (int)limit;
|
||||||
|
}
|
||||||
|
// set home velocity
|
||||||
|
if (spindleIniFile->Find(&limit, "HOME_SEARCH_VELOCITY", spindleString) == 0){
|
||||||
|
search_vel = (int)limit;
|
||||||
|
}
|
||||||
|
/* set home angle - I believe this is a bad idea - andypugh 30/12/21
|
||||||
|
if (spindleIniFile->Find(&limit, "HOME", spindleString) >= 0){
|
||||||
|
home_angle = (int)limit;
|
||||||
|
}*/
|
||||||
|
home_angle = 0;
|
||||||
|
// set spindle increment
|
||||||
|
if (spindleIniFile->Find(&limit, "INCREMENT", spindleString) == 0){
|
||||||
|
increment = limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 != emcSpindleSetParams(spindle, max_pos, min_pos, max_neg,
|
||||||
|
min_neg, search_vel, home_angle, home_sequence, increment)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
iniAxis(int axis, const char *filename)
|
||||||
|
|
||||||
|
Loads ini file parameters for specified axis, [0 .. AXES - 1]
|
||||||
|
|
||||||
|
*/
|
||||||
|
int iniSpindle(int spindle, const char *filename)
|
||||||
|
{
|
||||||
|
EmcIniFile spindleIniFile(EmcIniFile::ERR_TAG_NOT_FOUND |
|
||||||
|
EmcIniFile::ERR_SECTION_NOT_FOUND |
|
||||||
|
EmcIniFile::ERR_CONVERSION);
|
||||||
|
|
||||||
|
if (spindleIniFile.Open(filename) == false) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// load its values
|
||||||
|
if (0 != loadSpindle(spindle, &spindleIniFile)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
22
src/emc/ini/inispindle.hh
Normal file
22
src/emc/ini/inispindle.hh
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
/********************************************************************
|
||||||
|
* Description: inispindle.hh
|
||||||
|
*
|
||||||
|
* Derived from a work by Fred Proctor & Will Shackleford
|
||||||
|
*
|
||||||
|
* Author:
|
||||||
|
* License: GPL Version 2
|
||||||
|
* System: Linux
|
||||||
|
*
|
||||||
|
* Copyright (c) 2021 All rights reserved.
|
||||||
|
*
|
||||||
|
* Last change: file created by andypugh 30/12/21
|
||||||
|
********************************************************************/
|
||||||
|
#ifndef INISPINDLE_HH
|
||||||
|
#define INISPINDLE_HH
|
||||||
|
|
||||||
|
#include "emc.hh" // EMC_AXIS_STAT
|
||||||
|
|
||||||
|
/* initializes spindle modules from ini file */
|
||||||
|
extern int iniSpindle(int spindle, const char *filename);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -193,6 +193,16 @@ void refresh_jog_limits(emcmot_joint_t *joint, int joint_num)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void apply_spindle_limits(spindle_status_t *s){
|
||||||
|
if (s->speed > 0) {
|
||||||
|
if (s->speed > s->max_pos_speed) s->speed = s->max_pos_speed;
|
||||||
|
if (s->speed < s->min_pos_speed) s->speed = s->min_pos_speed;
|
||||||
|
} else if (s->speed < 0) {
|
||||||
|
if (s->speed < s->min_neg_speed) s->speed = s->min_neg_speed;
|
||||||
|
if (s->speed > s->max_neg_speed) s->speed = s->max_neg_speed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int check_axis_constraint(double target, int id, char *move_type,
|
static int check_axis_constraint(double target, int id, char *move_type,
|
||||||
int axis_no, char axis_name) {
|
int axis_no, char axis_name) {
|
||||||
int in_range = 1;
|
int in_range = 1;
|
||||||
|
|
@ -1738,6 +1748,27 @@ void emcmotCommandHandler(void *arg, long servo_period)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case EMCMOT_SET_SPINDLE_PARAMS:
|
||||||
|
rtapi_print_msg(RTAPI_MSG_DBG, "SPINDLE_SETUP: spindle %d/%d max_pos %f min_pos %f"
|
||||||
|
"max_neg %f min_neg %f, home: %f, %f, %d\n",
|
||||||
|
emcmotCommand->spindle, emcmotConfig->numSpindles, emcmotCommand->maxLimit,
|
||||||
|
emcmotCommand->min_pos_speed, emcmotCommand->max_neg_speed, emcmotCommand->minLimit,
|
||||||
|
emcmotCommand->search_vel, emcmotCommand->home, emcmotCommand->home_sequence);
|
||||||
|
spindle_num = emcmotCommand->spindle;
|
||||||
|
if (spindle_num >= emcmotConfig->numSpindles){
|
||||||
|
reportError(_("Attempt to configure non-existent spindle"));
|
||||||
|
emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_COMMAND;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
emcmotStatus->spindle_status[spindle_num].max_pos_speed = emcmotCommand->maxLimit;
|
||||||
|
emcmotStatus->spindle_status[spindle_num].min_neg_speed = emcmotCommand->minLimit;
|
||||||
|
emcmotStatus->spindle_status[spindle_num].max_neg_speed = emcmotCommand->max_neg_speed;
|
||||||
|
emcmotStatus->spindle_status[spindle_num].min_pos_speed = emcmotCommand->min_pos_speed;
|
||||||
|
emcmotStatus->spindle_status[spindle_num].home_search_vel = emcmotCommand->search_vel;
|
||||||
|
emcmotStatus->spindle_status[spindle_num].home_sequence = emcmotCommand->home_sequence;
|
||||||
|
emcmotStatus->spindle_status[spindle_num].increment = emcmotCommand->offset;
|
||||||
|
|
||||||
|
break;
|
||||||
case EMCMOT_SPINDLE_ON:
|
case EMCMOT_SPINDLE_ON:
|
||||||
rtapi_print_msg(RTAPI_MSG_DBG, "SPINDLE_ON: spindle %d/%d speed %d\n",
|
rtapi_print_msg(RTAPI_MSG_DBG, "SPINDLE_ON: spindle %d/%d speed %d\n",
|
||||||
emcmotCommand->spindle, emcmotConfig->numSpindles, (int) emcmotCommand->vel);
|
emcmotCommand->spindle, emcmotConfig->numSpindles, (int) emcmotCommand->vel);
|
||||||
|
|
@ -1780,6 +1811,7 @@ void emcmotCommandHandler(void *arg, long servo_period)
|
||||||
emcmotStatus->spindle_status[n].direction = -1;
|
emcmotStatus->spindle_status[n].direction = -1;
|
||||||
}
|
}
|
||||||
emcmotStatus->spindle_status[n].brake = 0; //disengage brake
|
emcmotStatus->spindle_status[n].brake = 0; //disengage brake
|
||||||
|
apply_spindle_limits(&emcmotStatus->spindle_status[n]);
|
||||||
}
|
}
|
||||||
emcmotStatus->atspeed_next_feed = emcmotCommand->wait_for_spindle_at_speed;
|
emcmotStatus->atspeed_next_feed = emcmotCommand->wait_for_spindle_at_speed;
|
||||||
|
|
||||||
|
|
@ -1882,10 +1914,11 @@ void emcmotCommandHandler(void *arg, long servo_period)
|
||||||
}
|
}
|
||||||
for (n = s0; n<=s1; n++){
|
for (n = s0; n<=s1; n++){
|
||||||
if (emcmotStatus->spindle_status[n].speed > 0) {
|
if (emcmotStatus->spindle_status[n].speed > 0) {
|
||||||
emcmotStatus->spindle_status[n].speed += 100; //FIXME - make the step a HAL parameter
|
emcmotStatus->spindle_status[n].speed += emcmotStatus->spindle_status[n].increment;
|
||||||
} else if (emcmotStatus->spindle_status[n].speed < 0) {
|
} else if (emcmotStatus->spindle_status[n].speed < 0) {
|
||||||
emcmotStatus->spindle_status[n].speed -= 100;
|
emcmotStatus->spindle_status[n].speed -= emcmotStatus->spindle_status[n].increment;
|
||||||
}
|
}
|
||||||
|
apply_spindle_limits(&emcmotStatus->spindle_status[n]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -1897,12 +1930,21 @@ void emcmotCommandHandler(void *arg, long servo_period)
|
||||||
emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_COMMAND;
|
emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_COMMAND;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (emcmotStatus->spindle_status[spindle_num].speed > 100) {
|
s0 = spindle_num;
|
||||||
emcmotStatus->spindle_status[spindle_num].speed -= 100; //FIXME - make the step a HAL parameter
|
s1 = spindle_num;
|
||||||
} else if (emcmotStatus->spindle_status[spindle_num].speed < -100) {
|
if (spindle_num ==-1){
|
||||||
emcmotStatus->spindle_status[spindle_num].speed += 100;
|
s0 = 0;
|
||||||
}
|
s1 = motion_num_spindles - 1;
|
||||||
break;
|
}
|
||||||
|
for (n = s0; n<=s1; n++){
|
||||||
|
if (emcmotStatus->spindle_status[n].speed > emcmotStatus->spindle_status[n].increment) {
|
||||||
|
emcmotStatus->spindle_status[n].speed -= emcmotStatus->spindle_status[n].increment;
|
||||||
|
} else if (emcmotStatus->spindle_status[n].speed < -1.0 * emcmotStatus->spindle_status[n].increment) {
|
||||||
|
emcmotStatus->spindle_status[n].speed += emcmotStatus->spindle_status[n].increment;
|
||||||
|
}
|
||||||
|
apply_spindle_limits(&emcmotStatus->spindle_status[n]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case EMCMOT_SPINDLE_BRAKE_ENGAGE:
|
case EMCMOT_SPINDLE_BRAKE_ENGAGE:
|
||||||
rtapi_print_msg(RTAPI_MSG_DBG, "SPINDLE_BRAKE_ENGAGE");
|
rtapi_print_msg(RTAPI_MSG_DBG, "SPINDLE_BRAKE_ENGAGE");
|
||||||
|
|
|
||||||
|
|
@ -1940,10 +1940,10 @@ static void output_to_hal(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (spindle_num = 0; spindle_num < emcmotConfig->numSpindles; spindle_num++){
|
for (spindle_num = 0; spindle_num < emcmotConfig->numSpindles; spindle_num++){
|
||||||
|
double speed;
|
||||||
if(emcmotStatus->spindle_status[spindle_num].css_factor) {
|
if(emcmotStatus->spindle_status[spindle_num].css_factor) {
|
||||||
double denom = fabs(emcmotStatus->spindle_status[spindle_num].xoffset
|
double denom = fabs(emcmotStatus->spindle_status[spindle_num].xoffset
|
||||||
- emcmotStatus->carte_pos_cmd.tran.x);
|
- emcmotStatus->carte_pos_cmd.tran.x);
|
||||||
double speed;
|
|
||||||
double maxpositive;
|
double maxpositive;
|
||||||
if(denom > 0) speed = emcmotStatus->spindle_status[spindle_num].css_factor / denom;
|
if(denom > 0) speed = emcmotStatus->spindle_status[spindle_num].css_factor / denom;
|
||||||
else speed = emcmotStatus->spindle_status[spindle_num].speed;
|
else speed = emcmotStatus->spindle_status[spindle_num].speed;
|
||||||
|
|
@ -1955,32 +1955,38 @@ static void output_to_hal(void)
|
||||||
speed = -maxpositive;
|
speed = -maxpositive;
|
||||||
if(speed > maxpositive)
|
if(speed > maxpositive)
|
||||||
speed = maxpositive;
|
speed = maxpositive;
|
||||||
|
|
||||||
*(emcmot_hal_data->spindle[spindle_num].spindle_speed_out) = speed;
|
|
||||||
*(emcmot_hal_data->spindle[spindle_num].spindle_speed_out_rps) = speed/60.;
|
|
||||||
} else {
|
} else {
|
||||||
*(emcmot_hal_data->spindle[spindle_num].spindle_speed_out) =
|
speed = emcmotStatus->spindle_status[spindle_num].speed *
|
||||||
emcmotStatus->spindle_status[spindle_num].speed *
|
|
||||||
emcmotStatus->spindle_status[spindle_num].net_scale;
|
emcmotStatus->spindle_status[spindle_num].net_scale;
|
||||||
*(emcmot_hal_data->spindle[spindle_num].spindle_speed_out_rps) =
|
|
||||||
emcmotStatus->spindle_status[spindle_num].speed *
|
|
||||||
emcmotStatus->spindle_status[spindle_num].net_scale / 60.;
|
|
||||||
}
|
}
|
||||||
*(emcmot_hal_data->spindle[spindle_num].spindle_speed_out_abs) =
|
|
||||||
fabs(*(emcmot_hal_data->spindle[spindle_num].spindle_speed_out));
|
// Limit to spindle velocity limits
|
||||||
*(emcmot_hal_data->spindle[spindle_num].spindle_speed_out_rps_abs) =
|
if (speed > 0){
|
||||||
fabs(*(emcmot_hal_data->spindle[spindle_num].spindle_speed_out_rps));
|
if (speed > emcmotStatus->spindle_status[spindle_num].max_pos_speed) {
|
||||||
*(emcmot_hal_data->spindle[spindle_num].spindle_speed_cmd_rps) =
|
speed = emcmotStatus->spindle_status[spindle_num].max_pos_speed;
|
||||||
|
} else if (speed < emcmotStatus->spindle_status[spindle_num].min_pos_speed) {
|
||||||
|
speed = emcmotStatus->spindle_status[spindle_num].min_pos_speed;
|
||||||
|
}
|
||||||
|
} else if (speed < 0) {
|
||||||
|
if (speed < emcmotStatus->spindle_status[spindle_num].min_neg_speed) {
|
||||||
|
speed = emcmotStatus->spindle_status[spindle_num].min_neg_speed;
|
||||||
|
} else if (speed > emcmotStatus->spindle_status[spindle_num].max_neg_speed) {
|
||||||
|
speed = emcmotStatus->spindle_status[spindle_num].max_neg_speed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*(emcmot_hal_data->spindle[spindle_num].spindle_speed_out) = speed;
|
||||||
|
*(emcmot_hal_data->spindle[spindle_num].spindle_speed_out_rps) = speed/60.;
|
||||||
|
*(emcmot_hal_data->spindle[spindle_num].spindle_speed_out_abs) = fabs(speed);
|
||||||
|
*(emcmot_hal_data->spindle[spindle_num].spindle_speed_out_rps_abs) = fabs(speed / 60);
|
||||||
|
*(emcmot_hal_data->spindle[spindle_num].spindle_on) = (speed != 0) ? 1 : 0;
|
||||||
|
*(emcmot_hal_data->spindle[spindle_num].spindle_forward) = (speed > 0) ? 1 : 0;
|
||||||
|
*(emcmot_hal_data->spindle[spindle_num].spindle_reverse) = (speed < 0) ? 1 : 0;
|
||||||
|
*(emcmot_hal_data->spindle[spindle_num].spindle_brake) =
|
||||||
|
(emcmotStatus->spindle_status[spindle_num].brake != 0) ? 1 : 0;
|
||||||
|
// What is this for? Docs don't say
|
||||||
|
*(emcmot_hal_data->spindle[spindle_num].spindle_speed_cmd_rps) =
|
||||||
emcmotStatus->spindle_status[spindle_num].speed / 60.;
|
emcmotStatus->spindle_status[spindle_num].speed / 60.;
|
||||||
*(emcmot_hal_data->spindle[spindle_num].spindle_on) =
|
|
||||||
((emcmotStatus->spindle_status[spindle_num].state *
|
|
||||||
emcmotStatus->spindle_status[spindle_num].net_scale) != 0) ? 1 : 0;
|
|
||||||
*(emcmot_hal_data->spindle[spindle_num].spindle_forward) =
|
|
||||||
(*emcmot_hal_data->spindle[spindle_num].spindle_speed_out > 0) ? 1 : 0;
|
|
||||||
*(emcmot_hal_data->spindle[spindle_num].spindle_reverse) =
|
|
||||||
(*emcmot_hal_data->spindle[spindle_num].spindle_speed_out < 0) ? 1 : 0;
|
|
||||||
*(emcmot_hal_data->spindle[spindle_num].spindle_brake) =
|
|
||||||
(emcmotStatus->spindle_status[spindle_num].brake != 0) ? 1 : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*(emcmot_hal_data->program_line) = emcmotStatus->id;
|
*(emcmot_hal_data->program_line) = emcmotStatus->id;
|
||||||
|
|
|
||||||
|
|
@ -189,6 +189,8 @@ extern "C" {
|
||||||
EMCMOT_SET_AXIS_ACC_LIMIT, /* set the max axis acc */
|
EMCMOT_SET_AXIS_ACC_LIMIT, /* set the max axis acc */
|
||||||
EMCMOT_SET_AXIS_LOCKING_JOINT, /* set the axis locking joint */
|
EMCMOT_SET_AXIS_LOCKING_JOINT, /* set the axis locking joint */
|
||||||
|
|
||||||
|
EMCMOT_SET_SPINDLE_PARAMS, /* One command to set all spindle params */
|
||||||
|
|
||||||
} cmd_code_t;
|
} cmd_code_t;
|
||||||
|
|
||||||
/* this enum lists the possible results of a command */
|
/* this enum lists the possible results of a command */
|
||||||
|
|
@ -220,6 +222,8 @@ extern "C" {
|
||||||
double motor_offset; /* offset from joint to motor position */
|
double motor_offset; /* offset from joint to motor position */
|
||||||
double maxLimit; /* pos value for position limit, output */
|
double maxLimit; /* pos value for position limit, output */
|
||||||
double minLimit; /* neg value for position limit, output */
|
double minLimit; /* neg value for position limit, output */
|
||||||
|
double min_pos_speed; /* spindle minimum positive speed */
|
||||||
|
double max_neg_speed; /* spindle maximum negative speed */
|
||||||
EmcPose pos; /* line/circle endpt, or teleop vector */
|
EmcPose pos; /* line/circle endpt, or teleop vector */
|
||||||
PmCartesian center; /* center for circle */
|
PmCartesian center; /* center for circle */
|
||||||
PmCartesian normal; /* normal vec for circle */
|
PmCartesian normal; /* normal vec for circle */
|
||||||
|
|
@ -541,11 +545,19 @@ Suggestion: Split this in to an Error and a Status flag register..
|
||||||
int locked; // spindle lock engaged after orient
|
int locked; // spindle lock engaged after orient
|
||||||
int orient_fault; // fault code from motion.spindle-orient-fault
|
int orient_fault; // fault code from motion.spindle-orient-fault
|
||||||
int orient_state; // orient_state_t
|
int orient_state; // orient_state_t
|
||||||
int spindle_index_enable; /* hooked to a canon encoder index-enable */
|
int spindle_index_enable; /* hooked to a canon encoder index-enable */
|
||||||
double spindleRevs; /* position of spindle in revolutions */
|
double spindleRevs; /* position of spindle in revolutions */
|
||||||
double spindleSpeedIn; /* velocity of spindle in revolutions per minute */
|
double spindleSpeedIn; /* velocity of spindle in revolutions per minute */
|
||||||
int at_speed;
|
int at_speed;
|
||||||
int fault; /* amplifier fault */
|
int fault; /* amplifier fault */
|
||||||
|
double max_pos_speed; /* spindle speed limits */
|
||||||
|
double min_pos_speed; /* signed values, so max_neg = 0 */
|
||||||
|
double max_neg_speed; /* and min_neg = -1e99 indicates no limit */
|
||||||
|
double min_neg_speed;
|
||||||
|
double home_angle;
|
||||||
|
double home_search_vel;
|
||||||
|
int home_sequence;
|
||||||
|
double increment;
|
||||||
} spindle_status_t;
|
} spindle_status_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ LIBEMCSRCS := \
|
||||||
emc/ini/emcIniFile.cc \
|
emc/ini/emcIniFile.cc \
|
||||||
emc/ini/iniaxis.cc \
|
emc/ini/iniaxis.cc \
|
||||||
emc/ini/inijoint.cc \
|
emc/ini/inijoint.cc \
|
||||||
|
emc/ini/inispindle.cc \
|
||||||
emc/ini/initraj.cc \
|
emc/ini/initraj.cc \
|
||||||
emc/ini/inihal.cc \
|
emc/ini/inihal.cc \
|
||||||
emc/nml_intf/interpl.cc
|
emc/nml_intf/interpl.cc
|
||||||
|
|
|
||||||
|
|
@ -384,6 +384,12 @@ extern int emcJogAbs(int nr, double pos, double vel, int jjogmode);
|
||||||
|
|
||||||
extern int emcJointUpdate(EMC_JOINT_STAT stat[], int numJoints);
|
extern int emcJointUpdate(EMC_JOINT_STAT stat[], int numJoints);
|
||||||
|
|
||||||
|
|
||||||
|
// implementation functions for EMC_SPINDLE types
|
||||||
|
|
||||||
|
extern int emcSpindleSetParams(int spindle, double max_pos, double min_pos, double max_neg,
|
||||||
|
double min_neg, double search_vel, double home_angle, int sequence, double increment);
|
||||||
|
|
||||||
// implementation functions for EMC_TRAJ types
|
// implementation functions for EMC_TRAJ types
|
||||||
|
|
||||||
extern int emcTrajSetJoints(int joints);
|
extern int emcTrajSetJoints(int joints);
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,16 @@ typedef struct AxisConfig_t {
|
||||||
double MaxLimit;
|
double MaxLimit;
|
||||||
} AxisConfig_t;
|
} AxisConfig_t;
|
||||||
|
|
||||||
|
typedef struct SpindleConfig_t {
|
||||||
|
int Inited;
|
||||||
|
double max_pos_speed;
|
||||||
|
double max_neg_speed;
|
||||||
|
double min_pos_speed;
|
||||||
|
double min_neg_speed;
|
||||||
|
int home_sequence;
|
||||||
|
double home_search_velocity;
|
||||||
|
} SpindleConfig_t;
|
||||||
|
|
||||||
typedef struct TrajConfig_t {
|
typedef struct TrajConfig_t {
|
||||||
int Inited; // non-zero means traj called init
|
int Inited; // non-zero means traj called init
|
||||||
int Joints;
|
int Joints;
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
#include "inifile.hh"
|
#include "inifile.hh"
|
||||||
#include "iniaxis.hh"
|
#include "iniaxis.hh"
|
||||||
#include "inijoint.hh"
|
#include "inijoint.hh"
|
||||||
|
#include "inispindle.hh"
|
||||||
#include "initraj.hh"
|
#include "initraj.hh"
|
||||||
#include "inihal.hh"
|
#include "inihal.hh"
|
||||||
|
|
||||||
|
|
@ -72,6 +73,7 @@ static emcmot_status_t emcmotStatus;
|
||||||
static struct TrajConfig_t TrajConfig;
|
static struct TrajConfig_t TrajConfig;
|
||||||
static struct JointConfig_t JointConfig[EMCMOT_MAX_JOINTS];
|
static struct JointConfig_t JointConfig[EMCMOT_MAX_JOINTS];
|
||||||
static struct AxisConfig_t AxisConfig[EMCMOT_MAX_AXIS];
|
static struct AxisConfig_t AxisConfig[EMCMOT_MAX_AXIS];
|
||||||
|
static struct SpindleConfig_t SpindleConfig[EMCMOT_MAX_SPINDLES];
|
||||||
|
|
||||||
static emcmot_command_t emcmotCommand;
|
static emcmot_command_t emcmotCommand;
|
||||||
|
|
||||||
|
|
@ -586,13 +588,18 @@ int emcAxisUpdate(EMC_AXIS_STAT stat[], int axis_mask)
|
||||||
|
|
||||||
static int JointOrTrajInited(void)
|
static int JointOrTrajInited(void)
|
||||||
{
|
{
|
||||||
int joint;
|
int joint, spindle;
|
||||||
|
|
||||||
for (joint = 0; joint < EMCMOT_MAX_JOINTS; joint++) {
|
for (joint = 0; joint < EMCMOT_MAX_JOINTS; joint++) {
|
||||||
if (JointConfig[joint].Inited) {
|
if (JointConfig[joint].Inited) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (spindle = 0; spindle < EMCMOT_MAX_SPINDLES; spindle++) {
|
||||||
|
if (SpindleConfig[spindle].Inited) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (TrajConfig.Inited) {
|
if (TrajConfig.Inited) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -640,6 +647,27 @@ int emcAxisInit(int axis)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int emcSpindleInit(int spindle)
|
||||||
|
{
|
||||||
|
int retval = 0;
|
||||||
|
|
||||||
|
if (spindle < 0 || spindle >= EMCMOT_MAX_SPINDLES) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// init emcmot interface
|
||||||
|
if (!JointOrTrajInited()) {
|
||||||
|
usrmotIniLoad(emc_inifile);
|
||||||
|
if (0 != usrmotInit("emc2_task")) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SpindleConfig[spindle].Inited = 1;
|
||||||
|
if (0 != iniSpindle(spindle, emc_inifile)) {
|
||||||
|
retval = -1;
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
int emcJointHalt(int joint)
|
int emcJointHalt(int joint)
|
||||||
{
|
{
|
||||||
if (joint < 0 || joint >= EMCMOT_MAX_JOINTS) {
|
if (joint < 0 || joint >= EMCMOT_MAX_JOINTS) {
|
||||||
|
|
@ -1708,7 +1736,7 @@ int emcPositionSave() {
|
||||||
int emcMotionInit()
|
int emcMotionInit()
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
int joint, axis;
|
int joint, axis, spindle;
|
||||||
|
|
||||||
r = emcTrajInit(); // we want to check Traj first, the sane defaults for units are there
|
r = emcTrajInit(); // we want to check Traj first, the sane defaults for units are there
|
||||||
// it also determines the number of existing joints, and axes
|
// it also determines the number of existing joints, and axes
|
||||||
|
|
@ -1731,7 +1759,15 @@ int emcMotionInit()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (spindle = 0; spindle < TrajConfig.Spindles; spindle++) {
|
||||||
|
if (0 != emcSpindleInit(spindle)) {
|
||||||
|
rcs_print("%s: emcSpindleInit(%d) failed\n", __FUNCTION__, spindle);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Ignore errors from emcPositionLoad(), because what are you going to do?
|
// Ignore errors from emcPositionLoad(), because what are you going to do?
|
||||||
(void)emcPositionLoad();
|
(void)emcPositionLoad();
|
||||||
|
|
@ -1834,6 +1870,35 @@ int emcMotionSetDout(unsigned char index, unsigned char start,
|
||||||
return usrmotWriteEmcmotCommand(&emcmotCommand);
|
return usrmotWriteEmcmotCommand(&emcmotCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int emcSpindleSetParams(int spindle, double max_pos, double min_pos, double max_neg,
|
||||||
|
double min_neg, double search_vel, double home_angle, int sequence, double increment)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (spindle < 0 || spindle >= EMCMOT_MAX_SPINDLES) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
emcmotCommand.command = EMCMOT_SET_SPINDLE_PARAMS;
|
||||||
|
emcmotCommand.spindle = spindle;
|
||||||
|
emcmotCommand.maxLimit = max_pos;
|
||||||
|
emcmotCommand.minLimit = min_neg;
|
||||||
|
emcmotCommand.min_pos_speed = min_pos;
|
||||||
|
emcmotCommand.max_neg_speed = max_neg;
|
||||||
|
emcmotCommand.home = home_angle;
|
||||||
|
emcmotCommand.search_vel = search_vel;
|
||||||
|
emcmotCommand.home_sequence = sequence;
|
||||||
|
emcmotCommand.offset = increment;
|
||||||
|
|
||||||
|
int retval = usrmotWriteEmcmotCommand(&emcmotCommand);
|
||||||
|
|
||||||
|
if (emc_debug & EMC_DEBUG_CONFIG) {
|
||||||
|
rcs_print("%s(%d, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %i, %.4f) returned %d\n",
|
||||||
|
__FUNCTION__, spindle, max_pos, min_pos, max_neg, min_neg, search_vel, home_angle,
|
||||||
|
sequence, increment, retval);
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
int emcSpindleAbort(int spindle)
|
int emcSpindleAbort(int spindle)
|
||||||
{
|
{
|
||||||
return emcSpindleOff(spindle);
|
return emcSpindleOff(spindle);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue