Schneider M241 Modbus communication with multiple slaves

HamzaSA

Member
Join Date
Aug 2017
Location
Sarajevo
Posts
34
Hello friends,

I need help regarding Modbus protocol when dealing with multiple slaves. Even though I am new to Modbus, I have read the documentation and I understand how it is supposed to work.

My question is how do I interpret the data I receive from slaves inside my PLC program?

Additional information:

I have written a PLC program for Schneider M241 PLC using SoMachine v4.1 and it has been working as intended from when it was commisioned.

Now, the customer has installed a couple of PM5100 multifunctional meters and wants to have live feed of measurements to SCADA. From what I understand, given the equipment I have, the only possible to do this is by linking the meters to my PLC via Modbus, then have the SCADA read the data from PLC memory.

I have configured the Serial Line 2 and Modbus as seen in the attached pictues.

Now, how do I actually read the data from slave? After some investigation I've found out that I should probably be using the Read_Var function block. (pic is attached.)

How do I configure the slave adresses individually?
Do I need a separate rung with a separate Read_Var for each slave?
Where in PLC memory do the read values end up so I can access them?

Hopefully I have managed to explain my problem sufficiently. Please do tell if I need to provide more additional information.

Best regards!

Tarik

Edit:

I have already downloaded the Modbus table of registers for PM5100 so I know which registers I should access regarding the measurements I want to be read.

Serial_Line_2.PNG Modbus_Manager.PNG Read_Var.jpg
 
Last edited:
You will need to configure your RS485 port as master

You will need a RED_VAR per slave, each one will define:

(ADDR) the slave address in a special format which the manual will tell you
(ObjType) the type of data you are reading
(FirstObj) The data source
(Quantitiy) The amount of registers you want from the slave
(Buffer) And the data destination in your PLC

There has been lots of discussions around RED_VAR over the years, have a search and see what you turn up.
 
Last edited:
Update

I've figured out that I need to set slave adresses on the slaves itself. I've set them to 126 and 127 (2 meters for now) and wired them in series.

I have managed to read the holding registers from 2 mutlifunctional meters using Modbus Poll, so the communication is all but completed.

All that is left is to store the values I get from the holding registres inside PLC memory. I will try to figure that out as well.
 
You will need to configure your RS485 port as master

You will need a RED_VAR per slave, each one will define:

(ADDR) the slave address in a special format which the manual will tell you
(ObjType) the type of data you are reading
(FirstObj) The data source
(Quantitiy) The amount of registers you want from the slave
(Buffer) And the data destination in your PLC

There has been lots of discussions around RED_VAR over the years, have a search and see what you turn up.

Please take a look at the attached picture. If I understand correctly, the address of the slave is in the format of NumberOfSerialLine.SlaveAddress so in my case it would be 2.126? I am not getting any feedback info from slave when I try accessing through SoMachine, but I get correct values when I connect throguh Modbus Poll so I guess it is an error in my PLC application.

read_var_example_2.PNG
 
Last edited:
Please take a look at the attached picture. If I understand correctly, the address of the slave is in the format of NumberOfSerialLine.SlaveAddress so in my case it would be 2.126? I am not getting any feedback info from slave when I try accessing through SoMachine, but I get correct values when I connect throguh Modbus Poll so I guess it is an error in my PLC application.

I am not 100% sure about the addressing on the M241 series using SoMachine, i use Unity and M340 and M580, and thats generally rack.channel etc, what does the manual say ?

I don't think you need to link the output of the ADDM block (done) to the execute of the Read_var as once the ADDM block has built the string once it should be there for the ADDR of the read_var

You will need to initiate a read on a certain trigger (every x seconds etc) and check that you get the done back from the read_var before you try and read again
 
I am not 100% sure about the addressing on the M241 series using SoMachine, i use Unity and M340 and M580, and thats generally rack.channel etc, what does the manual say ?

I don't think you need to link the output of the ADDM block (done) to the execute of the Read_var as once the ADDM block has built the string once it should be there for the ADDR of the read_var

You will need to initiate a read on a certain trigger (every x seconds etc) and check that you get the done back from the read_var before you try and read again

So basially my trigger for the Read_Var will be a timer combined with the status of "Done"?
 
So basially my trigger for the Read_Var will be a timer combined with the status of "Done"?

Lots of different ways to do it but that's one way, or you can use the done of one read to trigger the next etc. you need to handle the error bits too but hats up do you how you want to do that in your application, you may want to stop reading that particular slave and read the rest or hold and alarm
 
Do not wire in series - wire in parallel with a 120 ohm resistor across both wires at the end of the line as a terminator.
 
Do not wire in series - wire in parallel with a 120 ohm resistor across both wires at the end of the line as a terminator.

Yes, I misspoke, that's how I wired them. If I understand correctly, termination resistor is needed if the propagation delay is close to/equal or/ greater than one bit (pulse) width. I have about 100m of cable with a transmission rate of 9600 bps, so not needed in this case?

