Failing to enable any movement using the Igus Dryve D1 controller, using Modbus TCP and Python.

Ilias Kondis

Level-1
Beiträge
1
Reaktionspunkte
0
Zuviel Werbung?
-> Hier kostenlos registrieren
Hello everyone, I am facing a problem trying to use the Igus Dryve D1 Controller. I have it set up and connected to an Igus brushless DC motor which drives a linear axis. I am able to actually move my axis using the drive profile set to binary in the web UI provided by Igus. So the system is set up as it should.

Problems start when I try to use some python scripts to actually move the axis using the Modbus TCP/IP protocol. I am able to establish a connection through my scripts, but when I try to send some control words to the dryve I cannot get it to perform any movements. Actually no matter what controllwords I sent to it, when I request for the status of the dryve using the status word, the status is always the same.

Actually, revewing the UI drive profile page, I can see that when I send some controlwords that define feed rate, velocity or other parameters like that I can see them change. But when I try to do a homing for example no movement occurs. I am attaching some code and some pictures, I hope you could provide some assistance.

  • First things first my script, which is an adaptation of the 8th sample program provided by Igus, can be found on the end of the post. The major problem is that the status word never changes so the script is stuck in infinite loop when the `init()` functions is called.
  • Secondly, I try to pass the shutdown, enable and switch on controlwords from a cmd and the results can be found on the attached images .
I would appreciate any assistance.

