# Is\_secondary\_program parameter in URScript Modbus functions

**URL:** <https://forum.universal-robots.com/t/is-secondary-program-parameter-in-urscript-modbus-functions/24521>\
**Category:** URScript\
**Created:** [October 20, 2022, 7:15am UTC](https://forum.universal-robots.com/t/is-secondary-program-parameter-in-urscript-modbus-functions/24521 "2022-10-20T07:15:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![csaba.mucsi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/csaba.mucsi/32/277_2.png) [@csaba.mucsi](https://forum.universal-robots.com/u/csaba.mucsi)\
**Post date:** [October 20, 2022, 7:15am UTC](https://forum.universal-robots.com/t/is-secondary-program-parameter-in-urscript-modbus-functions/24521/1 "2022-10-20T07:15:08Z")

</div>

Hello,

In several modbus functions - for example `modbus_get_signal_status` - there is a boolean parameter called “is\_secondary\_program” where the documentation says:  
is\_secondary\_program: A boolean for internal use only. **Must be set to False**

However, we are implementing a modbus heartbeat functionality that is supposed to be sent by a secondary program twice a second, while the main robot program is not running or is doing something else. When these modbus functions are called from a secondary program, should the is\_secondary\_program parameter be set to True even if the documentation says “Must be set to False” ?

Thanks,

Csaba

---

<div class="post-metadata">

**Author:** ![csaba.mucsi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/csaba.mucsi/32/277_2.png) [@csaba.mucsi](https://forum.universal-robots.com/u/csaba.mucsi)\
**Post date:** [October 21, 2022, 12:51pm UTC](https://forum.universal-robots.com/t/is-secondary-program-parameter-in-urscript-modbus-functions/24521/2 "2022-10-21T12:51:57Z")

</div>

Update: it seems that using modbus functions in a secondary program may introduce random connection errors in the modbus communication. Sending this secondary program periodically ca. twice a second:

```auto
sec heartbeat():
  modbus_set_output_register("HEARTBEAT", (1 + modbus_get_signal_status("HEARTBEAT", False))%256, False)
end

```

Tested with both `is_secondary_program=True` and `False`, the random timeouts can be observed.  
Without the above code (only using primary program) the timeouts can’t be observed anymore.

Is it in general safe to use modbus functions from the secondary program?

@Ebbe do you have any suggestions here?
