Recent

Author Topic: Modbus on Raspberry Pi  (Read 1886 times)

jdp

  • Jr. Member
  • **
  • Posts: 90
Re: Modbus on Raspberry Pi
« Reply #45 on: November 08, 2019, 05:24:34 pm »
If there is no Modbus Lib for CLI only then there is a gap for one as a lot of IOT edge devices
Did you read my previous message at all about 2 other MODBUS libraries and one even comming with CLI demo?
https://forum.lazarus.freepascal.org/index.php/topic,47289.msg338661.html#msg338661

Hi yes I did. Thanks for pointing them out to me.

As there is no documentation I have no idea how they work to read a float from a register.
« Last Edit: November 08, 2019, 06:03:01 pm by jdp »

white_zombie

  • New Member
  • *
  • Posts: 12
Re: Modbus on Raspberry Pi
« Reply #46 on: November 08, 2019, 09:43:52 pm »
Then you will probably like BitHelpers from my signature  ;)

I already known your library, although I have not used it yet, mostly because over the years I had been writing my own routines for this, but your library is far more complete that what I have, it would be great to have in integrated in FPC.

What I known very well is your pasettimino library, it save me a lot of work in one of my projects, it was very helpful to have the communication with Siemens PLC done without any dependencies in external dlls. By the way, I am the guy who send you the patches for the Linux compatibility of the library.

avra

  • Hero Member
  • *****
  • Posts: 1717
    • Additional info
Re: Modbus on Raspberry Pi
« Reply #47 on: November 08, 2019, 11:43:19 pm »
As there is no documentation I have no idea how they work to read a float from a register.
You should check with your hardware device manual, but floats are usually with single precision (32 bit) and stored in two registers next to each other. You find address of it in the documentation, and load starting register (16 bits) and following register (also 16 bits). Usually you use MODBUS function with parameters like first register address and number of registers to read. Then you read directly 32 bits from 2 registers and cast them to single float type. Beware that your device may have different endianess - if it does you have to adapt to that. That's all.

What I known very well is your pasettimino library, it save me a lot of work in one of my projects, it was very helpful to have the communication with Siemens PLC done without any dependencies in external dlls.
I am always glad to see pasettimino being used. It is based on Arduino lib so it is not thread safe yet. Hopefully I will catch time to change that.

By the way, I am the guy who send you the patches for the Linux compatibility of the library.
Nice to see you here too, Victor - and thank you once again for the patches.  :D
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib