async def main(reset=True):
    # connect to motor and set initial values
    connectionManager = ConnectionManager(argList='--port 1')
    x = TMCM_1161(connectionManager.connect())
    initialize(x)
    # stop motors before setActualPosition (data sheet p76/110, table 15)
    if reset:
        x.stop()
        x.setActualPosition(0)

    # Move motor to initial value
    print('moving to initial position')
    set_speed(x, 1600, 1000, 3, 7)
    await move(x, 'abs', 51200, 1000, 'x')
    x.stop()
    report(x)  # print info in case of an error

    print('Start measurement')
    # increase pulse division to 6 for a smoother movement during measurement
    set_speed(x, 2047, 2047, 5, 8)
    result = []

    now = time.time()
    x.connection.clearDigitalOutput(
        0)  # sets digital output to high in my case
    x.connection.clearDigitalOutput(
        1)  # sets digital output to high in my case

    for i in range(100):
        val = await move(x, 'rel', -1024, 2047, 'x')
        ans = get_all_inputs(x)
        result.append((val, ans))
        print(i, val, ans)

    x.connection.setDigitalOutput(0)  # clears digital output in my case
    x.connection.setDigitalOutput(1)

    total = time.time() - now
    print(f'Finished measurement in {total:.2f}s')

    report(x)
    x.stop()

    # Plotting
    X = [i[0] for i in result]
    A = [i[1][0] for i in result]
    T = [i[1][1] for i in result]
    V = [i[1][2] for i in result]

    fig, (ax1, ax2, ax3) = plt.subplots(1, 3)
    ax1.plot(X, A)
    ax2.plot(X, T)
    ax3.plot(X, V)

    ax2.set_xlabel('Motor Position')
    ax1.set_ylabel('AIN_0 [0/4095]')
    ax2.set_ylabel('Temperature [°C]')
    ax3.set_ylabel('Voltage [1/10V]')
    plt.show()
예제 #2
0
 def __init__(self):
     port = "COM20"  #"/dev/ttyS0" #Change for different Interface type
     #port = "COM8"#"/dev/ttyS0" #Change for different Interface type
     interface = "serial_tmcl"
     datarate = "115200"
     arg = f"--interface {interface} --port {port} --data-rate {datarate}"
     print(arg)
     self.connectionManager = ConnectionManager(arg.split())
     self.connected = False
예제 #3
0
    def __init__(self, motor_id=1, diameter=0.5, gear_ratio=60):
        self.m_per_sec_convert = 3.14159 * diameter / (gear_ratio * 60)
        self.rpm_convert = gear_ratio * 60 / (3.14159 * diameter)
        msg = "--interface socketcan_tmcl --host-id 2 --module-id {module}".format(module = motor_id)
        connectionManager = ConnectionManager(msg.split())
        self.myInterface = connectionManager.connect()

        self.motorID = motor_id
        self.module = TMCM_1670(self.myInterface)

        # motor configuration
        self.module.setMaxTorque(3000)
        #self.module.showMotorConfiguration()

        # encoder configuration
        #self.module.showEncoderConfiguration()

        # motion settings
        self.module.setMaxVelocity(4000)
        self.module.setAcceleration(4000)
        self.module.setRampEnabled(1)
        self.module.setTargetReachedVelocity(100)
        self.module.setTargetReachedDistance(1000)
        self.module.setMotorHaltedVelocity(5)
        #self.module.showMotionConfiguration()

        # PI configuration
        self.module.setTorquePParameter(2000) #4000 #2:000
        self.module.setTorqueIParameter(2000) #2000
        self.module.setVelocityPParameter(800) #1000
        self.module.setVelocityIParameter(600) #500
        self.module.setPositionPParameter(300)
        #self.module.showPIConfiguration()

        # use out_0 output for enable input (directly shortened)
        self.module.setDigitalOutput(0);

        # sync actual position with encoder N-Channel 
        self.module.setActualPosition(0)
Created on 31.01.2020

@author: JM
'''

if __name__ == '__main__':
    pass

import time
import PyTrinamic
from PyTrinamic.connections.ConnectionManager import ConnectionManager
from PyTrinamic.modules.TMCM1630.TMCM_1630 import TMCM_1630

PyTrinamic.showInfo()
connectionManager = ConnectionManager(
    "--interface pcan_tmcl"
)  #This setting is configurated for PCAN , if you want to use another Connection please change this line
myInterface = connectionManager.connect()

module = TMCM_1630(myInterface)
"""
    Define all motor configurations for the 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 working.
"""

" motor configuration "
module.setMotorPoles(4)
module.setMaxTorque(2000)
module.showMotorConfiguration()
예제 #5
0
Created on 09.04.2020

@author: JM
'''

if __name__ == '__main__':
    pass

