Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1225

Python • Re: Connecting RS485 via Modbus to Mitsubishi

$
0
0
Hi,
i'm back. I tried and tried a lot of codes a none of them worked.

So what i have done is to connect my raspberry to the MR-J4-40A-RJ through an RS232 to RS485 converter, the UC-232A (this one https://www.aten.com/it/it/products/sol ... ri/uc232a/ ). Then this UC-232A is connected to my SC-FRPC cable (this one https://mitsubishi-electric-eshop.mee.c ... 0000088426 ) that is connected to the Mitsubishi.

I tried again with some code but i still can't get something work. Looking at this sliced documentation (attached to this reply, i had to place it in a zip file) at the page 6, it makes an example of how to make a package communication to get the first alarm in the alarm history.
So i tried this but still doesn't work because it prints a null value, meanwhile in the alarm history there are some allarms:

Code:

import serial# Create a serial objectser = serial.Serial(    port='COM7',  # Replace with your port    baudrate=115200,    parity=serial.PARITY_NONE,    stopbits=serial.STOPBITS_TWO,    bytesize=serial.EIGHTBITS,    timeout=1)# Define control charactersSTX = '\x02'  # Start of TextETX = '\x03'  # End of TextSOH = '\x01'  # Start of HeaderEOT = '\x04'# Define command componentsstation_no = '00'  # Station numbercommand = '33'  # Command codedata_no = '10'  # Data number# Construct commandcommand_to_send = station_no + command + STX + data_no + ETX# Calculate checksumchecksum = sum(bytearray(command_to_send, 'utf-8')) & 0xFF# Add checksum to commandcommand_to_send += '{:02X}'.format(checksum)command_to_send = SOH + command_to_send + EOT# Send commandser.write(command_to_send.encode())# Receive responseresponse = ser.readall()print(response)
MITSUBISHI_MR-J4-40A-RJ-Servo-Amplifier-Instruction-Manual.zip

Statistics: Posted by Tiziano Faver — Tue Jun 04, 2024 9:40 am



Viewing all articles
Browse latest Browse all 1225

Trending Articles