orthotweezers
Class OrthoTweezersControl

java.lang.Object
  |
  +--orthotweezers.OrthoTweezersControl

public class OrthoTweezersControl
extends java.lang.Object

OrthoTweezersControl interfaces with all the hardware of the orthotweezer system, providing control of the stage, tweezers, strain gauges, etc. This class contains only the basic methods necessary to interface to the system. For more sophisticated manipulation routines, see OrthoTweezersTools which uses this class.

See Also:
OrthoTweezersTools

Constructor Summary
OrthoTweezersControl()
          Creates new OrthoTweezersControl.
 
Method Summary
 void calibrateStrainErrors()
          This sets xArmStrainError, xTipStrainError, yArmStrainError and yTipStrain error by running a calibration algorithm.
 void calibrateXArmDeflection(double deflection)
          This adjusts strainToDeflectionXArm so that the current reading of xArmStrain() will yeild the given deflection.
 void calibrateXTipDeflection(double deflection)
          This adjusts strainToDeflectionXTip so that the current reading of xTipStrain() will yeild the given deflection.
 void calibrateXTipForce(double force)
          This adjusts strainToForceXTip so that the current reading of xTipStrain() will yeild the given force.
 void calibrateYArmDeflection(double deflection)
          This adjusts strainToDeflectionYArm so that the current reading of yArmStrain() will yeild the given deflection.
 void calibrateYTipDeflection(double deflection)
          This adjusts strainToDeflectionYTip so that the current reading of yTipStrain() will yeild the given deflection.
 void calibrateYTipForce(double force)
          This adjusts strainToForceYTip so that the current reading of yTipStrain() will yeild the given force.
 void getPreferences(Preferences preferences)
          Set the relevant fields in the Preferences object, such as STAGE_X, with the values in this object.
 void moveProbeX(double position)
          Move probe X to the position smoothly.
 void moveProbeY(double position)
          Move probe Y to the position smoothly.
 void moveToXY(double x, double y)
          Move the stage to the x, y position, moving diagonally if necessary.
 void moveToZ(double z)
          Move the stage to the z position.
 double probeXPosition()
          Return the nomalized position of probe X in the range -1 to 1.
 double probeYPosition()
          Return the nomalized position of probe Y in the range -1 to 1.
 void relay1Off()
          Set the digital output for relay number 1 to 0.
 void relay1On()
          Set the digital output for relay number 1 to 1.
 boolean relay1State()
          Return true if relay number 1 is on, otherwise false.
 void reset()
          Reset the orthotweezers system to its default state.
 void resetXArmStrain()
          Assume that probe X is at the zero position and set strainOffsetXArm so that xArmStrain() will read zero.
 void resetXTipStrain()
          Assume there is no force on the tip of probe X and set strainOffsetXTip so that xTipStrain() will read zero.
 void resetYArmStrain()
          Assume that probe Y is at the zero position and set strainOffsetYArm so that yArmStrain() will read zero.
 void resetYTipStrain()
          Assume there is no force on the tip of probe Y and set strainOffsetYTip so that yTipStrain() will read zero.
 void setFromPreferences(Preferences preferences)
          Initialize control parameters, such as stageX, from the preferences.
 void setStageXYZ(double x, double y, double z)
          Set the present position of the stage.
 double stageX()
          Return the X position of the stage in millimeters.
 double stageY()
          Return the Y position of the stage in millimeters.
 double stageZ()
          Return the Z position of the stage in millimeters.
 double strainErrorXArm()
           
 double strainErrorXTip()
           
 double strainErrorYArm()
           
 double strainErrorYTip()
           
 double strainOffsetXArm()
          Get the offset which is added to the probe X arm strain gauge reading.
 double strainOffsetXTip()
          Get the offset which is added to the probe X tip strain gauge reading.
 double strainOffsetYArm()
          Get the offset which is added to the probe Y arm strain gauge reading.
 double strainOffsetYTip()
          Get the offset which is added to the probe Y tip strain gauge reading.
 double strainToDeflectionXArm()
          Get the parameter to convert strain to deflection on the probe X arm.
 double strainToDeflectionXTip()
          Get the parameter to convert strain to deflection on the probe X tip.
 double strainToDeflectionYArm()
          Get the parameter to convert strain to deflection on the probe Y arm.
 double strainToDeflectionYTip()
          Get the parameter to convert strain to deflection on the probe Y tip.
 double strainToForceXTip()
          Get the parameter to convert strain to force on the probe X tip.
 double strainToForceYTip()
          Get the parameter to convert strain to force on the probe Y tip.
 double xArmDeflection()
          Get the deflection of the probe X arm.
 double xArmStrain()
          Get the reading of the probe X arm strain gauge and add it to strainOffsetXArm().
 void xStep(boolean direction)
          Move X one step, updating _xSteps.
 double xTipDeflection()
          Get the deflection of the probe X tip.
 double xTipForce()
          Get the force on the probe X tip.
 double xTipStrain()
          Get the reading of the probe X tip strain gauge and add it to strainOffsetXTip().
 double yArmDeflection()
          Get the deflection of the probe Y arm.
 double yArmStrain()
          Get the reading of the probe Y arm strain gauge and add it to strainOffsetYArm().
 void yStep(boolean direction)
          Move Y one step, updating _ySteps.
 double yTipDeflection()
          Get the deflection of the probe Y tip.
 double yTipForce()
          Get the force on the probe Y tip.
 double yTipStrain()
          Get the reading of the probe Y tip strain gauge and add it to strainOffsetYTip().
 void zStep(boolean direction)
          Move Z one step, updating _zSteps.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrthoTweezersControl

