Beispiel #1
0
    n = input('Select iface (1-{0}):'.format(len(ids)))
    return module.make_iface(ids[n-1],param)

#------------------------------------------------------------------------------
# MAIN
#------------------------------------------------------------------------------
if __name__ == '__main__':
    iface = get_iface('ixxat')
    io_service = canio2.IOService(iface)
    
    NODE_ID = 1
    node = CANopenNode(NODE_ID, io_service) 
    waiter = canio2.TriggersWaiter(io_service)
    
    print 'Resetting node...' 
    if node.reset(5000) == False:
        print 'Boot Timeout'
        sys.exit(1)
    print 'Node state after reset: ' + str(node.state)
    node.state = CANopenNode.STATES.OPERATIONAL
    print 'Node state : ' + str(node.state)

    print('* Drive Initialization.')
    print('\tClear Faults.')
    node.wu16(0x6040,0x80) 
    print('\tMotor parameters Setup.')
    node.wu16(0x6402,1) # motor type
    node.wu16(0x6410,1,7000) # cont. current limit, ma
    node.wu16(0x6410,2,8000) # out current limit, ma
    node.wu8(0x6410,3,1) # pole paires
    node.wu16(0x6410,4,3000) # max speed in current mode
Beispiel #2
0
###############################################################################
# Example: 
# CANopen node reset
###############################################################################
import canio2
from canio2 import CANopenNode

# CAN module (CAN iface type) initialization
module = canio2.make_module('ixxat') 
# CAN iface creation. Pass iface id and bitrate to make_iface method.
iface = module.make_iface('HW104122','1000K')
# io_service object is a link between low and high levels
io_service = canio2.IOService(iface)

# CANopen Node object initialization
NODE_ID = 1
node = CANopenNode(NODE_ID, io_service) 
if node.reset(5000) == False:
    print 'Error: Boot Timeout'
else:
    print 'Boot OK'
print 'State:', node.state
Beispiel #3
0
        print('[{0}] {1}'.format(n, i))
    n = input('Select iface (1-{0}):'.format(len(ids)))
    return module.make_iface(ids[n-1],param)

#------------------------------------------------------------------------------
# MAIN
#------------------------------------------------------------------------------
if __name__ == '__main__':
    iface = get_iface('ixxat', None, '1000K')
    io_service = canio2.IOService(iface)
    
    n = CANopenNode(NODE_ID, io_service) 
    waiter = canio2.TriggersWaiter(io_service)
    
    print('Resetting node...')
    if n.reset(6000) == False:
        print 'Boot Timeout'
        sys.exit(1)
    print('Node state after reset: ' + str(n.state))
    n.state = CANopenNode.STATES.OPERATIONAL
    time.sleep(0.1)
    if n.state == CANopenNode.STATES.OPERATIONAL:
        print('Node state : OPERATIONAL')
    else:
        raise Exception('Can\'t setup operational mode')
    try:
        # Initialisation
        n.wu32(0x3004,0)                       # disable power stage
        time.sleep(0.1)
        n.wu32(0x3900, 0x1) # motor type
        # controller feedback (encoder OR hall sensors)