pass

import time
from PyTrinamic.connections.ConnectionManager import ConnectionManager
from PyTrinamic.modules.TMCM1270.TMCM_1270 import TMCM_1270

"""
    Choose the right bustype before starting the script.
    If no connection type is given the default connection type for this script is usb_tmcl.
    For further details look in our ConnectionManager and the connection interfaces.
"""

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

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

# This function initialized the ds402StateMachine
node.setup_402_state_machine()

objSwitchParameter    = module.sdo[0x2005]
objModeOfOperation    = module.sdo[0x6060]
objActualPosition     = module.sdo[0x6064]
objTargetPosition     = module.sdo[0x607A]
objAcceleration       = module.sdo[0x6083]

if node.is_faulted():
    node.reset_from_fault() # Reset node from fault and set it to Operation Enable state 

def startPP():
Created on 03.12.2019

@author: JM
'''

import PyTrinamic
from PyTrinamic.connections.ConnectionManager import ConnectionManager
from PyTrinamic.modules.TMCM1270.TMCM_1270 import TMCM_1270
import time

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_1270 = TMCM_1270(myInterface)

DEFAULT_MOTOR = 0

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

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

time.sleep(5);

print("Stopping")
Module_1270.stop()

print("ActualPostion") 
Пример #3
0
from PyTrinamicMicro import PyTrinamicMicro
import struct
import logging
import time

# Prepare Logger
PyTrinamicMicro.set_logging_console_enabled(False)
logger = logging.getLogger(__name__)
logger.info("TMCL Slave on USB_VCP interface")

# Main program
lin = None
logger.info("Initializing interface ...")
con = usb_vcp_tmcl_interface()
slave = tmcl_slave_demo()
module = TMCM_1270(can_tmcl_interface())
module.setMaxAcceleration(0, 100000)
logger.info("Interface initialized.")

t = 0

while (not (slave.status.stop)):
    # Handle connection
    if (con.request_available()):
        logger.debug("Request available.")
        request = con.receive_request()
        if (not (slave.filter(request))):
            continue
        logger.debug("Request for this slave detected.")
        reply = slave.handle_request(request)
        con.send_reply(reply)
Пример #4
0
'''
Rotate the motor with TMCM1270 using CAN interface.

Created on 05.10.2020

@author: LK
'''

from PyTrinamic.modules.TMCM1270.TMCM_1270 import TMCM_1270
from PyTrinamicMicro.platforms.motionpy.connections.can_tmcl_interface import can_tmcl_interface
from pyb import Pin
import time

con = can_tmcl_interface()
module = TMCM_1270(con)
en = Pin(Pin.cpu.A4, Pin.OUT_PP)

en.low()

module.rotate(0, 1000)
time.sleep(5)
module.stop(0)

en.high()

con.close()