MODBUS and System air

modbus
Tags: #<Tag:0x00007f014b717f20>

(Morten Bogetvedt) #21

Hi

What kind of cable did you use between the systemair RJ45 connector and the computer?
I’m looking into hooking up my VSR300 to Openhab

//Morten


(Kim Skatun) #22

Its rj11 :slight_smile:


(Marcin) #23

My recuperator has RJ45 on Modbus, so I have reused cat5 cable, which I have for 1wire. I just add RJ45 on particular pair of cables and then spit it in front of Raspberry. Two wires are connected to cheap RS485/USB connector which is installed in Raspberry.


(Morten Bogetvedt) #24

True. Have you connected one to your pc?
Is it just to use a RS485 to usb converter, plug it in, add the port and use the modbus binding?


(Kim Skatun) #25

@moskovskiy82

Which connector is it that you connected it to?

https://www.google.no/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&ved=0ahUKEwjbvN6Zw-PRAhUF1iwKHWxeBVoQFggfMAE&url=https%3A%2F%2Fwww.systemair.com%2Fglobalassets%2Fdocumentation%2F54472.pdf&usg=AFQjCNHS25DQMegYgA3R2YXeBhf-pokkUQ&sig2=4thUVk-PWe919OKQ6Vb2qw&bvm=bv.145393125,d.bGg

I can only see 1 signal in…


(moskovskiy82) #26

Wrong manual. Find the one for the printed card for your unit. There are like 6 or 7 digital inputs on the printed card. All you have to do is wire them to relays and set their functions via the VSR control unit with display.


(Kim Skatun) #27

This one it is , I guess 1,2,3 is the Input pins…

https://www.google.no/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwjkz-OTtPvRAhVjLZoKHQdtAWIQFggaMAA&url=https%3A%2F%2Fwww.systemair.com%2Fglobalassets%2Fdocumentation%2F35983.pdf&usg=AFQjCNEWV2DkTbyQSd2zJNI0e4l44xGumg&sig2=w4-ODYznqPy3AoR6VsxbTw&bvm=bv.146094739,d.bGs

I just hope I am able to dissable the pcb lid, Its a tight installation…


(Kim Skatun) #28

I am thinking about using this ethernet to modbus controller:
https://www.aliexpress.com/item/Serial-server-Modbus-TCP-to-RTU-RS232-RS485-dual-serial-transfer-network/32740113824.html?spm=2114.10010108.1000013.1.JumUXE&scm=1007.13339.81019.0&pvid=4fcf1d55-6a53-4b4c-b3e4-e2953cf8b6a7&tpp=1

Or should I better stick to usb version?


(Rossko57) #29

I use a similar “USR” branded product with success. That has a mode that properly supports Modbus, so that your host talks to it with Modbus-TCP and it talks Modbus-RTU on the serial side.

I know nothing about ZQWL product.

I have also trialled a NNZN product with Modbus feature, but didn’t use it because of the +5v power requirement. (My real modbus slaves run at +12V)

Not all gateways have this special mode feature. If it is lacking you would need some kind of virtual serial port installing on your host so that OH binding can talk serial.

If your USB works, what advantage are you expecting?


(Kim Skatun) #30

Like this one?
USR


(Rossko57) #31

No. That model 300 does not mention Modbus in the blurb. You have to be careful here.

The model 410 is similar but with the Modbus TCP<>RTU gateway feature.

I use these in an industrial setting, a steel-framed warehouse 80x100m with wired ethernet.
I wouldn’t think you would need them in a home, except the odd case where you want to share an existing ethernet to an outbuilding instead of running a long wire from a USB/485 adaptor ?
Maybe the WiFi versions would be of interest though.


(I am) #32

Hi all,

I’m using Systemair with modbus and today I have managed to read/write all inputs I was interested in. As first request was for fan speed so the simple way of doing it I came up with (I’m just a starter to OH2):

/etc/openhab2/services/modbus.cfg

serial.fan.connection=/dev/ttyUSB2:9600:8:none:1:rtu:35:5000 serial.fan.id=1 serial.fan.start=100 serial.fan.length=38 serial.fan.type=holding

No need to apply the formula in documentation if you are not reading digital inputs or coils. For all temperatures etc. holding should be used with direct register number. I did read all FAN items, so “lenght” can be only 1 for just a fan speed setup if you like. As for “9600:8:none:1” part- please check your modbus configuration from the HVAC panel, it could be different.

/etc/openhab2/items/default.items

Fan item for read and write, it reads and writes from/to the same register

/etc/openhab2/rules/default.rules

[code]rule "Process fan commands"
when
Item Fans received command
then
logInfo(“FansRules”, “Processing Fans command”)
if(receivedCommand != null) {
switch(receivedCommand) {
case “0” : sendCommand(Fans, 0)
case “1” : sendCommand(Fans, 1)
case “2” : sendCommand(Fans, 2)
case “3” : sendCommand(Fans, 3)
}
}

end

