Example Code

Interfacing NI Hardware directly from MATLAB Phased Array Toolbox for Radar applications

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Hardware

  • PXIe-1095
  • PXIe-5840

    Software

  • LabVIEW

    Driver

  • RF Device Drivers

    Operating System

  • Windows

    Other

  • MATLAB
  • Phased Array Toolbox
  • DLL

Code and Documents

Attachment

Description

Simple Radar using MATLAB Phased Array Toolbox based on NI Hardware

This example is the result of a project done in collaboration with Mathworks.

The purpose of it is to Leverage Mathworks tools and NI rapid prototyping tools and hardware in order to excell in aerospace and deffense.

A typical design flow in ADG starts with a simulation in a choosen language. (This can be c c# MATLAB or many other language).

Then we have to move the concept to a test hardware to see how the design works in the real world

Transitioning from modelling and simulation tools into hardware-based prototyping testbeds is a critical step in turning radar concepts into fielded capability.

This example shows you how to model a radar system with MathWorks® Phased Array Toolbox™ and MATLAB, then how to use wrappers for LabVIEW to directly target NI vector signal transceivers from MATLAB. Allowing an accelerated, iterative design process, where new algorithms can be rapidly assessed both in simulation and with real hardware.

The purpose of this example is to demonstrate standard capabilities of NI software and hardware.

NI's contribution to this project is the interface with which the MATLAB Phased Array Toolbox is able to use a real PXIe-5840 hardware for transmit and receive.

 

 

 

 

 

 

 

 

How to Use

Supported Devices:

PXIe-5820/5830/5831/5832/5840/5841

 

Software Requirements:

LabView 2020 or later
NI RFSG Driver
NI RFSA Driver
MATLAB
Phased Array Toolbox for MATLAB

 

 Usage:

  1. Extract the attached .zip file
  2. Open the file below in MATLAB:MatLabCode\Examples\Radar_Example_NI_Hardware.mlx
  3. Set the generatorResource and analyzerResource parameter (needs to be the same as the name of the VST device in MAX you want to use)
  4. Run the MATLAB script
  5. Tweaking the signal parameters, the number of iterations and the parameters of the phased.RangeDopplerResponse function, you can get better range and speed resolutions.

 

 

 

 

 

 

Additional Information

Description of attached files:

MATLAB Phased Array Toolbox Based on NI Hardware.pptx

Contains the explanation of the software layers, the hardware setup and the recommended calling sequence of the MATLAB wrapper functions.

 

RFSG_A_Wrapper for MATLAB.zip

This file package contains the whole software stack and the MATLAB example code that has been built upon it. Also a few other minor but useful examples.

MATLAB Radar example
MATLAB NI.Transmitter System Object
MATLAB NI.Receiver System Object
RFSA/RFSG wrapper DLLs
LabView project to build the RFSA/RFSG wrapper DLLs
Preliminary Python wrappers for RFSG/RFSA
Simple Python radar examples

 

 

 

 

 

 

 

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
ChuckM
Member
Member
on

Hi

 

This looks great but I ran into an issue executing the script and was hoping you could help. 

#error "We don't know the Compiler"

Within Matlab I have 'MEX configured to use 'MinGW64 Compiler (C)'

 

 

transmitter = NI.Transmitter(...
'DeviceResource', generatorResource,...
'PowerLevel', -3,...
'SampleRate', fs,...
'CenterFrequency', fc,...
'RefClkSrc', refClkSource,...
'TriggerOutputTerminal', triggerLine...
);
Error using loadlibrary
Failed to preprocess the input file.
Output from preprocessor is:In file included from C:\Sandbox\MatlabNI\RFSG_A_Wrapper for
MATLAB\Builds\extcode.h:14:0,
from C:\Sandbox\MatlabNI\RFSG_A_Wrapper for MATLAB\Builds\RFSGWrapper.h:1:
C:\Sandbox\MatlabNI\RFSG_A_Wrapper for MATLAB\Builds\platdefines.h:120:4: error: #error "We don't know the
Compiler"
#error "We don't know the Compiler"
^~~~~
C:\Sandbox\MatlabNI\RFSG_A_Wrapper for MATLAB\Builds\platdefines.h:135:4: error: #error "We don't know the
ProcessorType architecture"
#error "We don't know the ProcessorType architecture"
^~~~~
In file included from C:\Sandbox\MatlabNI\RFSG_A_Wrapper for MATLAB\Builds\extcode.h:14:0,
from C:\Sandbox\MatlabNI\RFSG_A_Wrapper for MATLAB\Builds\RFSGWrapper.h:1:
C:\Sandbox\MatlabNI\RFSG_A_Wrapper for MATLAB\Builds\platdefines.h:354:3: error: #error
#error
^~~~~


Error in NI.Transmitter/InitRFSG (line 123)
[~,~]=loadlibrary(obj.pLibname);

Error in NI.Transmitter (line 42)
InitRFSG(obj);

Contributors