# How to switch from gui to API smoothly

**URL:** <https://forum.liquidinstruments.com/t/how-to-switch-from-gui-to-api-smoothly/823>\
**Category:** Software & APIs\
**Created:** [October 19, 2023, 9:33am UTC](https://forum.liquidinstruments.com/t/how-to-switch-from-gui-to-api-smoothly/823 "2023-10-19T09:33:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eliot](https://avatars.discourse-cdn.com/v4/letter/e/8baadc/32.png) [@eliot](https://forum.liquidinstruments.com/u/eliot)\
**Post date:** [October 19, 2023, 9:33am UTC](https://forum.liquidinstruments.com/t/how-to-switch-from-gui-to-api-smoothly/823/1 "2023-10-19T09:33:34Z")

</div>

Hi all, I’m using MIM mode where LockinAmps extract phase signal and feedback through pid as shown in the attached picture.

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/liquidinstruments/original/1X/e54fd4f1aaf29b2f423df7eddf6e455034da65a0.jpeg)

By monitoring phase signal in pid slot, I note that pid doesn’t break during switching from API to gui while break during switching from gui to API. Here is the minimum python API code that breaks pid during handing over the LockinAmp:

```python
from moku.instruments import MultiInstrument
from moku.instruments import WaveformGenerator, LockInAmp, PIDController
mim = MultiInstrument('192.168.50.8', platform_id=4, persist_state=True, ignore_busy=True, force_connect=True)
oppositePhase = LockInAmp(slot=2, multi_instrument=mim)
mim.relinquish_ownership()

```

The (phase) pulse in following picture(only one pic is allowed so I attached in the reply) illustrates pid breaking which is not acceptable in our experiment. By adding long delay I find out that is `oppositePhase = LockInAmp(slot=2, multi_instrument=mim)` that cause the pid to break.

I noticed that LockinAmp has a parameter ‘persist\_state’. However this doesn’t work both from my tests and from the truth that ‘persist\_state’ is not used in MIM mode by taking a look at the python API codes.

So my question is: Is there any ways to switch to API w/o breaking pid, given that the pid doesn’t break during switch to gui?

---

<div class="post-metadata">

**Author:** ![eliot](https://avatars.discourse-cdn.com/v4/letter/e/8baadc/32.png) [@eliot](https://forum.liquidinstruments.com/u/eliot)\
**Post date:** [October 19, 2023, 9:34am UTC](https://forum.liquidinstruments.com/t/how-to-switch-from-gui-to-api-smoothly/823/2 "2023-10-19T09:34:30Z")

</div>

![image](https://canada1.discourse-cdn.com/flex035/uploads/liquidinstruments/original/1X/1d52bc1cf13c565d4b1201ec5f28ba236901d8ba.png)

---

<div class="post-metadata">

**Author:** ![nadia](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.liquidinstruments.com/nadia/32/315_2.png) [@nadia](https://forum.liquidinstruments.com/u/nadia)\
**Post date:** [November 17, 2023, 5:17am UTC](https://forum.liquidinstruments.com/t/how-to-switch-from-gui-to-api-smoothly/823/3 "2023-11-17T05:17:38Z")

</div>

Hi @eliot

Would you be able to update your firmware and moku package and try this again? If the issue persists, could you upload the summary of each of the instrument states:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/liquidinstruments/original/1X/5dc6fb011d954d48bfd2ca1b27d8558377ee83ee.png)
