Page 1 of 1

RS485 communication error on RevPi connect

Posted: 17 Jan 2023, 03:57
by Makoto G
I want to control a CEMCO pH controller using RS485 communication with RevPi Connect SE.
https://www.cemco.jp/en/water_quality/pet_m3P/

The RS485 socket on the front panel of the RevPi connect SE and the RS485 terminal of the pH controller are connected with a twisted pair cable.
A 120Ω termination resistor is attached to the rs485 terminal on the pH controller side.
When I wrote and run the python code that calls the measurement values from the pH controller, there is no data reply from the pH controller.
Then, The RevPi's power LED turns red.

I attach the python code I wrote, so please let me know if you have any suggestions.
I would also like to know if a terminating resistor on the RevPi side is required.

Thank you in advance.

----------------------------------------------------------------------------------------------
import serial
import time
import struct

ser = serial.Serial('/dev/ttyAMA0')
ser.baudrate = 1200
ser.parity = serial.PARITY_NONE
ser.bytesize = serial.EIGHTBITS
ser.stopbits = serial.STOPBITS_ONE
ser.timeout = 5

pid = 0x31
hid = 0x30
r = 0x52
dno1 = 0x31
dno2 = 0x30
dno3 = 0x30
bcc = 0b0000

commands = [ 0x30, pid, 0x30, hid, r, dno1, dno2, dno3, 0x03 ]

data = struct.pack("B", 0x02)
print("tx: ", data)
ser.write(data)
ser.flush()

data = struct.pack("B", 0x41)
print("tx: ", data)
ser.write(data)
ser.flush()

for cmd in commands:
data = struct.pack("B", cmd)
print("tx: ", data)
ser.write(data)
ser.flush()
bcc = (bcc + cmd) & 0b11111111

bcc = struct.pack("B", bcc)
print("bcc: ", bcc)
ser.write(bcc)
ser.flush()

rtex = ser.readline()
print("rtex: ", rtex)

ser.close()

Re: RS485 communication error on RevPi connect

Posted: 17 Jan 2023, 09:05
by nicolaiB
You're not using the rs485 interface: /dev/ttyAMA0 is the serial part of the PiBridge nad therefore piControl can no longer access the interface, thus turns the led red. Please use the right device path (/dev/RS485)

Nicolai

Re: RS485 communication error on RevPi connect

Posted: 18 Jan 2023, 00:52
by Makoto G
Thank you Nicolai.
Changing the device path to /dev/ttyRS485 fixed the issue.