public OrthoTweezersControl()
Creates new OrthoTweezersControl. Before exiting, the application should call reset() to return the orthotweezers system to its default state.
See Also:
reset()
Method Detail

setFromPreferences

public void setFromPreferences(Preferences preferences)
Initialize control parameters, such as stageX, from the preferences.
Parameters:
preferences - the Preferences object which should already have values loaded from the preferences file

getPreferences

public void getPreferences(Preferences preferences)
Set the relevant fields in the Preferences object, such as STAGE_X, with the values in this object. Typically an application calls getPreferences just before saving the preferences to a file.
Parameters:
preferences - the Preferences object into which the control parameters will be saved

reset

public void reset()
           throws CancelException
Reset the orthotweezers system to its default state. This moves probe X and probe Y to the zero position. This should be called before exiting the application.
Throws:
CancelException - thrown by CancelThread.check()
See Also:
CancelThread

xStep

public void xStep(boolean direction)
Move X one step, updating _xSteps.
Parameters:
direction - true for increasing X, false for decreasing

yStep

public void yStep(boolean direction)
Move Y one step, updating _ySteps.
Parameters:
direction - true for increasing Y, false for decreasing

moveProbeX

public void moveProbeX(double position)
                throws CancelException
Move probe X to the position smoothly. This operates the piezoelectric directly without regard to the strain gauge readings on the probe arm. Because of piezoelectric hysteresis, calling this method with a certain value for the position will not always result in the same actual deflection of the probe. To get a certain deflection, use OrthoTweezersTools.seekXArmDeflection. This calls CancelThread.check() to maybe throw a CancelException.
Parameters:
position - normalized position in the range -1 to 1. Values outside this range are clipped to this range.
Throws:
CancelException - thrown by CancelThread.check()
See Also:
OrthoTweezersTools.seekXArmDeflection(double), CancelThread

moveProbeY

public void moveProbeY(double position)
                throws CancelException
Move probe Y to the position smoothly. This operates the piezoelectric directly without regard to the strain gauge readings on the probe arm. Because of piezoelectric hysteresis, calling this method with a certain value for the position will not always result in the same actual deflection of the probe. To get a certain deflection, use OrthoTweezersTools.seekYArmDeflection. This calls CancelThread.check() to maybe throw a CancelException.
Parameters:
position - normalized position in the range -1 to 1. Values outside this range are clipped to this range.
Throws:
CancelException - thrown by CancelThread.check()
See Also:
OrthoTweezersTools.seekYArmDeflection(double), CancelThread

