Sub SetupDunkerMotor (theNode As Integer)
Print "Setting up Index Motor ", Int(theNode)
Time = 0
NODESCAN.Int(theNode) 'scan for node
Time=0
Pause NODELIVE.Int(theNode) Or Time > 6000 'wait for it to go live or timeout
If Time > 6000 Then ?"Index_Motor node ",Int(theNode) ," scan timed out":?:Exit Sub
If NODELIVE.Int(theNode) Then
REMOTEOBJECT(theNode,0x3000,0,_robUINT32) = 0x1 'clear error
Wait 100
CONNECT.1.Int(theNode)=1
Wait 100
CONFIG(theNode) = _cfREMOTE_DRIVE
Pause REMOTESTATUS(_busCANOPEN,theNode) = _rsCANOPEN_OPERATIONAL
Wait=100
'Must disable axis before setting the parameters, or it won't work.
REMOTEOBJECT( theNode, 0x3004,0,_robUINT32 ) = 0x0 'Disable drive
REMOTEOBJECT( theNode, 0x3900,0,_robUINT32 ) = 0x1 'Motor type 1 = brushless
REMOTEOBJECT( theNode, 0x3910,0,_robUINT32 ) = 0x8 'Motor poles
REMOTEOBJECT( theNode, 0x3911,0,_robUINT32 ) = 0x2 'Motor polarity
REMOTEOBJECT( theNode, 0x3003,0,_robUINT32 ) = 0x7 'Device mode = position
REMOTEOBJECT( theNode, 0x3962, 0, _robUINT32 ) = 2000 'Encoder resolution
REMOTEOBJECT( theNode, 0x3350, 0, _robINT32 ) = 0x96a 'Selects source of Velocity feedback - 96a is encoder
REMOTEOBJECT( theNode, 0x3550, 0, _robINT32 ) = 0x96a 'Selects source of SVelocity feedback - 96a is encoder
REMOTEOBJECT( theNode, 0x608F, 1, _robUINT32 ) = 1 'Set Velocity Encoder Resolution per revolution eg 1
REMOTEOBJECT( theNode, 0x608F, 2, _robUINT32 ) = 2000 'Set Velocity Encoder Resolution encoder increments eg 4000
REMOTEOBJECT( theNode, 0x6090, 1, _robUINT32 ) = 1 'enc increments per unit of time eg 1
REMOTEOBJECT( theNode, 0x6090, 2, _robUINT32 ) = 2000 'motor revs per unit of time eg 4000
REMOTEOBJECT( theNode, 0x3321, 0, _robUINT32 ) = 1000000000 'Set Max Velocity parameter
REMOTEOBJECT( theNode, 0x3323, 0, _robUINT32 ) = 1000000000 'Set Max Velocity parameter
REMOTEOBJECT( theNode, 0x607F, 0, _robUINT32 ) = 1000000000 'Set Max Velocity parameter
REMOTEOBJECT( theNode, 0x608c, 0, _robUINT8 ) = 0xA3 'Set velocity dimension
REMOTEOBJECT( theNode, 0x608e, 0, _robUINT8 ) = 0xAF 'Set acceleration dimension
REMOTEOBJECT( theNode, 0x608a, 0, _robUINT8 ) = 0xB4 'Set position dimension
REMOTEOBJECT( theNode, 0x6065, 0, _robUINT32 ) = 800 'Set Velocity Pos Following Error Window
REMOTEOBJECT( theNode, 0x3762, 0, _robINT32 ) = 0 'Set position
REMOTEOBJECT( theNode, 0x3510, 0, _robUINT32 ) = 100 'PwmKp
REMOTEOBJECT( theNode, 0x3511, 0, _robUINT32 ) = 100 'PwmKi
REMOTEOBJECT( theNode, 0x3221, 0, _robUINT32 ) = 5000 'Current limit max
REMOTEOBJECT( theNode, 0x3223, 0, _robUINT32 ) = 5000 'Curremt limit min
REMOTEOBJECT( theNode, 0x3310, 0, _robUINT32 ) = 400 'Kp
REMOTEOBJECT( theNode, 0x3311, 0, _robUINT32 ) = 0 'Ki
REMOTEOBJECT( theNode, 0x3312, 0, _robUINT32 ) = 0 'Kd
REMOTEOBJECT( theNode, 0x3313, 0, _robUINT32 ) = 10000 'Kr
REMOTEOBJECT( theNode, 0x3314, 0, _robUINT32 ) = 1000 'Kf
REMOTEOBJECT( theNode, 0x3210, 0, _robUINT32 ) = 100 'Current Kp
REMOTEOBJECT( theNode, 0x3211, 0, _robUINT32 ) = 100 'Current ki
REMOTEOBJECT( theNode, 0x3964, 0, _robUINT32 ) = 0 'Encoder / Hall checking
REMOTEOBJECT( theNode, 0x39A0, 0, _robUINT32 ) = 3 'Brake management enable is bit 0 disable / enable is bit 1
REMOTEOBJECT( theNode, 0x39A0, 0x10, _robUINT32 ) = 30 'Time between enabling drive and releasing brake
REMOTEOBJECT( theNode, 0x39A0, 0x11, _robUINT32 ) = 20 'Time between enabling brake and allowing next move to start
REMOTEOBJECT( theNode, 0x39A0, 0x12, _robUINT32 ) = 0 'Time between receiving disable drive command and the brake coming on
REMOTEOBJECT( theNode, 0x39A0, 0x13, _robUINT32 ) = 50 'Time between brake on and drive becoming disabled
REMOTEOBJECT( theNode, 0x39A0, 0x8, _robUINT32 ) = -0x160 'Set which output will be the brake enable
REMOTEOBJECT( theNode, 0x39A0, 0x18, _robUINT32 ) = 0x4 'Out is reset automatically if you enable
REMOTEOBJECT( theNode, 0x39A0, 0x1A, _robUINT32 ) = 0x4 'Out is reset automatically if you disable
REMOTEOBJECT( theNode, 0x373A,0, _robUINT32) = 5 'Position window to 5 encoder count
REMOTEOBJECT( theNode, 0x373B,0, _robUINT32) = 20 'Position window time to 20 milloseconds
If theNode = Stack_Reloader_Lift_Motor Then
SCALEFACTOR.theNode = 800
Else
SCALEFACTOR.theNode = 400
EndIf
SPEED.theNode = 30
ACCEL.theNode = Unloader_Index_Slow_Accel
DECEL.theNode = Unloader_Index_Slow_Accel
FOLERRORFATAL.theNode = 1
REMOTEOBJECT(theNode,0x3000,0,_robUINT32) = 1 'Cancel any error
Repeat
If REMOTESTATUS(_busCANOPEN,theNode) <> _rsCANOPEN_OPERATIONAL Then
?"Node ",theNode, " non operational"
REMOTESTATUS(_busCANOPEN,theNode) = _rsCANOPEN_OPERATIONAL
EndIf
Until REMOTESTATUS(_busCANOPEN,theNode) = _rsCANOPEN_OPERATIONAL
?"Index motor ",theNode, " setup complete"
?
EndIf
End Sub