def __init__(self): # Open communications with sensor Arduino board and motor for device in list_ports.comports(): if device.description == 'Trinamic Stepper Device': motorPort = device.device self.sens = sensorShield.sensorShield() try: myInterface = serial_tmcl_interface(motorPort) self.module = TMCM_1160(myInterface) except: print('Motor device not found') sys.exit() print("Opened connection to sensors") PyTrinamic.showInfo() PyTrinamic.showAvailableComPorts() print("\n")
''' if __name__ == '__main__': pass import time import PyTrinamic from PyTrinamic.connections.serial_tmcl_interface import serial_tmcl_interface from PyTrinamic.evalboards.TMC4671_eval import TMC4671_eval from PyTrinamic.ic.TMC4671.TMC4671_register import TMC4671_register from PyTrinamic.ic.TMC4671.TMC4671_mask_shift import TMC4671_mask_shift PyTrinamic.showInfo() PyTrinamic.showAvailableComPorts() myInterface = serial_tmcl_interface('COM5') tmc4671_eval = TMC4671_eval(myInterface) tmc4671_eval.showChipInfo() tmc4671_reg = TMC4671_register() tmc4671_ms = TMC4671_mask_shift() " configure TMC4671 for a BLDC motor with ABN-Encoder " " Motor type & PWM configuration " myInterface.writeMC(tmc4671_reg.MOTOR_TYPE_N_POLE_PAIRS, 0x00030004) myInterface.writeMC(tmc4671_reg.PWM_POLARITIES, 0x00000000) myInterface.writeMC(tmc4671_reg.PWM_MAXCNT, int(0x00000F9F)) myInterface.writeMC(tmc4671_reg.PWM_BBM_H_BBM_L, 0x00000505) myInterface.writeMC(tmc4671_reg.PWM_SV_CHOP, 0x00000007)
# Define parameters of magnet + shuttle system B0 = setup.B0 # Magnetic field strength at centre of magnet (Tesla) Circ = setup.circ # Circumference of spindle wheel (cm) BSample = float(sys.argv[3]) # Sample field strength (mT) speed = float(sys.argv[6]) # Motor speed (cm/s) accel = float(sys.argv[7]) # Acceleration (cm/s^2) dist = float(sys.argv[8]) # Distance to move (cm) ramp = str(sys.argv[9]) # Equation for velocity ramp # Open communications with motor driver PyTrinamic.showInfo() for device in list_ports.comports(): if device.description == 'Trinamic Stepper Device': port = device.device try: myInterface = serial_tmcl_interface(port) except: print('Motor driver not found') terminate() module = TMCM_1160(myInterface) print("\n") # Reset all error flags module.setUserVariable(9, 0) #Clear motor error flags module.setUserVariable(8, 0) #Set position to 'down' # Get operation mode mode = int(sys.argv[1] ) # 1 = Constant velocity, 2 = Velocity sweep, 3 = Constant time # Get tube type and fetch appropriate stall guard settings
if __name__ == '__main__': pass import time import PyTrinamic from PyTrinamic.connections.serial_tmcl_interface import serial_tmcl_interface from PyTrinamic.modules.TMCM_1640 import TMCM_1640 PyTrinamic.showInfo() PyTrinamic.showAvailableComPorts() " for usb connection " #myInterface = serial_tmcl_interface('COM9') " for RS485 connection " myInterface = serial_tmcl_interface('COM16', '9600') module = TMCM_1640(myInterface) " motor configuration " module.setMotorPoles(8) module.setMaxTorque(2000) module.showMotorConfiguration() " hall configuration " module.setHallInvert(0) module.showHallConfiguration() " motion settings " module.setMaxVelocity(1000) module.setAcceleration(2000)
# If the encoding failed, abort here if not (table): exit(1) # Display register values and plots of the waveforms table.printRegisters() table.plotQuarterWave(block=False) table.plotXY(block=False) table.plotWaveform(block=True) if not (UPLOAD_TABLE): exit(0) # Upload the table to a TMC5041 connected over USB myInterface = serial_tmcl_interface( PyTrinamic.firstAvailableComPort(USB=True)) TMC5041 = TMC5041_eval(myInterface) TMC5041.writeRegister(TMC5041.registers.MSLUT0, table._reg_MSLUT[0]) TMC5041.writeRegister(TMC5041.registers.MSLUT1, table._reg_MSLUT[1]) TMC5041.writeRegister(TMC5041.registers.MSLUT2, table._reg_MSLUT[2]) TMC5041.writeRegister(TMC5041.registers.MSLUT3, table._reg_MSLUT[3]) TMC5041.writeRegister(TMC5041.registers.MSLUT4, table._reg_MSLUT[4]) TMC5041.writeRegister(TMC5041.registers.MSLUT5, table._reg_MSLUT[5]) TMC5041.writeRegister(TMC5041.registers.MSLUT6, table._reg_MSLUT[6]) TMC5041.writeRegister(TMC5041.registers.MSLUT7, table._reg_MSLUT[7]) TMC5041.writeRegister(TMC5041.registers.MSLUTSEL, table._reg_MSLUTSEL) TMC5041.writeRegister(TMC5041.registers.MSLUTSTART, table._reg_MSLUTSTART) myInterface.close()