예제 #1
0
    n = 0
    for i in ids: 
        n+=1
        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')
    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
예제 #2
0
파일: example_3.py 프로젝트: JIRL/canio2
###############################################################################
# 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
예제 #3
0
파일: example_2.py 프로젝트: JIRL/canio2
###############################################################################
# Example: 
# CANopen node 'device type' reading
###############################################################################
import canio2
from canio2 import CANopenNode

# CAN module (CAN iface type) initialization
module = canio2.make_module('ixxat') 
# CAN iface creation. Pass iface id (or '*') 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) 
device_type= node.ru32(0x1000,0)
print 'Device Type:',hex(device_type)
예제 #4
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
예제 #5
0
    print('Available IDs:')
    n = 0
    for i in ids: 
        n+=1
        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
예제 #6
0
###############################################################################
# Example:
# CANopen node 'device type' reading
###############################################################################
import canio2
from canio2 import CANopenNode

# CAN module (CAN iface type) initialization
module = canio2.make_module('ixxat')
# CAN iface creation. Pass iface id (or '*') 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)
device_type = node.ru32(0x1000, 0)
print 'Device Type:', hex(device_type)
예제 #7
0
        print('[{0}] {1}'.format(n, i))
    n = input('Select iface (1-{0}):'.format(len(ids)))
    return module.make_iface(ids[n - 1], param)


#------------------------------------------------------------------------------
# init
#------------------------------------------------------------------------------
iface = get_iface('ixxat')
io_service = canio2.IOService(iface)

#------------------------------------------------------------------------------
# Main
#------------------------------------------------------------------------------
NODE_ID = 1
node = CANopenNode(NODE_ID, io_service)

print 'Node state:', node.state

print 'Setting state to:', CANopenNode.STATES.STOPPED
node.state = CANopenNode.STATES.STOPPED
print 'Node state: ', node.state

print 'Setting state to:', CANopenNode.STATES.PRE_OPERATIONAL
node.state = CANopenNode.STATES.PRE_OPERATIONAL
print 'Node state:', node.state

print 'Setting state to:', CANopenNode.STATES.OPERATIONAL

node.state = CANopenNode.STATES.OPERATIONAL
print 'Node state: ', node.state