That went off too soon …

https://en.wikipedia.org/wiki/IEC_61131-3

Even if we initially had different type names for each driver, we sort of 
consolidated on using the IEC defaults.
However, this doesn’t mean that we can only use these. It should be possible to 
support additional type names.

>From what I read from the spec you referenced, it shouldn’t be too difficult:

Int16=INT
Uint16=UINT
BitField16=WORD
Int32=DINT
Uint32=UDINT
BitField32=DWORD
…
Float32=REAL

Just the Arc and the Enum types I don’t quite know what they are and the 
scale-factors I haven’t seen before.

I would assume a simple translation from the SunSpec names to IEC/PLC4X-Names 
should get most of the job done.
I haven’t tested reading strings however.

But in general, I would say: If there’s a need to do so, PLC4X would 100% be 
extendible to support different types of encoding schemes.
Even if it meant having multiple DataIo implementations.
https://github.com/apache/plc4x/blob/develop/protocols/modbus/src/main/resources/protocols/modbus/modbus.mspec#L311


Chris







From: Christofer Dutz <[email protected]>
Date: Monday, 2. January 2023 at 14:28
To: [email protected] <[email protected]>
Subject: Re: Interpreting the modbus registers.
Hi Nils,

As it’s the goal of PLC4X to have a shared API over many protocols. We sort of 
settled on using this as a reference for the supported types:

From: Niels Basjes <[email protected]>
Date: Monday, 2. January 2023 at 13:33
To: [email protected] <[email protected]>
Subject: Re: Interpreting the modbus registers.
Hi,

Just as background info:
The Sunspec modbus spec is a standardized way of doing modbus for energy
equipment across many vendors with lots of different features. It also has
types like a `string` which is a sequence of modbus registers which are
then interpreted as ASCII (used for serial numbers, brand names) and a type
for an IPv6 address (and many others).

https://sunspec.org/
https://sunspec.org/wp-content/uploads/2015/06/SunSpec-Information-Models-12041.pdf
https://github.com/sunspec/models

Long ago I wrote some code to handle modbus for Sunspec (for my Solar
panels at home) and my SDM630 (which measures the power usage of my
Geothermal Heatpump at home)
See: https://github.com/nielsbasjes/energy

I recently got a new Heatpump which supports modbus itself and decided to
write some code for that thing too and cleanup/refactor/reconsider the code
I wrote a few years ago.
As part of this reconsidering I'm having a close look at this project.

How does the plc4x project look at having these kinds of very specific
decoders as part of this project ?
Or do you prefer to have them outside this project ?

Niels

On Mon, Jan 2, 2023 at 1:00 PM Christofer Dutz <[email protected]>
wrote:

> Hi Niels,
>
> and welcome to the plc4x community :-)
>
> In general, we already have a general-purpose mapping layer. However, it’s
> not as universal as you would need for that given use-case.
> So, if for example you read a register as type “REAL” it will
> automatically fetch two registers and interpret the two as 32bit floating
> point number.
>
> However, in your case you currently would need to manually do the
> conversion. Unfortunately, I don’t know the “sunspec”, so not 100% sure how
> this is encoded.
>
> Does that help?
>
> Chris
>
>
>
> From: Niels Basjes <[email protected]>
> Date: Monday, 2. January 2023 at 12:48
> To: [email protected] <[email protected]>
> Subject: Interpreting the modbus registers.
> Hi,
>
> The modbus protocol simply talks about 1 bit coils and 16 bit registers and
> are retrieved and written back.
> Modbus does not assign any meaning to these bits so real applications need
> a translation from these register bits to usable values.
> In some cases the meaning of the bits even varies with the content of other
> registers; For example the sunspec has a "scaling factor" which indicates
> how much 10^X a field must be multiplied to get the real value.
>
> Is there a generic example on how to implement such a mapping layer cleanly
> with plc4j?
>
> I did have a look at the OPM feature but that retrieves all values one by
> one; I want all measurements retrieved at the 'exact' same instant.
>
> --
> Best regards / Met vriendelijke groeten,
>
> Niels Basjes
>


--
Best regards / Met vriendelijke groeten,

Niels Basjes

Reply via email to