PID seems like almost working, but I have a great problem with model!
This commit is contained in:
@@ -86,7 +86,6 @@ void getModData(mountdata_t *mountdata){
|
||||
if(Xst == ST_MOVE) Xst = Xmodel->proc_move(Xmodel, &Xp, tnow);
|
||||
movestate_t Yst = Ymodel->get_state(Ymodel, &Yp);
|
||||
if(Yst == ST_MOVE) Yst = Ymodel->proc_move(Ymodel, &Yp, tnow);
|
||||
bzero(mountdata, sizeof(mountdata_t));
|
||||
mountdata->motXposition.t = mountdata->encXposition.t = mountdata->motYposition.t = mountdata->encYposition.t = tnow;
|
||||
mountdata->motXposition.val = mountdata->encXposition.val = Xp.coord;
|
||||
mountdata->motYposition.val = mountdata->encYposition.val = Yp.coord;
|
||||
@@ -210,6 +209,22 @@ static int chkYs(double s){
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// set SLEWING state if axis was stopped later
|
||||
static void setslewingstate(){
|
||||
//FNAME();
|
||||
mountdata_t d;
|
||||
if(MCC_E_OK == getMD(&d)){
|
||||
axis_status_t newx = d.Xstate, newy = d.Ystate;
|
||||
//DBG("old state: %d/%d", d.Xstate, d.Ystate);
|
||||
if(d.Xstate == AXIS_STOPPED) newx = AXIS_SLEWING;
|
||||
if(d.Ystate == AXIS_STOPPED) newy = AXIS_SLEWING;
|
||||
if(newx != d.Xstate || newy != d.Ystate){
|
||||
DBG("Started moving -> slew");
|
||||
setStat(newx, newy);
|
||||
}
|
||||
}else DBG("CAN't GET MOUNT DATA!");
|
||||
}
|
||||
|
||||
/*
|
||||
static mcc_errcodes_t slew2(const coordpair_t *target, slewflags_t flags){
|
||||
(void)target;
|
||||
@@ -241,7 +256,7 @@ static mcc_errcodes_t move2(const coordpair_t *target){
|
||||
cmd.Yspeed = MCC_MAX_Y_SPEED;
|
||||
mcc_errcodes_t r = shortcmd(&cmd);
|
||||
if(r != MCC_E_OK) return r;
|
||||
setStat(AXIS_SLEWING, AXIS_SLEWING);
|
||||
setslewingstate();
|
||||
return MCC_E_OK;
|
||||
}
|
||||
|
||||
@@ -279,7 +294,7 @@ static mcc_errcodes_t move2s(const coordpair_t *target, const coordpair_t *speed
|
||||
cmd.Yspeed = speed->Y;
|
||||
mcc_errcodes_t r = shortcmd(&cmd);
|
||||
if(r != MCC_E_OK) return r;
|
||||
setStat(AXIS_SLEWING, AXIS_SLEWING);
|
||||
setslewingstate();
|
||||
return MCC_E_OK;
|
||||
}
|
||||
|
||||
@@ -288,6 +303,7 @@ static mcc_errcodes_t move2s(const coordpair_t *target, const coordpair_t *speed
|
||||
* @return errcode
|
||||
*/
|
||||
static mcc_errcodes_t emstop(){
|
||||
FNAME();
|
||||
if(Conf.RunModel){
|
||||
double curt = nanotime();
|
||||
Xmodel->emergency_stop(Xmodel, curt);
|
||||
@@ -299,6 +315,7 @@ static mcc_errcodes_t emstop(){
|
||||
}
|
||||
// normal stop
|
||||
static mcc_errcodes_t stop(){
|
||||
FNAME();
|
||||
if(Conf.RunModel){
|
||||
double curt = nanotime();
|
||||
Xmodel->stop(Xmodel, curt);
|
||||
@@ -323,6 +340,7 @@ static mcc_errcodes_t shortcmd(short_command_t *cmd){
|
||||
if(!model_move2(Xmodel, ¶m, curt)) return MCC_E_FAILED;
|
||||
param.coord = cmd->Ymot; param.speed = cmd->Yspeed;
|
||||
if(!model_move2(Ymodel, ¶m, curt)) return MCC_E_FAILED;
|
||||
setslewingstate();
|
||||
return MCC_E_OK;
|
||||
}
|
||||
SSscmd s = {0};
|
||||
@@ -336,6 +354,7 @@ static mcc_errcodes_t shortcmd(short_command_t *cmd){
|
||||
s.YBits = cmd->YBits;
|
||||
DBG("X->%d, Y->%d, Xs->%d, Ys->%d", s.Xmot, s.Ymot, s.Xspeed, s.Yspeed);
|
||||
if(!cmdS(&s)) return MCC_E_FAILED;
|
||||
setslewingstate();
|
||||
return MCC_E_OK;
|
||||
}
|
||||
|
||||
@@ -353,6 +372,7 @@ static mcc_errcodes_t longcmd(long_command_t *cmd){
|
||||
if(!model_move2(Xmodel, ¶m, curt)) return MCC_E_FAILED;
|
||||
param.coord = cmd->Ymot; param.speed = cmd->Yspeed;
|
||||
if(!model_move2(Ymodel, ¶m, curt)) return MCC_E_FAILED;
|
||||
setslewingstate();
|
||||
return MCC_E_OK;
|
||||
}
|
||||
SSlcmd l = {0};
|
||||
@@ -365,6 +385,7 @@ static mcc_errcodes_t longcmd(long_command_t *cmd){
|
||||
l.Xatime = S2ADDER(cmd->Xatime);
|
||||
l.Yatime = S2ADDER(cmd->Yatime);
|
||||
if(!cmdL(&l)) return MCC_E_FAILED;
|
||||
setslewingstate();
|
||||
return MCC_E_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user