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
21 changes: 21 additions & 0 deletions GalilSup/Db/GALIL_controller_kinematics.req
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Kinematics

# Forward transforms (Readbacks)
file "galil_forward_transform.req" P=$(P), M=MTR$(CCP)09
file "galil_forward_transform.req" P=$(P), M=MTR$(CCP)10
file "galil_forward_transform.req" P=$(P), M=MTR$(CCP)11
file "galil_forward_transform.req" P=$(P), M=MTR$(CCP)12
file "galil_forward_transform.req" P=$(P), M=MTR$(CCP)13
file "galil_forward_transform.req" P=$(P), M=MTR$(CCP)14
file "galil_forward_transform.req" P=$(P), M=MTR$(CCP)15
file "galil_forward_transform.req" P=$(P), M=MTR$(CCP)16

# Reverse transforms (Setpoints)
file "galil_reverse_transforms.req" P=$(P), M=MTR$(CCP)09
file "galil_reverse_transforms.req" P=$(P), M=MTR$(CCP)10
file "galil_reverse_transforms.req" P=$(P), M=MTR$(CCP)11
file "galil_reverse_transforms.req" P=$(P), M=MTR$(CCP)12
file "galil_reverse_transforms.req" P=$(P), M=MTR$(CCP)13
file "galil_reverse_transforms.req" P=$(P), M=MTR$(CCP)14
file "galil_reverse_transforms.req" P=$(P), M=MTR$(CCP)15
file "galil_reverse_transforms.req" P=$(P), M=MTR$(CCP)16
20 changes: 13 additions & 7 deletions GalilSup/Db/galil_Home_Dummy_Move.dmc
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,24 @@ IF (home${AXIS}=1)
IF ((hjog${AXIS}=1) & (_BG${AXIS}=1) & (home${AXIS}=1))
ST${AXIS};ENDIF
IF ((hjog${AXIS}=1) & (_BG${AXIS}=0) & (home${AXIS}=1))
PR${AXIS}=(_SP${AXIS} * 2);SH${AXIS};WT100;BG${AXIS};hjog${AXIS}=2
PR${AXIS}=(_SP${AXIS} * 2);SH${AXIS};hjog${AXIS}=2
ENDIF
IF ((hjog${AXIS}=2) & (_BG${AXIS}=0) & (home${AXIS}=1) & (_SC${AXIS}=1))
hjog${AXIS}=3
IF ((hjog${AXIS}=2) & (_BG${AXIS}=0) & (_MO${AXIS}=0) & (home${AXIS}=1))
BG${AXIS};hjog${AXIS}=3
ENDIF
IF ((hjog${AXIS}=3) & (_BG${AXIS}=0) & (home${AXIS}=1) & (_SC${AXIS}=1))
hjog${AXIS}=4
ENDIF
IF ((hjog${AXIS}>=3) & (hjog${AXIS}<10) & (_BG${AXIS}=0) & (home${AXIS}=1))
IF ((hjog${AXIS}>=4) & (hjog${AXIS}<11) & (_BG${AXIS}=0) & (home${AXIS}=1))
hjog${AXIS}=hjog${AXIS}+1;WT10
ENDIF
IF ((hjog${AXIS}=10) & (_BG${AXIS}=0) & (home${AXIS}=1))
PR${AXIS}=(_SP${AXIS} * -2);SH${AXIS};WT100;BG${AXIS};hjog${AXIS}=11
IF ((hjog${AXIS}=11) & (_BG${AXIS}=0) & (home${AXIS}=1))
PR${AXIS}=(_SP${AXIS} * -2);SH${AXIS};hjog${AXIS}=12
ENDIF
IF ((hjog${AXIS}=11) & (_BG${AXIS}=0) & (home${AXIS}=1) & (_SC${AXIS}=1))
IF ((hjog${AXIS}=12) & (_BG${AXIS}=0) & (_MO${AXIS}=0) & (home${AXIS}=1))
BG${AXIS};hjog${AXIS}=13
ENDIF
IF ((hjog${AXIS}=13) & (_BG${AXIS}=0) & (home${AXIS}=1) & (_SC${AXIS}=1))
hjog${AXIS}=0;home${AXIS}=0;homed${AXIS}=1
MG "home${AXIS}", home${AXIS};MG "homed${AXIS}", homed${AXIS}
ENDIF
Expand Down
18 changes: 14 additions & 4 deletions GalilSup/Db/galil_dmc_ctrl.template
Original file line number Diff line number Diff line change
Expand Up @@ -591,15 +591,21 @@ record(ao,"$(P)PWRDET:SP") {
field(DTYP, "asynFloat64")
field(OUT, "@asyn($(PORT),0)USER_VAR pwrdet")
field(SCAN, "Passive")
# set a default non-zero as zero in galil is a problem
# and is never a test value
field(VAL, "2")
info(autosaveFields_pass0, "VAL")
info(archive, "VAL")
}

