# Best practice for MC-Protocol Read

**URL:** <https://discourse.nodered.org/t/best-practice-for-mc-protocol-read/61132>\
**Category:** Industrial\
**Created:** [11 April 2022 15:28 UTC](https://discourse.nodered.org/t/best-practice-for-mc-protocol-read/61132 "2022-04-11T15:28:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjmiller](https://avatars.discourse-cdn.com/v4/letter/r/13edae/32.png) [@rjmiller](https://discourse.nodered.org/u/rjmiller)\
**Post date:** [11 April 2022 15:28 UTC](https://discourse.nodered.org/t/best-practice-for-mc-protocol-read/61132/1 "2022-04-11T15:28:15Z")

</div>

Hi all,

I'm successfully connected to a Mitsubishi PLC and I'm able to read addresses using MC-Read. I want to read several addresses that are not contiguous, so I haven't used the ,CNT syntax in the address string.

Is there a way to feed the MC READ node with a list of addresses as an array ? Or am I ok to just create 10 different MC READ nodes, one for each address I want to read ? Should I use the same inject node to trigger them all at the same time ?

Thanks for your help !

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [11 April 2022 15:48 UTC](https://discourse.nodered.org/t/best-practice-for-mc-protocol-read/61132/2 "2022-04-11T15:48:07Z")

</div>

Do you have access to the PLC? Modifying the ladder to put all values you want into a contiguous area has 2 advantages...

1. It provides a cross-referenceable addresses for maintenance personnel.
2. Reading 10 items is 10x faster than 10 single reads.

Could you list out the addresses so I can see what areas and addresses you require?

---

<div class="post-metadata">

**Author:** ![rjmiller](https://avatars.discourse-cdn.com/v4/letter/r/13edae/32.png) [@rjmiller](https://discourse.nodered.org/u/rjmiller)\
**Post date:** [11 April 2022 16:00 UTC](https://discourse.nodered.org/t/best-practice-for-mc-protocol-read/61132/3 "2022-04-11T16:00:59Z")

</div>

Hi ! Thanks for the fast response !

We have access to the PLC, but would prefer to avoid any config changes as it is still supported by the equipment manufacturer. Perhaps we should try to group as many contiguous sets as possible in to a few MC READ nodes ? Here is a list of the addresses we want to read:

D100  
D102  
D104  
D106  
D108  
D110  
D112  
D121  
D124  
D128  
D130  
D134  
D136  
D145  
D149  
D2017  
D2080  
D270  
D271  
D280  
D281  
D282  
D283  
D288  
D290  
D30  
D31  
D32  
D74  
D8010  
D8012  
D8270  
D84  
D90  
D92  
M100  
M101  
M102  
M103  
M104  
M107  
M108  
M109  
M111  
M112  
M200  
M24  
M25  
M40  
M42  
M45  
M46  
M47  
M54  
M75  
X0  
X1  
Y20  
Y21  
Y22

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 April 2022 09:37 UTC](https://discourse.nodered.org/t/best-practice-for-mc-protocol-read/61132/4 "2022-04-12T09:37:44Z")

</div>

I would definitely group together as few reads as possible.

### THOUGHTS...

To read these addresses, I would break them up into 6 reads  
You can probably do all 6 reads at the same time but personally, I would do them at least 30ms or so apart to avoid issues.

While reading 520 bytes of data may seem excessive (when you only want 30 values), 1 round trip to the PLC for 520 bytes is FAR FASTER than 30 round trips to the PLC. Also, as the MITSI Q Series COMM processing is part of the PLC scan, it is also kinder on the PLC SCAN time.  
An additional benefit of reading all items in one go is that the data values are consistent

- i.e. D30 is read on the same PLC SCAN asn D31 and D32 etc
- This becomes important when data values are relative to each other & need to be consistent for logging or further calculations with each other.

### Grouping & offsets (to help with byte offsets in buffer-parser

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/7/07167194bc96b8773276cdd70d465dfa73abe898.png)

Demo...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/1/5160f977f01b6f4a3433893205ea83fdb13e3a4a.png)

Demo Flow (import using `CTRL-I` - requires `node-red-contrib-buffer-parser`)

```auto
[{"id":"45b5edc7195ba7c6","type":"MC Read","z":"a58fa62c.7c1eb8","name":"read D30,261","topic":"","connection":"8a67d1bd.c84ff","address":"D30,261","addressType":"str","outputFormat":0,"errorHandling":"throw","outputs":1,"x":464,"y":400,"wires":[["eea5d9718d76fbf0","900d7a64c0340d04","e712c5494e085c86"]]},{"id":"2e78ddf6fcd4de73","type":"inject","z":"a58fa62c.7c1eb8","name":"","props":[{"p":"payload.highnumber","v":"17169973925117969n","vt":"num"},{"p":"payload.highnumber-string","v":"17169973925117969","vt":"str"},{"p":"payload.lowernumber","v":"7169973925117969","vt":"num"},{"p":"payload.lowernumber-string","v":"7169973925117969","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":194,"y":400,"wires":[["45b5edc7195ba7c6","9f9b7266bc527743"]]},{"id":"79f29458d7d50d31","type":"debug","z":"a58fa62c.7c1eb8","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":898,"y":400,"wires":[]},{"id":"eea5d9718d76fbf0","type":"change","z":"a58fa62c.7c1eb8","name":"put D32 in payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.D32","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":706,"y":400,"wires":[["79f29458d7d50d31"]]},{"id":"900d7a64c0340d04","type":"change","z":"a58fa62c.7c1eb8","name":"put D74 in payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.D74","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":706,"y":448,"wires":[["25bda533abfa53cb"]]},{"id":"25bda533abfa53cb","type":"debug","z":"a58fa62c.7c1eb8","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":898,"y":448,"wires":[]},{"id":"e712c5494e085c86","type":"change","z":"a58fa62c.7c1eb8","name":"put D290 in payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.D290","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":716,"y":496,"wires":[["2f4037705390a459"]]},{"id":"2f4037705390a459","type":"debug","z":"a58fa62c.7c1eb8","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":898,"y":496,"wires":[]},{"id":"822a32821fa8cc7c","type":"MC Read","z":"a58fa62c.7c1eb8","name":"Read D2017,64","topic":"","connection":"8a67d1bd.c84ff","address":"D2017,64","addressType":"str","outputFormat":0,"errorHandling":"throw","outputs":1,"x":464,"y":576,"wires":[["3c50f581b6199752","9bc3a00a1ba0a0af"]]},{"id":"4f236a87a867b8da","type":"debug","z":"a58fa62c.7c1eb8","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":890,"y":576,"wires":[]},{"id":"3c50f581b6199752","type":"change","z":"a58fa62c.7c1eb8","name":"put D2017 in payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.D2017","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":708,"y":576,"wires":[["4f236a87a867b8da"]]},{"id":"9bc3a00a1ba0a0af","type":"change","z":"a58fa62c.7c1eb8","name":"put D2080 in payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.D2080","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":708,"y":624,"wires":[["85eeda2955fe857b"]]},{"id":"85eeda2955fe857b","type":"debug","z":"a58fa62c.7c1eb8","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":890,"y":624,"wires":[]},{"id":"9f9b7266bc527743","type":"delay","z":"a58fa62c.7c1eb8","name":"","pauseType":"delay","timeout":"30","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":262,"y":480,"wires":[["822a32821fa8cc7c"]]},{"id":"7ad5d79b5616b73e","type":"inject","z":"a58fa62c.7c1eb8","name":"","props":[{"p":"payload.highnumber","v":"17169973925117969n","vt":"num"},{"p":"payload.highnumber-string","v":"17169973925117969","vt":"str"},{"p":"payload.lowernumber","v":"7169973925117969","vt":"num"},{"p":"payload.lowernumber-string","v":"7169973925117969","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":190,"y":752,"wires":[["a348d9f3de5817bc","839ed009385deb76"]]},{"id":"a348d9f3de5817bc","type":"MC Read","z":"a58fa62c.7c1eb8","name":"read D30,261","topic":"","connection":"8a67d1bd.c84ff","address":"D30,261","addressType":"str","outputFormat":"1","errorHandling":"throw","outputs":1,"x":460,"y":752,"wires":[["bce96a67d38ebfd7"]]},{"id":"839ed009385deb76","type":"delay","z":"a58fa62c.7c1eb8","name":"","pauseType":"delay","timeout":"30","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":258,"y":832,"wires":[["a0513facf795638f"]]},{"id":"a0513facf795638f","type":"MC Read","z":"a58fa62c.7c1eb8","name":"Read D2017,64","topic":"","connection":"8a67d1bd.c84ff","address":"D2017,64","addressType":"str","outputFormat":"1","errorHandling":"throw","outputs":1,"x":460,"y":928,"wires":[["e3c72ca8ef3f9784"]]},{"id":"d494e85bcdf0c818","type":"debug","z":"a58fa62c.7c1eb8","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":894,"y":752,"wires":[]},{"id":"ddbfed8187f4fa3c","type":"debug","z":"a58fa62c.7c1eb8","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":894,"y":800,"wires":[]},{"id":"eb5324051bad9273","type":"debug","z":"a58fa62c.7c1eb8","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":886,"y":928,"wires":[]},{"id":"629eec6f949bfe21","type":"debug","z":"a58fa62c.7c1eb8","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":886,"y":976,"wires":[]},{"id":"88b8b57fd4fc3882","type":"debug","z":"a58fa62c.7c1eb8","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":894,"y":848,"wires":[]},{"id":"bce96a67d38ebfd7","type":"buffer-parser","z":"a58fa62c.7c1eb8","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"D32","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"D74","offset":88,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"D290","offset":520,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"value","resultTypeType":"return","multipleResult":true,"fanOutMultipleResult":true,"setTopic":true,"outputs":3,"x":660,"y":752,"wires":[["d494e85bcdf0c818"],["ddbfed8187f4fa3c"],["88b8b57fd4fc3882"]]},{"id":"e3c72ca8ef3f9784","type":"buffer-parser","z":"a58fa62c.7c1eb8","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"D2017","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"D2080","offset":126,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"value","resultTypeType":"return","multipleResult":true,"fanOutMultipleResult":true,"setTopic":true,"outputs":2,"x":662,"y":928,"wires":[["eb5324051bad9273"],["629eec6f949bfe21"]]},{"id":"05d3a61b9e87404a","type":"inject","z":"a58fa62c.7c1eb8","name":"","props":[{"p":"payload.highnumber","v":"17169973925117969n","vt":"num"},{"p":"payload.highnumber-string","v":"17169973925117969","vt":"str"},{"p":"payload.lowernumber","v":"7169973925117969","vt":"num"},{"p":"payload.lowernumber-string","v":"7169973925117969","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":178,"y":1040,"wires":[["f6ae0bcbeb7a496e","fa8a36ce5b1c7af6"]]},{"id":"f6ae0bcbeb7a496e","type":"MC Read","z":"a58fa62c.7c1eb8","name":"read D30,261","topic":"","connection":"8a67d1bd.c84ff","address":"D30,261","addressType":"str","outputFormat":"1","errorHandling":"throw","outputs":1,"x":448,"y":1040,"wires":[["f59da30dc638860e"]]},{"id":"fa8a36ce5b1c7af6","type":"delay","z":"a58fa62c.7c1eb8","name":"","pauseType":"delay","timeout":"30","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":246,"y":1104,"wires":[["db05581fe4db7f21"]]},{"id":"f59da30dc638860e","type":"buffer-parser","z":"a58fa62c.7c1eb8","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"plc/mit1/D32","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"plc/mit1/D74","offset":88,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"plc/mit1/D290","offset":520,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"value","resultTypeType":"return","multipleResult":true,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":648,"y":1040,"wires":[["8c79c4c28d18cca6"]]},{"id":"db05581fe4db7f21","type":"MC Read","z":"a58fa62c.7c1eb8","name":"Read D2017,64","topic":"","connection":"8a67d1bd.c84ff","address":"D2017,64","addressType":"str","outputFormat":"1","errorHandling":"throw","outputs":1,"x":448,"y":1104,"wires":[["80407c937e365737"]]},{"id":"80407c937e365737","type":"buffer-parser","z":"a58fa62c.7c1eb8","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"plc/mit1/D2017","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"plc/mit1/D2080","offset":126,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"value","resultTypeType":"return","multipleResult":true,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":650,"y":1104,"wires":[["8494a08eea4cde66"]]},{"id":"8494a08eea4cde66","type":"debug","z":"a58fa62c.7c1eb8","name":"to MQTT →","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"topic & \": \" & payload","statusType":"jsonata","x":854,"y":1104,"wires":[]},{"id":"8c79c4c28d18cca6","type":"debug","z":"a58fa62c.7c1eb8","name":"to MQTT →","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"topic & \": \" & payload","statusType":"jsonata","x":854,"y":1040,"wires":[]},{"id":"8a67d1bd.c84ff","type":"MC Protocol Connection","name":"","host":"localhost","port":"5003","protocol":"UDP","frame":"4E","plcType":"Q","ascii":false,"PLCStation":"","PCStation":"","PLCModuleNo":"","network":"","octalInputOutput":false,"timeout":"3000"}]

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 April 2022 09:51 UTC](https://discourse.nodered.org/t/best-practice-for-mc-protocol-read/61132/5 "2022-04-12T09:51:16Z")

</div>

> [@Steve-Mcl](#):
>
> While reading 520 bytes of data may seem excessive (when you only want 30 values), 1 round trip to the PLC for 520 bytes is FAR FASTER than 30 round trips to the PLC

Some proof...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/7/47473b973abc4709f8b886124bb5dca03b1fa3e5.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/3/83d4ff0ef40f2706ae24cabd5e4c904140acbc77.png)

---

<div class="post-metadata">

**Author:** ![rjmiller](https://avatars.discourse-cdn.com/v4/letter/r/13edae/32.png) [@rjmiller](https://discourse.nodered.org/u/rjmiller)\
**Post date:** [12 April 2022 11:14 UTC](https://discourse.nodered.org/t/best-practice-for-mc-protocol-read/61132/6 "2022-04-12T11:14:39Z")

</div>

Wow ! Thanks Steve-Mcl ! This is a more detailed response than I could have wished for ! You have been a tremendous help, and I wish you a fantastic day !

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [26 April 2022 11:15 UTC](https://discourse.nodered.org/t/best-practice-for-mc-protocol-read/61132/7 "2022-04-26T11:15:10Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
