Need help with Modbus over TCP for device [Resolved]

Begonnen von smarthacker, 30 November 2018, 21:28:22

Vorheriges Thema - Nächstes Thema

smarthacker

Hi All,

I am new to FHEM. I need some help.
I have a device  supporting Modbus TCP running on 10.1.2.90 port 502
I would like to read values from register 5000 and 5001 every seconds and want to display on UI.

I

define AXTHOR ModbusAttr 1 1 192.168.101.1:502 TCP
attr AXTHOR obj-h20-len 2
attr AXTHOR obj-h20-reading ananas
attr AXTHOR obj-h20-poll 1


But I can see the device name under ModbusAttr but unable to read values.
Also I am not sure about what these are "obj-h20-poll "
I assume its a perl sub I  need to define somewhere. I am good perl can some help me with.
Thanks in advance.

Wzut

why h20 if you want to read 5000 or 5001 ? -> h5000 or h5001
Maintainer der Module: MAX, MPD, UbiquitiMP, UbiquitiOut, SIP, BEOK, readingsWatcher

smarthacker

Thanks for the answer @Wzut I am really not aware of the FHEM I am going through the WIKI about the attributes.
Do I need additional changes in conf.
Thanks for quick response.

smarthacker

#3
Hi as suggested I tried the following conf.
I am trying to read 2 32 bit values from 2 adjacent registers using the following conf.
But I am getting the value for 1st register only i.r 40499 only but not for 40500

I used the following correctly but looks I missed something.
Can you please help.


obj-[cdih][1-9][0-9]*-len
defines the length of the data object in registers. It defaults to 1. Some devices store 32 bit floating point values in two registers. In this case you can set this attribute to two.



My Conf.

define ACTHOR ModbusAttr 1 1 192.168.101.1:502 TCP
attr ACTHOR obj-h40499-len 2
attr ACTHOR obj-h40499-reading Power
attr ACTHOR dev-h-combine 2
attr ACTHOR dev-h-defPoll 1
attr ACTHOR dev-h-defUnpack n

++++++++++++++++++++++++++++++++++MY DEBUG LOG++++++++++++++++++++++

2018.12.01 12:23:37.509 4: MYDEVICE: update timer modified: will call GetUpdate in 1.0 seconds at 2018-12-01 12:23:38 - Interval 1
2018.12.01 12:23:37.509 4: MYDEVICE: GetUpdate will request Power
2018.12.01 12:23:37.510 4: MYDEVICE: Send called with h40499, objLen 2 / reqLen 2 to id 1, op read, qlen 0
2018.12.01 12:23:37.510 4: MYDEVICE: Send queues fc 3 to 1, tid 25, for h40499 (Power), reqLen 2
2018.12.01 12:23:37.510 4: MYDEVICE: HandleSendQueue sends fc 3 to id 1, tid 25 for Power (h40499), len 2, device MYDEVICE (TCP), pdu 039e330002, V 3.7.3 - 22.12.2017
2018.12.01 12:23:37.512 4: MYDEVICE: ParseFrames got fcode 3 from 1, tid 25, values 085016f7HeaderLen 4, ActualLen 4, request was for h40499 (Power), len 2 for module MYDEVICE
2018.12.01 12:23:37.513 4: MYDEVICE: ParseObj for Power assigns 2128
2018.12.01 12:23:37.513 5: Starting notify loop for MYDEVICE, 1 event(s), first is Power: 2128
2018.12.01 12:23:37.513 4: dewpoint_notify: cmd_type=dewpoint devname=MYDEVICE dewname=dew_all, dev=MYDEVICE, dev_regex=.* temp_name=temperature hum_name=humidity
2018.12.01 12:23:37.514 5: dewpoint_notify: s='Power: 2128'
2018.12.01 12:23:37.514 5: dewpoint_notify: evName='Power:' val=2128'
2018.12.01 12:23:37.514 5: dewpoint max_timediff=1
2018.12.01 12:23:37.515 5: End notify loop for MYDEVICE



Wzut

Zitat von: smarthacker am 01 Dezember 2018, 13:30:10

obj-[cdih][1-9][0-9]*-len
defines the length of the data object in registers. It defaults to 1. Some devices store 32 bit floating point values in two registers. In this case you can set this attribute to two.

Why you didn't do that ?
Zitat von: smarthacker am 01 Dezember 2018, 13:30:10
attr ACTHOR obj-h40499-len 500
sorry but 500 is nonsens !
If you have a 32 bit float value which is stored in 40499 and 40500 then use 2
Maintainer der Module: MAX, MPD, UbiquitiMP, UbiquitiOut, SIP, BEOK, readingsWatcher

smarthacker

#5
Hi,

Sorry, it was the wrong conf I pasted but I used 2.
As stated in the debug log. But the problem is it is not working when I am getting the values on UI.
I would like to concatenate them.

Send queues fc 3 to 1, tid 25, for h40499 (Power), reqLen 2

I doubt the address starts from 0 and hence tried 40448 but it didn't worked as well. Problem is I am not getting 2 values.

smarthacker

Hi I used this


define MYDEVICE ModbusAttr 1 1 192.168.101.1:502 TCP
attr MYDEVICE obj-h40499-reading
attr MYDEVICE obj-h40499-len 2
attr MYDEVICE obj-h40499-unpack f
attr MYDEVICE obj-h40499-poll 1


Seems working somehow but I am not getting concatenated values.
Do I need to specify the expression params or I guess unpack f is wrongly used by me?

Is there anyway to to store values in $var and $var1 and concatenate

smarthacker

I resolved this using following conf.

define MYDEVICE  ModbusAttr 1 1 192.168.101.1:503 TCP
attr MYDEVICE obj-h40499-len 2
attr MYDEVICE obj-h40499-poll 1
attr MYDEVICE obj-h40499-reading power
attr MYDEVICE obj-h40499-unpack N