MATLAB Answers

Vicipn
0

Test & Measurement tool (tmtool): calling two or more channels in readwaveform

Asked by Vicipn
on 4 Mar 2011
I've connected a Tektronix oscilloscope over USB connections (DPO4104 and TDS2012B). I need to export data by the two channels of the TDS 2012B and when I connect the DPO4104 I need to get data for the 4 channels. But I can't do it. I select the readwaveform function but I don´t know how to call all channels.
My question is: How can I call two or more channels in the readwaveform function? I've been trying this:
Input argument(s): 'channel1', 'channel2', 'channel3', 'channel4'.
I hope that you can help me.

  0 Comments

Sign in to comment.

3 Answers

Answer by Walter Roberson
on 4 Mar 2011
 Accepted Answer

Sorry, no, only a single channel at a time is supported (I read the Tek tds2014 instrument control driver source to check.)

  0 Comments

Sign in to comment.


Answer by Ankit Desai on 1 Apr 2011

If you don't mind writing a little MATLAB code, you can open the MATLAB Instrument Driver in midedit tool and add your own, custom readwaveform function that does what you want.
1. midedit('tektronix_tds2014.mdd')
2. Navigate to Waveform>readwaveform
3. Look at the SCPI commands used to read waveform from one channel
4. Add your own function by right clicking "Waveform" node
5. Add the SCPI commands for the function you want
The online documentation on the same might help too.
Here's complete detail on using midedit.
Hope this helps.
-Ankit

  1 Comment

Thank´s i do exactly that and it´s work, now my problem is control the trigger of the osciloscope I don´t know how to do that. If you can help me I appreciate. See you and Good Look

Sign in to comment.


Answer by Helga
on 2 Jan 2012

I tried to write a new function for the driver, but it didn't work because it seems that this function
_fprintf(interface,['DATA:SOURCE ' trueSource]);_
doesn't allow two or more channels.
This is the code I wrote for more channels:
_fprintf(interface,['DATA:SOURCE ' trueSource ', ' trueSource2]);_
But when I check with query(interface, 'DATA:SOU?') I only see the first channel.
Has anybody solved this problem already?

  1 Comment

Hi there sorry for answered till this moment. Look, the main problem with the communication it´s the limitation for the data transport, the first thing that you must chek is the transfer, then the visa address and the visa brand (for example 'tek'). When you solve this, yau can do somthing like this:
dpo = visa(visa_brand,visa_address,'InputBufferSize',buffer,'OutputBufferSize',buffer);
fopen(dpo);
query(dpo,'*idn?;')
query(dpo,'*esr?;')
if ans ~= '0'
query(dpo,':allev?;')
end
% Obtención del estado del osciloscopio
head = query(dpo,':head?;');
head = head(end-1);
%verb = query(dpo,':verb?;');
%verb = verb(end-1);
fwrite(dpo,':head 0;*cls;');
[lrn_str bytes warning] = query(dpo,'*lrn?;');
%save dpo4k_spi.lrn lrn_str -ASCII %doesn't work, numerical data
fid = fopen('dpo4k_spi.lrn', 'wt');
fprintf(fid,lrn_str,'%s');
fclose(fid);
Note that it´s important open and close your fid, if you don´t do it, perhaps your program doesn´t work.
now, you can ask the equipment what does have in each channel, using something like this:
% for example channel 1 (ch1)
query(dpo,':data:source ch1;:data?;')
query(dpo,':wfmo?;')
query(dpo,':data?;')
reco1 = query(dpo,':hor:reco1?;'); % find length
fwrite(dpo,[':data:start 1;stop ' reco1(1:end-1) ';']);
% Getting vertical information
% Ch 1
yof1 = query(dpo,':wfmo:yof1?;','%s','%E');
ymu1 = query(dpo,':wfmo:ymu1?;','%s','%E');
yze1 = query(dpo,':wfmo:yze1?;','%s','%E');
% getting horizontal information
% Ch 1
nrp1 = query(dpo,':wfmo:nr_p1?;','%s','%E');
xin1 = query(dpo,':wfmo:xin1?;','%s','%E');
xze1 = query(dpo,':wfmo:xze1?;','%s','%E');
fwrite(dpo,':curve?;');
wave1 = int8(binblockread(dpo,'int8'));
scaled_wave1 = (double(wave1)-yof1).*ymu1+yze1;
scaled_time1 = linspace(xze1,xze1+(xin1*nrp1),nrp1);
Finaly, ypu can plot the scaled wave data with tha scaled time data, for that you can use the stairs command or plot command
This is only for the Cahnnel 1, you must repeat for the other chanels in your MATLAB code. If you´re using a Tektronix Osciloscope, you can chek thier page for more information and a little examples for control using MATLAB software.
Hope this may be usefull for you, please tell me about it. Have a nice day and keep walking forward

Sign in to comment.