rule "Update Fan speed"
when
Item Fans changed
then
logInfo(“FansRules”, “Processing speed update”)
var currentSpeed = Fans.state as DecimalType
postUpdate(Fans, currentSpeed)
end[/code]

First rule to write a register (change fan speed) based on what you select in website, second one to update a value if you change the speed manually on HVAC (to reflect that change in website).

/etc/openhab2/sitemaps/default.sitemap

sitemap default label="Home" { Frame label="Fans" { Selection item=Fans label="Fan Speed" icon="fan" mappings=[0="Off", 1="Low", 2="Medium", 3="Max"] } }

A selectable item in webpage, changing numbers to human readable format :slight_smile:

Hope that helps someone as I was struggling to get it working. I’m using linux with USB-to-RS485 adapter from aliexpress, RJ45 cable (~8 meters) with RJ45 on one side (connecting to modbus) and 2-wire on another (connecting to USB adapter), schematics are on the Systemair modbus documentation.


Modbus RTU over TCP ( serial com redirector )?
(Kim Skatun) #33

Great tutorial!

How can we make usb number static so it doesn’t change on reboot or unplug?

What does this part mean?

have trouble to find the pinout, which did you use?

Can I connect it where the manual control goes?


(I am) #34

holdings are configured starting “serial.fan.start” and not in the connect line. After some experimenting I was able to read/write to correct registers if I take 1 off the original one. Not sure why it’s like that, maybe it’s the way it works in OH2 and it’s intentional but as I’m new to this and it just worked- I did not question it :slight_smile:

[quote=“skatun”]have trouble to find the pinout, which did you use?

Can I connect it where the manual control goes?

[/quote]

You need to connect the one marked as 2 in chapter 6 (logical diagram) and the same one (just a picture of the board itself) marked as 11 on the chapter 6.9.1. Do not touch the manual control- it will be connected with RJ11 cable to a different port on the board.
When you are connecting cable on the USB-to-Serial adapter (these 2 wires) make sure you follow the A(-) B(+) polarity shown in chapter 6.


(Kim Skatun) #35

A+ pin4 and B+ pin5 on the RJ45, however it seems like the manual control sits on the same modbus line or?, If I connect it to a splitter on the manual control I only need 1m of cable instead of running a new 15m cable to the PCB


(I am) #36

Manual control connects to port marked 3 and modbus to port marked 11 in picture shown in chapter 6.9.1. At least on my unit. Based on the wiring diagram one could assume you can connect modbus from manual control panel also bu I did not try this as it is fixed on my unit so there was no point of connecting with splitters as I could use normal modbus port on the PCB.


Modbus error messages
(Kim Skatun) #37

So I opened up the remote panel,
Here is the pinout of the Rj 11
Pin1 = GND
Pin2 =12V
Pin3 = B
Pin 4= A


(Kim Skatun) #38

I am struggeling to get it to work… It throws me a lot of errors:

17:41:09.741 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 03 00 64 00 26 85 cf
17:41:09.742 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: CRC Error in received frame: 0 bytes:
17:41:09.744 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@dac561 (unit id 1 & transaction 249). Serial parameters: SerialParameters@858d5[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=5000]
17:41:09.792 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 03 00 64 00 26 85 cf
17:41:09.794 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: CRC Error in received frame: 0 bytes:
17:41:09.796 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 2/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@dac561 (unit id 1 & transaction 249). Serial parameters: SerialParameters@858d5[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=5000]
17:41:09.844 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 03 00 64 00 26 85 cf
17:41:09.845 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: CRC Error in received frame: 0 bytes:
17:41:09.847 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 3/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@dac561 (unit id 1 & transaction 249). Serial parameters: SerialParameters@858d5[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=5000]
17:41:09.849 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute reached max tries 3, throwing last error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@dac561. Serial parameters: SerialParameters@858d5[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=5000]
17:41:09.858 [ERROR] [.binding.modbus.internal.ModbusSlave] - ModbusSlave (fan): Error getting modbus data for request net.wimpi.modbus.msg.ReadMultipleRegistersRequest@dac561. Error: I/O exception - failed to read. Endpoint ModbusSerialSlaveEndpoint@5fe948[portName=/dev/ttyUSB0]. Connection: SerialConnection@1c4776d[portName=/dev/ttyUSB0,port=/dev/ttyUSB0]
17:41:10.100 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 03 00 64 00 26 85 cf
17:41:10.105 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: CRC Error in received frame: 0 bytes:
17:41:10.109 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@934ace (unit id 1 & transaction 250). Serial parameters: SerialParameters@858d5[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=5000]
17:41:10.157 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 03 00 64 00 26 85 cf
17:41:10.158 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: CRC Error in received frame: 0 bytes:
17:41:10.160 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 2/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@934ace (unit id 1 & transaction 250). Serial parameters: SerialParameters@858d5[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=5000]
17:41:10.208 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 03 00 64 00 26 85 cf
17:41:10.209 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: CRC Error in received frame: 0 bytes:
17:41:10.211 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 3/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@934ace (unit id 1 & transaction 250). Serial parameters: SerialParameters@858d5[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=5000]
17:41:10.214 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute reached max tries 3, throwing last error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@934ace. Serial parameters: SerialParameters@858d5[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=5000]

