""" Move a motor back and forth using velocity and position mode of the TMC5041 """ import time import pytrinamic from pytrinamic.connections import ConnectionManager from pytrinamic.evalboards import TMC5041_eval pytrinamic.show_info() with ConnectionManager().connect() as my_interface: print(my_interface) # Create TMC5041-EVAL class which communicates over the Landungsbrücke via TMCL eval_board = TMC5041_eval(my_interface) mc = eval_board.ics[0] motor0 = eval_board.motors[0] print(motor0) motor1 = eval_board.motors[1] print(motor1) for i in range(2): print("Preparing parameter for motor" + str(i) + "...") eval_board.write_register(mc.REG.A1[i], 1000) eval_board.write_register(mc.REG.V1[i], 50000) eval_board.write_register(mc.REG.D1[i], 500) eval_board.write_register(mc.REG.DMAX[i], 500) eval_board.write_register(mc.REG.VSTART[i], 0) eval_board.write_register(mc.REG.VSTOP[i], 10) eval_board.write_register(mc.REG.AMAX[i], 1000)
""" Dump all register values of the TMC5062 IC. The connection to a Landungsbrücke is established over USB. TMCL commands are used for communicating with the IC. """ import pytrinamic from pytrinamic.connections import ConnectionManager from pytrinamic.evalboards import TMC5062_eval pytrinamic.show_info() my_interface = ConnectionManager().connect() print(my_interface) eval_board = TMC5062_eval(my_interface) mc = eval_board.ics[0] print("Motion controller info: " + str(mc.get_info())) print("Register dump for " + str(mc.get_name()) + ":") print("GCONF: 0x{0:08X}".format( eval_board.read_register(mc.REG.GCONF))) print("GSTAT: 0x{0:08X}".format( eval_board.read_register(mc.REG.GSTAT))) print("SLAVECONF: 0x{0:08X}".format( eval_board.read_register(mc.REG.SLAVECONF))) print("INPUT: 0x{0:08X}".format( eval_board.read_register(mc.REG.INPUT_OUTPUT))) print("X_COMPARE: 0x{0:08X}".format( eval_board.read_register(mc.REG.X_COMPARE))) for i in range(2):
import pytrinamic from pytrinamic.connections import ConnectionManager from pytrinamic.modules import TMCM1636 import time pytrinamic.show_info() # connection_manager = ConnectionManager("--interface serial_tmcl --port COM4 --data-rate 115200") connection_manager = ConnectionManager("--interface kvaser_tmcl --module-id 1") with connection_manager.connect() as my_interface: module = TMCM1636(my_interface) motor = module.motors[0] # Define motor configuration for the TMCM-1636. # # The configuration is based on our standard BLDC motor (QBL4208-61-04-013-1024-AT). # If you use a different motor be sure you have the right configuration setup otherwise the script may not work. # drive configuration motor.drive_settings.motor_type = motor.ENUM.MOTOR_TYPE_THREE_PHASE_BLDC motor.drive_settings.pole_pairs = 4 motor.drive_settings.max_current = 2000 motor.drive_settings.commutation_mode = motor.ENUM.COMM_MODE_DIGITAL_HALL motor.drive_settings.target_reached_distance = 5 motor.drive_settings.target_reached_velocity = 500 print(motor.drive_settings) # hall sensor configuration motor.digital_hall.direction = 0 motor.digital_hall.polarity = 1 motor.digital_hall.offset = 0
import pytrinamic from pytrinamic.connections import ConnectionManager from pytrinamic.modules import TMCC160 import time pytrinamic.show_info() # please select your CAN adapter # my_interface = ConnectionManager("--interface pcan_tmcl").connect() my_interface = ConnectionManager("--interface kvaser_tmcl").connect() with my_interface: module = TMCC160(my_interface) motor = module.motors[0] # Define motor configuration for the TMCC160-EVAL. # # The configuration is based on our standard BLDC motor (QBL4208-61-04-013-1024-AT). # If you use a different motor be sure you have the right configuration setup otherwise the script may not work. # drive configuration motor.drive_settings.poles = 8 motor.drive_settings.max_current = 2000 motor.drive_settings.target_reached_velocity = 500 motor.drive_settings.target_reached_distance = 5 motor.drive_settings.open_loop_current = 1000 # encoder configuration motor.abn_encoder.resolution = 4096 # motor.abn_encoder.resolution = 16384 motor.abn_encoder.direction = 0
import pytrinamic from pytrinamic.connections import ConnectionManager from pytrinamic.modules import TMCM1630 import time pytrinamic.show_info() # please select a CAN or USB interface # CAN # my_interface = ConnectionManager("--interface pcan_tmcl").connect() # my_interface = ConnectionManager("--interface kvaser_tmcl").connect() # USB my_interface = ConnectionManager().connect() with my_interface: module = TMCM1630(my_interface) motor = module.motors[0] # Define motor configuration for the TMCM-1630. # # The configuration is based on our standard BLDC motor (QBL4208-61-04-013-1024-AT). # If you use a different motor be sure you have the right configuration setup otherwise the script may not work. # drive configuration motor.drive_settings.poles = 8 motor.drive_settings.max_current = 2000 motor.drive_settings.target_reached_velocity = 500 motor.drive_settings.target_reached_distance = 5
#This program downloads a TMCL binary file to a module. #Such binary files can be generated using the TMCL Creator in the TMCL-IDE #(switch on the option "Generate binary file") or by the command line tool TMCLAsm. from functools import partial; from pytrinamic.connections import ConnectionManager from pytrinamic.tmcl import TMCLCommand filename = "test.bin" #This can be any TMCL binary file generated by the TMCL-IDE or by TMCLAsm with open(filename, 'rb') as TMCLFile: connection_manager = ConnectionManager("--interface serial_tmcl --port COM4 --data-rate 9600") #This can also be any other interface with connection_manager.connect() as my_interface: my_interface.send(TMCLCommand.START_DOWNLOAD_MODE, 0, 0, 0) for cmd_array in iter(partial(TMCLFile.read, 8), b''): my_interface.send(cmd_array[0], cmd_array[1], cmd_array[2], (cmd_array[3]<<24)|(cmd_array[4]<<16)|(cmd_array[5]<<8)|(cmd_array[6])) my_interface.send(TMCLCommand.QUIT_DOWNLOAD_MODE, 0, 0, 0) my_interface.send(TMCLCommand.RESET_APPLICATION, 0, 0, 0) my_interface.send(TMCLCommand.RUN_APPLICATION, 0, 0, 0) #This can be omitted if the porgram does not need to be started right after downloading TMCLFile.close()
import pytrinamic from pytrinamic.connections import ConnectionManager from pytrinamic.modules import TMCM1270 import time pytrinamic.show_info() # This example uses PCAN, if you want to use another connection please change this line. connectionManager = ConnectionManager("--interface pcan_tmcl") myInterface = connectionManager.connect() module = TMCM1270(myInterface) motor = module.motors[0] print("Preparing parameters") motor.max_acceleration = 20000 print("Rotating") motor.rotate(50000) time.sleep(5) print("Stopping") motor.stop() print("ActualPostion = {}".format(motor.actual_position)) time.sleep(5) print("Doubling moved distance") motor.move_by(motor.actual_position, 50000) while not(motor.get_position_reached()):
"""Example that shows how to download a TMCL script to the TMCL scrip memory of a TMCM-1636. TMCL scripts are stored non-volatile with the download. """ import time from pytrinamic.connections import ConnectionManager from pytrinamic.modules import TMCM1636 from pytrinamic.tmcl import TMCLCommand connection_manager = ConnectionManager( "--interface serial_tmcl --port COM4 --data-rate 115200") with connection_manager.connect() as my_interface: module = TMCM1636(my_interface) motor = module.motors[0] module.connection.send(TMCLCommand.START_DOWNLOAD_MODE, 0, 0, 0) # The following commands will not be executed but are load into the TMCL script memory of the module. # Notice that the parameter for the jump command is the index of the command to jump to. # Here the JA jumps to [1] which is "ROR 0, 500". module.connection.send(TMCLCommand.SAP, motor.AP.CommutationMode, 0, 3) # [0] SAP 15, 0, 4 # Loop: module.connection.send(TMCLCommand.ROR, 0, 0, 500) # [1] ROR 0, 500 module.connection.send(TMCLCommand.WAIT, 0, 0, 100) # [2] WAIT TICKS, 0, 100 module.connection.send(TMCLCommand.ROR, 0, 0, -500) # [3] ROR 0, -500 module.connection.send(TMCLCommand.WAIT, 0, 0,
import pytrinamic from pytrinamic.connections import ConnectionManager from pytrinamic.ic import MAX22216 from pytrinamic.RAMDebug import Channel, RAMDebug, RAMDebug_Trigger pytrinamic.show_info() with ConnectionManager(debug=True).connect() as my_interface: print(my_interface) ch = Channel.field(0, MAX22216.FIELD.ADC_VM_RAW, signed=True, eval_channel=1) trigger = Channel.field(0, MAX22216.FIELD.ADC_VM_RAW, signed=True, eval_channel=1) debug = RAMDebug(my_interface) debug.set_channel(ch) debug.set_trigger_type(RAMDebug_Trigger.TRIGGER_RISING_EDGE_SIGNED) debug.set_trigger_threshold(50) debug.start_measurement(is_eval=True) while (not debug.is_measurement_done()): pass samples = debug.get_samples() print("\nDone.")
import pytrinamic from pytrinamic.connections import ConnectionManager from pytrinamic.modules import TMCM3351 import time pytrinamic.show_info() connectionManager = ConnectionManager( ) # If no Interface is selected , the default interface is usb_tmcl with connectionManager.connect() as myInterface: module = TMCM3351(myInterface) motor_0 = module.motors[0] motor_1 = module.motors[1] motor_2 = module.motors[2] # Please be sure not to use a too high current setting for your motor. print("Preparing parameters") # preparing drive settings motor_0.drive_settings.max_current = 128 motor_0.drive_settings.standby_current = 0 motor_0.drive_settings.boost_current = 0 motor_0.drive_settings.microstep_resolution = motor_0.ENUM.microstep_resolution_256_microsteps print(motor_0.drive_settings) motor_1.drive_settings.max_current = 128 motor_1.drive_settings.standby_current = 0 motor_1.drive_settings.boost_current = 0 motor_1.drive_settings.microstep_resolution = motor_0.ENUM.microstep_resolution_256_microsteps print(motor_1.drive_settings) motor_2.drive_settings.max_current = 128 motor_2.drive_settings.standby_current = 0
import pytrinamic from pytrinamic.connections import ConnectionManager from pytrinamic.modules import TMCM1370 import time pytrinamic.show_info() connectionManager = ConnectionManager( "--interface serial_tmcl --port COM10 --data_rate 9600") myInterface = connectionManager.connect() module = TMCM1370(myInterface) motor = module.motors[0] # preparing drive settings motor.drive_settings.max_current = 50 motor.drive_settings.standby_current = 0 motor.drive_settings.boost_current = 0 motor.drive_settings.microstep_resolution = motor.ENUM.MicrostepResolution256Microsteps print(motor.drive_settings) # preparing linear ramp settings motor.linear_ramp.max_velocity = 20000 motor.linear_ramp.max_acceleration = 40000 print(motor.linear_ramp) time.sleep(1.0) # set move_by relative to the actual position motor.set_axis_parameter(motor.AP.RelativePositioningOption, 1) # clear position counter
import pytrinamic from pytrinamic.connections import ConnectionManager from pytrinamic.modules import TMCM1636 import time pytrinamic.show_info() # please select your interface # my_interface = ConnectionManager("--interface serial_tmcl --port COM4 --data-rate 115200").connect() my_interface = ConnectionManager("--interface kvaser_tmcl --module-id 1").connect() with my_interface: module = TMCM1636(my_interface) motor = module.motors[0] # Define motor configuration for the TMCM-1636. # # The configuration is based on our standard BLDC motor (QBL4208-61-04-013-1024-AT). # If you use a different motor be sure you have the right configuration setup otherwise the script may not work. # drive configuration motor.drive_settings.motor_type = motor.ENUM.MOTOR_TYPE_THREE_PHASE_BLDC motor.drive_settings.pole_pairs = 4 motor.drive_settings.max_current = 2000 motor.drive_settings.commutation_mode = motor.ENUM.COMM_MODE_DIGITAL_HALL motor.drive_settings.target_reached_distance = 5 motor.drive_settings.target_reached_velocity = 500 print(motor.drive_settings) # hall sensor configuration motor.digital_hall.direction = 0
14: "TMC2300", 21: "TMC6300", 22: "TMC2226", } class GP: VitalSignsErrorMask = 1 DriversEnable = 2 DebugMode = 3 BoardAssignment = 4 HWID = 5 PinState = 6 if __name__ == "__main__": from pytrinamic.connections import ConnectionManager cm = ConnectionManager() interface = cm.connect() LB = Landungsbruecke(interface) print("ID EEPROM content:") print("Mc: ", LB.eeprom_drv.read_id_info()) print("Drv:", LB.eeprom_mc.read_id_info()) print("Board IDs:") print(LB.get_board_ids()) print("Board Names:") print(LB.get_board_names())
import pytrinamic from pytrinamic.connections import ConnectionManager from pytrinamic.modules import TMCM1161 import time pytrinamic.show_info() # using USB interface connectionManager = ConnectionManager() myInterface = connectionManager.connect() print(myInterface) with myInterface: module = TMCM1161(myInterface) motor = module.motors[0] # The configuration is based on our TMCM-1161-TMCL # If you use a different motor be sure you have the right configuration setup otherwise the script may not working. print("Preparing parameters...") # preparing drive settings motor.drive_settings.max_current = 1000 motor.drive_settings.standby_current = 0 motor.drive_settings.boost_current = 0 motor.drive_settings.microstep_resolution = motor.ENUM.MicrostepResolution256Microsteps print(motor.drive_settings) # preparing linear ramp settings motor.linear_ramp.max_acceleration = 1000
import pytrinamic from pytrinamic.connections import ConnectionManager from pytrinamic.modules import TMCM6110 import time pytrinamic.show_info() connectionManager = ConnectionManager() # using USB with connectionManager.connect() as myInterface: module = TMCM6110(myInterface) motor_0 = module.motors[0] motor_1 = module.motors[1] motor_2 = module.motors[2] motor_3 = module.motors[3] motor_4 = module.motors[4] motor_5 = module.motors[5] # If you use a different motor_0 be sure you have the right configuration setup otherwise the script may not work. print("Preparing parameters") # preparing drive settings motor_0.drive_settings.max_current = 200 motor_0.drive_settings.standby_current = 0 motor_0.drive_settings.boost_current = 0 motor_0.drive_settings.microstep_resolution = motor_0.ENUM.microstep_resolution_256_microsteps print(motor_0.drive_settings) motor_1.drive_settings.max_current = 200 motor_1.drive_settings.standby_current = 0 motor_1.drive_settings.boost_current = 0 motor_1.drive_settings.microstep_resolution = motor_0.ENUM.microstep_resolution_256_microsteps print(motor_1.drive_settings)