Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

MUlti-register read on modbus

Status
Not open for further replies.

dexdyne

Civil/Environmental
Jul 10, 2007
8
0
0
GB
I am aware that Modbus is seen as a set of 16-bit registers.

I am aware that some of the numbers I'll want to read across a Modbus will need >1 adjacent 16-bit registers - floating point for instance needs 2 or 4.

Similarly some data will neeed 32-bit integers, which could suffer in the same way.

It would obviously be a disaster if I read the top 16 bits of an old value, and the bottom 16 bits of a new one. Integer counters could be wrong by 64K, floating point values by almost any amount.

If we use the modbus "read-a block-of-registers-at-once" command, can we be totally confident that the PLC will snapshot all the registers in the block in between any 32-bit-integer or floating-point write operation by the PLC program, and that we CANNOT be given an inconsistent half-and-half value?

Or do I need to do multi-register transfers using all sorts of software semaphores and software routines built into the PLC software to be certain of consistency?

David
 
Replies continue below

Recommended for you

This depends on how you are reading the registers. If you are manually writing Modbus commands you will simply specify the start address and number of registers and you will get a snapshot of the congruent registers. You'll then have to parse them yourself. If you are using an I/O server most will allow you to specify the type of data using a modifier on the address. For example, if I ask for "R30008" I'll get a 16 bit integer. If I ask for "R30008:L" I'll get a 32 bit long integer corresponding to R30008 and R30009. If I ask for "R30008:R" I'll get a 32 bit real of the same two register. The modifier is specific to the I/O server so you have to review the documentation to determine what to use.
 
Thanks mls1,

We've got our own s/w in a box

see
which does the Modbus reads. It will use a block-read on any adjacent blocks of registers, so we're half way there.

The Modbus driver at our end is home-brewed, and I'm going to have to get the programmer guy to build me a more comprehensive set of modifiers - at present we only handle 16-bit unsigned and 32-bit fpt properly.

--------------------------

My real question was - when you do the multi-register-read:

1. does the PLC firmware snapshot a sample of all the registers in a block to a holding area , then send them to you from there?.

2. If there is such a snapshot, then is it guaranteed not to occur halfway through the PLC application updating a 32-bit value... in other words if I ask for the Modbus read while a write to Modbus-visible-memory of a fpt value is taking place, can I ever get half the old value, and half the new?

I know computer makers get paranoid about this sort of stuff, I don't know if PLC people get to same depth.

David
 
Status
Not open for further replies.
Back
Top