Discrete Inputs, Coils and Registers Cmds

C

Thread Starter

criders

Hello All,

I am creating an embedded device that works using Mod Bus. Everything is progressing rather smoothly. I just finished the Mod Bus function (0x01) Read Coils. I was about to start on the next one, but it seems that it is the same as the first one. I am trying to match up data to the Mod Bus commands, but all the documentation is not very clear on the subject.

The device will have:

Digital Inputs - DIN (x8)
Digital Outputs - DOUT (x8)
Analog Inputs - AIN (x8)
Analog Outputs - AOUT (x8)

Various data for setting things up like baud rate,parity, process variables, etc. that the user can change.
Various data like the firmware number that the user can read but cannot change.

By my estimates, I think that this is the right approach to take:

DIN : (0x02) Read Discrete Inputs
DOUT : (0x01) Read Coils
AIN : (0x04) Read Input Registers
AOUT : (0x03) Read Holding Registers
Process variables : (0x03) Read Holding Registers
Firmware number : (0x04) Read Input Registers

I guess I am not clear on Coils, Discrete Inputs, Input Registers, and Holding Registers and the data that should be associated with each one.

If anyone could provide a simple explanation on this, that would be helpful.

Thanks,
criders
 
Your division of:

DIN : Discrete Inputs
DOUT : Coils
AIN : Input Registers
AOUT : Holding Registers
Process variables : Holding Registers
Firmware number : Input Registers

sounds pretty good. Generally, Discrete inputs and input registers are for read-only data, and coils and holding registers are for read-write data.

The reason for having both read-only and read-write address types is to remove the possibility for certain types of errors. For example, the user needs to be able to write to analogue outputs. However, it makes no sense for the user to be able to write to the firmware revision number address. Since there is no function for writing to input registers, the user *can't* make this type of mistake and you don't have to figure out how to deal with it.

It is also possible to "overlay" some or all of the input registers on the holding registers, and/or some or all of the discrete inputs on the coils. "Overlaying" data means to have two different data addresses effectively point to the same data. You would typically only do this to allow for example a mixture of data types to be read with one read operation (if this happens to be convenient for the user).
 
Top