record(ai,"$(P)PWRDET") {
field(DESC, "Get Power off detect value")
field(DTYP, "asynFloat64")
field(INP, "@asyn($(PORT),0)USER_VAR pwrdet")
field(SCAN, "10 second")
field(SDIS, "$(P)PWRDET:SP.PACT")
field(FLNK, "$(P)PWRDET:ALERT.PROC")
info(archive, "VAL")
}

## 0 = ok, 1 = problem
Expand All @@ -610,7 +616,7 @@ record(calcout,"$(P)PWRDET:ALERT") {
field(INPB, "$(P)PWRDET:SP")
field(CALC, "A!=B")
field(OOPT, "When Zero")
field(OUT, "$(P)PWRDET:TIMER.PROC")
field(OUT, "$(P)PWRDET:TIMER.PROC PP")
info(archive, "VAL")
}

Expand All @@ -622,12 +628,16 @@ record(bo,"$(P)PWRDET:RESET:SP") {
}

## how often we should set a new test value
## A % 360 means 3600 seconds as we are on 10 second scan link
## A = 360 means 3600 seconds as we are on 10 second scan link
## Changing value is only a check in case it got saved into galil
## firmware so changing this once per ioc run is fine
## make sure we don't set a new value too soon
## after ioc startup in case of a quick restart causing a race condition
record(calcout, "$(P)PWRDET:TIMER") {
field(DESC, "Set new PWRDET test value")
field(CALC, "A % 360; A := A + 1")
field(CALC, "A = 360; A := A + 1")
field(INPA, "0")
field(OOPT, "When Zero")
field(OOPT, "When Non-zero")
field(DOPT, "Use OCAL")
field(OCAL, "CEIL(RNDM*100)+1")
field(OUT, "$(P)PWRDET:SP PP")
Expand Down
2 changes: 1 addition & 1 deletion GalilSup/Db/galil_motor_extras.template
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ record(bo,"$(P)$(M)_USWITCH_CMD")
{
field(DESC,"use switch")
field(DTYP,"asynInt32")
field(VAL, "1")
field(VAL, "0")
field(PINI,"YES")
field(ZNAM,"No")
field(ZSV, "NO_ALARM")
Expand Down
18 changes: 11 additions & 7 deletions GalilSup/src/GalilAxis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ GalilAxis::GalilAxis(class GalilController *pC, //Pointer to controller instance
int switch_type) //motor enable/disable switch type
: asynMotorAxis(pC, (toupper(axisname[0]) - AASCII)),
pC_(pC), last_encoder_position_(0), smoothed_encoder_position_(0), encoder_smooth_factor_(0.0), motor_dly_(0.0),
first_poll_(true),encDirOk_(true), pollRequest_(10, sizeof(int))
first_poll_(true),encDirOk_(true), last_done_(1), pollRequest_(10, sizeof(int))
{
string limit_code; //Code generated for limits interrupt on this axis
string digital_code; //Code generated for digital interrupt related to this axis
Expand Down Expand Up @@ -2046,6 +2046,8 @@ void GalilAxis::checkEncoder(void)
double sc_code = getGalilAxisVal("_SC");
// get axis moving state
double bg_code = getGalilAxisVal("_BG");
// in case we are homing record hjog
int hjog_code = getGalilAxisVal("hjog");
//Pass stall status to higher layers
setIntegerParam(pC_->motorStatusSlip_, 1);
//Set the stop reason so limit deceleration is applied during stop
Expand All @@ -2058,7 +2060,7 @@ void GalilAxis::checkEncoder(void)
sprintf(message, "Encoder stall stop motor %c", axisName_);
//Set controller error mesg monitor
pC_->setCtrlError(message);
std::cerr << "STALL: pestall_time=" << pestall_time << " (>" << estall_time << ") encoderMove_=" << encoderMove_ << " encDirOk_=" << encDirOk_ << " _SC" << axisName_ << "=" << sc_code << " [" << lookupStopCode((int)sc_code) << "] _BG" << axisName_ << "=" << bg_code << std::endl;
std::cerr << "STALL: pestall_time=" << pestall_time << " (>" << estall_time << ") encoderMove_=" << encoderMove_ << " encDirOk_=" << encDirOk_ << " _SC" << axisName_ << "=" << sc_code << " [" << lookupStopCode((int)sc_code) << "] _BG" << axisName_ << "=" << bg_code << " hjog" << axisName_ << "=" << hjog_code << std::endl;
}
}
}
Expand Down Expand Up @@ -2180,7 +2182,7 @@ void GalilAxis::checkHoming(void)

