Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Modbus question for digital barometer


CESPool Apr 19, 2019 06:00 PM

Hello,

I'm dealing with a Modbus problem for a digital barometer. I'm using a CR6 and this barometer:

https://www.baranidesign.com/meteopressure-msb181

It talks in serial with 9600 baud, no parity, and 8 databits.

The pressure is on Register 24 ( 32bit float) little endian. (DCBA).

Terminal string example:

01 03 0018 0002 7687

where
01 - address of the device

03 - function code 03

0018 - starting register ( 24DEC = 18Hex)0002 - count of registers to be read out ( here 2x 16 bit)

7687 - CRC

Here's the modbusmaster function I've created for the program:

ModbusMaster (ResultPressure,ComC1,9600,1,3,ModbusDataPressure(),25,1,3,1000)

The terminal is showing this output which looks correct:

10:59:00.000 T 01 03 00 18 00 02 44 0C ......D.
10:59:00.031 R 01 03 04 92 ED 7D 44 67 DD .....}Dg.

And I'm getting the value 1.632812E37.  I believe I need to convert this value with MoveBytes.

Any help with this would be great. Thanks!


CESPool Apr 24, 2019 05:56 PM

Bump


CESPool Apr 25, 2019 08:49 PM

SOLVED!

Here's the movebyte function that I used to parse the data:

Sub RunBaraniBarometer()
  ModbusMaster (ResultPressure,ComC1,9600,1,3,ModbusDataPressure(),25,1,3,1000,2)
EndSub

Sub BigtoLittle()
  'converts modbus output to decimal readable values
  MoveBytes (InverseModbusDataPressure(1),3,ModbusDataPressure(1),0,1)
  MoveBytes (InverseModbusDataPressure(1),2,ModbusDataPressure(1),1,1)
  MoveBytes (InverseModbusDataPressure(1),1,ModbusDataPressure(1),2,1)
  MoveBytes (InverseModbusDataPressure(1),0,ModbusDataPressure(1),3,1)
EndSub


ronlootensVU Apr 30, 2019 10:59 AM

Because pressure output of the Barani is two bytes I used the next command that worked fine for me:

ModbusMaster(ModbusResult1,32,19200,1,4,Modbus1(),1,5,1,100,3)

'32 used for SDMIO in RS485 mode on CR1000

then value in mBar:

If Modbus1(4) = 1 Then val = 65536 Else val = 0
AirPress = (Modbus1(3) + val)/100

finally I added elevation correction:

elevation_cor = 1013.25 * (1 - (1 -elevation/44307.69231)^5.253283)
Airpress_cor = AirPress + elevation_cor

maybe it helps playing with modbus

Ron

Log in or register to post/reply in the forum.