MATLAB via a USB connection

Hello,

I am using Moku:Go and would like to connect it to MATLAB via a USB connection. I have already downloaded the required Add-ons and API for MATLAB. However, when I attempt to communicate with Moku:Go using the IP address obtained from the Moku App, an error occurs.

Is it possible to use a USB connection for communication between Moku:Go and MATLAB, or is Wi-Fi the only available option? If Wi-Fi is the only option, can I use my personal Wi-Fi network with internet access instead of the hotspot provided by Moku:Go?

Thank you for your assistance.

Hi onyu,

welcome to the Moku forum !

MATLAB can connect to any Moku over USB. When using USB, Moku implements IPv6. The format uses square brackets :

>> i=MokuOscilloscope('[fe80:0000:0000:0000:7269:79ff:feb9:0962%30]', force_connect=true)

Alternatively, you can connect to a Moku by USB, wifi or ethernet via its serial number. This is the format for connecting to MokuGo with serial # 000600

>> i=MokuOscilloscope('mokugo-000600.local', force_connect=true)

Finally, you can connect the Moku to your wifi network.

  1. Open the Moku app on your Windows or macOS machine.
  2. Navigate to the “Configure device” settings by right-clicking on your Moku:Go tile in the “Select your device” window.
  3. Go to the “Wi-Fi” tab and select “Join a Wi-Fi network.”
  4. Choose your network from the dropdown and enter the password if required.

Regards,

Paul.






Hello,



Thank you for your response. However, I am still experiencing issues with establishing a communication connection. I’ve attached some pictures for your reference, and I would appreciate it if you could provide guidance on connecting Moku:Go via USB.



I have tried accessing the device using IPv6, IPv4, and the serial number, but none of them worked. One issue I suspect is that the IP address shown in the Moku App is different from the IP address displayed in the Command Prompt (cmd). Even after setting the PC’s IP address to match the one shown in the Moku App, the connection between MATLAB and Moku:Go still fails.



Additionally, when I check the device information in the Moku App, it shows “API Server: Not Installed.” Could this be causing the issue? If so, I would appreciate any guidance on how to resolve this as well.



Thank you for your support.




|

  • |

2025년 1월 1일 (수) 오전 4:30, PaulC via Liquid Instruments <notifications@liquidinstruments.discoursemail.com>님이 작성:

Also the problem occurs in python as well.

2025년 1월 2일 (목) 오전 10:27, 김온유 <onyu0333@gmail.com>님이 작성:

Hi onyu,

thank you very much for the further detailed information.

“Additionally, when I check the device information in the Moku App, it shows “API Server: Not Installed.” Could this be causing the issue?”

Yes, good observation, this is likely the issue. Please refer to this Knowledge Base article

https://knowledge.liquidinstruments.com/matlab/api-server-not-installed

Does this help ?

Regards,

Paul.

