MATLAB and oscilloscope connection and computer connection

Source: Internet
Author: User

Recently carried out the oscilloscope data acquisition, Mso2014,openchoice software +tekvisa driver can be, the waveform can be directly used MATLAB processing.

Later found that the oscilloscope can be directly connected with MATLAB.

Http://blog.sina.com.cn/s/blog_4eff3a0e0100zb8h.html

1. Start Matlab, enter Tmtool, and pop up a new window. 2. On the left, under the Test&measurement window, open the hardware tree and select the connection mode of the oscilloscope to the computer. For example, I chose a USB connection under Visa. You may need to install a USB driver before you buy an oscilloscope.    It is said that in some cases can also not install the driver, because MATLAB has its own! 3. The Middle main window, scan, search, search the oscilloscope, you can press "connect" to connect,

4. Read the oscilloscope's explanatory PDF to learn about the oscilloscope's commands.    such as my oscilloscope, to the oscilloscope Send command curve?, will return to the oscilloscope measurement data, you can also send some instructions to adjust the vertical axis of the unit, send command is write, request reply is query.    5. In the Communicate tab of the Tmtool window, send the command, read the reply, and see the corresponding m code under the Session Log tab.    6. Copy the code under the session log, go back to MATLAB, create a new M file, paste the code in front of the function, and then fill in the need for subsequent processing, and then the M file is complete! 7. Similar steps, you can write callback under the GUI, or you can write the S function in Simulink. Note: 1. For Matlab, the oscilloscope is an object, obj, to be fopen when enabled, fclose when not in use.    In practice, if the fopen after the program operation error, the next time before commissioning, we should first fclose, to prevent the next fopen error. 2. Write the command to the object, the command format is string, and if you need to write many regular commands such as XX1,XX2,XX3, you can strcat and num2str two commands. The former combines multiple str into one STR, it is important to note that the space on the right of each STR is automatically ignored, such as strcat (' xx ', ' 1 '), and xx1, not xx 1.    That's what made me three days of mistakes, that's what happens! 3.simulink Module Library, there is a Instrument Control Toolbox library, which has the query instrument module for reading data from the oscilloscope and other objects, set the ID and other information must be written in STR format, that is, with two ',. Individuals do not like to use this module, or the S function is more flexible.

Contribution Part code: OBJ1 = Visa (' NI ', ' usb0::0x0699::0x0413::c013300::0::instr '); fopen (obj1); fclose (obj1); the first sentence is to connect the oscilloscope, Addresses and other information are defined as Object obj1. The last sentence do not forget to close Oh ~ fprintf (obj1, ' Data:source CH1 ');% tells the oscilloscope that the data source I want to read is channel 1~ N=100;data=zeros (1,n*100); for I=1:n Temp=str2num (    Query (Obj1, ' curve? ')); Data ((100* (i-1) +1):(100*i)) =temp;......end% read 100 data each time, continuously read n times, get data, that is, a 100*n length vector, must first define a good vector length oh, can greatly improve the operation efficiency of MATLAB.  Since the query read-in data is in STR format, the Str2Num command can be turned into a vector. Some of the above are references, but the discovery is not like that, for the above program does not run through, so still want to write for their own oscilloscope.

MATLAB and oscilloscope connection and computer connection

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.