For now, I still have trouble with reading the registers with Read_Var from SoMachine. Anyone has any suggestions?

Tarik
 
Yes, I misspoke, that's how I wired them. If I understand correctly, termination resistor is needed if the propagation delay is close to/equal or/ greater than one bit (pulse) width. I have about 100m of cable with a transmission rate of 9600 bps, so not needed in this case?

For now, I still have trouble with reading the registers with Read_Var from SoMachine. Anyone has any suggestions?

Tarik

Its a bit difficult to say whats going on, did you change the serial ports to be a Master ?

Have a check here to see if you have everything configured correctly:

https://www.schneider-electric.com/en/faqs/FA301693/
 
Its a bit difficult to say whats going on, did you change the serial ports to be a Master ?

Have a check here to see if you have everything configured correctly:

https://www.schneider-electric.com/en/faqs/FA301693/

I think the problem is that I can't get my virtual device to recognize the serial to usb connection.

The software I used for checking the Slave registres (Modbus Poll) was on my host device, but my SoMachine is on the VM. There might be some drivers possibly missing as the OS on the VM is run of the mill Win7.
 
Last edited:
Are you running your PLC logic on an actual M221 hardware or just on the simulator? Your comment about a VM makes me think the latter.

If so, i don't believe that comms functions work in the simulator.

If you are actually using hardware, i vaguely remember there being an LED for the Serial port activity. Is that flashing when your READ_VAR instruction executes?
 
Are you running your PLC logic on an actual M221 hardware or just on the simulator? Your comment about a VM makes me think the latter.

If so, i don't believe that comms functions work in the simulator.

If you are actually using hardware, i vaguely remember there being an LED for the Serial port activity. Is that flashing when your READ_VAR instruction executes?

I'm currently in the office, and I have the meters with me hooked up to some regular 230V AC voltage, just so I can have a measurement; and the PLCs in question are at a facility a few hundred kilometers away, so the latter. I'm just trying to build a logic inside PLC that I can simply download at the site on to the PLC and not program on the site itself.

However, the problem isn't the simulator per se, but the actual VM. I can't read the registres when I run the Modbus Poll program from INSIDE the VM, but I can read everything perfectly fine when I run the Modbus Poll program from the host.

When I open the Device manager in VM (after connecting my serial-usb adapter) I can see the USB-SERIAL-CH340(COM4) but when I try connecting through Modbus Poll on this port, it says "Port 4 not available".

Also, after plugging the device in while in VM, it says the drivers haven't been installed successfully, but they install just fine on the host machine.

This is so frustrating..

EDIT: Added a pic when I run Modbus Poll program from host machine, where it works perfectly fine. In VM, when I run the same program, it cannot even connect to the port where it SAYS the device is connected at.

modbus_poll.PNG
 
Last edited:
So you have SoMachine on a VM in your office, the PLC is at a remote site and the meters are on your desk using a USB to RS485 adapter connected to the VM ? It might have been worth mentioning that in your original post !

I would suggest getting another PLC on the desk and proving all this first locally before you do anything else, there is just too much going on to put a finger on what the issue is, it could be a whole heap of things !
 
So you have SoMachine on a VM in your office, the PLC is at a remote site and the meters are on your desk using a USB to RS485 adapter connected to the VM ? It might have been worth mentioning that in your original post !

I would suggest getting another PLC on the desk and proving all this first locally before you do anything else, there is just too much going on to put a finger on what the issue is, it could be a whole heap of things !

Yeah, first, I apologize for not mentioning this at the beginning.

My meters are connected through RS485-RS232-USB adapter to the PC.

I have a program for checking Modbus data called Modbus Poll and when I run it on the host, it works fine.

SoMachine is installed on a VM. Forget the SoMachine for now. I have installed the said ModbusPoll on the VM. When I try the exact same process of reading data through Modbus on my VM (as I did on the host), it simply is not working.

This leads me to believe that the problem is in the VM itself.

I am installing SoMachine now on the host itself, and I will try to run the logic then. Meanwhile, if anyone has any suggestions on how to make this serial-usb work on the VM, please let me know.
 

Similar Topics

Hello, As part of our project, we are using an M241 controller. This controller interfaces with an industrial computer and a router via a switch...
Replies
2
Views
99
Hello, Recently I was asked to analyze the logic of the air conditioning system in one of our departments. The PLC that controls this system is...
Replies
2
Views
149
I have a machine that has M241 PLC. I need to add a couple of outputs to the program, and I don't have the original code. Am I screwed or can I...
Replies
1
Views
470
Hello everyone! I have a Schneider M241 as master of a CAN network with several encoders and whatnot, everything is working fairly well. Now...
Replies
3
Views
1,710
I'm thinking of selecting the Schneider M241 PLC for a product line. Has anyone worked with this PLC before? Please share your likes/dislikes...
Replies
5
Views
3,612
Back
Top Bottom