probeXPosition

public double probeXPosition()
Return the nomalized position of probe X in the range -1 to 1.

probeYPosition

public double probeYPosition()
Return the nomalized position of probe Y in the range -1 to 1.

zStep

public void zStep(boolean direction)
Move Z one step, updating _zSteps.
Parameters:
direction - true for increasing Z, false for decreasing

xArmStrain

public double xArmStrain()
Get the reading of the probe X arm strain gauge and add it to strainOffsetXArm(). This performs a new A/D conversion for the strain gauge.
Returns:
the strain gauge reading on the arm of probe X in volts, adjusted by the offset parameter
See Also:
strainOffsetXArm()

yArmStrain

public double yArmStrain()
Get the reading of the probe Y arm strain gauge and add it to strainOffsetYArm(). This performs a new A/D conversion for the strain gauge.
Returns:
the strain gauge reading on the arm of probe Y in volts, adjusted by the offset parameter
See Also:
strainOffsetYArm()

xTipStrain

public double xTipStrain()
Get the reading of the probe X tip strain gauge and add it to strainOffsetXTip(). This performs a new A/D conversion for the strain gauge.
Returns:
the strain gauge reading on the tip of probe X in volts, adjusted by the offset parameter
See Also:
strainOffsetXTip()

yTipStrain

public double yTipStrain()
Get the reading of the probe Y tip strain gauge and add it to strainOffsetYTip(). This performs a new A/D conversion for the strain gauge.
Returns:
the strain gauge reading on the tip of probe Y in volts, adjusted by the offset parameter
See Also:
strainOffsetYTip()

strainOffsetXArm

public double strainOffsetXArm()
Get the offset which is added to the probe X arm strain gauge reading. You can obtain the raw strain gauge reading as xArmStrain() - strainOffsetXArm().
Returns:
the probe X arm strain offset parameter in volts
See Also:
xArmStrain()

strainOffsetYArm

public double strainOffsetYArm()
Get the offset which is added to the probe Y arm strain gauge reading. You can obtain the raw strain gauge reading as yArmStrain() - strainOffsetYArm().
Returns:
the probe Y arm strain offset parameter in volts
See Also:
yArmStrain()

strainOffsetXTip

public double strainOffsetXTip()
Get the offset which is added to the probe X tip strain gauge reading. You can obtain the raw strain gauge reading as xTipStrain() - strainOffsetXTip().
Returns:
the probe X tip strain offset parameter in volts
See Also:
xTipStrain()

strainOffsetYTip

public double strainOffsetYTip()
Get the offset which is added to the probe Y tip strain gauge reading. You can obtain the raw strain gauge reading as yTipStrain() - strainOffsetYTip().
Returns:
the probe Y tip strain offset parameter in volts
See Also:
yTipStrain()

strainToDeflectionXArm

public double strainToDeflectionXArm()
Get the parameter to convert strain to deflection on the probe X arm. The deflection in microns is xArmStrain()*strainToDeflectionXArm().
Returns:
the probe X arm strain to deflection conversion parameter from volts to millimeters

strainToDeflectionXTip

public double strainToDeflectionXTip()
Get the parameter to convert strain to deflection on the probe X tip. The deflection in microns is xTipStrain()*strainToDeflectionXTip().
Returns:
the probe X tip strain to deflection conversion parameter from volts to millimeters

strainToDeflectionYArm

public double strainToDeflectionYArm()
Get the parameter to convert strain to deflection on the probe Y arm. The deflection in microns is yArmStrain()*strainToDeflectionYArm().
Returns:
the probe Y arm strain to deflection conversion parameter from volts to millimeters

strainToDeflectionYTip

public double strainToDeflectionYTip()
Get the parameter to convert strain to deflection on the probe Y tip. The deflection in microns is yTipStrain()*strainToDeflectionYTip().
Returns:
the probe Y tip strain to deflection conversion parameter from volts to millimeters

strainToForceXTip

