示例#1
0
from PyTrinamicMicro.platforms.motionpy2.connections.rs485_tmcl_interface import rs485_tmcl_interface
from PyTrinamic.modules.TMCM1240.TMCM_1240 import TMCM_1240
import logging

MODULE_ID = 1
GP_BANK = 0
AP_AXIS = 0

logger = logging.getLogger(__name__)
logger.info("Test module TMCM1240 parameters via RS485")

logger.info("Initializing interface.")
interface = rs485_tmcl_interface(module_id=MODULE_ID)

logger.info("Initializing module.")
module = TMCM_1240(interface)

logger.info("Testing global parameter access.")

logger.info("Getting global parameter ({}, {}) ...".format(
    "timer_0", module.GPs.timer_0))
logger.info("{}".format(module.getGlobalParameter(module.GPs.timer_0,
                                                  GP_BANK)))
logger.info("Getting global parameter ({}, {}) ...".format(
    "timer_1", module.GPs.timer_1))
logger.info("{}".format(module.getGlobalParameter(module.GPs.timer_1,
                                                  GP_BANK)))
logger.info("Getting global parameter ({}, {}) ...".format(
    "timer_2", module.GPs.timer_2))
logger.info("{}".format(module.getGlobalParameter(module.GPs.timer_2,
                                                  GP_BANK)))
'''
Rotate the motor with TMCM1240 using CAN interface.

Created on 21.10.2020

@author: LK
'''

from PyTrinamic.modules.TMCM1240.TMCM_1240 import TMCM_1240
from PyTrinamicMicro.platforms.motionpy.connections.can_tmcl_interface import can_tmcl_interface
import time

con = can_tmcl_interface()
module = TMCM_1240(con)

module.rotate(50000)
time.sleep(5)
module.stop()

con.close()
示例#3
0
from PyTrinamicMicro.platforms.motionpy1.modules.linear_distance import linear_distance
from PyTrinamic.modules.TMCM1240.TMCM_1240 import TMCM_1240
from PyTrinamicMicro.platforms.motionpy1.modules.hc_sr04_multi import hc_sr04_multi
from PyTrinamicMicro.platforms.motionpy1.modules.MCP23S08 import MCP23S08
from PyTrinamicMicro.platforms.motionpy1.connections.rs485_tmcl_interface import rs485_tmcl_interface

module = TMCM_1240(rs485_tmcl_interface())
module.setMaxAcceleration(0, 100000)

lin = linear_distance(
    sensor = hc_sr04_multi(avg_window=100),
    sensor_index = 1,
    module = module
)

lin.homing_direct(velocity=100000)

print(lin.bounds)
Created on 21.09.2020

@author: AA
'''

import PyTrinamic
from PyTrinamic.connections.ConnectionManager import ConnectionManager
from PyTrinamic.modules.TMCM1240.TMCM_1240 import TMCM_1240
import time

PyTrinamic.showInfo()

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

DEFAULT_MOTOR = 0

print("Preparing parameters")
Module_1240.setMaxAcceleration(10000)
Module_1240.setMaxCurrent(128)

print("Rotating")
Module_1240.rotate(20000)

time.sleep(5);

print("Stopping")
Module_1240.stop()
from PyTrinamicMicro.platforms.motionpy.connections.rs485_tmcl_interface import rs485_tmcl_interface
from PyTrinamicMicro import PyTrinamicMicro
import struct
import logging

# 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_motionpy()
module = TMCM_1240(rs485_tmcl_interface(data_rate=115200))
module.setMaxAcceleration(0, 100000)
logger.info("Interface initialized.")

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)
    # Handle flags
    if (slave.status.lin[0]):
示例#6
0
Created on 21.09.2020

@author: AA
'''

import PyTrinamic
from PyTrinamic.connections.ConnectionManager import ConnectionManager
from PyTrinamic.modules.TMCM1240.TMCM_1240 import TMCM_1240
import time

PyTrinamic.showInfo()

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

print("Preparing parameters")
module.setMaxAcceleration(40000)
module.setMaxCurrent(50)

" set moveBy() relative to the actual position "
module.setAxisParameter(module.APs.relative_positioning_option, 1)

print("Rotating")
module.rotate(20000)
time.sleep(5)

print("Stopping")
module.stop()
time.sleep(1);