I connected to the API server but I keep getting an error:(

2025년 1월 2일 (목) 오후 1:29, PaulC via Liquid Instruments <notifications@liquidinstruments.discoursemail.com>님이 작성:

Hi onyu,

Can you ensure you have set ‘force_connect’ to true :

i=MokuOscilloscope(‘mokugo-000600.local’, force_connect=true)

Paul.

“Thanks to your help, the IP connection seems to have been successfully established. However, a bitstream issue has occurred. While downloading the MATLAB API, the .bar files were automatically downloaded to the path C:\Users\onyou\AppData\Roaming\MathWorks\MATLAB Add-Ons\Collections\moku-MATLAB\data, and all folders (mokugo, moku20, mokupro) now contain the .bar files. Could you please provide a solution to resolve this issue? Thank you.”

2025년 1월 2일 (목) 오후 1:55, PaulC via Liquid Instruments <notifications@liquidinstruments.discoursemail.com>님이 작성:

Hi onyu,

could you ensure you have the appropriate bitstreams for your Moku ? - I think your Moku is on firmware version 600; so try this in MATLAB

> >> moku_download(600)

Regards,

Paul.

Hello, and thank you for your kind and helpful responses, which have enabled me to successfully connect the Moku:Go to MATLAB via USB. However, I’ve encountered some additional issues and would appreciate your assistance.

  1. External Trigger for Data Logging
    I would like to use an external trigger to control the data logging functionality of Moku:Go. Specifically, I want to start and stop data logging from MATLAB and save the logged data. However, after reviewing the user forum, I noticed mentions that controlling Moku:Go’s data logging via an external trigger is not supported. Is this still the case, or are there any updates or workarounds available?

  2. Saving and Verifying Logged Data
    My ultimate goal is to save the data obtained from two channels of the Moku:Go as a MATLAB (.mat) file. Before converting to the MATLAB format, I attempted to save the data as a CSV file to verify its contents. Unfortunately, the CSV file appears to contain no logged data, as shown in the attached image. Could you provide guidance on how to resolve this issue?

Thank you for your time and support. I look forward to your response

.


2025년 1월 2일 (목) 오후 2:33, PaulC via Liquid Instruments <notifications@liquidinstruments.discoursemail.com>님이 작성:

Hello onyu,

  1. Datalogging trigger.
    You can start a datalogging session from a trigger source as detailed here

Moku API

However, you cannot stop the datalogging via an external trigger.

  1. Saving logged data
    The downloaded data will be in a Liquid Instrument .li format; you can convert this with “mokucli” or the GUI file converter.
    I am attaching a MATLAB script that implements this conversion.

Regards,

Paul.

Datalogger_Download_Log.m (1.5 KB)

Dear PaulC,

Thank you for your previous response. I followed your advice and successfully saved the .li file. However, I am encountering an issue during the conversion of the .li file to a .mat file. Additionally, upon examining the .li file, the amount of data seems insufficient compared to what I expected. Specifically, for a sampling rate of 125,000 over 10 seconds across two channels, the data recorded appears to be less than anticipated.

I have recently downloaded and installed the latest version of mokucli, and its path is C:\Program Files\Liquid Instruments\Moku CLI\mokucli.exe.

Currently, I am acquiring data through two input channels. Are there any specific considerations or best practices when using two channels for data acquisition? Furthermore, I would like to understand how the .li file organizes the data from two channels. For example, does the file save data for Channel 1 in row 1 and Channel 2 in row 2, or is it structured differently?

I am attaching the MATLAB code I used for this process. Below is the error message I received:

acquisition_mode: ‘Precision’


    acquisition_rate: 125000
            comments: ''
            duration: 10
           file_name: 'LoggingData_19700101_130808.li'
    file_name_prefix: 'LoggingData'
            location: 'persist'

Progress: 9 seconds remaining
Progress: 8 seconds remaining
Progress: 7 seconds remaining
Progress: 6 seconds remaining
Progress: 5 seconds remaining
Progress: 4 seconds remaining
Progress: 3 seconds remaining
Progress: 2 seconds remaining
Progress: 1 seconds remaining
Progress: 0 seconds remaining
File downloaded successfully!
Original .li file saved for verification:
E:\내 드라이브\[0] FTIR\[2] 제어 자료\[0]사용중인 코드\data_202450106\Moku_datalog_test2\LoggingData_19700101_130808.li
Error bad conversion

I would greatly appreciate your assistance in resolving these issues and clarifying my questions. Thank you in advance for your support.

2025년 1월 4일 (토) 오전 7:59, PaulC via Liquid Instruments <notifications@liquidinstruments.discoursemail.com>님이 작성:

(attachments)

moku_datalogging_test.m (3.71 KB)

Hi onyu,

can you try the file conversion using the GUI version of the file convertor ?

Does it work on the consol/command line e.g.

mokucli --format mat <filename.li>

Regards,

Paul.

Thank you for your response.

The reason why the conversion from .il to .mat files was not successful was because the file path for saving the .il files in MATLAB was set to a non-English language directory.

Additionally, I would like to ask about another issue. When obtaining data using Moku through MATLAB, the data inside the Moku device is not deleted but continues to accumulate. This eventually fills up the storage and causes errors. Is there a way to implement an automatic file deletion feature within the Moku device using MATLAB code?

Thank you again for your help!

2025년 1월 9일 (목) 오전 9:43, PaulC via Liquid Instruments <notifications@liquidinstruments.discoursemail.com>님이 작성:

Hi onyu,

thanks for explaining the issue with the non-English characters.

You can delete files on the Moku via the API

https://apis.liquidinstruments.com/api/reference/static/delete.html

Regards,

Paul.

The Matlab command

m = MokuOscilloscope(‘[fe80::7269:79ff:feb9:12be]’, force_connect=true)

never worked for me. It is returning a lengthy error message starting with the following:

Error using urlread2 (line 200)
Java exception occurred:
java.net.SocketException: Protocol family unavailable

In order to connect to the Matlab API via USB, I need to set a proxy in the admin mode and then connect to Moku by writing “localhost” instead of the IP address:

!powershell “netsh interface portproxy set v4tov6 listenport=8090 connectaddress=[fe80::7269:79ff:feb9:12be] connectport=http”
m = MokuOscilloscope(‘localhost:8090’);

The good thing is that I need to do this only once, and the next times the settings are remembered both on the PC and the Moku (which is kind of surprising). This issue has been bugging me for a long time, and when I saw Onyu’s reply that it worked for him/her, I thought it was resolved after the software/firmware updates. But unfortunately that’s not the case, every time I try to connect using the command that Paul provided at the beginning of this thread, I get that Java exception error.