SLC 5/05 Modbus Master

CQ21

Member
Join Date
Apr 2021
Location
Columbia
Posts
61
A quick question:

How many slaves can be supported by SLC 5/05 modbus master configuration? I am using CH0 RS-232 port.
 
The SLC-5/05 uses MSG instructions instead of a "scanlist" or polling mechanism, so the amount of memory you have available for the 51-Word message control data blocks would probably be the limiting factor. One 255-word Integer data file can only hold five control blocks.

To my knowledge, the SLC-5/05's Modbus RTU master implementation supports the ordinary slave ID addresses of 1-127.
 
Thanks for clarification Ken!

In that case does anyone know how I can use the MSG instruction to read the holding registers of multiple modbus slaves? Maybe some sample code?

I've tried myself but I can't get it to work the thing just times out. I'm pretty sure I'm just doing something wrong with my code but I've attached a reference of my network configuration just in case.

Also I'm trying to read 32 consecutive registers from each slave, for example, NX:0 to NX:31

Thanks in advance!

Capture2.PNG
 
The SLC 5/05 serial port Channel 0 is RS232 which only supports point to point connections. So you need to insert some sort of converter in your drawing to convert the RS232 electrical signals to RS422 or RS485.

I have had good results with products from this site:

https://www.commfront.com/collections/rs232-rs485-rs422-ttl-serial-converters

As for your code, show us what you have.
 
Last edited:
That diagram would be appropriate for a "2 wire RS-485" system if the terminals were labeled "Data A" and "Data B" instead of "Tx" and "Rx".

For an RS-232 system, you would want Tx on the PLC connected to Rx on the slave device.

And as noted, RS-232 is really just a point-to-point system. Three devices connected together like that would probably not work (though some RS-232 transceivers would tolerate it).

Start with just one device, connected "null modem' with Tx -> Rx and Rx -> Tx and Gnd -> Gnd.

If you're going to test with a PC instead of the MicroLogix, there are a zillion Modbus RTU Master utilities. I like Chipkin Automation Systems because of their clear protocol decode features, and the useful "Discover" feature that checks a range of slave IDs and function codes.

In general, a PC's serial port and the SLC-5/0x serial port are both "DTE" devices with male pins, so they can be plugged in as substitutes with no wiring changes.
 
Apologies, I forgot to mention I am using a converter and the previous image should indicate an RS-485 network, my bad.

I have three examples:

The first is code that I got working with just one slave device.

The second is code that I altered to add the second slave device (I am not very experienced with msg so I just set the first MSG DN bit to trigger the second MSG)

The last is the MSG block configuration of the second slave and the first slave is configured in a similar fashion.

The two slaves have modbus addresses 1 and 2 just to make things simpler

Working Code.PNG Altered Code.PNG MSG Block.PNG
 
That points out a mistake on my part: the MSG control blocks for a serial port are smaller (14 Words) than for an Ethernet port (51 Words). But those aren't the issue here.

Do you get an error or timeout when you trigger these messages ? The first one, at least, seems to complete with a /DN bit.
 
Yes, the first picture when I set up the code for one slave works fine.

But when I add the second slave that's when things stop working. I can't read from either slave...

Here's the error that I get for both MSG blocks.

Error message 1.PNG Error message 2.PNG
 
Are these two slaves identical hardware?

Can you show the MSG config details for the one that is working?

What is the nature of the data you are requesting? I ask because if it is 32 bit integers or floats, the slave might complain if you were to, for example, make a request starting with the 2nd word that is part of one of those data types. Your MB Data Address being 2 made me think about that possibility.

The error code would reveal that sort of complaint from the slave. The error code will disappear when the MSG is retriggered.

As for your logic structure, I normally recommend sequencing that waits for a DN or ER bit from each MSG before moving to the next. For a hardwired network, you can probably set the timeout word for each message to 1 second. That will improve performance if/when one of the slaves is non-responsive.

EDIT: That error you just posted (timeout in local processor) is the most common that you would see for anything all the way from improper wiring to a slave that is turned off or just ignoring the message.

Your MB data address is different in the two MSG blocks. That is the starting address of the block of data, so if these two slaves are the same type of hardware, they should both have the same MB data address if you are requesting symmetrical blocks of data from both slaves.

Also, many Modbus devices (most all VFDs) require a power cycle following any changes to the serial port settings, so the Slave ID number or baud rate might not take effect until you fully power down the device and power it back up.
 
Last edited:
Yes! Success!

I cycled power and my MSG is working! Thanks guys!

But thanks OkiePC for catching my error! I indeed had different starting MD addresses.

Although it is working fine, I would like to ask if anyone could provide some tips on how to cascade msg instructions just in case I were to add more MB slaves or write more complex code. Some screenshots would be a big help.

This is what I have so far...

Ladder code.PNG
 
I have a system I use for controlling message sequences and an example for use with Radioline modems. This example could be trimmed down further to fit your needs.
 

Similar Topics

Hi! Please share the MODBUS protocol code for the subject Regards
Replies
10
Views
2,422
Hey guys! I've been dabbling with getting a RS-485 device that uses modbus protocol into my SLC 5/05. I've steered towards buying a Modbus...
Replies
2
Views
1,290
Hello all! I am currently trying to read some temp values from a M2B+ controller (link...
Replies
38
Views
13,214
Hi, I'm trying to work out if I can use Channel 0 of my SLC CPUs (configured as Modbus Master) to talk to other manufacturers PLCs. I'm using...
Replies
1
Views
1,502
Hi, I'm hoping to use an SLC 5/05 PLC to communicate as Modbus RTU Master to a number of Modbus TCP slaves. I understand that a gateway is...
Replies
3
Views
4,276
Back
Top Bottom