This standard uses Modbus, which is a generic industrial communication protocol, that is physically either on top of RS485 (aka RTU) or TCP Ethernet.įronius (and presumably other manufacturers) offer data logging solutions themselves, so why on earth would I make my own data logging solution? Well Fronius offer two solutions to get data. Its called SunSpec and works not just on Fronius devices but other manufacturers too. So how am I extracting the data from the devices? Well thankfully, there is a standard specification for communicating with solar power inverters and smart meters. The web viewer is going to be written up in a secondary post. It collects daily values, and some basic statistics on daily figures. This project is about collecting data from the solar inverter and feed-in power meter, and put the data into a database, so it can later be viewed from a webpage. He rarely however, actually does anything with said data because its too hard to compile into a format that is useful. The systems engineer in my father loves to collect data. My father being an ex-process and systems engineer, decided on using a system from Fronius as it was commercial/industrial quality equipment (at least from information available), and so would be built to last and perform. Along with the solar panels, they obviously got an inverter, and also purchased a “smart meter”, which is able to measure energy throughput to and from the grid. This post is pretty long as I wanted to provide proper documentation on how it works, without having multiple documents covering the same topic.Īround mid-2016, my parents had solar panels installed.
DISPLAY FLOAT IN MODBUS POLL SOFTWARE CODE
All rights reserved.Note: If you want to get stuck into the code implementation, skip to the first horizontal line. This information helps you decode misaligned or unknown binary strings. It also breaks out the components, showing the exponent and significand fields. Here is a good online calculator which shows the 32-bit and 64-bit hex form of IEEE floating point values.
![display float in modbus poll software display float in modbus poll software](https://www.modbustools.com/images/mbpoll-write-single-register.png)
Return struct.pack("f", data) # get true big-endian This code fragment converts a 32-bit floating point into a 4-byte binary string in one of three forms: if(form in ): Without this setting, the devices cannot be integrated with the widely used Modicon 984, Quantum and Momentum PLC. In fact, most slave/server devices natively supporting methods #2 or #3 will include a user setting perhaps labeled "Modicon Compatibility Mode" to force method #1. In reality, method #1 is the most universally supported. Bottomline: Method should be configurableĪny master/client wishing to read 32-bit floats from any arbitrary Modbus slave/server must allow user configuration to select which of these 3 methods to assume. These vendors tend to predefine ranges of registers types, so while reading 10 holding registers starting at 4x00001 returns 20 bytes, reading 10 holding registers starting at 4x07001 returns 40 bytes. Thus these vendors return 32-bit floating points as double-sized (32-bit) registers in true big-endian format. They reasoned that since the read response includes a byte count, the master/client could understand that a read of 10 registers resulting in 40 bytes of data meant that the registers were 32-bit and not 16-bit. Still other vendors used a gray area within the Modbus standard, encoding 32-bit floating points in a manner neither allowed nor forbidden by the standard.
![display float in modbus poll software display float in modbus poll software](https://docplayer.net/docs-images/40/14933148/images/page_1.jpg)
Method #3: one 32-bit special register, 32-bit big-endian Other vendors approaching the same problem took to heart the "Modbus is Big-Endian" mantra and returned 32-bit floating points as two consecutive registers, with the high-word in the first register. Method #2: two 16-bit holding registers, high-word first So the bytes within the words are still big-endian, while the words are psuedo-little-endian. Because these PLC used little-endian processors and the 32-bit floating points were placed directly in the normal 4x read/write holding register space, 32-bit floating points moved under Modbus as two consecutive registers, the low-word in the first register.
DISPLAY FLOAT IN MODBUS POLL SOFTWARE UPGRADE
The Modicon 984E PLC with the enhanced math module upgrade began the wide use of 32-bit floating points under Modbus. Method #1: two 16-bit holding registers, low-word first It is impossible to define how any new Modbus device you obtain will handle 32-bit floating points. Unfortunately, the history of 32-bit floating points under Modbus is one of ad-hoc solutions. Modbus Floating Points Moving 32-bit Floating Points under Modbus