Article Produce and Edit MATLAB Sample Code

MATLAB sample code can be generated from the ADRV9001 TES GUI. All settings from TES are preserved in the sample code.

Requirements:

  • MATLAB v2022b or higher
  • ADRV9001 evaluation platform
  • ADRV9001 TES GUI

1. Generate the sample code

Open TES GUI and successfully connect and program the device. Then, in the sample code menu, choose MATLAB and save the files to your desired folder.

2. File structure

All required files will be saved from TES. The main operations of the device are split into convenient files. main.m is the main program file which will call the other files. Open main.m.

There is some setup code for the FPGA at the beginning of the file and then each of the other functions are called in turn:

3. Run the code

From the main.m file, press the run button. A connection will be established and then the device will start to be configured. There will be several user inputs for the program to run.

When the program finishes successfully, you will see an output of the ADRV9001Device object

4. MATLAB Documentation

For existing users of the MATLAB sample code, they will notice in the format of the code from SDK 24 onwards. A 'MATLAB wrapper' was created to add functionality and improve user experience for the MATLAB sample code.

The main added feature was the addition of built-in documentation. In MATLAB, to access the 'help' functionality, it is required to target the object itself instead of an instance of the object. In this case, see below. analog_devices_eval_client_adrv9001_device is the object to target.

To access the help menu, simply call "help analog_devices_eval_client_adrv9001_device". Documentation is available for all the supported APIs. Follow the links in the help menu to find the needed API.

5. Editing the Code

As an example, suppose we would like to change the Tx attenuation. The Tx attenuation is set in the "beginTransmitting.m" file:

From the API call itself, it's not necessarily clear what is needed to change the attenuation. We will use the documentation to help.

From the help menu, click on 'Tx'. Another menu will appear:

Click on the bottom link to access the documentation. Another window will appear:

This window contains all the APIs related to 'Tx'. In this case, click on 'attenuation_set'.

Now, all the documentation for this API is listed. Towards the bottom, the parameters of the function are described. In this case, we can see the last parameter is 'attenuation_md_b' which is what we are interested in changing.

Using this information, we can now edit the function to have 12dB attenuation as such:

Run the code again to ensure it works correctly.

Before You Switch


Switching languages will make ADI Explorer unavailable. Resume your session by switching back to English and reopening ADI Explorer.