`
import struct
import socket
import time

# digital inputs
DInputs = [0, 0, 0, 0, 0, 13, 0, 43, 13, 0, 0, 0, 96, 253, 0, 0, 0, 0, 4]
DInputs_array = bytearray(DInputs)

# Status word 6041h
# Status request
status = [0, 0, 0, 0, 0, 13, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2]
status_array = bytearray(status)

# Control word 6040h
# Command: shutdown
shutdown = [0, 0, 0, 0, 0, 15, 0, 43, 13, 1, 0, 0, 96, 64, 0, 0, 0, 0, 2, 6, 0]
shutdown_array = bytearray(shutdown)

# Control word 6040h
# Command: Switch on
switchOn = [0, 0, 0, 0, 0, 15, 0, 43, 13, 1, 0, 0, 96, 64, 0, 0, 0, 0, 2, 7, 0]
switchOn_array = bytearray(switchOn)

# Control word 6040h
# Command: enable operation
enableOperation = [0, 0, 0, 0, 0, 15, 0, 43,13, 1, 0, 0, 96, 64, 0, 0, 0, 0, 2, 15, 0]
enableOperation_array = bytearray(enableOperation)

# Control word 6040h
# Command: stop motion
stop = [0, 0, 0, 0, 0, 15, 0, 43,13, 1, 0, 0, 96, 64, 0, 0, 0, 0, 2, 15, 1]
stop_array = bytearray(stop)

# Control word 6040h
# Command: reset dryve
reset = [0, 0, 0, 0, 0, 15, 0, 43,13, 1, 0, 0, 96, 64, 0, 0, 0, 0, 2, 0, 1]
reset_array = bytearray(reset)

# Variable start value
start = 0
ref_done = 0
error = 0

define tcp_modbusbus(ip, port=502):
# Establish connection between the master and the slave
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
except socket.err:
print('Failed to connect. Try again, you probably did a stupid mistake. Classic.')

socket.connect((ip, port))
print('A wild socket appeared. Connection successful')
return socks

def decimal2dword(value):
# converts decimal integer to 4 byte array
sequence = list(struct.unpack("4b", struct.pack("i", value)))
for i in range(0,4):
if sequence<0:
sequence=256+sequence
return sequence

def sendCommand(data, socket):
#Create socket and send request
sock.send(data)
res = sock.recv(24)
#Print response telegram
print(list(res))
return list(res)


define set_shdn():
#sending Shutdown Controlword and check the following Statusword. checking
#several status words because of various options. look at bit assignment
#Statusword, data package in user manual
sendCommand(reset_array, socket)
sendCommand(shutdown_array, sock)
while (sendCommand(status_array, sock) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 33 , 6]
and sendCommand(status_array, sock) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 33, 22]
and sendCommand(status_array, sock) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 33, 2]):
print("wait for shdn")
#1 second delay
time.sleep(1)

def set_swon():
#Sending Switch on Disabled Controlword and check the following Statusword.
#Checking several status words because of various options. look at bit
#assignment status word, data package in user manual
sendCommand(switchOn_array, socket)
while (sendCommand(status_array, sock) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 35 , 6]
and sendCommand(status_array, sock) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 35, 22]
and sendCommand(status_array, sock) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 35, 2]):
print("wait for sw on")
time.sleep(1)

define set_op_en():
#Operation Enable Controlword and check the following Statusword.
#Checking several status words because of various options. look at bit
#assignment status word, data package in user manual
sendCommand(enableOperation_array, sock)
while (sendCommand(status_array, sock) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 39 , 6]
and sendCommand(status_array, sock) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 39, 22]
and sendCommand(status_array, sock) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 39, 2]):
print("wait for open")
time.sleep(1)

define set_mode(mode):
#Set operation modes in object 6060h Modes of Operation
sendCommand(bytearray([0, 0, 0, 0, 0, 14, 0, 43, 13, 1, 0, 0, 96, 96, 0, 0, 0, 0, 1, mode]), sock)
while (sendCommand(bytearray([0, 0, 0, 0, 0, 13, 0, 43, 13, 0, 0, 0, 96, 97, 0, 0, 0, 0, 1]), sock) ! = [0, 0, 0, 0, 0, 14, 0, 43, 13, 0, 0, 0, 96, 97, 0, 0, 0, 0, 1, mode]):
print("wait for mode")
time.sleep(0.1)

define init():
#Call of the function sendCommand to start the State Machine with the previously defined telegrams (Manual: Visualization State Machine)
set_mode(1)
sendCommand(reset_array, socket)
set_shdn()
set_swon()
set_op_en()

define homing ():
#Reset the start bit in the control word
sendCommand(enableOperation_array, sock)
#Parameterization of the objects according to the manual
#6060h Modes of operation
#Set Homing mode (see "def set_mode(mode):"; Byte 19 = 6)
set_mode(6)
# 6092h_01h Feed constant Subindex 1 (Feed)
#Set feed constant to 5400 (axis in video); refer to manual (byte 19 = 24; byte 20 = 21; byte 21 = 0; byte 22 = 0)
sendCommand(bytearray([0, 0, 0, 0, 0, 17, 0, 43, 13, 1, 0, 0, 96, 146, 1, 0, 0, 0, 4, 112, 23, 0, 0 ]), socks)
# 6092h_02h Feed constant Subindex 2 (Shaft revolutions)
#Set shaft revolutions to 1; refer to manual (byte 19 = 1; byte 20 = 0; byte 21 = 0; byte 22 = 0)
sendCommand(bytearray([0, 0, 0, 0, 0, 17, 0, 43, 13, 1, 0, 0, 96, 146, 2, 0, 0, 0, 4, 1, 0, 0, 0 ]), socks)
# 6099h_01h Homing speed switch
#Speed during search for switch is set to 60 rpm (byte 19 = 112; byte 20 = 23; byte 21 = 0; byte 22 = 0)
sendCommand(bytearray([0, 0, 0, 0, 0, 17, 0, 43, 13, 1, 0, 0, 96, 153, 1, 0, 0, 0, 4, 112, 23, 0, 0 ]), socks)
# 6099h_02h Homing speeds Zero
#Set speed during Search for zero to 60 rpm (byte 19 = 112; byte 20 = 23; byte 21 = 0; byte 22 = 0)
sendCommand(bytearray([0, 0, 0, 0, 0, 17, 0, 43, 13, 1, 0, 0, 96, 153, 2, 0, 0, 0, 4, 112, 23, 0, 0 ]), socks)
# 609Ah homing acceleration
#Set homing acceleration to 1000 rpm/min² (byte 19 = 160; byte 20 = 134; byte 21 = 1; byte 22 = 0)
sendCommand(bytearray([0, 0, 0, 0, 0, 17, 0, 43, 13, 1, 0, 0, 96, 154, 0, 0, 0, 0, 4, 160, 134, 1, 0 ]), socks)
# 6040h control word
#start homing
sendCommand(bytearray([0, 0, 0, 0, 0, 15, 0, 43, 13, 1, 0, 0, 96, 64, 0, 0, 0, 0, 2, 31, 0]), socket )
#Check status word for signal referenced and if an error in the D1 comes up
while (sendCommand(status_array, sock) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 39 , 22]
and sendCommand(status_array, sock) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 8, 6]
and sendCommand(status_array, sock) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 8, 34]
and sendCommand(status_array, sock) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 8, 2]):
time.sleep(0.1)
print("homing")

if __name__ == '__main__':
# Do not forget to Provide the ip of the D1
socket = tcp_modbusbus('169.254.238.8')

# Ask if there is an Error on D1
if (sendCommand(status_array, sock) == [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 8 , 22]
or sendCommand(status_array, sock) == [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 8, 6]
or sendCommand(status_array, sock) == [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 8, 34]
or sendCommand(status_array, sock) == [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 8, 2] ):
error = 1
print('Error, fuck. Troubleshoot.')
otherwise:
error = 0

if error == 0:
init()
time.sleep(0.5)

# homing()
sock.shutdown(socket.SHUT_RDWR)
socket.close()

`
 
Hi, I am currently facing the same problem, the D1 always answers

0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 39, 4

which is a statusword, that i am not able to decipher.

Were you able to solve your problem?

All the best,
Benjiman
 
Zurück
Oben