/// <summary> /// Converts a <see cref="byte"/> array holding binary coded digits to a readable string. /// </summary> /// <param name="data">The binary coded digit bytes</param> /// <param name="isLittleEndian">Value indicating if the first nibble contains the least significant part</param> /// <returns>A string containing numeric data</returns> /// <exception cref="ArgumentException">The array contains one or more non-BCD bytes.</exception> public static void SetRAMPSBoard(this ArduinoSession session) { //Stepper // X session.StepperConfiguration(0, new DeviceConfig { MotorInterface = DeviceConfig.MotorInterfaceType.Driver, StepOrPin1Number = 54, DirectionOrPin2Number = 55, EnablePinNumber = 38, InvertEnablePinNumber = true }); // Y session.StepperConfiguration(1, new DeviceConfig { MotorInterface = DeviceConfig.MotorInterfaceType.Driver, StepOrPin1Number = 60, DirectionOrPin2Number = 61, EnablePinNumber = 56, InvertEnablePinNumber = true }); // Z session.StepperConfiguration(2, new DeviceConfig { MotorInterface = DeviceConfig.MotorInterfaceType.Driver, StepOrPin1Number = 46, DirectionOrPin2Number = 48, EnablePinNumber = 62, InvertEnablePinNumber = true }); // E0 session.StepperConfiguration(3, new DeviceConfig { MotorInterface = DeviceConfig.MotorInterfaceType.Driver, StepOrPin1Number = 26, DirectionOrPin2Number = 28, EnablePinNumber = 24, InvertEnablePinNumber = true }); // E1 session.StepperConfiguration(4, new DeviceConfig { MotorInterface = DeviceConfig.MotorInterfaceType.Driver, StepOrPin1Number = 36, DirectionOrPin2Number = 34, EnablePinNumber = 30, InvertEnablePinNumber = true }); }
/// <summary> /// Converts a <see cref="byte"/> array holding binary coded digits to a readable string. /// </summary> /// <param name="data">The binary coded digit bytes</param> /// <param name="isLittleEndian">Value indicating if the first nibble contains the least significant part</param> /// <returns>A string containing numeric data</returns> /// <exception cref="ArgumentException">The array contains one or more non-BCD bytes.</exception> public static void SetCNCShieldV3Board(this ArduinoSession session) { //Stepper // X session.StepperConfiguration(0, new DeviceConfig { MotorInterface = DeviceConfig.MotorInterfaceType.Driver, StepOrPin1Number = 2, DirectionOrPin2Number = 5, EnablePinNumber = 8, InvertEnablePinNumber = true }); // Y session.StepperConfiguration(1, new DeviceConfig { MotorInterface = DeviceConfig.MotorInterfaceType.Driver, StepOrPin1Number = 3, DirectionOrPin2Number = 6, EnablePinNumber = 8, InvertEnablePinNumber = true }); // Z session.StepperConfiguration(2, new DeviceConfig { MotorInterface = DeviceConfig.MotorInterfaceType.Driver, StepOrPin1Number = 4, DirectionOrPin2Number = 7, EnablePinNumber = 8, InvertEnablePinNumber = true }); // A session.StepperConfiguration(3, new DeviceConfig { MotorInterface = DeviceConfig.MotorInterfaceType.Driver, StepOrPin1Number = 11, DirectionOrPin2Number = 13, EnablePinNumber = 8, InvertEnablePinNumber = true }); }
public ArduinoSession GetArduinoSession() { if (arduinoSession == null) { var connection = GetConnection(); var session = new ArduinoSession(connection); var firmware = session.GetFirmware(); if (firmware.MajorVersion >= 2) { session.ResetBoard(); //步进电机 session.CreateStepperMoveCompleteMonitor().Monitor(f => { GetStepperStep(f.DeviceNumber).Invoke(f.DeviceNumber); }); session.CreateReceivedStringMonitor().Monitor(f => { }); session.StepperConfiguration(0, new DeviceConfig { MotorInterface = DeviceConfig.MotorInterfaceType.Driver, StepOrPin1Number = 26, DirectionOrPin2Number = 28, EnablePinNumber = 24, InvertEnablePinNumber = true }); session.StepperEnable(0, true); session.StepperSetSpeed(0, 32767); session.StepperSetScceleration(0, 5000); arduinoSession = session; } else { session.Dispose(); throw new Exception("读取设备失败"); } } return(arduinoSession); }