// ISIS: need to confirm limits high/low limit behaviour
bool home_timeout = homing_ && (stoppedTime_ >= homing_timeout) && !cancelHomeSent_;
bool home_soft_limits_hit = (((readback > highLimit_ && softlimits) || (readback < lowLimit_ && softlimits)) && homing_ && !cancelHomeSent_ && done_);
bool home_soft_limits_hit = (((readback > highLimit_ && softlimits) || (readback < lowLimit_ && softlimits)) && home_timeout && done_);
if (home_timeout || home_soft_limits_hit)
{
sprintf(pC_->cmd_, "MG homed%c\n", axisName_);
Expand All @@ -2189,7 +2191,7 @@ void GalilAxis::checkHoming(void)

if (homed == 1)
{
std::cerr << "Looks like homing completed OK but unsolicited message from controller got lost" << std::endl;
std::cerr << "Looks like homing completed OK but unsolicited message from controller got lost for axis " << axisName_ << std::endl;
// execute logic as per GalilController::processUnsolicitedMesgs
this->homedExecuted_ = false;
this->pollRequest_.send((void*)&MOTOR_HOMED, sizeof(int));
Expand Down Expand Up @@ -2976,7 +2978,10 @@ asynStatus GalilAxis::poller(bool& moving)

//Extract axis motion data from controller datarecord, and load into GalilAxis instance
status |= getStatus();
if (status) goto skip;
if (status) {
done_ = last_done_;
goto skip;
}

//Set poll variables in GalilAxis based on data record info
setStatus(&moving);
Expand Down Expand Up @@ -3046,7 +3051,6 @@ asynStatus GalilAxis::poller(bool& moving)
smoothed_encoder_position_ = (1.0 - encoder_smooth_factor_) * encoder_position_ +
encoder_smooth_factor_ * smoothed_encoder_position_;
}
skip:
//Save encoder position, and done for next poll cycle
last_encoder_position_ = encoder_position_;
last_done_ = done_;
Expand All @@ -3056,7 +3060,7 @@ asynStatus GalilAxis::poller(bool& moving)
//By this driver during homing
revlast_ = rev_;
fwdlast_ = fwd_;

skip:
//Set status
if (encoder_smooth_factor_ != 0.0)
{
Expand Down
2 changes: 2 additions & 0 deletions GalilSup/src/GalilConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ void GalilConnector::run(void)
//Check GalilController for response
//Test synchronous communication
//Query controller for synchronous connection handle
strcpy(pC_->cmd_, "EO 0"); // first we also turn off echo mode as it really breaks things
pC_->sync_writeReadController();
strcpy(pC_->cmd_, "WH");
sync_status = pC_->sync_writeReadController(true);
//Store the handle controller used for sync
Expand Down
Loading