Esempio n. 1
0
import time
import PyTrinamic
from PyTrinamic.connections.serial_tmcl_interface import serial_tmcl_interface
from PyTrinamic.connections.uart_ic_interface import uart_ic_interface
from PyTrinamic.evalboards.TMC4671_eval import TMC4671_eval
from PyTrinamic.ic.TMC4671.TMC4671 import TMC4671

PyTrinamic.showInfo()
PyTrinamic.showAvailableComPorts()

" use evalboard via landungsbrücke or directly via UART"
USE_LANDUNGSBRUECKE = False #True

if USE_LANDUNGSBRUECKE:
    myInterface = serial_tmcl_interface('COM5')
    tmc4671 = TMC4671_eval(myInterface).ic()
else:
    myInterface = uart_ic_interface('COM6')
    tmc4671 = TMC4671(myInterface)

" get register set "
tmc4671_reg = tmc4671.register()

" get register set "
tmc4671.showChipInfo()



" ===== 1) base configuration ====="

polePairs = 4
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)

" ADC configuration "
'''

if __name__ == '__main__':
    pass

import time
from PyTrinamic.connections.ConnectionManager import ConnectionManager
from PyTrinamic.evalboards.TMC4671_eval import TMC4671_eval
from PyTrinamic.ic.TMC4671.TMC4671 import TMC4671 as TMC4671_IC

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

if myInterface.supportsTMCL():
    # Create an TMC4671-Eval class which communicates over the Landungsbruecke via TMCL
    TMC4671 = TMC4671_eval(myInterface)
else:
    # Create an TMC4671 IC class which communicates directly over UART
    TMC4671 = TMC4671_IC(myInterface)

" read ChipInfo "

TMC4671.showChipInfo

" configure TMC4671 for a BLDC motor with ABN-Encoder "

" Motor type &  PWM configuration "
TMC4671.writeRegister(TMC4671.registers.MOTOR_TYPE_N_POLE_PAIRS, 0x00030004)
TMC4671.writeRegister(TMC4671.registers.PWM_POLARITIES, 0x00000000)
TMC4671.writeRegister(TMC4671.registers.PWM_MAXCNT, int(0x00000F9F))
TMC4671.writeRegister(TMC4671.registers.PWM_BBM_H_BBM_L, 0x00000505)