from the Have No Clue department...
Discrete Inputs, Coils and Registers Cmds
Application Questions and Problems topic
Posted by criders on 16 November, 2009 - 10:13 am
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


Posted by M Griffin on 16 November, 2009 - 8:41 pm
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).


Posted by criders on 18 November, 2009 - 11:40 am
Cool.

Thanks M Griffin.

Your use of this site is subject to the terms and conditions set forth under Legal Notices and the Privacy Policy. Please read those terms and conditions carefully. Subject to the rights expressly reserved to others under Legal Notices, the content of this site and the compilation thereof is © 1999-2010 Nerds in Control, LLC. All rights reserved.

Users of this site are benefiting from open source technologies, including PHP, MySQL and Apache. Be happy.


Fortune
Mencken and Nathan's Fifteenth Law of The Average American:
The worst actress in the company is always the manager's wife.