Welcome to another edition of ProSoft Technologies video training.
edition we'll be covering the process for configuring the MVI56E-MCM as a
master communicating with a slave device over a Modbus network.
If you are unfamiliar with any of the Modbus terminology or topics like function
codes or Modbus data addressing, ProSoft Technology has a training video that
covers the basics of understanding the Modbus protocol that might be helpful.
The MVI56E enhance Modbus master slave communication module allow
Rockwell Automation ControlLogix processors to easily interface with
devices using the Modbus RTU ASCII serial communications protocol.
The MVI56E-MCM and MVI56E-MCMXT feature two independently configurable serial
ports that can be configured as a Modbus master or slave, sharing the same user
control 10,000 word database. An Ethernet port is also provided for debugging.
In this video we'll install the add-on profile and add-on instruction for the
MCM, we'll go through the process to configure the MCM as a Modbus master and
then set up master commands to talk to a power monitor. We'll create a command to
read the minimum and maximum levels for phase A voltage. We'll write a voltage
limit for phase A. Then we'll write some bits to reset the minimum and maximum
voltage for phase A.
This is the node of the power monitor and the addresses that I'll be using.
We'll start by adding the add-on profile for the ProSoft family of products. You can download a copy of the
AOP off the product disk or by going to our website at www.prosoft-technology.com
and going to the MVI56E-MCM product page.
Be sure to also grab the sample ladder file for the MVI56E-MCM.
We'll be using this a little later.
To install the add-on profile
double click on MP setup and follow the prompts to complete the installation.
Be sure that all Rockwell software is closed when you do this including RSlinx.
Once this is done will open up RSLogix 5000, you can also use Studio 5000.
I have a new project already set up. We'll bring the MVI56E-MCM into the project by
expanding the I/O configuration in the Controller Organizer, right-click on the
1756 backplane and select New Module. In the select module screen clear the
vendor filters and then select ProSoft then go down and choose the MVI56E-MCM
module, click Create, in the new module window give the module name
I'm going to name it My_MCM. The slot number should be the slot the MCM occupies in your rack,
and click OK. Next we'll import the MVI56E-MCM add-on instruction ladder to
get the processor talking to the module. In the Controller Organizer window
expand Tasks and drill down to Main Program and double click on Main Routine
once the main routine opens right-click on any rung and select Import Rung then
browse for and select the .L5X add-on rung file and click Import.
When the import configuration window opens change the slot number by modifying the
Local: slot # field to match the number of the slot that the MVI56E-MCM is
actually using. In this case I have the module in slot 2
my rack so I'll change each field to slot 2.
Once this is done click OK
return to Main Routine and delete the empty rung 0. Now the user-defined data
types imported with the add-on rung are listed in the data type section of the
Controller Organizer tree as you can see here and this also brings in the ladder
logic and controller tags for the MCM module.
The MVI56E-MCM module has a database of 10,000 registers
typically you can think of this database as having two sections: read data and write data.
The read data is sent to the ControlLogix CPU from the network
while the write data is read from the ControlLogix CPU and then sent out over the network.
To configure the MCM's database will use the MCM.CONFIG.ModDef controller tag.
the ModDef tag configures the entire module's database and I'll go through the
essential entries here. The write start register defines where within the MCM's
database the write data from the ControlLogix CPU will begin in this example the
data will start at 0. So that would be the very first register of the entire
database. The write register count parameter specifies the number of
registers that will be allocated to the write data from the ControlLogix CPU to
the MVI56E-MCM. In the example the count is set to 600 registers.
I'll go down to the read start register and this specifies the starting register in the
MCM module where data will be transferred from the network to the module
and then sent on to the processor. In this case the read registers will
begin at 1,000. And the read register count defines the total number of
registers the MCM will write to the ControlLogix CPU.
Again the count is set here to 600 registers.
So with this configuration the database would look something like this.
And once we finished configuring the module's database, we can move on to
configuring the MCM's serial ports.
And we'll do this by going to the MCM.CONFIG. .port 1 and port 2 controller tags
I'll only be using port 1 for this training video so under the MCM.CONFIG
.port 1. I'll set enable to 1 this will enable serial port 1 on the MCM.
Next with type set to 0 the port will be a Modbus master. Entering a 1 here
would set the port as a slave. Next I'll set the baud rate to 19200, parity to
0, data bits to 8 and stop bits to 1. These settings must all match those of
the slave devices on the Modbus Network that you'll be connecting to and I can
now begin adding Modbus master commands.
Each port on the MVI56E-MCM has a master command controller tag for creating master commands.
For port 1 the tag is at MCM.CONFIG.Port 1MasterCmd. Here we can create up to 325
commands for the port. I'll create a few commands to illustrate how different
commands work with our database configuration and note that you'll need
to consult the user manual for your slave device in order to know what
addresses in that device you would want to read and write data to. I've done this
for my power monitor so I will begin by setting up a master command to read the
minimum and maximum phase A voltage.
Expand MCM.CONFIG.Port1MasterCmd
[0] and under enable, I'll type a 1 which sets the command to run continuously.
Next I'll enter an internal address of 1000, this is where the returned data
will be placed in the MCM database which is the starting address for the read
data portion of our internal database.
Each of the two numbers I'm going to read will be float values which, due to the limitations of
the Modbus protocol, require two 16-bit registers each. So I'll move down to
count and enter 4 as the number of registers I want to use.
I'll select node 1 as the device to give the command to
a function code of 3 means to read multiple holding registers
and a device address of 1024 means we'll start
reading registers from address 41,025 in our power monitor which is where the
values for phase A voltage that I'm trying to read are kept.
That does it for the command, now our floats will each be divided into two 16-bit words when
they are read into the database and we won't be able to view them properly
unless we go through an extra step to convert them back into a 32-bit
floating-point number and we'll go through that process now.
So looking at the controller tags we'll click on the Edit tab and what we need to do is create a
REAL data array that we can copy our two pairs of words into. This will allow them
to be displayed as floating-point numbers. Click on a blank row and enter a
name, I'll call this RealData; the name can be anything you like.
We'll set the data type to REAL and dimensions to 2 since I only have two float values that
I want to read. Click OK. Now that we have the array we need some ladder logic to
copy the words from our Read data to our new Real data array. We'll go back to
Main Routine and add a rung.
On the new rung we'll add a ladder element
in the window that pops up go down to file, miscellaneous and select Copy File.
click OK and the copy element will appear in the ladder. We'll click on the
source field and will drill down to the Read Data and select the tags that our
read command will place the data into.
This will be starting at read data 0.
The destination will, of course, be our REAL data array starting at RealData [0].
The length in this case will be 2 since
length always refers to the number of tags in the destination array so if we
were going to do this same process backwards and copy the two float values
to a 16-bit integer array the length would be 4 to accommodate that data.
We'll verify the routine. So we should be ready to download the configuration to
the processor now. I'll go up to communication select Who Active on the
screen I'll look in my Ethernet connections, locate the Ethernet module
in the ControlLogix rack, I'll open up the backplane and select the processor
and click Download. Then click download again on the download screen
and once the download is complete we're given the option to go online, we'll do that.
If everything's gone to plan we should have the minimum and maximum
voltage data in the MCM.DATA.ReadData.
And there it is and as you can see it's not anything recognizable as a voltage value.
To see that we'll need to look in our Real data array.
And there they are!
Now the Modbus protocol does not specify what order the words of double integers
or float values should be transmitted in; different industrial vendors order them
differently. If they're read in the wrong order the data in the MCM will not
appear properly. If this happens, all you have to do when you set up the command
is enter a 1 for Swap. This will swap the word order when you're dealing with
32-bit values. There's also a code for swapping bit order and words and bits.
Moving on I'll create a couple of write commands, one to set the phase A voltage
limit and one to reset the minimum and maximum voltage readings
that we looked at earlier.
I'll set the limit first: expand MCM.CONFIG.Port 1MasterCmd[1]
I'll type a 2 for enable which sets the command to execute conditionally
so that it will only write if the data changes or in this instance if we write a new value.
I'll enter an internal address of 0 which is where the register will be written from
in the MCM's database. This is also the starting address for the MCM's write data section.
I'll enter 1 as the number of registers I want to use and I'll select
node 1 as the device to give this command to.
I'll use function code 6 to write a single holding register.
Finally, a device address of 50 means I'll write
the registers to slave address 40,051 which is the register where the limit
for phase A voltage is stored in the power monitor. Next I'll expand MCM
CONFIG.Port1MasterCmd[2] This will be a command to write some
bits that will reset the minimum and maximum voltage readings.
Under enable, I'll type a 2 so the command runs conditionally I'll enter an internal
address of 160 for return data placement in the database. Now, for the MCM module,
anytime you're dealing with a coil or bit level Modbus function code the
internal address for that command must be to the bit level as well.
This is a write command, so we're going to the write section of our database.
The first command is using the first register in the write data so we need to start at
address two, but I'm going to write these bits from the 11th word which will be
write data 10. We multiply that by 16 to get the bit level address and that gives
us 160. For count will enter 2 as the number of registers we want to use.
So that's 2 bits which will encompass bit 160 and 161. Again we're addressing node 1,
a function code of 15 means to write multiple coils.
The device address will be 1208, this is the bit-level address in the
power monitor that we want to write to. Now you should know that there are
devices that will place the bit to enable and disable functions not in the
bit level address range but in the regular 16-bit holding registers, in the
40,001 address range. If you find you need to read or write bits in
that range, you won't use a bit level function code, you'd use a function code
to read or write to the register where the bits you want are situated.
So now that my commands are set up I'll warm boot the module. This will resend the
configuration with the new command to the processor and once the reboot is
complete we'll go back online. At this point we should be able to go to MCM.STATUS
and look at the pass counter. If it's counting that tells us that the
module is actively communicating with the processor.
Now we can write some data to the power monitor to set a limit and reset the
minimum and maximum values for phase A voltage.
So in our first command we wanted to set the limit
we'll drill down to MCM.DATA.WriteData[0]
which is where we specify we'd be writing from in the command. I'll enter a value of 225 to
set the limit in the monitor to 225 volts on phase A. Now if it goes over
this limit the monitor will send an alert. In the second command we wanted to
set some bits in the power monitor to reset the minimum and maximum values for phase A.
I specified the first bit would come from bit address 160 in the MCM's
write data array. This means that we'll go to work 10, this will be MCM.DATA.WriteData[10]
and we'll expand this out and set the first two bits here to 1
and these will be bits 160 and 161 in the bit level addressing. These will set the
bits in the power monitor to reset the minimum and maximum values and once
we've done this we'll probably have to go back and set these bits back to 0 so
that the program doesn't just keep resetting those values. And those are the
basics of how to set up a MVI56E-MCM modbus serial communication module.
As always if you have any questions or would like to see more training videos
visit our website at www.prosoft-technology.com
And again if you'd like to learn more about the
Modbus protocol and how to use it, you can check out our video on YouTube
Understanding Modbus.
That should do it for this training session. Until next time, happy training!