Support Forums
Connecting power meter with Modbus RTU to DT85

Hi,
I'm pretty new to Dex2 and DT and I'm trying to connect a power meter using Modbus RTU (RS 485) to Serial Port in my DT85. I've tried to write my own script with help of many code examples found in internet which didn't work. I also tried to program DT with Dex2 using graphical features it provides.

Code below is generated by Dex2:
62a21cdd9b71d

And this is code I wrote which can't be even uploaded to Dex2:

BEGIN"config"
 'Generated by new dEX-2
  password=""

PROFILE SERSEN_PORT BPS=9600

PROFILE SERSEN_PORT FLOW=NONE

PROFILE SERSEN_PORT DATA_BITS=8

PROFILE SERSEN_PORT STOP_BITS=1

PROFILE SERSEN_PORT PARITY=NONE

PROFILE SERSEN_PORT MODE=RS485

PROFILE SERSEN_PORT FUNCTION=MODBUS_MASTER

PROFILE MODBUS_SERVER SERSEN_ADDRESS=0

RS10S

RA("b:",ALARMS:OV:10KB,DATA:OV:1MB)5S
LOGONA
1MODBUS(AD1,R1:4096,=1001CV,W)
1001CV("Voltage")


END

Anyone knows the solution to this problem?

Hi, I'm pretty new to Dex2 and DT and I'm trying to connect a power meter using Modbus RTU (RS 485) to Serial Port in my DT85. I've tried to write my own script with help of many code examples found in internet which didn't work. I also tried to program DT with Dex2 using graphical features it provides. Code below is generated by Dex2: ![62a21cdd9b71d](serve/attachment&path=62a21cdd9b71d) And this is code I wrote which can't be even uploaded to Dex2: ```` BEGIN"config" 'Generated by new dEX-2 password="" PROFILE SERSEN_PORT BPS=9600 PROFILE SERSEN_PORT FLOW=NONE PROFILE SERSEN_PORT DATA_BITS=8 PROFILE SERSEN_PORT STOP_BITS=1 PROFILE SERSEN_PORT PARITY=NONE PROFILE SERSEN_PORT MODE=RS485 PROFILE SERSEN_PORT FUNCTION=MODBUS_MASTER PROFILE MODBUS_SERVER SERSEN_ADDRESS=0 RS10S RA("b:",ALARMS:OV:10KB,DATA:OV:1MB)5S LOGONA 1MODBUS(AD1,R1:4096,=1001CV,W) 1001CV("Voltage") END ```` Anyone knows the solution to this problem?

Hi szymon,

As your program require a single MODBUS channel, it would be better if you create it on the dEX 2.0. Then based on the template you can expand it further. Your program has some weaknesses:

  • As MODBUS read voltage, it will not use MODBUS type 0 (R0), most likely MODBUS type 4 for holding register.
  • There is a shift by 1 on dataTaker declaration to read a register address, when you declare 4096, it means the register target would be 4095.
  • It is rare to use the MBI setting (integer), except the sensor indicates a division number. Meaning if the division is 10 then the MODBUS output would be divided by 10 to gain a floating-point number. Beside the MBF that you should use, you need to declare the byte sequence (endianness).

A recommendation, please try to reduce the allocation memory to 30M when using firmware version 9.22.

The right sample program would be (with assumption of using a floating-point and a holding register)

  BEGIN"config"
 'Generated by new dEX-2
  password=""



  RS1S

  RA"Modbus"("b:",ALARMS:OV:100KB:W60,DATA:OV:1MB)5S
    LOGONA
    1MODBUS("Voltage~",AD1,R4:4096,MBF,=1001CV,LM)


END

The profile setting is no longer part of the program, it will allow you to change them without any need to resend the program. Or if you wish to include them in the program please use manual channels.

  BEGIN"config"
 'Generated by new dEX-2
  password=""

'Manual "Profile1"{
PROFILE SERSEN_PORT BPS=9600
PROFILE SERSEN_PORT FLOW=NONE
PROFILE SERSEN_PORT DATA_BITS=8
PROFILE SERSEN_PORT STOP_BITS=1
'Manual}

'Manual "Profile2"{
PROFILE SERSEN_PORT PARITY=NONE
PROFILE SERSEN_PORT MODE=RS485
PROFILE SERSEN_PORT FUNCTION=MODBUS_MASTER
PROFILE MODBUS_SERVER SERSEN_ADDRESS=0
'Manual}

  RS1S

  RA"Modbus"("b:",ALARMS:OV:100KB:W60,DATA:OV:1MB)5S
    LOGONA
    1MODBUS("Voltage~",AD1,R4:4096,MBF,=1001CV,LM)


END

Best regards,
dataTaker Expert

Hi szymon, As your program require a single MODBUS channel, it would be better if you create it on the dEX 2.0. Then based on the template you can expand it further. Your program has some weaknesses: - As MODBUS read voltage, it will not use MODBUS type 0 (R0), most likely MODBUS type 4 for holding register. - There is a shift by 1 on dataTaker declaration to read a register address, when you declare 4096, it means the register target would be 4095. - It is rare to use the MBI setting (integer), except the sensor indicates a division number. Meaning if the division is 10 then the MODBUS output would be divided by 10 to gain a floating-point number. Beside the MBF that you should use, you need to declare the byte sequence (endianness). A recommendation, please try to reduce the allocation memory to 30M when using firmware version 9.22. The right sample program would be (with assumption of using a floating-point and a holding register) ```` BEGIN"config" 'Generated by new dEX-2 password="" RS1S RA"Modbus"("b:",ALARMS:OV:100KB:W60,DATA:OV:1MB)5S LOGONA 1MODBUS("Voltage~",AD1,R4:4096,MBF,=1001CV,LM) END ```` The profile setting is no longer part of the program, it will allow you to change them without any need to resend the program. Or if you wish to include them in the program please use manual channels. ```` BEGIN"config" 'Generated by new dEX-2 password="" 'Manual "Profile1"{ PROFILE SERSEN_PORT BPS=9600 PROFILE SERSEN_PORT FLOW=NONE PROFILE SERSEN_PORT DATA_BITS=8 PROFILE SERSEN_PORT STOP_BITS=1 'Manual} 'Manual "Profile2"{ PROFILE SERSEN_PORT PARITY=NONE PROFILE SERSEN_PORT MODE=RS485 PROFILE SERSEN_PORT FUNCTION=MODBUS_MASTER PROFILE MODBUS_SERVER SERSEN_ADDRESS=0 'Manual} RS1S RA"Modbus"("b:",ALARMS:OV:100KB:W60,DATA:OV:1MB)5S LOGONA 1MODBUS("Voltage~",AD1,R4:4096,MBF,=1001CV,LM) END ```` Best regards, dataTaker Expert
edited Jun 27 at 11:08 am
32
1
2
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft