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> /// /// </summary> /// <param name="sn">Serial number of Xemo controller. Labeled on on of side panel of Xemo Controller SU 360</param> /// <param name="comPort">Port number referred to Xemo device. By default is 0 that means auto matching.</param> /// <param name="baudRate">BaudRate for chosen com port. Not used in case interface initialization via USB.</param> /// <param name="sets">Initial settings of current settings</param><seealso cref="SampleChangerSettings"/> public SampleChanger(int sn, ushort comPort = 0, int baudRate = 19200, SampleChangerSettings sets = null) { try { if (!XemoDet.ContainsKey(sn)) { Report.Notify(new Message(Codes.ERR_XM_INI_DEV_NF) { DetailedText = $"Device with such serial number '{sn}' not found" }); throw new ArgumentNullException($"Device with such serial number '{sn}' not found"); } if (sets == null) { Settings = new SampleChangerSettings(); } SerialNumber = sn; ComPort = GetComPortByDeviceId(SerialNumber); _baudRate = baudRate; PairedDetector = XemoDet[sn]; if (ComPort == 0) { XemoDLL.ML_DeIniCom(); } else { XemoDLL.ML_DeIniComPort((short)ComPort); } Connect(); ErrorHandlerDel = ErrorHandler; // you must save a "copy" of the delegate so that if the C functions calls this method at any time, this copy is still "alive" and hasn't been GC ML_ErrorCallBackDelegate(ErrorHandlerDel); InitializeAxes(); } catch (Exception ex) { Report.Notify(new Message(Codes.ERR_XM_INI_UNREG) { DetailedText = ex.Message }); throw; } }
private void Connect() { try { //XemoDLL.ML_DeIniCom(); //XemoDLL.ML_DeIniComPort((short)ComPort); XemoDLL.ML_IniUsb((short)ComPort, SerialNumber.ToString()); SelectCurrentComPort(); Reset(); } catch (Exception ex) { Report.Notify(new Message(Codes.ERR_XM_CON_UNREG) { DetailedText = ex.Message }); } }
/// <summary> /// A running MotionBasic program is halted. The online fifo is erased. The axes /// and outputs remain unchanged. /// </summary> public void HaltSystem() { SelectCurrentComPort(); XemoDLL.MB_SysControl(XemoConst.Halt); }
/// <summary> /// Sets the controller in the status which it had after being switched on. All axes /// are stopped immediately, all outputs are reset and all parameters are returned /// to their initial values. /// </summary> public void ResetSystem() { SelectCurrentComPort(); XemoDLL.MB_SetFifo(XemoConst.FfClear); XemoDLL.MB_SysControl(XemoConst.Reset); }
/// <summary> /// When an error occurs, the related error number is stored in an error buffer. /// Further, the bit ERR is set in the system status _state.The numbers of sequential errors /// are stored in the error buffer as well.With ResErr, the oldest of the /// errors is always erased from the error buffer first, then the next error, and so /// on.A critical error erases all other errors in the fifo and puts itself in first place. /// If another critical error occurs after that, it will overwrite the already present /// critical error. No commands can be executed. Not until after all errors have /// been erased with the instruction ResErr is it possible to execute commands again. /// </summary> public void ResetErrors() { SelectCurrentComPort(); XemoDLL.MB_ResErr(); }
public void SelectCurrentComPort() { //if (ComPort != 0) XemoDLL.ML_ComSelect((short)ComPort); }
/// <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); }
private void Home(Axes ax) { SelectCurrentComPort(); XemoDLL.MB_Home((short)ax); XemoDLL.MB_Still((short)ax); }
private void Stop(Axes ax) { SelectCurrentComPort(); XemoDLL.MB_Stop((short)ax); }
public bool IsNegativeSwitcher(Axes ax) { return(XemoDLL.MB_IoGet((short)ax, 0, 0, XemoConst.InPolarity) != 0); }
public bool IsReferenceSwitcher(Axes ax) { return(XemoDLL.MB_IoGet((short)ax, 0, 2, XemoConst.InPolarity) != 0); }
/// <summary> /// A running MotionBasic is aborted. All axes are stopped and all outputs reset. /// The online fifo is erased.All position counters and settings remain unchanged. /// </summary> public void BreakSystemProgram() { SelectCurrentComPort(); IsStopped = true; XemoDLL.MB_SysControl(XemoConst.Break); }
public void Disconnect() { BreakSystemProgram(); XemoDLL.ML_DeIniCom(); }
/// <summary> /// Like _Reset but with a restart of the possibly loaded MotionBasic program. /// NOTE: When switched on and at every program start in the main routine, the controller is automatically reset. /// </summary> public void RestartSystem() { SelectCurrentComPort(); XemoDLL.MB_SysControl(XemoConst.Restart); }
private int GetAxisParameter(Axes axis, short paramCode) { SelectCurrentComPort(); return(XemoDLL.MB_AGet((short)axis, paramCode)); }