# Generate modbus flex sequence

**URL:** <https://discourse.nodered.org/t/generate-modbus-flex-sequence/68203>\
**Category:** General\
**Created:** [25 September 2022 18:08 UTC](https://discourse.nodered.org/t/generate-modbus-flex-sequence/68203 "2022-09-25T18:08:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![xjust](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/xjust/32/39096_2.png) [@xjust](https://discourse.nodered.org/u/xjust)\
**Post date:** [25 September 2022 18:08 UTC](https://discourse.nodered.org/t/generate-modbus-flex-sequence/68203/1 "2022-09-25T18:08:20Z")

</div>

I have a few registers to read using modbus flex:  
To avoid modbus congestion,can anyone help me generate a sequence of registers/quantity to have as little queries as possible ?

For example :  
numbers = [10,11,12,18,500,501,505]

should generate only 2 queries :  
address 10 quantity 9  
address 500 quantity 6

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [26 September 2022 06:34 UTC](https://discourse.nodered.org/t/generate-modbus-flex-sequence/68203/2 "2022-09-26T06:34:39Z")

</div>

Are you asking for a general algorithm that will work with a random set of registers? If so that is more of a maths question than node red I think.

---

<div class="post-metadata">

**Author:** ![xjust](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/xjust/32/39096_2.png) [@xjust](https://discourse.nodered.org/u/xjust)\
**Post date:** [26 September 2022 10:15 UTC](https://discourse.nodered.org/t/generate-modbus-flex-sequence/68203/3 "2022-09-26T10:15:05Z")

</div>

Yes. Exactly.

If the difference between the registers is higher than say 20, generate different a request. Otherwise combine them all in one read.

I tried a few things, didn't succeed just yet, hence the post here.

For now I make the all requests manually, and filter the output with the registers I need.

---

<div class="post-metadata">

**Author:** ![xjust](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/xjust/32/39096_2.png) [@xjust](https://discourse.nodered.org/u/xjust)\
**Post date:** [27 September 2022 07:07 UTC](https://discourse.nodered.org/t/generate-modbus-flex-sequence/68203/4 "2022-09-27T07:07:29Z")

</div>

nevermind.figured it out 🙂

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [27 September 2022 21:37 UTC](https://discourse.nodered.org/t/generate-modbus-flex-sequence/68203/5 "2022-09-27T21:37:41Z")

</div>

Is it general enough to share ? Others may find it useful.

---

<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 November 2022 21:38 UTC](https://discourse.nodered.org/t/generate-modbus-flex-sequence/68203/6 "2022-11-26T21:38:36Z")

</div>

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