LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus (DSC Module) - Illegal Data Address

Hi

 

I need to implement a Modbus Slave in an application on a cRIO system. I set up a "I/O server" (DSC Module) and created shared variables for all the registers I need. The Slave has been tested and works fine, I'm using about 20 holding registers and I'm able to both read from and write to them.

The issue is that when the Modbus Master reads a holding register that I have not implemented the slave replies with the value "0x00 0x00" (LabVIEW default for integer) and not with exception response code 02 (a holding register inquiry for a nonexistent address should reply with function 0x83 and code 0x02 - Illegal Data Address).

Is it possible to change a setting or something, in order to force the DSC Module to send an exception response code, in stead of simply a default value, for registers that are not specifically configured?

 

Hope someone can help me - I would really like not to write all the necessary code for a modbus slave myself.

0 Kudos
Message 1 of 3
(4,036 Views)

Simon,

If the slave is actually sending the 0X00, 0X00 response to the master query then there is no way for the Labview app to know that the register is non existant.  Your slave should respond with an illegal address code. If it does not then the master assumes the register exists and has a zero value.

Len

0 Kudos
Message 2 of 3
(4,023 Views)

Hi Lenvno

Thanks for your reply.

I think you misunderstood me.

I have an application running on a cRIO. On this cRIO I need to implement a Modbus Slave in which specific holding registers should be used. Through a serial connection a different device, acting as a Modbus Master, obtains information from this slave.

On the cRIO, in my LabVIEW application, I have created an I/O server - Modbus Slave. Using shared variables I write values to specific holding registers on the Modbus Slave.

The Modbus Master obtains the values from these registers using function code 0x03, read holding register - this works correctly. However, when the Modbus master query registers that I have not defined, the I/O server on the cRIO replies with a register value of 0, instead of Illegal Data Address. It seems like when using this I/O server, all possible Modbus registers is filled with the LabVIEW default value and the slave therefore always will reply with a value even if the register is not used.

 

My question is therefore, how can i change this? If the Master query a register that I am not writing to (and is therefore unused), I would like the slave to reply with "Exception Response" code 0x02 - "Illegal Data Address", and not just the value of 0. 

 

/Simon

0 Kudos
Message 3 of 3
(4,012 Views)