Here is the code:
import matplotlib.pyplot as plt
from moku.instruments import MultiInstrument
from moku.instruments import ArbitraryWaveformGenerator,Oscilloscope
from Msequence import msequence,repeat_bits
import numpy as np
import matplotlib.pyplot as plt
polynomial_coefficients = [8,6]
m_sequence_output = msequence(polynomial_coefficients)
plt.figure(14)
plt.plot(m_sequence_output[1])
plt.title('Square wave fed to Moku Pro')
plt.ylabel('Amplitude')
plt.xlabel('Time')
plt.grid(True)
plt.show()
m= MultiInstrument('192.168.73.1', platform_id=4, force_connect=True)
try:
wg=m.set_instrument(1, ArbitraryWaveformGenerator)
osc=m.set_instrument(2, Oscilloscope)
connections= [dict(source="Input1", destination="Slot1InA"),
dict(source="Slot1OutA", destination="Slot2InA"),
dict(source="Slot1OutA", destination="Slot2InB"),
dict(source="Slot2OutA", destination="Output1")
]
print(m.set_connections(connections=connections))
wg.generate_waveform(channel=1, sample_rate='Auto',
lut_data=list(m_sequence_output[1]), frequency=10e3,
amplitude=1)
osc.set_timebase(-5e2, 5e-2, strict=False)
data=osc.get_data(timeout=60, wait_reacquire=True, wait_complete=True)
plt.ion()
plt.show()
plt.grid(b=True)
plt.ylim([-1,1])
plt.xlim([data['time'][0], data['time'][-1]])
line1, = plt.plot([])
line2, = plt.plot([])
ax=plt.gca()
while True:
data=osc.get_data()
line1.set_ydata(data['Ch1'])
line2.set_ydata(data['Ch2'])
line1.set_xdata(data['time'])
line2.set_xdata(data['time'])
plt.pause(0.001)
except Exception as e:
raise e
finally:
m.relinquish_ownership()
and the error:
File "/home/bonhardt/anaconda3/lib/python3.9/site-packages/spyder_kernels/py3compat.py", line 356, in compat_exec
exec(code, globals, locals)
File "/home/bonhardt/Desktop/PHD_2022/DI PROJECT/DI python code/Multi_instruments_FEB24.py", line 74, in <module>
raise e
File "/home/bonhardt/Desktop/PHD_2022/DI PROJECT/DI python code/Multi_instruments_FEB24.py", line 48, in <module>
data=osc.get_data(timeout=60, wait_reacquire=True, wait_complete=True)
File "/home/bonhardt/anaconda3/lib/python3.9/site-packages/moku/instruments/_oscilloscope.py", line 547, in get_data
return self.session.post(
File "/home/bonhardt/anaconda3/lib/python3.9/site-packages/moku/session.py", line 14, in func_wrapper
return self.resolve(response)
File "/home/bonhardt/anaconda3/lib/python3.9/site-packages/moku/session.py", line 167, in resolve
self.handle_http_error(response)
File "/home/bonhardt/anaconda3/lib/python3.9/site-packages/moku/session.py", line 110, in handle_http_error
raise exceptions.MokuException(
MokuException: Unknown exception. Status code:504