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

imranahmed

Advanced Member level 3
Joined
Dec 4, 2011
Messages
808
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
Karachi,Pakistan
Activity points
6,389
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: 41
  • PLA_RequestAnswerTable.png
    PLA_RequestAnswerTable.png
    58.9 KB · Views: 43
Last edited:

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
49,894
Helped
14,482
Reputation
29,234
Reaction score
13,391
Trophy points
1,393
Location
Bochum, Germany
Activity points
286,515
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

Advanced Member level 3
Joined
Dec 4, 2011
Messages
808
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
Karachi,Pakistan
Activity points
6,389
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.
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
49,894
Helped
14,482
Reputation
29,234
Reaction score
13,391
Trophy points
1,393
Location
Bochum, Germany
Activity points
286,515
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

Advanced Member level 3
Joined
Dec 4, 2011
Messages
808
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
Karachi,Pakistan
Activity points
6,389
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: 37
  • PLA_RequestAnswerCal.png
    PLA_RequestAnswerCal.png
    18.1 KB · Views: 26
Last edited:

KlausST

Super Moderator
Staff member
Joined
Apr 17, 2014
Messages
21,809
Helped
4,580
Reputation
9,174
Reaction score
4,765
Trophy points
1,393
Activity points
143,900
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
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
49,894
Helped
14,482
Reputation
29,234
Reaction score
13,391
Trophy points
1,393
Location
Bochum, Germany
Activity points
286,515
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.
 

LaTeX Commands Quick-Menu:

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top