This a little guide with all the things to know to communicate correctly with the Modbus device BCPME284S by Schneider Electric
- User Guide - User Guide for the installation of BCPME
- Register List - Register List and How to Read Different Data Types
- Simply Modbus - Simple guide with examples to learn about the modbus TCP/IP protocol
- Modbus Wikipedia - Wikipedia page about modbus and all different types (useful for function code)
There are only few step to install:
- cd inside the cloned repo and
pip3.5 install bcpme/
- change the ip address and port of the influxdb server in "learn_check.py" file (look for the "TODO")
- configure the bcpme devices with the connected devices
This device communicate with the Modbus protocol over TCP/IP the modbus request, as you can see int the docs, is built in this precise order:
- 2 bytes transaction id (
0
in our case) - 2 bytes protocol id (
0
in our case) - 2 bytes length: the following number of bytes (usually
6
in our case) - 1 bytes unit id: see the section about unit id (
1
or2
in our case) - 1 bytes function code: the function code that tells the action to do (
4
to read,6
to write) - x bytes data: depends on the function code
The Modbus device is composed of 4 panels and each one has a number and a letter assigned, we have:
- Panel 1A
- Panel 1B
- Panel 2A
- Panel 2B
each panel has 21 sensors each one numbered physically from 1 to 21, but seen from the software perspective Panel 1A and Panel 1B ( the same for Panel 2A and Panel 2B) are just one block that goes from 1 to 42:
- to access Panel 1 (A and B) we use
1
for the "unit id" byte in the modbus request - to access Panel 2 (A and B) we use
2
for the "unit id" byte in the modbus request
but the number that are written on the panels and the number of registers doesn't always match this is because as you can se at Page 15 of The User Guide there are 4 types of configuration.
the following table match the physical number with the "virtual" one:
To set the type of the configuration you have to write to the register number 6
the corresponding value of the configuration:
0
- Top Feed1
- Bottom Feed2
- Sequential3
- Odd / Even
There are around 20 different type of operations supported, we are just intrested in 2
- Read Input Register: (function code:
4
) to read one or more register and the "data" bytes are used as following- 2 bytes number of the first register to read
- 2 bytes number of registers to read
- Write Single Holding Register: (function code:
6
) to write one register the "data" bytes are used as following- 2 bytes number of the register to write
- 2 bytes the value to write
little note: The numbers of the registers in the documentations of the bcpme are augmented by 1 it means that for ex. to access the register described as number 6 in the docs, we have to use number 5
The first page of the Register List Document shows how to read all the different data types
There are a value register and a scale register and to obtain the final value:
result = value_16 * pow(10, scale)
There are two near value register and a scale register to obtain the final value:
result = value_32 * pow(10, scale)
There are two near value register to obtain the final value:
result = value
In order to access the registers that contains data about multi phase measures you have to enable "user defined status register" number 62017
with 1
and if needed assign to the registers starting from 62116
to 62157
and write the val 0
for phase 1,1
for phase 2,2
for phase 3
The BCPME python class handle all the type of wire configurations so there's no need to care about them. You can add new device in two ways:
- From the physical side: using the panel number, panel letter and the number physically written on it
- From the virtual side: using the unit id and the virtual number
each time a device is added to the BCPME class it saves the map of the devices in json using the physical hierarchy so that it's easy to add devices also editing the json file, but the map of devices in the class uses the virtual hierarchy for convenience.
When Initializing a new BCPME if there's an already saved device with the same name it loads its configuration so when it's initialized once you just need to do BCPME("name")
The file bcpme_register_map.json
has all the useful registers with the corresponding scale values so there's no need to scroll all the documentation to find the address of you want to read
- Dario Furlan - Initial work - https://github.com/iofurlan
Fell free to contribute to this project. This project is licensed under the MIT License - see the LICENSE file for details