Does this means that the USB port is wrong or is it something else?
I tried doing this:

|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/5p, 480M
        |__ Port 1: Dev 3, If 0, Class=Vendor Specific Class, Driver=smsc95xx, 4                                                                                        80M
        |__ Port 2: Dev 4, If 0, Class=Vendor Specific Class, Driver=usbfs, 12M

then I plugged in the dongle

[17:28:12] pi@openHABianPi2:~$ sudo lsusb -t
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc_otg/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/5p, 480M
        |__ Port 1: Dev 3, If 0, Class=Vendor Specific Class, Driver=smsc95xx, 480M
        |__ Port 2: Dev 4, If 0, Class=Vendor Specific Class, Driver=usbfs, 12M
        |__ Port 4: Dev 5, If 0, Class=Vendor Specific Class, Driver=ch341, 12M
[17:33:07] pi@openHABianPi2:~$  ls /dev/tty*
/dev/tty    /dev/tty13  /dev/tty19  /dev/tty24  /dev/tty3   /dev/tty35  /dev/tty40  /dev/tty46  /dev/tty51  /dev/tty57  /dev/tty62    /dev/ttyprintk
/dev/tty0   /dev/tty14  /dev/tty2   /dev/tty25  /dev/tty30  /dev/tty36  /dev/tty41  /dev/tty47  /dev/tty52  /dev/tty58  /dev/tty63    /dev/ttyS0
/dev/tty1   /dev/tty15  /dev/tty20  /dev/tty26  /dev/tty31  /dev/tty37  /dev/tty42  /dev/tty48  /dev/tty53  /dev/tty59  /dev/tty7     /dev/ttyUSB0
/dev/tty10  /dev/tty16  /dev/tty21  /dev/tty27  /dev/tty32  /dev/tty38  /dev/tty43  /dev/tty49  /dev/tty54  /dev/tty6   /dev/tty8
/dev/tty11  /dev/tty17  /dev/tty22  /dev/tty28  /dev/tty33  /dev/tty39  /dev/tty44  /dev/tty5   /dev/tty55  /dev/tty60  /dev/tty9
/dev/tty12  /dev/tty18  /dev/tty23  /dev/tty29  /dev/tty34  /dev/tty4   /dev/tty45  /dev/tty50  /dev/tty56  /dev/tty61  /dev/ttyAMA0
[17:35:40] pi@openHABianPi2:~$ dmesg | grep tty
[    0.000000] Kernel command line: 8250.nr_uarts=1 dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2709.boardrev=0xa02082 bcm2709.serial=0xc6cdb751 smsc95xx.macaddr=B8:27:EB:CD:B7:51 bcm2708_fb.fbswap=1 bcm2709.uart_clock=48000000 vc_mem.mem_base=0x3ea00000 vc_mem.mem_size=0x3f000000  dwc_otg.lpm_enable=0 console=ttyS0,115200 kgdboc=ttyS0,115200 console=tty1 elevator=deadline net.ifnames=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait
[    0.001317] console [tty1] enabled
[    0.839016] console [ttyS0] disabled
[    0.840403] 3f215040.uart: ttyS0 at MMIO 0x3f215040 (irq = 59, base_baud = 31250000) is a 16550
[    1.621370] console [ttyS0] enabled
[    3.474022] 3f201000.uart: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a PL011 rev2
[   10.049806] systemd[1]: Expecting device dev-ttyS0.device...
[   10.557358] systemd[1]: Starting system-getty.slice.
[   10.566884] systemd[1]: Created slice system-getty.slice.
[   10.574352] systemd[1]: Starting system-serial\x2dgetty.slice.
[   10.584749] systemd[1]: Created slice system-serial\x2dgetty.slice.
[  641.323074] usb 1-1.2: FTDI USB Serial Device converter now attached to ttyUSB0
[  694.578890] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
[197120.581891] [  490]     0   490     1110       30       6       0        0             0 agetty
[197120.594687] [  511]     0   511     1370      220       7       0        0             0 agetty
[391518.767389] [  490]     0   490     1110       30       6       0        0             0 agetty
[391518.779894] [  511]     0   511     1370       30       7       0        0             0 agetty
[578720.176689] [  490]     0   490     1110       30       6       0        0             0 agetty
[578720.189125] [  511]     0   511     1370       29       7       0        0             0 agetty
[762320.608835] [  490]     0   490     1110       30       6       0        0             0 agetty
[762320.621248] [  511]     0   511     1370       29       7       0        0             0 agetty
[775046.477450] usb 1-1.4: ch341-uart converter now attached to ttyUSB0

Any ideas?


(Kim Skatun) #39

@ZyXEL can you confirm what error codes you got when it was wrong usb port or register number. Its either wiring wrong, bad usb dongle, wrong usb port or wrong register, howe er the error code gives me no clue which one of these it is. Any ideas how to figure that out?


(Kim Skatun) #40

@ZyXEL What modbus binding do you use? 1.10?