Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error code 19 #116

Open
DailyNir opened this issue Aug 8, 2024 · 8 comments
Open

Error code 19 #116

DailyNir opened this issue Aug 8, 2024 · 8 comments

Comments

@DailyNir
Copy link

DailyNir commented Aug 8, 2024

i am using custom gripper with RS485 communication, right now it is connected to AC control BOX 24V GND L_A L_B , this is my code:

import os
import sys
import time
sys.path.append(os.path.join(os.path.dirname(file), '../../..'))

from xarm.wrapper import XArmAPI
arm = XArmAPI('172.16.1.209')
time.sleep(0.5)
if arm.warn_code != 0:
arm.clean_warn()
if arm.error_code != 0:
arm.clean_error()

arm.motion_enable(True)
arm.set_mode(0)
arm.set_state(0)

ret = arm.core.set_modbus_timeout(20)
print('set modbus timeout, ret = %d' % (ret[0]))

ret = arm.core.set_modbus_baudrate(115200)
print('set modbus baudrate, ret = %d' % (ret[0]))
time.sleep(2)
data_frame = [0x01, 0x06, 0x00, 0x80, 0x00, 0x01, 0x49, 0xE2]
ret = arm.core.tgpio_set_modbus(data_frame, len(data_frame))
print('set modbus, ret = %d' % (ret[0]))
time.sleep(2)


i am getting: SDK_VERSION: 1.13.8
ROBOT_IP: 172.16.1.209, VERSION: v2.2.2, PROTOCOL: V1, DETAIL: 6,6,XI1304,AC1303,v2.2.2, TYPE1300: [1, 1]
change protocol identifier to 3
ControllerError, code: 1
servo_error_code, servo_id=1, status=3, code=0
ControllerError had clean
servo_error_code, servo_id=1, status=0, code=0
[motion_enable], xArm is not ready to move
[set_state], xArm is ready to move
set modbus timeout, ret = 0
set modbus baudrate, ret = 0
set modbus, ret = 0
ControllerError, code: 19

please advise how to integrate correctly

@MinnaZhong
Copy link

Hi Nir,

Does it support standard Modbus RTU protocol? If not, you need to use the data transparent transmission function, set is_transparent_transmission=True.

For example:
arm.set_tgpio_modbus_baudrate(115200)
arm.set_tgpio_modbus_timeout(500,is_transparent_transmission=True)
arm.getset_tgpio_modbus_data(is_transparent_transmission=True)

If there are still problems, please share the SN of your robot to [email protected], thank you,

@DailyNir
Copy link
Author

DailyNir commented Aug 9, 2024

Yes. It does support it.

Please advise how to proceed .

@MinnaZhong
Copy link

Hi Nir,

Then no need to add CRC, we will add it automatically. How about removing 0x49, 0xE2?

@DailyNir
Copy link
Author

tried this and getting the same: #!/usr/bin/env python3

Software License Agreement (BSD License)

Copyright (c) 2019, UFACTORY, Inc.

All rights reserved.

Author: Vinman [email protected] [email protected]

"""
Example: yinshi gripper Control
Please make sure that the gripper is attached to the end.
"""

import os
import sys
import time
sys.path.append(os.path.join(os.path.dirname(file), '../../..'))

from xarm.wrapper import XArmAPI
arm = XArmAPI('172.16.1.221')
time.sleep(0.5)
if arm.warn_code != 0:
arm.clean_warn()
if arm.error_code != 0:
arm.clean_error()

arm.motion_enable(True)
arm.set_mode(0)
arm.set_state(0)
ret=arm.set_tgpio_modbus_baudrate(115200)
print('set modbus baudrate, ret = %d' % (ret))
time.sleep(2)

ret = arm.set_tgpio_modbus_timeout(500,is_transparent_transmission=True)

print('set modbus timeout, ret = %d' % (ret))

def calculate_crc16(data):
crc = 0xFFFF
for pos in data:
crc ^= pos
for _ in range(8):
if (crc & 1) != 0:
crc >>= 1
crc ^= 0xA001
else:
crc >>= 1
return crc & 0xFFFF

def build_modbus_command(slave_addr, function, register_addr, write_data):
command = [
0xFA,
slave_addr,
function,
(register_addr >> 8) & 0xFF,
register_addr & 0xFF,
(write_data >> 8) & 0xFF,
write_data & 0xFF
]
# crc = calculate_crc16(command)
# command.append(crc & 0xFF)
# command.append((crc >> 8) & 0xFF)
return command

Parameters for the calibration command

slave_addr = 0x01
function = 0x06
register_addr = 0x0080
write_data = 0x0001

Build the command

data_frame = build_modbus_command(slave_addr, function, register_addr, write_data)

Print the built command for verification

print("Built command: ", data_frame)

Send the command using tgpio_set_modbus

ret = arm.getset_tgpio_modbus_data(is_transparent_transmission=True, datas=data_frame)
print('set modbus, ret = %d' % (ret[0]))

Wait for 2 seconds

time.sleep(2)
###############################
SDK_VERSION: 1.13.8
ROBOT_IP: 172.16.1.221, VERSION: v2.2.2, PROTOCOL: V1, DETAIL: 6,6,XI1304,AC1303,v2.2.2, TYPE1300: [1, 1]
change protocol identifier to 3
ControllerError, code: 19
[motion_enable], xArm is not ready to move
[set_state], xArm is ready to move
set modbus baudrate, ret = 0
ControllerError had clean
set modbus timeout, ret = 0
Built command: [250, 1, 6, 0, 128, 0, 1]
set modbus, ret = 0
ControllerError, code: 19

@DailyNir
Copy link
Author

same error here also:import os
import sys
import time

from xarm.wrapper import XArmAPI
arm = XArmAPI('172.16.1.209')
time.sleep(0.5)
if arm.warn_code != 0:
arm.clean_warn()
if arm.error_code != 0:
arm.clean_error()

arm.motion_enable(True)
arm.set_mode(0)
arm.set_state(0)

ret = arm.core.set_modbus_timeout(20)
print('set modbus timeout, ret = %d' % (ret[0]))

ret = arm.core.set_modbus_baudrate(115200)
print('set modbus baudrate, ret = %d' % (ret[0]))
time.sleep(2)
data_frame = [0x01, 0x06, 0x00, 0x80, 0x00, 0x01]
ret = arm.core.tgpio_set_modbus(data_frame, len(data_frame))
print('set modbus, ret = %d' % (ret[0]))
time.sleep(2)

@MinnaZhong
Copy link

Hi

Please provide the SN of your robot to [email protected],
Do you have xArm Gripper? Can you control it normally?

Please try to send the data via 'Settings-Externals-Modbus RTU', take a screenshot of the result to us.
Btw, what will be returned by your gripper if you sending [01 06 00 80 00 01]?
image

@DailyNir
Copy link
Author

DailyNir commented Aug 12, 2024 via email

@DailyNir
Copy link
Author

DailyNir commented Aug 12, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants