NanoVNA icon indicating copy to clipboard operation
NanoVNA copied to clipboard

MATLAB (on Windows) unable to read from NanoVNA V2_2

Open amritzoad opened this issue 1 year ago • 0 comments

Dear everyone,

I found it to be very confusing to make the NanoVNA V2_2 to work with MATLAB.

On Matlab, a serialport object is to be used for serial port communication.

I am quite certain that I can send commands to the NanoVNA V2_2 like sweepStartHz, sweepStepHz, and swepPoints followed by the respective number, and the device responds to these commands by going into USB Mode.

The problem comes when I try to read the data from the device. I am just not able to do so. The MATLAB has commands like read and readline but how to use them with the NanoVNA V2_2? Is it the limited Matlab functionality of something else? I just cannot understand.

The code that works so far in my opinion is as follows:

port = 'COM4'; BaudRate = 9600; device = serialport(port, BaudRate); start = 100e6; stop = 2e9; points = 101; step = (stop-start)/(points); writeline(device,"sweepPoints"+ num2str(typecast(points,'uint16'))); writeline(device,"sweepStartHz"+ num2str(typecast(step,'uint64'))); writeline(device,"sweepStepHz"+ num2str(typecast(step,'uint64')));

amritzoad avatar Jul 13 '22 14:07 amritzoad