Closed DHavron closed 2 years ago
Hi, at least the status word looks familiar, so in general it dose not look too bad. I guess you barely get out of the "Switch On Disabled" state, are there some stop switches you may need to bride or to deactivate in software?
For the position mode you probably need also a transition from 15 to 31 for every target position update.
problem solved.
import pysoem
import ctypes
import time
master = pysoem.Master()
master.open('NPF_{180CCD7E-236F-4835-98AE-A40535A0EBA0}')
def config_func():
device.sdo_write(0x214B, 0, bytes(ctypes.c_int16(0)))
device.sdo_write(0x6060, 0, bytes(ctypes.c_int8(1)))
if master.config_init() > 0:
device = master.slaves[0]
device.config_func = config_func()
master.config_map()
if master.state_check(pysoem.SAFEOP_STATE, 50000) == pysoem.SAFEOP_STATE:
master.state = pysoem.OP_STATE
master.write_state()
master.state_check(pysoem.OP_STATE, 50000)
print('al status code {} ({})'.format(hex(device.al_status),pysoem.al_status_code_to_string(device.al_status)))
if master.state == pysoem.OP_STATE:
device.sdo_write(0x60FF, 0, bytes(ctypes.c_int32(200))) #target_velocity
device.sdo_write(0x607A, 0, bytes(ctypes.c_int32(10000))) #profile_target_position
for control_cmd in [0, 6, 7,15,31]:
device.sdo_write(0x6040, 0, bytes(ctypes.c_uint16(control_cmd)))
print(ctypes.c_uint16.from_buffer_copy(device.sdo_read(0x6041, 0)).value)
try:
while 1:
time.sleep(.01)
except KeyboardInterrupt:
print('stopped')
device.output = bytes(len(device.output))
else:
print('failed to got to OP_STATE')
else:
print('failed to got to safeop state')
master.state = pysoem.PREOP_STATE
master.write_state()
else:
print('no device found')
master.close()
Hey, I am trying to drive a Leadshine CS3E D1008. I have already tried with both SDO and PDO. With the help of SDO, I was able to write data to the controller. I am using this code:
I get an answer: 592 561 624 624
when using this code:
I get an answer: 592 592 592 592
motor does not rotate