# Could not Read data from 2 slave Modbus RTU

**URL:** <https://www.wago.community/t/could-not-read-data-from-2-slave-modbus-rtu/723>\
**Category:** CODESYS\
**Tags:** how-to, edge-controller, codesys\
**Created:** [December 28, 2023, 3:24am UTC](https://www.wago.community/t/could-not-read-data-from-2-slave-modbus-rtu/723 "2023-12-28T03:24:00Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![umairyamin](https://avatars.discourse-cdn.com/v4/letter/u/dec6dc/32.png) [@umairyamin](https://www.wago.community/u/umairyamin)\
**Post date:** [December 28, 2023, 3:24am UTC](https://www.wago.community/t/could-not-read-data-from-2-slave-modbus-rtu/723/1 "2023-12-28T03:24:00Z")

</div>

Hi there,

I have a situation here. I am using PLC Edge Controller and I want to read data from my slaves Autonics ARIO-C-MR through Modbus RTU. I have managed to read the data when I write a code just to read just 1 slave. But when I try to read 2 slaves at one time, the first slave seems to be no problem but there seems error for the second slave **“The addressed SI/TTY does not exist or is already attached”** as shown in the picture I’ve attached below.

 ![Error](https://us1.discourse-cdn.com/flex016/uploads/wago/original/1X/f4395df22a4b8022ba7cc88ac0ffe2143f3bed23.png)

Hope somebody could give me suggestion on how to solve this problem. Thank you!

Best regards,  
Umair Yamin

---

<div class="post-metadata">

**Author:** ![anssikone.fi](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@anssikone.fi](https://www.wago.community/u/anssikone.fi)\
**Post date:** [December 30, 2023, 8:06am UTC](https://www.wago.community/t/could-not-read-data-from-2-slave-modbus-rtu/723/2 "2023-12-30T08:06:08Z")

</div>

Hi Umair,  
I think that you have to handle modbus transaction status.  
Do not send anything to second slave until the first one is completed or time out.  
By the way…why don’t use Modbus master functionalities on device tree?

BR  
Anssi

---

<div class="post-metadata">

**Author:** ![umairyamin](https://avatars.discourse-cdn.com/v4/letter/u/dec6dc/32.png) [@umairyamin](https://www.wago.community/u/umairyamin)\
**Post date:** [January 2, 2024, 7:00am UTC](https://www.wago.community/t/could-not-read-data-from-2-slave-modbus-rtu/723/3 "2024-01-02T07:00:07Z")

</div>

hi Anssi,

thank you for your suggestion. How do I not send anything to second slave until the first one is completed ? got any example? Would really appreciate your help.

Modbus master functionalities on device tree is using Modbus\_COM is it? I tried using that but it cant even read 1 slave. But im still troubleshooting it.

BR,  
Umair

---

<div class="post-metadata">

**Author:** ![bjornidar](https://avatars.discourse-cdn.com/v4/letter/b/5fc32e/32.png) [@bjornidar](https://www.wago.community/u/bjornidar)\
**Post date:** [January 2, 2024, 12:20pm UTC](https://www.wago.community/t/could-not-read-data-from-2-slave-modbus-rtu/723/4 "2024-01-02T12:20:58Z")

</div>

> [@umairyamin](#):
>
> ged to read the data when

You need to utilize the “xTrigger” and “xError”. When xTrigger is reset by the MbMaster and xError is false, the query to the first slave is successfull, then you can move on to the next slave.

---

<div class="post-metadata">

**Author:** ![anssikone.fi](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@anssikone.fi](https://www.wago.community/u/anssikone.fi)\
**Post date:** [January 2, 2024, 7:07pm UTC](https://www.wago.community/t/could-not-read-data-from-2-slave-modbus-rtu/723/5 "2024-01-02T19:07:24Z")

</div>

Hi Umair,  
I’ve got a problem when replying your message.  
I can send some tips directly if needed.  
I’ve used serial modbus master a lot in Wago.

BR  
Anssi

umairyamin via WAGO Open Source Community kirjoitti 2024-01-02 09:10:

---

<div class="post-metadata">

**Author:** ![umairyamin](https://avatars.discourse-cdn.com/v4/letter/u/dec6dc/32.png) [@umairyamin](https://www.wago.community/u/umairyamin)\
**Post date:** [January 3, 2024, 2:31am UTC](https://www.wago.community/t/could-not-read-data-from-2-slave-modbus-rtu/723/6 "2024-01-03T02:31:42Z")

</div>

Hi Anssi,

Yes. I would love to get your tips. It would be helpful.

BR  
Umair

---

<div class="post-metadata">

**Author:** ![umairyamin](https://avatars.discourse-cdn.com/v4/letter/u/dec6dc/32.png) [@umairyamin](https://www.wago.community/u/umairyamin)\
**Post date:** [January 3, 2024, 2:34am UTC](https://www.wago.community/t/could-not-read-data-from-2-slave-modbus-rtu/723/7 "2024-01-03T02:34:11Z")

</div>

Hi bjorn,

how do I “utilize” the xTrigger and xError? I am so sorry, I am really a beginner to this thing.

![image](https://us1.discourse-cdn.com/flex016/uploads/wago/original/1X/8f3957377b1a0e14b86b613e1905bfdfdb874a32.png)

Am I not utilizing it right now according to the code?

---

<div class="post-metadata">

**Author:** ![bjornidar](https://avatars.discourse-cdn.com/v4/letter/b/5fc32e/32.png) [@bjornidar](https://www.wago.community/u/bjornidar)\
**Post date:** [January 3, 2024, 9:21am UTC](https://www.wago.community/t/could-not-read-data-from-2-slave-modbus-rtu/723/8 "2024-01-03T09:21:28Z")

</div>

As you can only initialize the Modbus Master block/ RS-485 port once, you need a sequence to switch between the two slaves.

1. SET xTrigger
2. Wait for xTrigger to be FALSE  
2.1 No Error
3. Change slave
4. SET xTrigger  
…

---

<div class="post-metadata">

**Author:** ![WagoKurt](https://sea2.discourse-cdn.com/flex016/user_avatar/www.wago.community/wagokurt/32/11_2.png) [@WagoKurt](https://www.wago.community/u/WagoKurt)\
**Post date:** [January 4, 2024, 11:58pm UTC](https://www.wago.community/t/could-not-read-data-from-2-slave-modbus-rtu/723/9 "2024-01-04T23:58:11Z")

</div>

You might want to try the built-in Modbus master, here is an example.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/wago/original/1X/f9223d996d9b869d052d8673550c7b5ae3ec229c.png)

---

<div class="post-metadata">

**Author:** ![anssikone.fi](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@anssikone.fi](https://www.wago.community/u/anssikone.fi)\
**Post date:** [January 5, 2024, 4:34pm UTC](https://www.wago.community/t/could-not-read-data-from-2-slave-modbus-rtu/723/10 "2024-01-05T16:34:54Z")

</div>

Hi,  
as posted by Kurt and Bjorn, timing is very important when playing with RS485 serial port.  
You can find xtrigger when defining Codesys modbus master “channels”.  
xtrigger is extremely usefull because typically Modbus write register transactions are event triggered (sometimes once per month) and read register transactions are more or less cyclic.  
By the way. Did you find modbus serial master in project tree?  
It is strongly recommended to use it.  
[https://help.codesys.com/webapp/\_mod\_f\_master;product=core\_modbus\_configuration\_editor;version=3.5.16.0](https://help.codesys.com/webapp/_mod_f_master;product=core_modbus_configuration_editor;version=3.5.16.0)

---

<div class="post-metadata">

**Author:** ![umairyamin](https://avatars.discourse-cdn.com/v4/letter/u/dec6dc/32.png) [@umairyamin](https://www.wago.community/u/umairyamin)\
**Post date:** [January 8, 2024, 1:44am UTC](https://www.wago.community/t/could-not-read-data-from-2-slave-modbus-rtu/723/11 "2024-01-08T01:44:23Z")

</div>

I tried this way. But when I used this way, I cannot even read data from 1 slave. I am also not sure why.  
I already put the communication parameter that I used when I successfully read 1 slave using function block such as baud rate, parity, read register, etc.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/wago/original/1X/4ec434f8aedc06dce5635e2f1a176f534d277236.png)

---

<div class="post-metadata">

**Author:** ![umairyamin](https://avatars.discourse-cdn.com/v4/letter/u/dec6dc/32.png) [@umairyamin](https://www.wago.community/u/umairyamin)\
**Post date:** [January 8, 2024, 1:44am UTC](https://www.wago.community/t/could-not-read-data-from-2-slave-modbus-rtu/723/12 "2024-01-08T01:44:45Z")

</div>

Hi,  
I tried this way. But when I used this way, I cannot even read data from 1 slave. I am also not sure why.  
I already put the communication parameter that I used when I successfully read 1 slave using function block such as baud rate, parity, read register, etc.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/wago/original/1X/4ec434f8aedc06dce5635e2f1a176f534d277236.png)

---

<div class="post-metadata">

**Author:** ![anssikone.fi](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@anssikone.fi](https://www.wago.community/u/anssikone.fi)\
**Post date:** [January 8, 2024, 6:42pm UTC](https://www.wago.community/t/could-not-read-data-from-2-slave-modbus-rtu/723/13 "2024-01-08T18:42:46Z")

</div>

Hmm… The bus is not running. Why ?  
Try to connect your Modbus IW1 to an other word type variable in PLC\_PRG.

wVariable1 := %IW1 ;  
wVariable2 := %IW2 ;  
wVariable3 := %IW3 ;

---

<div class="post-metadata">

**Author:** ![umairyamin](https://avatars.discourse-cdn.com/v4/letter/u/dec6dc/32.png) [@umairyamin](https://www.wago.community/u/umairyamin)\
**Post date:** [January 9, 2024, 4:42am UTC](https://www.wago.community/t/could-not-read-data-from-2-slave-modbus-rtu/723/14 "2024-01-09T04:42:59Z")

</div>

Do you mean change these type variable ? The one that I circled.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/wago/original/1X/cfce9074e902357f020bcad006dd20cea16be787.png)

And btw, what is wVariable1 ? Is it your variable name for %IW1?

---

<div class="post-metadata">

**Author:** ![anssikone.fi](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@anssikone.fi](https://www.wago.community/u/anssikone.fi)\
**Post date:** [January 9, 2024, 8:09am UTC](https://www.wago.community/t/could-not-read-data-from-2-slave-modbus-rtu/723/15 "2024-01-09T08:09:08Z")

</div>

> [@anssikone.fi](#):
>
> wVariable1 := %IW1 ;  
> wVariable2 := %IW2 ;  
> wVariable3 := %IW3 ;

Negative,  
definition in PLC\_PRG

VAR  
wVariable1 : WORD ; // Only for testing Modbus register update  
wVariable2 : WORD ;  
wVariable3 : WORD ;  
END\_VAR

Unused variables are not updated.

---

<div class="post-metadata">

**Author:** ![umairyamin](https://avatars.discourse-cdn.com/v4/letter/u/dec6dc/32.png) [@umairyamin](https://www.wago.community/u/umairyamin)\
**Post date:** [January 10, 2024, 1:09am UTC](https://www.wago.community/t/could-not-read-data-from-2-slave-modbus-rtu/723/16 "2024-01-10T01:09:39Z")

</div>

I actually applied the same thing using Modbus TCP and it successfully worked. But for Modbus RTU, it doesnt work. I am not sure why.

I have checked the paramater communication settings, I have followed the one that I used in function block where I can read the data. But in the end, Modbus RTU using configurator doesnt show any result even for 1 slave.

If I want to say theres a wiring problem, there should not be since I can get data when I read 1 slave using function block.

---

<div class="post-metadata">

**Author:** ![anssikone.fi](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@anssikone.fi](https://www.wago.community/u/anssikone.fi)\
**Post date:** [January 10, 2024, 7:36pm UTC](https://www.wago.community/t/could-not-read-data-from-2-slave-modbus-rtu/723/17 "2024-01-10T19:36:19Z")

</div>

I’m agree that TCP case.  
What is your communication parameter setup exactly ?  
9600,N,8,1 two wire half duplex ??  
Be sure that RS485 A and B are okay.

Second slave looks strange…

---

<div class="post-metadata">

**Author:** ![WagoKurt](https://sea2.discourse-cdn.com/flex016/user_avatar/www.wago.community/wagokurt/32/11_2.png) [@WagoKurt](https://www.wago.community/u/WagoKurt)\
**Post date:** [January 11, 2024, 4:22pm UTC](https://www.wago.community/t/could-not-read-data-from-2-slave-modbus-rtu/723/18 "2024-01-11T16:22:17Z")

</div>

Hello,  
Can you post your Modbus mapping configuration? I am wondering what the Function Code is, and whether the device supports it. Also, FC 23 is not possible with half duplex RS485.

---

<div class="post-metadata">

**Author:** ![umairyamin](https://avatars.discourse-cdn.com/v4/letter/u/dec6dc/32.png) [@umairyamin](https://www.wago.community/u/umairyamin)\
**Post date:** [January 12, 2024, 3:05am UTC](https://www.wago.community/t/could-not-read-data-from-2-slave-modbus-rtu/723/19 "2024-01-12T03:05:06Z")

</div>

Hello,  
this is my Modbus mapping configuration where i cant even read 1 slave.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/wago/original/1X/a578a56b5c6cb0d685bc9cb538d3790fa427211f.png)

This is my modbus using function block, where i can read slave 1 perfectly.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/wago/original/1X/123c6d864b3401a3d0d8892c3a20aa60a8c50acc.png)

---

<div class="post-metadata">

**Author:** ![umairyamin](https://avatars.discourse-cdn.com/v4/letter/u/dec6dc/32.png) [@umairyamin](https://www.wago.community/u/umairyamin)\
**Post date:** [January 12, 2024, 3:11am UTC](https://www.wago.community/t/could-not-read-data-from-2-slave-modbus-rtu/723/20 "2024-01-12T03:11:50Z")

</div>

This is my communication parameter setup when im using function block, where i can get data from slave 1 successfully.  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/wago/original/1X/608374d6cd797ebe1230f27330c2bca7e80b1001.png)

This my communication parameter setup when im using Modbus tree, where i couldnt even read data from 1 slave.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/wago/original/1X/a3232e6f9419c4746e4afc3406726056e32e1e21.png)

This is the error that appeared when I run the modbus tree, and the data isnt showing.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/wago/original/1X/0dd9dcc7dca194e08a04a3825b7a94b5c2af8074.png)

I wonder why its happening.

[Next page](https://www.wago.community/t/could-not-read-data-from-2-slave-modbus-rtu/723.md?page=2)
