完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好,我正在尝试编写matlab程序,将正弦波发送到任何电路,并在相位频率和幅度频率中评估所需组件的阻抗。
现在,我能够与我的33522b波形发生器通信,我可以通过matlab进行扫描。 但是,我在使用相位频率获取数据时遇到问题,我对此没有任何线索。 有关于它的任何指南或有用的matlab脚本吗? 如何将水平轴调整到频域? 提前致谢。 以上来自于谷歌翻译 以下为原文 Hi everyone, I'm trying to write matlab program that sends sine waves to any circuit and evaulates desired component's impedance in phase-frequency and amplitude-frequency. Now, I'm able to communicate with my 33522b waveform generator and I can make sweep on it via matlab. However, I have a problem with getting data in terms of phase-frequency and I don't have any clue about it. Is there any guide or helpful matlab script about it ? How can i adjust my horizontal axis to frequency domain ? Thanks in advance. |
|
相关推荐
2 条评论
11个回答
|
|
有意思...... - 你交叉发布到两个论坛。
我删除了其他帖子。 - 您没有指明您正在使用的范围或您尝试过的内容。 大多数Keysight(和Agilent)示波器都具有FFT或频谱功能。 你看过那些吗? 这是一个学校项目吗? 人 以上来自于谷歌翻译 以下为原文 Interesting... - You cross-posted to two forums. I have deleted the other post. - You don't indicate what scope you are using or what you have tried. Most Keysight (and Agilent) scopes have an FFT or Spectrum function available. Have you looked at those? Is this for a school project? Al |
|
|
|
是的,这是一个有点学校的项目,我正在尝试为我们的电子实验室开发一个程序,以节省在电路上重复测量的时间。 我正在使用33522B波形发生器,它正在发送正弦波,其值由用户决定电路。 这是代码。 + function userTest(start,stop,amp)+ + fgen = visa('AGILENT','GPIB0 :: 10 :: INSTR'); + + set(fgen,'OutputBufferSize',100000); + + fopen(fgen) ; + + fprintf(fgen,'* IDN?'); + + idn = fscanf(fgen); + + fprintf(idn)+ + fprintf(' n n')+ + fprintf(fgen,'* RST' ); + + fprintf(fgen,'* CLS'); + + fprintf(fgen,'SOURCE1:FUNCTION SIN'); + + fprintf(fgen,'SOURCE1:VOLT:UNIT VPP'); + + fprintf(fgen, convertStrAmp(amp)'); + + fprintf(fgen,convertStartFrq(start)); + + fprintf(fgen,convertStopFrq(stop)); + + fprintf(fgen,'SOURCE1:SWEEP:SPACING LINEAR'); + + fprintf (fgen,'SOURCE1:SWEEP:TIME 20'); + + fprintf(fgen,'TRIGGER1:SOURCE IMM'); + + fprintf(fgen,'SOURCE1:SWEEP:STATE ON'); + + fprintf(fgen,' OUTPUT1 ON'); + + fprintf(fgen,'SYST:ERR?'); + + errorstr = fscanf(fgen); + +%错误检查+ +如果strncmp(errorstr,'+ 0,“没有错误”',13 )+ + errorcheck ='没有任何错误生成的波形 n'; + + fprintf(错误检查)+ + else + + errorcheck ='有错误 n'; + + fprintf(错误检查)+ +结束+ + fclose(fgen) ; + +删除(fgen); + +结束+现在我想要mea 确定电路中元件的相位和幅度(R,L,C等)。 顺便说一下仪器是MSO-X 2014A。 实际上,我认为我可以使用MEASure:FREQUENCY和MEASure:PHASE命令。 问题我无法在matlab上保留值并绘制它。 不幸的是,我找不到4000系列程序员指南中的频谱命令。 另外,抱歉重复发帖。 我已经意识到我的第一篇文章的错误,我无法删除它。 以上来自于谷歌翻译 以下为原文 Yeah, it's kinda school project, I'm trying to develop a program for our electronic lab to save time for repeating measurement at circuits. I'm using 33522B Waveform generator which on I'm sending sine wave whose values decided by user to circuits. Here's the code. +function userTest(start,stop,amp)+ +fgen = visa('AGILENT','GPIB0::10::INSTR');+ +set (fgen,'OutputBufferSize',100000);+ +fopen(fgen);+ +fprintf (fgen, '*IDN?');+ +idn = fscanf (fgen);+ +fprintf (idn)+ +fprintf ('nn')+ +fprintf (fgen, '*RST');+ +fprintf (fgen, '*CLS');+ +fprintf(fgen,'SOURCE1:FUNCTION SIN');+ +fprintf(fgen,'SOURCE1:VOLT:UNIT VPP');+ +fprintf(fgen,convertStrAmp(amp)');+ +fprintf(fgen,convertStartFrq(start));+ +fprintf(fgen,convertStopFrq(stop));+ +fprintf(fgen,'SOURCE1:SWEEP:SPACING LINEAR');+ +fprintf(fgen,'SOURCE1:SWEEP:TIME 20');+ +fprintf(fgen,'TRIGGER1:SOURCE IMM');+ +fprintf(fgen,'SOURCE1:SWEEP:STATE ON');+ +fprintf(fgen,'OUTPUT1 ON');+ +fprintf(fgen, 'SYST:ERR?');+ +errorstr = fscanf (fgen);+ +% error checking+ +if strncmp (errorstr, '+0,"No error"',13)+ +errorcheck = 'Waveform generated without any error n';+ +fprintf (errorcheck)+ +else+ +errorcheck = 'There is a error n';+ +fprintf (errorcheck)+ +end+ +fclose(fgen);+ +delete(fgen);+ +end+ Now I want to measure phase and amplitude of an element in a circuit (R,L,C etc.). By the way the instrument is MSO-X 2014A. Actually, I thought that I can use MEASure: FREQUENCY and MEASure: PHASE command. The problem I can't hold the value on the matlab and plot it. Unfortunatley, I couldn't find a command for spectrum in 4000's series programmer guide. Also, sorry for repeating posts. I've realized my mistake for first post and I couldn't delete it. |
|
|
|
60user196 发表于 2018-10-12 20:25 也许你输错了,但是当你有2000系列示波器时,我不明白为什么你看了4000系列编程指南。 在任何情况下,2000和4000系列示波器都具有FFT功能。 如果要使用它,则必须打开它并从中卸载数据。 *尽管*,这可能不是进行此测量的正确方法。 您可能想要做的是将源设置为给定频率(此时您正在扫描它)和幅度,然后读取输入和输出的当前幅度,以及两个信号之间的相位。 这两种测量都会产生噪音,因此您可能需要多次进行所有测量并对结果取平均值。 然后,您需要将信号源设置为新的频率和幅度,然后进行另一组测量。 您不能只扫描并进行一次测量。 您必须同步源和范围。 人 以上来自于谷歌翻译 以下为原文 Maybe you mistyped, but I don't understand why you looked in the 4000 series programming guide, when you have a 2000 series scope. In any case, both the 2000 and the 4000 series scopes have an FFT function. If you want to use it, you will have to turn it on and unload the data from it. *That's probably not the correct way to do this measurement, though*. What you probably want to do is set the source to a given frequency (right now you are sweeping it) and amplitude, then read the current magnitude of the input and output, along with the phase between the two signals. Both of these measurements will be noisy, so you will probably want to make all measurements multiple times and average the results. Then you'll want to set the source to a new frequency and amplitude and make another set of measurements. You can't just sweep and make one measurement. You have to synchronize the source and the scope. Al |
|
|
|
nvywyerwer 发表于 2018-10-12 20:33 好的,现在遇到了问题。 非常感谢 ! 顺便说一句,我找不到2k-X系列指南。 以上来自于谷歌翻译 以下为原文 Ok, got what the problem is now. Thanks a lot ! I couldn't find the 2k-X series guide by the way. |
|
|
|
“顺便说一下,我找不到2k-X系列指南。” 嗯......我们试着让这很容易。 我搜索了“MSOX2014”并进入了产品页面。 我选择了“文档”选项卡,然后单击“手册”对列表进行了细化。 列表中有6个,包括pdf和chm格式的编程指南。 祝你的申请好运...... Al 以上来自于谷歌翻译 以下为原文 "I couldn't find the 2k-X series guide by the way." Hmmm... We try to make that pretty easy. I searched on "MSOX2014" and got to the Product page. I selected the 'Documents' tab, then refined the list by clicking on 'Manuals'. There were 6 in the list, including the Programming Guide in pdf and chm formats. Good luck with your application... Al |
|
|
|
好吧,我带来了一个解决方案。 这是交易。 但它给出了超时错误。 + function userTest(start,stop,amp,data_points)+ + fgen = visa('AGILENT','GPIB0 :: 10 :: INSTR'); + + set(fgen,'OutputBufferSize',100000); + + fgen。 超时= 10; + + fopen(fgen); + +%MSO-2014A + + mso =签证('AGILENT','GPIB0 :: 7 :: INSTR'); + + set(mso,'OutputBufferSize',100000); + + mso.Timeout = 10; + + fopen(mso); + +%查询Idendity字符串和报告+ + fprintf(fgen,'* IDN?'); + + idn = fscanf(fgen); + + fprintf(idn) + + fprintf(' n n')+ +%查询Idendity字符串和报告+ + fprintf(mso,'* IDN?'); + + idn = fscanf(mso); + + fprintf(idn)+ + fprintf( ' n n')+ +%清除并重置乐器+ + fprintf(fgen,'* RST'); + + fprintf(fgen,'* CLS'); + +%清除并重置乐器+ + fprintf(mso,' * RST'); + + fprintf(mso,'* CLS'); + + fprintf(mso,':ACQuire:TYPE NORMal'); + +%选择波形形状,幅度和偏移+ + fprintf(fgen,'SOURCE1 :FUNCTION SIN'); + + fprintf(fgen,'SOURCE1:VOLT:UNIT VPP'); + + fprintf(fgen,convertStrAmp(amp)'); + +%选择扫描的频率边界+ + fprintf(fgen, convertStartFrq(start)); + + fprintf(f gen,convertStopFrq(stop)); + +%选择扫描模式+ + fprintf(fgen,'SOURCE1:SWEEP:SPACING LINEAR'); + +%设置扫描时间(秒)。+ + fprintf(fgen,'SOURCE1:SWEEP :TIME 5'); + +%选择扫描触发源+ + fprintf(fgen,'TRIGGER1:SOURCE IMM'); + +%启用扫描状态。+ + fprintf(fgen,'SOURCE1:SWEEP:STATE ON'); + +%启用输出。+ + fprintf(fgen,'OUTPUT1 ON'); + + a =开始:(停止 - 开始)/ data_points:停止-1; + + b = 1:1:data_points; + + c = 1:1:data_points; + +表示j = 1:1:data_points + fprintf(mso,'MEASure:VAMPlitude CHAN2'); b(j)= str2double(查询(mso,'MEASure:VAMPlitude?')); fprintf(mso,'MEASure:PHASe CHAN1,CHAN2'); c(j)= str2double(查询(mso,'MEASure:PHASe?CHAN1,CHAN2')); 暂停(5 / data_points)+结束+ +%启用输出+ +%fprintf(fgen,'OUTPUT ON'); %打开通道1输出+%读取错误+ + fprintf(fgen,'SYST:ERR?'); + + errorstr = fscanf(fgen); + +%错误检查+ +如果strncmp(errorstr,'+ 0,“没有错误 “',13)+ + errorcheck ='波形生成没有任何错误 n'; + + fprintf(错误检查)+ + else + + errorcheck ='有错误 n'; + + fprintf(错误检查)+ +结束+ + %使用函数生成器关闭签证会话+ + fclose(fgen); + +删除(fgen); + + fclose(mso); + +删除(mso); + +%disp(size(a)); + +% disp(size(b)); + + subplot(1,2,1); + + stem(a,b); + + xlabel('frequency [hz]'); + + ylabel('magnitude [v_ {pp }]'); + + subplot(1,2,2); + + stem(a,c); + + xlabel('frequency [hz]'); + + ylabel('phase [pi]'); + + end +编辑:mduden于2016年1月6日上午11:16 以上来自于谷歌翻译 以下为原文 Well, I came with a solution. Here's the deal. But it gives a timeout error. +function userTest(start,stop,amp,data_points)+ +fgen = visa('AGILENT','GPIB0::10::INSTR');+ +set (fgen,'OutputBufferSize',100000);+ +fgen.Timeout=10;+ +fopen(fgen);+ +%MSO-2014A+ +mso = visa('AGILENT','GPIB0::7::INSTR');+ +set (mso,'OutputBufferSize',100000);+ +mso.Timeout=10;+ +fopen(mso);+ +%Query Idendity string and report+ +fprintf (fgen, '*IDN?');+ +idn = fscanf (fgen);+ +fprintf (idn)+ +fprintf ('nn')+ +%Query Idendity string and report+ +fprintf (mso, '*IDN?');+ +idn = fscanf (mso);+ +fprintf (idn)+ +fprintf ('nn')+ +%Clear and reset instrument+ +fprintf (fgen, '*RST');+ +fprintf (fgen, '*CLS');+ +%Clear and reset instrument+ +fprintf (mso,'*RST');+ +fprintf (mso,'*CLS');+ +fprintf(mso,':ACQuire:TYPE NORMal');+ +%Select the waveform shape, amplitude and offset+ +fprintf(fgen,'SOURCE1:FUNCTION SIN');+ +fprintf(fgen,'SOURCE1:VOLT:UNIT VPP');+ +fprintf(fgen,convertStrAmp(amp)');+ +%Select the frequency boundaries of the sweep+ +fprintf(fgen,convertStartFrq(start));+ +fprintf(fgen,convertStopFrq(stop));+ +%Select the sweep mode+ +fprintf(fgen,'SOURCE1:SWEEP:SPACING LINEAR');+ +%Set the sweep time in seconds.+ +fprintf(fgen,'SOURCE1:SWEEP:TIME 5');+ +%Select the sweep trigger source+ +fprintf(fgen,'TRIGGER1:SOURCE IMM');+ +%Enable Sweep State.+ +fprintf(fgen,'SOURCE1:SWEEP:STATE ON');+ +%Enable output.+ +fprintf(fgen,'OUTPUT1 ON');+ +a = start:(stop-start)/data_points:stop-1;+ +b = 1:1:data_points;+ +c = 1:1:data_points;+ +for j=1:1:data_points+ fprintf(mso,'MEASure:VAMPlitude CHAN2'); b(j) = str2double(query(mso,'MEASure:VAMPlitude?')); fprintf(mso,'MEASure:PHASe CHAN1,CHAN2'); c(j) = str2double(query(mso,'MEASure:PHASe? CHAN1, CHAN2')); pause(5/data_points) +end+ +%Enable Output+ +% fprintf(fgen,'OUTPUT ON'); % turn on channel 1 output+ +% Read Error+ +fprintf(fgen, 'SYST:ERR?');+ +errorstr = fscanf (fgen);+ +% error checking+ +if strncmp (errorstr, '+0,"No error"',13)+ +errorcheck = 'Waveform generated without any error n';+ +fprintf (errorcheck)+ +else+ +errorcheck = 'There is a error n';+ +fprintf (errorcheck)+ +end+ +%closes the visa session with the function generator+ +fclose(fgen);+ +delete(fgen);+ +fclose(mso);+ +delete(mso);+ +% disp(size(a));+ +% disp(size(b));+ +subplot(1,2,1);+ +stem(a,b);+ +xlabel('frequency [hz]');+ +ylabel('magnitude [v_{pp}]');+ +subplot(1,2,2);+ +stem(a,c);+ +xlabel('frequency [hz]');+ +ylabel('phase [pi]');+ +end+ Edited by: mduden on Jan 6, 2016 11:16 AM |
|
|
|
如果您收到超时错误,那么是时候进行一些调试以确定哪个命令不起作用。 在你这样做之前,你需要回到基础并停止SWEEPING! - 您可能会使用此代码获得某种曲线,但不会根据频率进行校准。 您将在“随机”时间获得结果,但您不会知道每次测量的捕获频率。 你需要知道这一点。 - 因为你的频率会不断变化,一个接一个地测量幅度和相位,然后平均会给你带来奇怪的,不好的结果。 每次测量都将以不同的频率进行,如上所述,您将不知道这些频率是什么,或者它们改变了多少。 - 知道输出幅度很大,但您也需要知道输入幅度。 您的电路可能具有不同的输入阻抗,这也会导致幅度发生变化。 - 我很确定您正在使用MEASURE命令和查询错误,但我没有2000系列范围来测试。 我的所有编程都是使用Infiniium示波器完成的。 您应该花一些时间使用Keysight I / O Libraries Suite的交互式I / O功能。 它允许您微调命令。 下载免费的Command Expert SW也可能很有用。 它还可以帮助您正确地获取代码,创建可以交互式测试的序列,然后直接导出到MATLAB脚本。 您正在尝试模拟VNA,为此,您需要了解VNA的工作原理。 这里有一些基本信息:http://www.keysight.com/main/redirector.jspx?action = ref& cname = EDITORIAL& ckey = 1000001258-1%3Aepsg%3Atcn& pl = eng& amp; cc = US& nfr = -11143.0.00这比你需要的多,但他们谈论的是放大器和滤波器的测试。 人 以上来自于谷歌翻译 以下为原文 If you're getting a timeout error, then it's time to do some debugging to figure out which command isn't working. Before you do that, you need to go back to basics and STOP SWEEPING! - You might get some sort of a curve with this code, but it won't be calibrated to frequency. You will get results at "random" times, but you won't know what frequency each measurement is captured at. You need to know that. - Because your frequency will be changing constantly, measuring amplitude and phase one after the other, and then averaging will give you strange, and bad results. Each measurement will be made at a different frequency, and, as I said above, you won't know what those frequencies are, or how much they change. - Knowing the output amplitude is great, but you need to know the input amplitude as well. Your circuit may have varying input impedance which will cause that amplitude to change as well. - I'm pretty sure that you are using the MEASURE commands and queries incorrectly, but I don't have a 2000 series scope to test with. All of my programming is done with Infiniium scopes. You should spend some time with the Interactive I/O feature of the Keysight I/O Libraries Suite. It allows you to fine-tune your commands. It might also be useful to download the free Command Expert SW. It will also help you get the code right, creating sequences that you can test interactively, then export directly to MATLAB scripts. You are trying to emulate a VNA, and to do that you need to learn how a VNA works. There's some basic information here: http://www.keysight.com/main/redirector.jspx?action=ref&cname=EDITORIAL&ckey=1000001258-1%3Aepsg%3Atcn&lc=eng&cc=US&nfr=-11143.0.00 It's more than you need, but they talk about testing amplifiers and filters. Al |
|
|
|
您的数据对我来说不对。 - 您没有说22uF帽是串联还是并联。 无论哪种情况,两个图都看错了。 - 目前还不清楚输出端是否有任何终止,或者它是否刚被探测过。 - 您需要将相位显示转换为展开阶段 - 只是在代码中加入延迟并不能保证示波器能够以精确的间隔进行测量。 范围获取命令,解析命令并获取数据需要一些时间。 这个过程有不同的延迟。 您的代码应如下所示: - 设置频率和幅度 - 以单一模式运行示波器若干次并测量输入和输出幅度,以及每次相位 - 再次执行此操作您还应运行模拟以查看 你的结果应该是什么样的。 人 以上来自于谷歌翻译 以下为原文 Your data looks wrong to me. - You don't say if the 22uF cap is in series or in parallel. In either case both graphs look wrong. - It's unclear if there is any termination on the output, or if it's just probed. - You need to convert your phase display to unwrapped phase - Just putting a delay in your code doesn't guarantee that the scope will make the measurements at exact intervals. It takes time for the scope to get the command, parse it, and get the data back. There are varying delays in this process. Your code should be as follows: - set a frequency and amplitude - run the scope in single mode some number of times and measure the input and output amplitudes, along with the phase each time - do it again You should also run a simulation to see what your results should look like. Al |
|
|
|
好的,非常感谢。 特别感谢您的耐心等待。 我还有一个问题:)考虑到您的步长和150欧姆电阻和22uF电容串联,是否可以为for循环中的电容创建复数阵列(阻抗)Z = R + jX? For loop将测量您提到的每个频率的电压,而不是扫描。 R =电阻值(DC),V(c)/ I,I可以测量环路中每次测量时的电流值,来自另一个电阻器100欧姆。 X =电抗= 1 /(2 * pi * f * c),将在每个频率测量。 在循环结束时,它将创建Z阵列,我想我可以绘制阻抗的幅度和相位的展开(角度(Z))和abs(Z)。 以上来自于谷歌翻译 以下为原文 Ok, thank you very much. Especially thank you for your patience. I have one more question :) Considering your step and 150 ohm resistor and 22uF capacitance in series, is it possible to create complex number array (impedance) Z = R + jX for capacitance in a for loop ? For loop will measure voltages at every frequency as you mentioned, not sweeped. R = resistor value (DC), V(c) / I, I can measure current value at every measurement in the loop from the other resistor 100 ohm. X = reactance = 1/(2*pi*f*c), will measure at every frequency. at the end of the loop, it will create Z array and I think I can plot unwrap(angle(Z)) and abs(Z) for magnitude and phase of impedance. |
|
|
|
60user196 发表于 2018-10-12 21:54 从理论上讲,可以做你想做的事。 在实践中,这很难。 每个器件,无论是电阻器,电容器还是电感器,都具有串联和并联的电阻,电容和电感。 即使是用于进行测量的电线和适配器也是如此。 您必须考虑用于进行测量的信号源和探头的复阻抗。 有很聪明的人非常努力地编写SW来进行这些计算。 有商业软件包,一些非常昂贵,将取得你的结果,并将它们变成最合适的模型。 请查看此范围探针手册,尤其是Performance Plots和Spice Models。 http://www.keysight.com/main/redirector.jspx?action=ref&cname=EDITORIAL&ckey=890537&lc=eng&cc=US&nfr=-34023.536894991.00我知道创建此数据的人 。 我知道如何解释他们创建的数据,但我无法创建这些图形和模型。 他们多年来一直这样做,并且仍然承认他们不知道他们应该知道多少。 人 以上来自于谷歌翻译 以下为原文 In theory, it is possible to do what you want. In practice, it's very hard. Every device, whether it's a resistor, capacitor or inductor, has resistance, capacitance, and inductance, both in series and in parallel. The same thing applies to even the wires and adapters that you use to make the measurement. You have to take into account the complex impedance of the signal source, and the probe, that you are using to make the measurement. There are very smart people who work very hard to write SW to make these calculations. There are commercial SW packages, some very expensive, that will take your results and turn them into a best fit model. Take a look at this scope probe manual, especially the Performance Plots and Spice Models. http://www.keysight.com/main/redirector.jspx?action=ref&cname=EDITORIAL&ckey=890537&lc=eng&cc=US&nfr=-34023.536894991.00 I know the guys who created this data. I know how to interpret the data they create, but there's no way I could create these graphs and models. They have been doing this for years, and still admit that they don't know as much as they should. Al |
|
|
|
好的,我明白了,感谢您的留言和帮助。 我会考虑这个。 以上来自于谷歌翻译 以下为原文 Ok, I got it, thanks for your messages and help. I'll consider this. |
|
|
|
只有小组成员才能发言,加入小组>>
1229 浏览 0 评论
2350 浏览 1 评论
2160 浏览 1 评论
2026 浏览 5 评论
2908 浏览 3 评论
973浏览 1评论
关于Keysight x1149 Boundary Scan Analyzer
707浏览 0评论
N5230C用“CALC:MARK:BWID?”获取Bwid,Cent,Q,Loss失败,请问大佬们怎么解决呀
808浏览 0评论
1230浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-25 19:35 , Processed in 1.695194 second(s), Total 104, Slave 87 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号