import time
from PyTrinamic.connections.ConnectionManager import ConnectionManager
from PyTrinamic.modules.TMCM1617.TMCM_1617 import TMCM_1617
"""
    Choose the right bustype before starting the script
"""

connectionManager = ConnectionManager(" --interface pcan_CANopen",
                                      connectionType="CANopen")
network = connectionManager.connect()

node = network.addDs402Node(TMCM_1617.getEdsFile(), 1)
module = node

#This function initialized the ds402StateMachine
node.setup_402_state_machine()

#####################
#Communication area
objManufacturerDeviceName = module.sdo[0x1008]
objManufacturerHardwareVersion = module.sdo[0x1009]

print()
print("Module name: %s" % objManufacturerDeviceName.raw)
예제 #6
0
@author: JM
'''

if __name__ == '__main__':
    pass

import PyTrinamic
from PyTrinamic.connections.ConnectionManager import ConnectionManager
from PyTrinamic.modules.TMCM1636.TMCM_1636 import TMCM_1636
import time

PyTrinamic.showInfo()

" choose the right bustype before starting the script "
connectionManager = ConnectionManager(" --interface kvaser_CANopen", connectionType = "CANopen")
network = connectionManager.connect()

node = network.addDs402Node(TMCM_1636.getEdsFile(), 1)
module = node

" this function initializes the DS402 state machine "
node.setup_402_state_machine()

" communication area "
objManufacturerDeviceName      = module.sdo[0x1008]
objManufacturerHardwareVersion = module.sdo[0x1009]

print()
print("Module name:        %s" % objManufacturerDeviceName.raw)
print("Hardware version:   %s" % objManufacturerHardwareVersion.raw)
예제 #7
0
#!/usr/bin/env python3
'''
Move a motor back and forth using velocity and position mode of the TMC2300

Created on 27.03.2020

@author: JM
'''

import time
import PyTrinamic
from PyTrinamic.connections.ConnectionManager import ConnectionManager
from PyTrinamic.evalboards.TMC2300_eval import TMC2300_eval

connectionManager = ConnectionManager()
myInterface = connectionManager.connect()

PyTrinamic.showInfo()

TMC2300 = TMC2300_eval(myInterface)
TMC2300.showChipInfo()

DEFAULT_MOTOR = 0

TMC2300.ICStandby(DEFAULT_MOTOR, 0)

TMC2300.setMicrostepResolution(DEFAULT_MOTOR, 256)

print("Rotating")
TMC2300.rotate(DEFAULT_MOTOR, 10 * 25600)
예제 #8
0
@author: JM, ED
'''

if __name__ == '__main__':
    pass

import time
import PyTrinamic
from PyTrinamic.connections.ConnectionManager import ConnectionManager
from PyTrinamic.modules.TMCM1633.TMCM_1633 import TMCM_1633

PyTrinamic.showInfo()

" please select your CAN adapter "
#connectionManager = ConnectionManager("--interface pcan_tmcl")
connectionManager = ConnectionManager("--interface kvaser_tmcl")
myInterface = connectionManager.connect()

module = TMCM_1633(myInterface)
"""
    Define motor configuration for the TMCM-1633.

    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.
"""

" motor configuration "
module.setMotorPoles(8)
module.setMaxTorque(2000)
module.showMotorConfiguration()
예제 #9
0
'''
Created on 30.12.2018

@author: ED
'''

if __name__ == '__main__':
    pass

import PyTrinamic, time
from PyTrinamic.connections.ConnectionManager import ConnectionManager
from PyTrinamic.modules.TMCM1640.TMCM_1640 import TMCM_1640

PyTrinamic.showInfo()

myInterface = ConnectionManager().connect()
module = TMCM_1640(myInterface)
module.showModuleInfo()
motor = module.motor(0)

"""
    Define motor configuration for the TMCM-1640.

    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.
"""

" motor configuration "
motor.setMotorPolePairs(4)
motor.setMaxTorque(2000)
motor.showConfiguration()
예제 #10
0
@author: JM, ED
'''

if __name__ == '__main__':
    pass

import PyTrinamic, time
from PyTrinamic.connections.ConnectionManager import ConnectionManager
from PyTrinamic.modules.TMCC160.TMCC_160 import TMCC_160

PyTrinamic.showInfo()

" please select your CAN adapter "
#myInterface = ConnectionManager("--interface pcan_tmcl").connect()
myInterface = ConnectionManager("--interface kvaser_tmcl").connect()

module = TMCC_160(myInterface)
module.showModuleInfo()
motor = module.motor(0)
"""
    Define motor configurations 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.
"""

" motor configuration "
motor.setMotorPolePairs(4)
motor.setMaxTorque(2000)
motor.showConfiguration()
예제 #11
0
################################# Preparation ##################################
PyTrinamic.showInfo()

if len(sys.argv) < 2:
    print("Usage:\n\tFirmwareUpdate.py HexFilePath [connection options]")
    exit(1)

print("Opening hex file (" + sys.argv[1] + ")")

try:
    f = open(sys.argv[1], "rt")
except FileNotFoundError:
    print("Error: Hex file not found")
    exit(1)

connectionManager = ConnectionManager(sys.argv)

############################### Hex file parsing ###############################
print("Parsing hex file")

data = []
extendedAddress = 0
segmentAddress  = 0
for lineNumber, line in enumerate(f, 1):
    ### Parse a hex file line
    # Check for RECORD MARK
    if line[0] != ':':
        continue

    # CHKSUM validation
    # All Bytes summed together modulo 256 have to be 0
예제 #12
0
'''
Created on 17.04.2020

