Logic Machine Forum
Button through RS485 - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Button through RS485 (/showthread.php?tid=1435)



Button through RS485 - Jayce - 08.06.2018

Hello,

I have a plain button (non-knx) which I want to control through LM, unfortunately I don't have any analog ports in my LM type. I've read somewhere that I can simply connect the button to RS485 port in the LM (A and gnd). I need a script for that. I've found this script which I modified for me and it does transfer but all I get after pressing the button is 1. There is also a huge delay (when I get 1 I have to wait a while for it to work again, I'm suspecting that this might be because of wrong baudrate. What I need though is to get 1/0 according to the state of that button.

Code:
-- open port on first call
if not port then
require('serial')
port = serial.open('/dev/RS485-1', { baudrate = 4800, parity = 'odd', duplex = 'half', databits = 8, stopbits = 1 })
port:flush()
end
-- port ready
if port then
-- read one byte
char = port:read(1, 1)
-- send back if read succeeded
if char then
port:write(char)
end
end

grp.write('30/1/1', char)



RE: Button through RS485 - Erwin van der Zwart - 08.06.2018

Hi,

I hope your controller is still working..

I never seen a short circuit on a communication port as a solution.

We have a KNX interface for your taskĀ - MTN670802 - that is not very expensive.

BR,

Erwin


RE: Button through RS485 - Jayce - 11.06.2018

Hello,

Thank you for your response, I also hope it's still working. Well atleast it actually worked the way I wanted. Guess I won't use it like that anymore, I better get what you posted.