private void Move(Axes axis, int?coordinate = null, int?speed = null, Direction?dir = null) { try { if (IsStopped) { return; } _activeAxis = axis; if (coordinate == null && speed == null) { return; } SelectCurrentComPort(); PinnedPosition = PinnedPositions.Moving; if (coordinate.HasValue) { var _speed = XemoDLL.MB_AGet((short)axis, XemoConst.Speed); if (speed.HasValue) { XemoDLL.MB_ASet((short)axis, XemoConst.Speed, speed.Value); } //XemoDLL.MB_Delay(100); XemoDLL.MB_Amove((short)axis, coordinate.Value); XemoDLL.MB_Still((short)axis); XemoDLL.MB_ASet((short)axis, XemoConst.Speed, _speed); //XemoDLL.MB_Delay(1000); return; } if (speed.HasValue && dir.HasValue) { XemoDLL.MB_Jog((short)axis, (int)dir.Value * speed.Value); return; } } catch (Exception ex) { Report.Notify(new Message(Codes.ERR_XM_MOVE_UNREG) { DetailedText = ex.Message }); } }
/// <summary> /// See description for each parameter before change something! /// </summary> /// <param name="ax"></param> private void InitAxisParam(Axes ax) { try { SelectCurrentComPort(); var axisNum = (short)ax; var XemoType = XemoDLL.MB_Get(XemoConst.Version); XemoDLL.MB_ASet(axisNum, XemoConst.Current, Settings.AxesParams.MOTOR_CURRENT[axisNum]); XemoDLL.MB_ASet(axisNum, XemoConst.StopCurr, Settings.AxesParams.MOTOR_STOP_CURRENT[axisNum]); XemoDLL.MB_ASet(axisNum, XemoConst.Micro, Settings.AxesParams.MICROSTEP_RESOLUTION[axisNum]); XemoDLL.MB_ASet(axisNum, XemoConst.Iscale, (int)Math.Round((float)Settings.AxesParams.INC_PER_REVOLUTION[axisNum] / Settings.AxesParams.MICROSTEP_RESOLUTION[axisNum])); // 10 000 XemoDLL.MB_ASet(axisNum, XemoConst.Uscale, (int)Math.Round(unchecked (Settings.AxesParams.MM_PER_REVOLUTION[axisNum] * 100f))); // 800 //var _speeds = new int[] { Settings.YVelocity, Settings.XVelocity, Settings.CVelocity }; var _speeds = new int[] { 4000, 4000, 3000 }; if (_speeds[axisNum] > Settings.AxesParams.MAX_VELOCITY[axisNum]) { XemoDLL.MB_ASet(axisNum, XemoConst.Speed, Settings.AxesParams.MAX_VELOCITY[axisNum]); } else { XemoDLL.MB_ASet(axisNum, XemoConst.Speed, _speeds[axisNum]); } XemoDLL.MB_ASet(axisNum, XemoConst.Accel, (int)Math.Round(unchecked (Settings.AxesParams.ACCELERATION_FACTOR[axisNum] *checked (Settings.AxesParams.MAX_VELOCITY[axisNum])))); // 10 000 XemoDLL.MB_ASet(axisNum, XemoConst.Vmin, (int)Math.Round(unchecked (Settings.AxesParams.START_STOP_FREQUENCY[axisNum] * 100f) / 10.0)); // 800 XemoDLL.MB_ASet(axisNum, XemoConst.Decel, (int)Math.Round(unchecked (Settings.AxesParams.DECELERATION_FACTOR[axisNum] *checked (Settings.AxesParams.MAX_VELOCITY[axisNum])))); // 10 000 XemoDLL.MB_ASet(axisNum, XemoConst.H1Speed, Settings.AxesParams.REF_VELOCITY_H1[axisNum] * 100); // 4000 XemoDLL.MB_ASet(axisNum, XemoConst.H2Speed, Settings.AxesParams.REF_VELOCITY_H2[axisNum] * 100); // -300 XemoDLL.MB_ASet(axisNum, XemoConst.H3Speed, Settings.AxesParams.REF_VELOCITY_H3[axisNum] * 100); // 10 000 XemoDLL.MB_ASet(axisNum, XemoConst.HOffset, (int)Math.Round(unchecked (Settings.AxesParams.ZERO_REF_OFFSET[axisNum] * 100))); //// negative switch polarity //XemoDLL.MB_IoSet(axisNum, 0, 0, XemoConst.InPolarity, Settings.AxesParams.POLARITY_SWITCHES[axisNum]); //// positive switch polarity //XemoDLL.MB_IoSet(axisNum, 0, 1, XemoConst.InPolarity, Settings.AxesParams.POLARITY_SWITCHES[axisNum]); //// reference switch polarity //XemoDLL.MB_IoSet(axisNum, 0, 2, XemoConst.InPolarity, Settings.AxesParams.POLARITY_SWITCHES[axisNum]); // all switches polarity XemoDLL.MB_IoSet(axisNum, 0, 3, XemoConst.InPolarity, Settings.AxesParams.POLARITY_SWITCHES[axisNum]); XemoDLL.MB_ASet(axisNum, XemoConst.SlLimit, -100000); XemoDLL.MB_ASet(axisNum, XemoConst.SrLimit, 100000); //XemoDLL.MB_ASet(axisNum, XemoConst.BLash, (int)Math.Round(unchecked(Settings.AxesParams.BLASH[axisNum] * 100))); //XemoDLL.MB_ASet(axisNum, XemoConst.StpEncoder, Settings.AxesParams.INC_MONITORING_ENCODER[axisNum]); //XemoDLL.MB_ASet(axisNum, XemoConst.FErrWin, Settings.AxesParams.POSITION_ERROR[axisNum]); } catch (Exception ex) { Report.Notify(new Message(Codes.ERR_XM_INI_AX_UNREG) { DetailedText = string.Join('.', $"Error during axis {(short)ax} initialization", ex.Message) }); } }
private void SetAxisParameter(Axes axis, short paramCode, int value) { SelectCurrentComPort(); XemoDLL.MB_ASet((short)axis, paramCode, value); }