@author: ed
'''

if __name__ == '__main__':
    pass

from PyTrinamic.connections.ConnectionManager import ConnectionManager
from modules.TMC4671_TMC6100_TOSV_REF import TMC4671_TMC6100_TOSV_REF
import time

connectionManager = ConnectionManager(
    "--interface serial_tmcl --port COM4 --data-rate 115200".split())
myInterface = connectionManager.connect()

module = TMC4671_TMC6100_TOSV_REF(myInterface)

" motor configuration "
module.setAxisParameter(module.APs.MaxCurrent, 2000)
module.showMotorConfiguration()

" hall sensor configuration"
module.showHallConfiguration()

" PI controller configuration "
module.setAxisParameter(module.APs.PressureP, 500)
module.setAxisParameter(module.APs.PressureI, 1000)
module.showPIConfiguration()
'''
Created on 06.05.2020

@author: ED
'''

if __name__ == '__main__':
    pass

import time
import PyTrinamic
from PyTrinamic.connections.ConnectionManager import ConnectionManager
from PyTrinamic.modules.TMCM1633.TMCM_1633 import TMCM_1633

PyTrinamic.showInfo()
connectionManager = ConnectionManager(
    "--interface kvaser_tmcl")  # You can select any CAN TMCL interface here
myInterface = connectionManager.connect()

module = TMCM_1633(myInterface)
"""
    Define all motor configurations for the TMCM-1633.

    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 working.
"""

# motor configuration
module.setMotorPoles(8)
module.setMaxTorque(4000)
module.showMotorConfiguration()
예제 #14
0
        8: "TMC2209",
        9: "TMCC160",
        10: "TMC6200",
        11: "TMC2160",
        12: "TMC7300",
        13: "TMC2590",
        18: "TMC2225",
        19: "TMC6100",
        14: "TMC2300",
        21: "TMC6300",
        22: "TMC2226",
    }


if __name__ == "__main__":
    from PyTrinamic.connections.ConnectionManager import ConnectionManager

    cm = ConnectionManager()
    interface = cm.connect()
    LB = Landungsbruecke(interface)

    print("ID EEPROM content:")
    print("Mc: ", LB.EepromDrv.read_id_info())
    print("Drv:", LB.EepromMc.read_id_info())

    print("Board IDs:")
    print(LB.getBoardIDs())

    print("Board Names:")
    print(LB.getBoardNames())
'''
Move a motor back and forth using the TMCM1370 module

Created on 08.07.2020

@author: JM
'''

import PyTrinamic
from PyTrinamic.connections.ConnectionManager import ConnectionManager
from PyTrinamic.modules.TMCM1370.TMCM_1370 import TMCM_1370
import time

PyTrinamic.showInfo()

connectionManager = ConnectionManager("--interface serial_tmcl")
myInterface = connectionManager.connect()
Module_1370 = TMCM_1370(myInterface)

DEFAULT_MOTOR = 0

print("Preparing parameters")
Module_1370.setMaxAcceleration(10000)

print("Rotating")
Module_1370.rotate(50000)

time.sleep(2);

print("Stopping")
Module_1370.stop()
예제 #16
0
'''
Move a motor back and forth using the TMCM6212 module

Created on 28.02.2019

@author: JM
'''

import PyTrinamic
from PyTrinamic.connections.ConnectionManager import ConnectionManager
from PyTrinamic.modules.TMCM6212.TMCM_6212 import TMCM_6212
import time

PyTrinamic.showInfo()

connectionManager = ConnectionManager(
)  # If no Interface is selected , the default interface is usb_tmcl
myInterface = connectionManager.connect()
Module_6212 = TMCM_6212(myInterface)

DEFAULT_MOTOR = 0

print("Preparing parameters")
Module_6212.setMaxAcceleration(9000)

print("Rotating")
Module_6212.rotate(40000)

time.sleep(5)

print("Stopping")
Module_6212.stop()