Jump to content
OMRON Forums

Recommended Posts

Posted

Dears,

I would like to read data from Omron TMFlow for cobot TM5-900 using python. If someone tried to obtain data like x,y,z positions, could you please share the code? This is my code, where I have connected, but the Y position shows 0.0 . How can I get the data by connecting modbus tcp.

from pymodbus.client import ModbusTcpClient
import struct
 
# Define the IP and port of the Omron TM robot
ROBOT_IP = '192.168.81.164'  # Replace with your robot's IP address
PORT = 502  # Standard Modbus TCP port
 
# Initialize the Modbus client
client = ModbusTcpClient(ROBOT_IP, port=PORT)
 
# Connect to the Modbus server
client.connect()
 
# Example: Reading the Y position from two holding registers
# Replace `100` with the actual starting address for the Y position
start_register_address = 7003  # Starting address of the holding register for Y position
response = client.read_holding_registers(start_register_address, 10)
 
# Check if the response is valid and process the Y position value
if not response.isError():
    # Combine the two registers into a 32-bit float (little-endian format)
    registers = response.registers
    y_position = struct.unpack('<f', struct.pack('<HH', registers[0], registers[1]))[0]
    print(f"Y Position: {y_position}")
else:
    print(f"Error reading Y position: {response}")
 
# Disconnect when done
client.close()
  • 2 months later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted

This Omron Forum currently only includes Barcode/Machine Vision (previously Microscan). For other Omron products please contact Omron’s main Technical Support by email at “ia.techsupport@omron.com”.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...