# Outputs not a valid modulation source for Waveform Gen. in MIM with Matlab/Python

**URL:** <https://forum.liquidinstruments.com/t/outputs-not-a-valid-modulation-source-for-waveform-gen-in-mim-with-matlab-python/725>\
**Category:** Support & Troubleshooting\
**Created:** [June 1, 2023, 6:11am UTC](https://forum.liquidinstruments.com/t/outputs-not-a-valid-modulation-source-for-waveform-gen-in-mim-with-matlab-python/725 "2023-06-01T06:11:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![michkern](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@michkern](https://forum.liquidinstruments.com/u/michkern)\
**Post date:** [June 1, 2023, 6:11am UTC](https://forum.liquidinstruments.com/t/outputs-not-a-valid-modulation-source-for-waveform-gen-in-mim-with-matlab-python/725/1 "2023-06-01T06:11:17Z")

</div>

**Moku model: Moku:Pro**  
**Operating system: Windows 11**  
**Software version: Firmware 580, MATLAB/Python API**

**Bug or support request description:**  
I’m trying to use the second channel of the WG as the modulation source for the first channel in MIM, which I can easily set-up using the iPad and desktop apps. When trying to automate the measurement and do it via the API, code that sets up FM modulation of Channel 1 with Channel 2 being the modulation source produces an error “Output2 not a valid modulation source”. A MWE for matlab

```auto
%Minimal working example of Moku:Pro MultiInstrument mode waveform
%generator API bug: cannot set Output2 as modulation source, while in single
%instrument mode yes

%Single instrument mode
wg=MokuWaveformGenerator('192.168.200.15',1)
wg.generate_waveform(1,'Sine','amplitude',2.0, 'frequency',57.8e6)
wg.generate_waveform(2,'Pulse', 'amplitude',1.0, 'frequency',1.0, 'offset',0.5, 'edge_time',4e-9,'pulse_width',69e-6)
wg.set_modulation(1,'Frequency','Output2','depth',30e3)

%connect to Moku:Pro via Ethernet, check the IP through desktop app/configure
%device/ethernet
mim = MokuMultiInstrument('192.168.200.15',4,1)
wg = mim.set_instrument(1, @MokuWaveformGenerator)
wg.generate_waveform(1,'Sine','amplitude',2.0, 'frequency',57.8e6)
wg.generate_waveform(2,'Pulse', 'amplitude',1.0, 'frequency',1.0, 'offset',0.5, 'edge_time',4e-9,'pulse_width',69e-6)
wg.set_modulation(1,'Frequency','Output2','depth',30e3)

```

The issue is reproducible with both MATLAB and Python. By playing around i’ve also noticed that “Input” 1-4 are also not valid sources, but “InputA” and B are.

---

<div class="post-metadata">

**Author:** ![Sam.Speece](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.liquidinstruments.com/sam.speece/32/191_2.png) [@Sam.Speece](https://forum.liquidinstruments.com/u/Sam.Speece)\
**Post date:** [June 7, 2023, 5:17pm UTC](https://forum.liquidinstruments.com/t/outputs-not-a-valid-modulation-source-for-waveform-gen-in-mim-with-matlab-python/725/2 "2023-06-07T17:17:09Z")

</div>

It looks like the issue is because you are trying to access the device level input from inside the instrument, which is not possible. To fix this, you will need to first manually set the connections of your Moku:Pro like you would inside the app, then use the instrument level inputs as the source. Below is an example where InputA is used as the modulation source and the MiM connections have the instrument slot output B connected to the same instrument slot input A.

```auto
from moku.instruments import WaveformGenerator
from moku.instruments import MultiInstrument

mim = MultiInstrument('192.168.XXX.XXX', platform_id=4, force_connect=True)

try:
	wg = mim.set_instrument(1, WaveformGenerator)
	connections = [dict(source="Slot1OutB", destination="Slot1InA"),
					dict(source="Slot1OutA", destination="Output1"),
					dict(source="Slot1OutB", destination="Output2")]
	wg.generate_waveform(channel=1, type='Sine', amplitude=2.0, frequency=57.8e6)
	wg.generate_waveform(channel=1, type='Pulse', amplitude=1.0, frequency=1.0, offset=0.5, edge_time=4e-9, pulse_width=69e-6)
	wg.set_modulation(channel=1,type='Frequency',source='InputA',depth=0, frequency=30e3, strict=False)

except Exception as e:
	raise e
finally:
	mim.relinquish_ownership()

```

---

<div class="post-metadata">

**Author:** ![michkern](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@michkern](https://forum.liquidinstruments.com/u/michkern)\
**Post date:** [November 30, 2023, 9:13am UTC](https://forum.liquidinstruments.com/t/outputs-not-a-valid-modulation-source-for-waveform-gen-in-mim-with-matlab-python/725/3 "2023-11-30T09:13:44Z")

</div>

Sorry for the late reply, but thanks a lot Sam!
