Logic Machine Forum
LM5 RS485 check - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Hardware (https://forum.logicmachine.net/forumdisplay.php?fid=12)
+--- Thread: LM5 RS485 check (/showthread.php?tid=1939)



LM5 RS485 check - gtsamis - 03.03.2019

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


RE: LM5 RS485 check - admin - 03.03.2019

You can connect two RS485 ports on LM5 together and write a script to test communication between them.


RE: LM5 RS485 check - gtsamis - 07.03.2019

(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!


RE: LM5 RS485 check - edgars - 10.06.2019

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')



RE: LM5 RS485 check - edgars - 10.06.2019

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