jordy_m
November 28, 2022, 3:12pm
1
Hi all,
I'm trying to deploy RS485 communication using the Portenta X8 as the server.
I'm using MaxLinear SP3485 - RS485 driver.
From the python-periphery lib I'm using Serial
I'm using the UART Tx(DI), Rx(RO) and gpio for switching the RTS (RE/DE) from the linux side
I'm using Oscilloscope to check if it's working:
Tx is working fine
Rx is always remain 3.3V (high) - I guess it's because of a pull up resistor
The result is that the communication isn't working, I don't get any reply from the other RS485 devices.
In the past I did the same with the Arduino YUN using SoftwareSerial and it worked perfectly
How can I resolve it?? please help!
Many thanks!
pylon
November 29, 2022, 3:18pm
2
How do you measure? RS485 doesn't have a defined voltage to GND (by specification).
Which may have other reasons.
How did you wire it? Post the schematics of the breakout board you're using (it's an SMD component, so you cannot use it directly on the breadboard).
Never, really never post code as an image! There is an extra button (</>) for posting code in the editor.
jordy_m
November 29, 2022, 4:26pm
3
How do you measure? RS485 doesn't have a defined voltage to GND (by specification).
this is how it look like before the RS485 driver. Yellow line for the UART RX and green for the UART TX
this is how it looks like after the RS485 driver on the A and B port
and this is how it supposed to be:
Which may have other reasons.
True
How did you wire it? Post the schematics of the breakout board you're using (it's an SMD component, so you cannot use it directly on the breadboard).
I'm using my own board. it used to run with the Arduino Yun...
Never, really never post code as an image! There is an extra button (</>) for posting code in the editor.
got it. thanks
class rs485_comm:
def __init__(self):
self.buffer = bytearray(16)
self.rs_485 = Serial("/dev/ttymxc1", 9600)
def rs485_comm(self, cmd, PAaddress, data1=0x00, data2=0x00, data3=0x00, data4=0x00, data5=0x00, data6=0x00, data7=0x00, data8=0x00):
print("-------------start RS485---------")
# self.rs_485.flush()
time.sleep(1)
self.buffer[0] = CORRY_HEADER
self.buffer[1] = cmd
self.buffer[2] = data1
self.buffer[3] = data2
self.buffer[4] = data3
self.buffer[5] = data4
self.buffer[6] = data5
self.buffer[7] = data6
self.buffer[8] = data7
self.buffer[9] = data8
self.buffer[10] = 0x00
self.buffer[11] = 0x00
self.buffer[12] = self.checksum(self.buffer,12)
self.buffer[13] = PAaddress
self.buffer[14] = 0x00
self.buffer[15] = CORRY_TAIL
rs485_rts.write(True)
time.sleep(0.1)
print("buffer in write is: ")
for i in range(len(self.buffer)):
print(self.buffer[i])
writing = self.rs_485.write(self.buffer)
print(writing)
rs485_rts.write(False)
time.sleep(0.1)
print("in read")
read_buffer = self.rs_485.read(16,5)
time.sleep(0.1)
rs485_rts.write(True)
print("buffer in read is: ")
for i in range(len(read_buffer)):
print(read_buffer[i])
self.rs_485.close()
return read_buffer
pylon
November 29, 2022, 6:20pm
4
If the board actually is powered by 5V the signal level is the same and that may fry your Portenta pins.
As to the high pulling, I quote the datasheet:
The receiver is equipped with a fail-safe feature that guarantees the receiver output will be in a HIGH state when the input is left unconnected.
That could be interpreted that the RO pin is pulled high if the line is not used.
jordy_m
December 4, 2022, 10:16am
5
rs485_rts.write(True)
time.sleep(0.1)
print("buffer in write is: ")
for i in range(len(self.buffer)):
print(self.buffer[i])
writing = self.rs_485.write(self.buffer)
print(writing)
rs485_rts.write(False)
time.sleep(0.1)
print("in read")
read_buffer = self.rs_485.read(16,5)
time.sleep(0.1)
rs485_rts.write(True)
print("buffer in read is: ")
for i in range(len(read_buffer)):
print(read_buffer[i])
self.rs_485.close()
return read_buffer
[/quote]
I moved the "time.sleep(0.1)" to be after the writing part. the switching was to fast so only half of the burst went through the RS485 driver in writing state.
now it's working
system
Closed
June 2, 2023, 10:16am
6
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.