change macros to config parameters
This commit is contained in:
@@ -53,6 +53,7 @@ limits_t
|
||||
.max = {.coord = 3.1241, .speed = 0.139626, .accel = 0.165806}}
|
||||
;
|
||||
static mcc_errcodes_t shortcmd(short_command_t *cmd);
|
||||
static mcc_errcodes_t get_hwconf(hardware_configuration_t *hwConfig);
|
||||
|
||||
/**
|
||||
* @brief curtime - monotonic time from first run
|
||||
@@ -87,6 +88,7 @@ static int initstarttime(){
|
||||
curtime(&t0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// return difference (in seconds) between time1 and time0
|
||||
double timediff(const struct timespec *time1, const struct timespec *time0){
|
||||
if(!time1 || !time0) return -1.;
|
||||
@@ -220,6 +222,9 @@ static mcc_errcodes_t init(conf_t *c){
|
||||
}
|
||||
if(!SSrawcmd(CMD_EXITACM, NULL)) ret = MCC_E_FAILED;
|
||||
if(ret != MCC_E_OK) return ret;
|
||||
// read HW config to update constants
|
||||
hardware_configuration_t HW;
|
||||
if(MCC_E_OK != get_hwconf(&HW)) return MCC_E_FAILED;
|
||||
return updateMotorPos();
|
||||
}
|
||||
|
||||
@@ -258,19 +263,6 @@ static void setslewingstate(){
|
||||
}else DBG("CAN't GET MOUNT DATA!");
|
||||
}
|
||||
|
||||
/*
|
||||
static mcc_errcodes_t slew2(const coordpair_t *target, slewflags_t flags){
|
||||
(void)target;
|
||||
(void)flags;
|
||||
//if(Conf.RunModel) return ... ;
|
||||
if(MCC_E_OK != updateMotorPos()) return MCC_E_FAILED;
|
||||
//...
|
||||
setStat(AXIS_SLEWING, AXIS_SLEWING);
|
||||
//...
|
||||
return MCC_E_FAILED;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief move2 - simple move to given point and stop
|
||||
* @param X - new X coordinate (radians: -pi..pi) or NULL
|
||||
@@ -427,6 +419,7 @@ static mcc_errcodes_t get_hwconf(hardware_configuration_t *hwConfig){
|
||||
if(!hwConfig) return MCC_E_BADFORMAT;
|
||||
if(Conf.RunModel) return MCC_E_FAILED;
|
||||
SSconfig config;
|
||||
DBG("Read HW configuration");
|
||||
if(!cmdC(&config, FALSE)) return MCC_E_FAILED;
|
||||
// Convert acceleration (ticks per loop^2 to rad/s^2)
|
||||
hwConfig->Xconf.accel = X_MOTACC2RS(config.Xconf.accel);
|
||||
@@ -485,6 +478,26 @@ static mcc_errcodes_t get_hwconf(hardware_configuration_t *hwConfig){
|
||||
hwConfig->locsspeed = (double)config.locsspeed * M_PI / (180.0 * 3600.0);
|
||||
// Convert backlash speed (ticks per loop to rad/s)
|
||||
hwConfig->backlspd = X_MOTSPD2RS(config.backlspd);
|
||||
// now read text commands
|
||||
int64_t i64;
|
||||
double Xticks, Yticks;
|
||||
DBG("SERIAL");
|
||||
// motor's encoder ticks per rev
|
||||
if(!SSgetint(CMD_MEPRX, &i64)) return MCC_E_FAILED;
|
||||
Xticks = ((double) i64) / 4.; // divide by 4 as these values stored
|
||||
if(!SSgetint(CMD_MEPRY, &i64)) return MCC_E_FAILED;
|
||||
Yticks = ((double) i64) / 4.;
|
||||
X_ENC_ZERO = Conf.XEncZero;
|
||||
Y_ENC_ZERO = Conf.YEncZero;
|
||||
X_MOT_STEPSPERREV = hwConfig->Xconf.motor_stepsperrev = (config.xbits.motrev) ? -Xticks : Xticks;
|
||||
Y_MOT_STEPSPERREV = hwConfig->Yconf.motor_stepsperrev = (config.ybits.motrev) ? -Yticks : Yticks;
|
||||
// axis encoder ticks per rev
|
||||
if(!SSgetint(CMD_AEPRX, &i64)) return MCC_E_FAILED;
|
||||
Xticks = (double) i64;
|
||||
if(!SSgetint(CMD_AEPRY, &i64)) return MCC_E_FAILED;
|
||||
Yticks = (double) i64;
|
||||
X_ENC_STEPSPERREV = hwConfig->Xconf.axis_stepsperrev = (config.xbits.encrev) ? -Xticks : Xticks;
|
||||
Y_ENC_STEPSPERREV = hwConfig->Yconf.axis_stepsperrev = (config.ybits.encrev) ? -Yticks : Yticks;
|
||||
return MCC_E_OK;
|
||||
}
|
||||
|
||||
@@ -540,6 +553,7 @@ static mcc_errcodes_t write_hwconf(hardware_configuration_t *hwConfig){
|
||||
config.Ysetpr = __bswap_32(hwConfig->Ysetpr);
|
||||
config.Xmetpr = __bswap_32(hwConfig->Xmetpr * 4);
|
||||
config.Ymetpr = __bswap_32(hwConfig->Ymetpr * 4);
|
||||
// todo - also write text params
|
||||
// TODO - next
|
||||
(void) config;
|
||||
return MCC_E_OK;
|
||||
|
||||
Reference in New Issue
Block a user