Cannot connect to the Moku:Lab using MATLAB

Moku model: Moku:Lab
Operating system: Microsoft Windows 10 Enterprise Version 10.0 (Build 19045)
Software version: MATLAB Version: 9.10.0.1602886 (R2021a) / moku-MATLAB 3.0.1

Bug description: I cannot connect to the Moku:Lab using MATLAB.

I have tried with two different Moku:Lab and get the same error.
I am able to connect when using a Moku:Go.
I am sharing the code below:

%%
clc
clear
close all
 
%% Connect to your Moku
ip = '192.168.73.1';
 
% Connect to your Moku and deploy the desired instrument
m = MokuOscilloscope(ip, force_connect='True');

m.relinquish_ownership()

I get the following error:

sun.net.www.protocol.http.HttpURLConnection:http://192.168.73.1/api/moku/claim_ownership

   404

Error using Requests/parse_response (line 40)
Unexpected error occurred

Error in Requests/http_post (line 128)
            response = obj.parse_response(output, extras);

Error in Moku/claim_ownership (line 219)
            response = obj.session.http_post('moku/claim_ownership', params);

Error in Moku (line 180)
                obj.claim_ownership('force_connect', force_connect, 'ignore_busy',
                ignore_busy, ...

Error in MokuOscilloscope (line 84)
            obj@Moku(IpAddr, force_connect, ignore_busy, persist_state, read_timeout,
            mimInited);

Error in MokuPhaseExmaple (line 17)
m = MokuOscilloscope(ip, force_connect='True');

We recently updated the Moku:Lab firmware so that it now uses the same API as Moku:Go and Moku:Pro. Have you recently updated your Moku:Lab firmware to 580? If so then it will use the moku-MATLAB toolbox which should work for both devices given the code you posted above (except of course changing the IP address). If not, then it will use the legacy MATLAB toolbox which you can download from here under the Legacy section.

Can confirm which firmware both devices are on to see if there is an issue with the API toolbox version?

1 Like

I just updated the firmware to 580.
I ran the same code with the new firmware and the same moku-MATLAB toolbox, and I got a different error message:

Error using Moku/load_instrument_resources (line 323)
Cannot find bitstream C:\Users\xxxx\AppData\Roaming\MathWorks\MATLAB
Add-Ons\Toolboxes\moku-MATLAB\data\moku20\01-000, please run moku_download(580) to download
instrument data

Error in MokuOscilloscope (line 87)
                obj.load_instrument_resources('01-000');

Error in MokuPhaseExmaple (line 17)
m = MokuOscilloscope(ip, force_connect='True');

Then, I uninstall the toolbox and installed the legacy MATLAB toolbox.
It got a different error message for the Moku:Lab and for the Moku:Go:

Error using moku/check_compatibility (line 172)
input file does not exist

Error in moku (line 71)
            [compat, py_vers] = obj.check_compatibility();

Error in MokuOscilloscope (line 36)
            obj@moku(IpAddr, 'oscilloscope');

Error in Test (line 10)
m = MokuOscilloscope(ip);

Type ā€œmoku_download(580)ā€ in Matlab command window and hit enter (you should be connected to the Internet). Thatā€™s what I had to do after updating the Moku Matlab API yesterday.

1 Like

Thank you.
So, in summary:

  • I updated the firmware of my Moku:Lab.
  • Updated the API to 3.0.1.
  • Run moku_download(580).

Now its working.

1 Like

Iā€™m having the same problem connecting MatLab to the Moku:Lab device. I sent the Moku out for cal and it came back with the firmware updated to version 600. I updated my ipad app and Iā€™m able to connect to the Moku just fine. When I connect to the Moku over Wifi, I can access it within my browser and see the following info:
Hardware Version: 2.0 Moku:Lab
Firmware Version: 600

In MatLab (R2004b), I download the Moku-MatLab AddOn package version 3.3.1. It says online that it is compatible with firmware version 600. I then typed ā€˜moku_download(600)ā€™ in the MatLab command window and downloaded the instrument data. Everything seems to be updated as far as I can tell. When I try to run the command ā€˜MokuOscilloscope(ā€˜192.168.73.1ā€™)ā€™ , I get the following error:

Not sure what Iā€™m missing here. Any thoughts?

Hi @kgagnon,

Can you check what API Server is loaded on your device, there may be an issue there? To do this right-click on your device in the App and readout what it says under ā€œDevice info > API serverā€. It should look something like the screenshot.

If it says ā€œAPI server: not loadedā€ then you can follow these steps to re-upload the firmware (including the latest API server)

  1. Alt/Option + Shift + Right click for windows/mac
  2. Press ā€œUpdate Firmwareā€

Let me know how this goes,
Indira

That fixed the issue. The API server was listed as Not Loaded. I also didnā€™t have the Windows app loaded on my computer. I purchased my Moku Lab unit when the windows app was still being developed so I never bothered to download it. Since I was able to control the unit with MatLab, I was all set until the calibration house upgraded the firmware in the Moku unit. With the API server loaded, Iā€™m able to communicate with the Moku Lab now. Looks like I need to update some of the instrument configuration commands in MatLab because those are no longer working. I tried updating a few of them and got those working so itā€™s just a matter of updating the rest of my MatLab code to work with the updated hardware/firmware. Thanks for your help!

Iā€™m glad that fixed the issue for you. Iā€™m sorry that your firmware was updated unexpectedly but that is a necessary part of the calibration process. Hopefully youā€™re able to take advantage of the updated features on the new firmware!

If we can help with any of the MatLab parameters that have changed dont hesitate to post them.

Good luck,
Indira