Logic Machine Forum
RS232 - DAYTON AMP - 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: RS232 - DAYTON AMP (/showthread.php?tid=3559)



RS232 - DAYTON AMP - fahd-bnh - 15.09.2021

Hello guys, 

I'm trying to integrate Dayton amp with the LM5 through RS232, I don't know what's wrong. 

I have created a virtual point to send an on-off command  to zone 1, but it didn't work.
in the bellow picture of the registers of the amp.

this is the script that i have used 

require('serial')

device = '/dev/RS232'

port = serial.open(device, { baudrate = 9600, parity = 'none', databits = 8, stopbits = 1  })

-- get value of KNX object
value = event.getvalue()

if (value == true) then
  -- send power on command with returns to make them stick
  char = "<01PR01\r" 
  port:write(char)
else
  -- send power off command
  char = "<01PR00\r" 
  port:write(char)
end

-- close port
port:close()


       


RE: RS232 - DAYTON AMP - admin - 16.09.2021

The code looks correct. Check the cables, maybe RX/TX has to be swapped?


RE: RS232 - DAYTON AMP - fahd-bnh - 16.09.2021

(16.09.2021, 07:33)admin Wrote: The code looks correct. Check the cables, maybe RX/TX has to be swapped

I did that and nothing change.


RE: RS232 - DAYTON AMP - fahd-bnh - 22.09.2021

(16.09.2021, 07:33)admin Wrote: The code looks correct. Check the cables, maybe RX/TX has to be swapped?

Hi, 
I have contacted the DAYTON technical support team about the problem however they gave me software to send the commands from it, and after sending the commands from their software it worked from the LM5  Smile
Please, in the pic below there's a guide, how to read the status of the AMP from the RS232.
   
1- write '?xx' (xx is the number of the zone) 
2- after I write  it, I will receive  a reply command that contains 23 characters 
 I want to take two characters from that string for example (12,13) and write that value in a 1byte virtual object ;
Could you help me to do that?


RE: RS232 - DAYTON AMP - admin - 22.09.2021

Try this, the status type is not described so it's assumed to be a hexadecimal number which converted from a string via tonumber(). 24 characters are read: 23 data characters + CR.

Code:
port:write('?01\r')
resp = port:read(24, 1)

if resp and #resp == 24 then
  data = resp:sub(12, 13)
  data = tonumber(data, 16)

  grp.update('32/1/1', data)
end