public double strainToForceXTip()
Get the parameter to convert strain to force on the probe X tip. The force in milli Newtons is xTipStrain()*strainToForceXTip().
Returns:
the probe X tip strain to force conversion parameter from volts to milli Netwons

strainToForceYTip

public double strainToForceYTip()
Get the parameter to convert strain to force on the probe Y tip. The force in milli Newtons is yTipStrain()*strainToForceYTip().
Returns:
the probe Y tip strain to force conversion parameter from volts to milli Netwons

xArmDeflection

public double xArmDeflection()
Get the deflection of the probe X arm. This performs a new A/D conversion for the strain gauge
Returns:
the deflection in millimeters

xTipDeflection

public double xTipDeflection()
Get the deflection of the probe X tip. This performs a new A/D conversion for the strain gauge. Note that xTipForce() also reads the probe X tip strain gauge. If you only want to read the gauge once to get them both, you can call xTipStrain() and multiply by strainToDeflectionXTip() and strainToForceXTip().
Returns:
the deflection in millimeters
See Also:
xTipStrain(), strainToDeflectionXTip(), strainToForceXTip()

yArmDeflection

public double yArmDeflection()
Get the deflection of the probe Y arm. This performs a new A/D conversion for the strain gauge
Returns:
the deflection in millimeters

yTipDeflection

public double yTipDeflection()
Get the deflection of the probe Y tip. This performs a new A/D conversion for the strain gauge. Note that yTipForce() also reads the probe Y tip strain gauge. If you only want to read the gauge once to get them both, you can call yTipStrain() and multiply by strainToDeflectionYTip() and strainToForceXYTip().
Returns:
the deflection in millimeters
See Also:
yTipStrain(), strainToDeflectionYTip(), strainToForceYTip()

xTipForce

public double xTipForce()
Get the force on the probe X tip. This performs a new A/D conversion for the strain gauge. Note that xTipDeflection() also reads the probe X tip strain gauge. If you only want to read the gauge once to get them both, you can call xTipStrain() and multiply by strainToDeflectionXTip() and strainToForceXTip().
Returns:
the force in milli Newtons
See Also:
xTipStrain(), strainToDeflectionXTip(), strainToForceXTip()

yTipForce

public double yTipForce()
Get the force on the probe Y tip. This performs a new A/D conversion for the strain gauge. Note that yTipDeflection() also reads the probe Y tip strain gauge. If you only want to read the gauge once to get them both, you can call yTipStrain() and multiply by strainToDeflectionYTip() and strainToForceYTip().
Returns:
the force in milli Newtons
See Also:
yTipStrain(), strainToDeflectionYTip(), strainToForceYTip()

moveToXY

public void moveToXY(double x,
                     double y)
              throws CancelException
Move the stage to the x, y position, moving diagonally if necessary. Note that the coordinates are as if there are axes painted on the stage, so that the probes reach that position. That is, for the probes to get to increasing X, the stage itself actually moves in the negative direction. This calls CancelThread.check() to maybe throw a CancelException.
Parameters:
x - x coordinate to move to, in millimeters
y - y coordinate to move to, in millimeters
Throws:
CancelException - thrown by CancelThread.check() or if got an InterruptedException.
See Also:
CancelThread

moveToZ

public void moveToZ(double z)
             throws CancelException
Move the stage to the z position. This calls CancelThread.check() to maybe throw a CancelException.
Parameters:
z - z coordinate to move to, in millimeters
Throws:
CancelException - thrown by CancelThread.check() or if got an InterruptedException.
See Also:
CancelThread

stageX

public double stageX()
Return the X position of the stage in millimeters.

stageY

public double stageY()
Return the Y position of the stage in millimeters.

stageZ

public double stageZ()
Return the Z position of the stage in millimeters.

setStageXYZ

public void setStageXYZ(double x,
                        double y,
                        double z)
Set the present position of the stage. This can be used when the application starts to return the state to what it was during the previous session. Or, all values of zero can be used to reset the origin.
Parameters:
x - the new stage X position in millimeters
y - the new stage Y position in millimeters
z - the new stage Z position in millimeters

resetXTipStrain

