This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

LM5 RS485 check
#1
Hi,

I have an LM5 communicating with an arduino board via RS485 serial port.
It was working for several months but suddenly it stooped without any obvious reason.
Is there any easy way to check if there is a hardware problem with the RS485 port?

Thank you in advance
George
Reply
#2
You can connect two RS485 ports on LM5 together and write a script to test communication between them.
Reply
#3
(03.03.2019, 16:24)admin Wrote: You can connect two RS485 ports on LM5 together and write a script to test communication between them.

Didn't though about it... thank's!
Reply
#4
here is the script for RS485 self-test with either OK or ERROR message in Alerts. 
Make sure to adjust port names accordingly (2nd, 3rd lines):

Code:
require('serial')

port1 = serial.open('/dev/RS485-1', { duplex = 'half' })
port2 = serial.open('/dev/RS485-2', { duplex = 'half' })

function test(p1, p2)
errors = 0

p1:flush()
p2:flush()

for i = 1, 100 do
p1:write('1234567890')
res = p2:read(10, 1)
if res and res == '1234567890' then
res = '+'
else
res = '-'
errors = errors + 1
if errors > 5 then
break
end
end

io.write(res)
io.flush()

if i % 50 == 0 then
print()
end
end
end

test(port2, port1)
test(port1, port2)

alert(errors > 0 and 'ERROR' or 'OK')
Reply
#5
Here is a nice article about necessity to use 3 wires when interconnecting RS485 devices. Might help somebody to protect RS485 or the whole device from the damage  Sleepy
Reply


Forum Jump: