Exemplo n.º 1
0
        private double TouchAndFindPressureSensor(double touchPointHeight, int timeoutSec = 60)
        {
            double needleHeight = 0;

            //Max down 0.5mm
            touchPointHeight -= 0.5;
            _mc.MoveToTarget(MotorZ, touchPointHeight);

            var stopwatch = new Stopwatch();

            stopwatch.Start();


            do
            {
                //if (_mc.IsMoving(MotorZ) == false)
                //{
                //    _mc.MoveToTargetRelative(MotorZ, -0.1);
                //    if (GetPosition(MotorZ)<=touchPointHeight)
                //    {
                //        throw new Exception("Find needle height timeout, maybe need to lower sensor: " + _coordinateId);
                //    }
                //}

                if (GetPressureValue() > NeedleTouchPressure)
                {
                    _mc.Stop(MotorZ);
                    Delay(800);
                    needleHeight = _mc.GetPosition(MotorZ) + NeedleOnZHeightCompensation;
                    SetSpeed(1);
                    _mc.MoveToTargetRelativeTillEnd(MotorZ, 2);
                    return(needleHeight);
                }

                if (stopwatch.ElapsedMilliseconds > timeoutSec * 1000)
                {
                    throw new Exception("Find needle height timeout, maybe need to lower sensor: " + _coordinateId);
                }
            } while (true);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Get motor encoder position or reference position of motors.
 /// </summary>
 /// <param name="motor"></param>
 /// <returns></returns>
 public double GetPosition(Motor motor)
 {
     return(_mc.GetPosition(motor));
 }