Closed orbweaver closed 3 years ago
There is support for scaling values, check out the scale
option when defining the registers.
that scaling seems to work on FLOAT32 just fine, but the device stores data in INT16 registers, and when I try to use the scale option on an INT16, it simply truncates the last digit, i.e. "842" becomes "84" instead of "84.2"
I think this is a bug.
I thought this was due to an issue with scaling, but this is because we are reporting this value as an integer since it was loaded as an integer, and of course integers don't have a factional part.
@orbweaver did you check the scaling-factor lately? I think it should work just fine if you specify INT16 and 0.1 as scaling factor. Otherwise, as Daniel said, it's a bug. The problem with your suggestion is that devices with scaling factors such as 200.0 or 0.2 or 0.128 won't be supported and we definitively have those...
Thanks for the update. I will be able to test next week and report back. Cheers.
@orbweaver any news?
OK I downloaded the latest and gave it a try. Still doesn't seem to have the desired effect. Pasted details below:
According to the PLC documentation, I need to move the decimal point to the left for the register containing "Total Power Factor" I started with this in the configuration: { name = "Total Power Factor", byte_order = "AB", data_type = "INT16", scale=1.0, address = [1048]},
and then ran a test:
telegraf --config pdp.test.conf --test 2021-02-18T18:31:31Z I! Starting Telegraf 1.17.2 pdp_modbus,datasource=pdp,host=scada-mon.local.net,name=pdp,type=holding_register Total\ Power\ Factor=89i 1613673091000000000
...and then I changed the scale setting to 0.1 to see what happens:
{ name = "Total Power Factor", byte_order = "AB", data_type = "INT16", scale=0.1, address = [1048]},
and the test output truncates a digit instead of introducing a decimal point:
telegraf --config pdp.test.conf --test 2021-02-18T18:32:18Z I! Starting Telegraf 1.17.2 pdp_modbus,datasource=pdp,host=scada-mon.local.net,name=pdp,type=holding_register Total\ Power\ Factor=8i 1613673139000000000
Ok I see the problem now. If you specify INT16
you always get an int16 also after scaling. Try FIXED
as data_type
this should do what you expect.
That did the trick. Thank you so much!
On 2021-02-22 08:37, Sven Rebhan wrote:
Ok I see the problem now. If you specify INT16 you always get an int16 also after scaling. Try FIXED as data_type this should do what you expect.
-- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub [1], or unsubscribe [2].
Links:
[1] https://github.com/influxdata/telegraf/issues/7266#issuecomment-783461771 [2] https://github.com/notifications/unsubscribe-auth/AEXHY4DPI5GFXJWDZ4YRFSDTAJ23XANCNFSM4LZU4VBQ
@orbweaver cool. I'm closing the issue then...
Hi, I have the same problem but I can't resolve with data_tye = FIXED. I receive this error:
2022-02-05T11:38:24Z E! [outputs.influxdb_v2] Failed to write metric (will be dropped: 422 Unprocessable Entity): unprocessable entity: failure writing points to database: partial write: field type conflict: input field "Temp B1" on measurement "modbus" is type float, already exists as type integer dropped=1
Any idea? tnx a lot
@gnoto I answered your comment on #10592, please continue the matter there.
Feature Request
add conversion mechanism to modbus - similar to snmp
Opening a feature request kicks off a discussion.
Proposal:
add a conversion/scaling feature to modbus data
Current behavior:
some modbus devices keep an integer value in their registers that are a multiple of the actual value i.e. "563" in the register represents an actual value of "56.3"
Desired behavior:
use a conversion factor, similar to the snmp input plugin. sample from snmp pasted below
Apply one of the following conversions to the variable value:
Use case:
when collecting from diverse data sources (snmp, modbus, exec scripts,etc) it would be beneficial to have the data uniformly formatted and scaled when storing them, to help simplify