Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: kulmx on July 04, 2015, 05:44:51 AM

Title: Modbus Do-more
Post by: kulmx on July 04, 2015, 05:44:51 AM
Hi
PLC H2-DM1+Serio-4(RS485 Modbus RTU master)+22 devices Slave
Need an example program block R/W Modbus 22 devices.
error output on loss of communication with the device
how to organize a function call R/W?
http://imgur.com/1FOBkyy
Example MODBUS Function codes descriptions:
http://www2.emersonprocess.com/siteadmincenter/PM%20Micro%20Motion%20Documents/Modbus-Map-Manual-20001741.pdf
Title: Re: Modbus Do-more
Post by: franji1 on July 07, 2015, 09:49:43 AM
You need to use the MRX - Modbus Network Read and MWX - Modbus Network Write instructions.  However, you also need to know the Function Code based on the data-type in the Slave.  Luckily, the manual provides that information.  Here's one key section in the slave manual where they provide a good mapping of the slave's terminology with Modbus terminology (and I will also be adding Do-more terminology).

This is from Section 1.3.2:
Note: Micro Motion terminology is a simplified version of Modbus terminology. The term "coil" is
used for both Modbus coils (read-write) and Modbus discrete inputs (read-only), and the term
"register" is used for both Modbus holding registers (read-write) and Modbus input registers (readonly).


So then, in Chapter 2, where they provide all the Modbus addresses, if they describe that address as a READONLY COIL, it is actually a Modbus Discrete-Input, which would utilize the following Function Codes in the MRX instruction:
MRX: Function Code 2 - Read (multiple) Discrete Inputs

If it is a READ/WRITE COIL, it is a Modbus Coil:
MRX: Function Code 1 - Read (multiple) Coils
MWX: Function Code 5 - Write Single Coil
MWX: Function Code 15 - Write Multiple Coils
If you are writing coils, try to utilize Multiple Coils over Single (e.g. you could use 10 MWX box for 10 single coils, or 1 MWX box for 10 multiple coils BUT ONLY WHEN THE 10 ARE CONTIGUOUS)

If it is a READ-ONLY REGISTER, it is an Input Register:
MRX: Function Code 4 - Read (multiple) Input Registers

If it is a READ/WRITE REGISTER, it is a Holding Register:
MRX: Function Code 3 - Read (multiple) Holding Registers
MWX: Function Code 6 - Write Single Holding Register
MWX: Function Code 16 - Write Multiple Holding Registers

I would recommend that you read/write Coils/Discrete Inputs into/out of Do-more's C bit memory.
You will want to read/write 32 BIT FLOATING POINT into/out of Do-more's R (real) memory.
You will want to read/write 32 BIT (long) INTEGER registers into/out of Do-more's D (32 bit integer) memory.
You will want to read/write "normal" registers into/out of Do-more's V (16 bit UNSIGNED) or N (16 bit SIGNED) memory, based on whether the value is unsigned or signed.

CAVEAT EMPTOR: The "Endian-ness" (byte/word order) of your slave may be different from Do-more's.  This COULD be an issue with 32 bit REALs and 32 bit INTEGER (DWORD).  Try looking at a REAL that you have READ from the slave in the Data View, where you know the value (e.g. 1.1).  If it looks like 1.1 in R memory, then the Endian-ness is the same, and there is no additional work to be done.  HOWEVER, if it looks like garbage, try using a SWAPB instruction on the R register, swapping ONLY WORDs (NOT Bytes) and see if that gives you the "correct" value in your data view of the R register.  If you have to use SWAPB, please post here and we will provide details on the best way to do it for both incoming/read values and outgoing/write values.  The master and slave Modbus drivers SHOULD be taking care of the Endian-ness at the BYTE level, but they cannot at the WORD level, hence this caveat.

If you need any of the ASCII registers, let us know, and we can show you how to map those into or out of STRING memory.
Title: Re: Modbus Do-more
Post by: kulmx on July 07, 2015, 04:25:49 PM
Hi
thanks for the detailed answer
There is still a question
You can make the simulation PLC program Modbus program Do-more desinger v1.3?
Title: Re: Modbus Do-more
Post by: franji1 on July 07, 2015, 05:23:00 PM
Just give me some examples like

From Slave 3, read Input Register 123
From Slave 10, write Holding Register 456 thru 460
From All Slaves, read Discrete Inputs 1 thru 10
...