public void resetXTipStrain()
Assume there is no force on the tip of probe X and set strainOffsetXTip so that xTipStrain() will read zero.
See Also:
xTipStrain()

resetYTipStrain

public void resetYTipStrain()
Assume there is no force on the tip of probe Y and set strainOffsetYTip so that yTipStrain() will read zero.
See Also:
yTipStrain()

resetXArmStrain

public void resetXArmStrain()
Assume that probe X is at the zero position and set strainOffsetXArm so that xArmStrain() will read zero.
See Also:
xArmStrain()

resetYArmStrain

public void resetYArmStrain()
Assume that probe Y is at the zero position and set strainOffsetYArm so that yArmStrain() will read zero.
See Also:
yArmStrain()

calibrateXArmDeflection

public void calibrateXArmDeflection(double deflection)
This adjusts strainToDeflectionXArm so that the current reading of xArmStrain() will yeild the given deflection. This assumes that strainOffsetXArm has already been calibrated using resetXArmStrain().
Parameters:
deflection - the actual deflection in millimeters that probe X arm is believed to be at
See Also:
resetXArmStrain()

calibrateYArmDeflection

public void calibrateYArmDeflection(double deflection)
This adjusts strainToDeflectionYArm so that the current reading of yArmStrain() will yeild the given deflection. This assumes that strainOffsetYArm has already been calibrated using resetYArmStrain().
Parameters:
deflection - the actual deflection in millimeters that probe Y arm is believed to be at
See Also:
resetYArmStrain()

calibrateXTipDeflection

public void calibrateXTipDeflection(double deflection)
This adjusts strainToDeflectionXTip so that the current reading of xTipStrain() will yeild the given deflection. This assumes that strainOffsetXTip has already been calibrated using resetXTipStrain().
Parameters:
deflection - the actual deflection in millimeters that probe X tip is believed to be at
See Also:
resetXTipStrain()

calibrateYTipDeflection

public void calibrateYTipDeflection(double deflection)
This adjusts strainToDeflectionYTip so that the current reading of yTipStrain() will yeild the given deflection. This assumes that strainOffsetYTip has already been calibrated using resetYTipStrain().
Parameters:
deflection - the actual deflection in millimeters that probe Y tip is believed to be at
See Also:
resetYTipStrain()

calibrateXTipForce

public void calibrateXTipForce(double force)
This adjusts strainToForceXTip so that the current reading of xTipStrain() will yeild the given force. This assumes that strainOffsetXTip has already been calibrated using resetXTipStrain().
Parameters:
force - the actual force in milli Newtons that probe X tip is believed to be at
See Also:
resetXTipStrain()

calibrateYTipForce

public void calibrateYTipForce(double force)
This adjusts strainToForceYTip so that the current reading of yTipStrain() will yeild the given force. This assumes that strainOffsetYTip has already been calibrated using resetYTipStrain().
Parameters:
force - the actual force in milli Newtons that probe Y tip is believed to be at
See Also:
resetYTipStrain()

calibrateStrainErrors

public void calibrateStrainErrors()
                           throws CancelException
This sets xArmStrainError, xTipStrainError, yArmStrainError and yTipStrain error by running a calibration algorithm. The calibration algorithm reads the each strain gauge for several iterations, computing the maximum and minimum readings. The error is maximum - minimum. This calls CancelThread.check() to maybe throw a CancelException.
Throws:
CancelException - thrown by CancelThread.check()
See Also:
CancelThread

strainErrorXArm

public double strainErrorXArm()

strainErrorXTip

public double strainErrorXTip()

strainErrorYArm

public double strainErrorYArm()

strainErrorYTip

public double strainErrorYTip()

relay1On

public void relay1On()
Set the digital output for relay number 1 to 1. You may check the state with relay1State()
See Also:
relay1State()

relay1Off

public void relay1Off()
Set the digital output for relay number 1 to 0. You may check the state with relay1State()
See Also:
relay1State()

relay1State

public boolean relay1State()
Return true if relay number 1 is on, otherwise false.
See Also:
relay1On(), relay1Off()