Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

RS485 Request and Answer

Status
Not open for further replies.

imranahmed

Advanced Member level 3
Joined
Dec 4, 2011
Messages
817
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
Karachi,Pakistan
Activity points
6,492
Please let me learn about sending RS485 Modbus RTU request via Arduino UNO and get answer from device.
I have written method for sending request and getting answer but I want to know somethings,
there is a lookup table how to use it and make a request in Arduino?
Polynomial is 0xA001.
Please see attachments.
 

Attachments

  • PLA_RequestAnswer.png
    PLA_RequestAnswer.png
    29.8 KB · Views: 123
  • PLA_RequestAnswerTable.png
    PLA_RequestAnswerTable.png
    58.9 KB · Views: 120
Last edited:

MODBUS has no standarized float format, it's manufacturer specific. Presume in case of doubt regular IEEE format, identical to float format used by most C compilers.

To implement MODBUS on Arduino, you can use existing library.
 

    imranahmed

    Points: 2
    Helpful Answer Positive Rating
MODBUS has no standarized float format, it's manufacturer specific. Presume in case of doubt regular IEEE format, identical to float format used by most C compilers.

To implement MODBUS on Arduino, you can use existing library.
Please recommend me any library I used ModbusMaster but I have some confusion for retrieving data from device.
I have to get analyser readings from its RS485 port.
 

I'm not yet using MODBUS on Arduino and can't suggest a specific library. I however implemented MODBUS master and slave on different platforms. I suggest to review the various available Arduino MODBUS libraries.

As for your general questions regarding "retrieving data", they are answered in the MODBUS APPLICATION PROTOCOL SPECIFICATION downloadable at modbus.org. I'm not sure what your application is. Is it a regular MODBUS Client ("Master")?
--- Updated ---

CRC implementation is described in MODBUS over serial line specification and implementation guide

The most recent specs are
 
Last edited:

    imranahmed

    Points: 2
    Helpful Answer Positive Rating
I'm not yet using MODBUS on Arduino and can't suggest a specific library. I however implemented MODBUS master and slave on different platforms. I suggest to review the various available Arduino MODBUS libraries.

As for your general questions regarding "retrieving data", they are answered in the MODBUS APPLICATION PROTOCOL SPECIFICATION downloadable at modbus.org. I'm not sure what your application is. Is it a regular MODBUS Client ("Master")?
--- Updated ---

CRC implementation is described in MODBUS over serial line specification and implementation guide

The most recent specs are
I have a Energy Analyser which displays Volt, Current and lot of other readings, it has RS485 port on back side showing AB, I want to retrieve its reading
via Arduino to display on Serial Monitor.

Attached is Energy Analyser`s Modbus Registers ducument, please see last of document.
--- Updated ---

How to calculate?
 

Attachments

  • pla33_modbus-v-1-2.pdf
    148.2 KB · Views: 129
  • PLA_RequestAnswerCal.png
    PLA_RequestAnswerCal.png
    18.1 KB · Views: 99
Last edited:

Hi,

You ask how to calculate the decimal value of a 32 bit float.

My answer:
I'd not calculate it manually.
The straight forward solution is to define a struct for the Modbus answer.
(Good thing here is that the answer almost always is a float).
Struct:
* uint8 a_ID
* uint8 a_func
* uint8 a_count
* float a_value
* uint16 a_crc

Then just use a_value as you like (calculations, compare, form into a string...)

Klaus
 

How to calculate?
Why didn't you try to do the calculation yourself according to IEEE float format specification during the last three days?

There are also online calculators, e.g. this https://www.h-schmidt.net/FloatConverter/IEEE754.html
The first hit when seaching for "ieee float calculator".

Typing in the example number clarifies that your device uses standard 32 bit float format

1642848477344.png


Respectively you get the value by casting 4 bytes to float. Just standard C programming.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top