Skip to content

Files

Latest commit

fdc2d34 · Apr 29, 2021

History

History
160 lines (119 loc) · 10.8 KB

modbus-interface.md

File metadata and controls

160 lines (119 loc) · 10.8 KB

BSM-WS36A Modbus Interface

Default Communication Parameters

The BSM-WS36A provides a Modbus RTU interface via RS-485 with the default communication parameters:

  • 8 data bits, 1 stop bit, even parity (8E1)
  • 19,200 Baud
  • Device address 42

The device supports the following baud rates 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, and 921600 and device addresses from 1 to 247. Section Changing Communication Parameters shows how to change them.

Data Access

Data on the device could be read via the Modbus function Read Holding Registers (function code 3) and written via Preset Multiple Registers (function code 10).

Writing to read-only data points/registers is ignored. This allows to set multiple non-adjacent data points in one transaction/write request which might come in handy when for example changing communication parameters.

Data Models

The BSM-WS36A provides an interface geared to the SunSpec Alliance's information models. See the following specifications for more details:

XML definitions of the models used by the BSM-WS36A could be found here:

Register Addresses

“The good thing about standards is that there are so many to choose from.” (Andrew S. Tanenbaum)

Modbus uses two different types of addressing schemes: Data addresses starting at one and protocol addresses (on the wire) starting from zero. So for example, the data address 40,001 will be encoded as 40,000 == 0x9c40 within an Modbus RTU frame on the wire. See Modicon Modbus Protocol Reference Guide chapter 2, section Data Addresses in Modbus Messages.

Model Instances

The BSM-WS36A provides the following model instances:

Start Address Model ID Payload Registers Label Model Name Instance Aliases
40003 1 66 Common common common, cb
40071 10 4 Serial Interface Header model_10 serial_interface_header, sih
40077 17 12 Serial Interface model_17 serial_interface, si
40091 203 105 AC Meter (Three Phase) ac_meter ac_meter, tpm
40198 64900 300 Signing Meter bsm bs_meter, bsm, sm
40500 64902 20 Communication Module Firmware Hash bsm_blob cm_firmware_hash, cfwh
40522 64901 252 Signed Current Snapshot bsm_snapshot signed_current_snapshot, scs
40776 64901 252 Signed Turn-On Snapshot bsm_snapshot signed_turn_on_snapshot, stons
41030 64901 252 Signed Turn-Off Snapshot bsm_snapshot signed_turn_off_snapshot, stoffs
41284 64901 252 Signed Start Snapshot bsm_snapshot signed_start_snapshot, sss
41538 64901 252 Signed End Snapshot bsm_snapshot signed_end_snapshot, ses
41792 64903 498 OCMF Signed Current Snapshot bsm_ocmf ocmf_signed_current_snapshot, oscs
42292 64903 498 OCMF Signed Turn-On Snapshot bsm_ocmf ocmf_signed_turn_on_snapshot, ostons
42792 64903 498 OCMF Signed Turn-Off Snapshot bsm_ocmf ocmf_signed_turn_off_snapshot, ostoffs
43292 64903 498 OCMF Signed Start Snapshot bsm_ocmf ocmf_signed_start_snapshot, osss
43792 64903 498 OCMF Signed End Snapshot bsm_ocmf ocmf_signed_end_snapshot, oses

Each model starts with a two register header followed by the given number of payload registers. The individual data point start addresses can be computed as

Data Point Start Address = Model Start Address + 2 + Data Point Offset

where the model start address is taken from the table above and the data point offset from the linked model definitions. They are also provided in the user manual.

For example, the address of the device address DA data point with offset 64 from the common model starting at 40003 computes as:

40069 = 40003 + 2 + 64

The BSM-WS36A instantiates models multiple times for the different snapshots or OCMF data. Instance aliases are provided by the Python support and the BSM Tool for accessing all model instances by a name. For example, the Signed Turn-On Snapshot could read with the BSM Tool as follows:

$ bsmtool --device=$BSMTOOL_DEVICE stons

The BSM Tool allows to print the actual model instances and the table above has been generated from this data. Note that the output from the BSM Tool gives protocol addresses and not data addresses.

$ bsmtool models
Address  ID       Payload  Label                                    Name             Aliases
40002    1        66       Common                                   common           common, cb
40070    10       4        Serial Interface Header                  model_10         serial_interface_header, sih
40076    17       12       Serial Interface                         model_17         serial_interface, si
40090    203      105      AC Meter                                 ac_meter         ac_meter, tpm
40197    64900    300      Signing Meter                            bsm              bs_meter, bsm, sm
40499    64902    20       Communication Module Firmware Hash       bsm_blob         cm_firmware_hash, cfwh
40521    64901    252      Signed Current Snapshot                  bsm_snapshot     signed_current_snapshot, scs
40775    64901    252      Signed Turn-On Snapshot                  bsm_snapshot     signed_turn_on_snapshot, stons
41029    64901    252      Signed Turn-Off Snapshot                 bsm_snapshot     signed_turn_off_snapshot, stoffs
41283    64901    252      Signed Start Snapshot                    bsm_snapshot     signed_start_snapshot, sss
41537    64901    252      Signed End Snapshot                      bsm_snapshot     signed_end_snapshot, ses
41791    64903    498      OCMF Signed Current Snapshot             bsm_ocmf         ocmf_signed_current_snapshot, oscs
42291    64903    498      OCMF Signed Turn-On Snapshot             bsm_ocmf         ocmf_signed_turn_on_snapshot, ostons
42791    64903    498      OCMF Signed Turn-Off Snapshot            bsm_ocmf         ocmf_signed_turn_off_snapshot, ostoffs
43291    64903    498      OCMF Signed Start Snapshot               bsm_ocmf         ocmf_signed_start_snapshot, osss
43791    64903    498      OCMF Signed End Snapshot                 bsm_ocmf         ocmf_signed_end_snapshot, oses

Data Representation

Standard Representation

The SunSpec Information Model Specification describes the interpretation of standard data types.

Binary Data

The BSM-WS36A provides several data as Binary Large Objects (BLOBs) - for example, its public key and snapshot signatures.

SunSpec does not define a data representation for BLOBs and so a proprietary bsm_blob or a similar arrangement of data points at the end of other models like at the ones above. For example: representation is used. Either by the specialized BLOB model

  • NB giving the number of Modbus registers B forming the BLOB data area

  • BB the actual number of bytes

  • B a repeating block with a single register of this name forming the BLOB data area

See Signed Snapshots for an example.