Using Simulink to Collect Data from a Network Analyzer
4 次查看(过去 30 天)
显示 更早的评论
I am currently trying to collect data from an Agilent (formerly HP) 8752C network analyzer. This device uses a GPIB connection. I have been able to connect to the device using the tmtool and have successfully queried the Network Analyzer for data. Using the tmtool connection, this data can be returned in the form of an ASCII string or as an array of a u8int. The returned array is multiple bytes long.
I need to collect data from the network analyzer for 10 seconds. I have tried to accomplish this using Simulink. I currently have the block "Query Instrument" set up to query the network analyzer using the same commands as the tmtool. The instrument response needs to be in the u8int binary data format because this type of network analyzer cannot use the fprintf commands as outlined here: https://www.mathworks.com/products/instrument/limitations.html#GPIB
I have connected the "Query Instrument" block to a "To Workspace" block to look at the data. However, when I run my simulation, each query to the Network Analyzer only returns one byte of data. This byte that is returned is the first byte from the returned query from the tmtool response.
What do I need to do to receive the other missing bytes of the response from the Network Analyzer in my Simulink program?
0 个评论
回答(1 个)
Vinod
2015-4-1
If you already have your MATLAB function that acquires the data from the instrument and formats it for use later, you could consider putting that code into a MATLAB function block. That should significantly simplify your task.
2 个评论
X W
2017-7-24
Hi Vinood, How is that done? I read the tutorials on MATLAB functions and combed the docs, https://www.mathworks.com/help/simulink/slref/matlabfunction.html
I see that the supported list for the block is: https://www.mathworks.com/help/simulink/ug/functions-supported-for-code-generation--alphabetical-list.html
I see neither gpib() nor visa() in that list, how do we go about using gpib or visa to stick into a MATLAB function block?
Vinod
2017-7-24
You are right that the MATLAB function block does not support C/C++ code generation for the GPIB or VISA functions. This is because these functions rely on external software to interface with hardware.
Does your application just involve a Simulink model that needs to pull in data from a Network Analyzer? Do you plan to deploy this Simulink model onto embedded firmware?
If your Simulink model only runs from within the MATLAB environment, you should be able to use the MATLAB function block.
If you are looking to create a standalone application, you may want to look at the MATLAB Compiler as a way to create a standalone executable.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Instrument Control Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!