Contact an Expert

Thread: Problems when using matlab to connect Agilent scope with multi-channels


Permlink Replies: 1 - Pages: 1 - Last Post: May 22, 2012 6:39 AM Last Post By: algoss Threads: [ Previous | Next ]
lixiaozhou222

Posts: 14
Registered: 09/27/11
Problems when using matlab to connect Agilent scope with multi-channels
Posted: May 20, 2012 11:36 PM
Click to report abuse...   Click to reply to this thread Reply
Dear everyone,
I am using matlab to connect Agilent 9000X scope, I have two signals connected to CH1 and CH2, respectively.
My purpose is to get data from both 1 and 2 channel using matlab.

When I use the following script to read data from a single channel CH1, it works well.

fprintf(obj1,':DIGITIZE CHANNEL1');
fprintf(obj1,':WAVEFORM:SOURCE CHANNEL1');
fprintf(obj1,':WAVEFORM:FORMAT BYTE');
fprintf(obj1,':WAVEFORM:DATA?');
A=binblockread(obj1,'int8');

But the problem is, if I change CH1 to CH2, then warning is, ''a time out occured before binblockread.''

fprintf(obj1,':DIGITIZE CHANNEL2');
fprintf(obj1,':WAVEFORM:SOURCE CHANNEL2');
fprintf(obj1,':WAVEFORM:FORMAT BYTE');
fprintf(obj1,':WAVEFORM:DATA?');
A=binblockread(obj1,'int8');

NOTE that I just read a single channel in the previous 2 cases.
Why does that happen? I just change 'CHANNEL1' to 'CHANNEL2', and nothing else is different.....
Thank you for kind help!

By the way, If I want to read data from CH1 and CH2 the same time, could I run it like this:

fprintf(obj1,':DIGITIZE CHANNEL1');
fprintf(obj1,':WAVEFORM:SOURCE CHANNEL1');
fprintf(obj1,':WAVEFORM:FORMAT BYTE');
fprintf(obj1,':WAVEFORM:DATA?');
A=binblockread(obj1,'int8');

fprintf(obj1,':DIGITIZE CHANNEL2');
fprintf(obj1,':WAVEFORM:SOURCE CHANNEL2');
fprintf(obj1,':WAVEFORM:FORMAT BYTE');
fprintf(obj1,':WAVEFORM:DATA?');
B=binblockread(obj1,'int8');

Or in this way:

fprintf(obj1,':DIGITIZE CHANNEL');

fprintf(obj1,':WAVEFORM:SOURCE CHANNEL1');
fprintf(obj1,':WAVEFORM:FORMAT BYTE');
fprintf(obj1,':WAVEFORM:DATA?');
A=binblockread(obj1,'int8');

fprintf(obj1,':WAVEFORM:SOURCE CHANNEL2');
fprintf(obj1,':WAVEFORM:FORMAT BYTE');
fprintf(obj1,':WAVEFORM:DATA?');
B=binblockread(obj1,'int8');

In what way can I make sure CH1 and CH2 are read synchronously?

Well, we still need to solve the 'time out' problem at first.

Edited by: lixiaozhou222 on May 20, 2012 11:37 PM

Edited by: lixiaozhou222 on May 20, 2012 11:43 PM

Edited by: lixiaozhou222 on May 20, 2012 11:44 PM

algoss


Posts: 594
Registered: 11/03/06
Re: Problems when using matlab to connect Agilent scope with multi-channels
Posted: May 22, 2012 6:39 AM   in response to: lixiaozhou222 in response to: lixiaozhou222
Click to report abuse...   Click to reply to this thread Reply
I have a few comments:

  • You need to take a look at the manual, specifically the section about "DIGITIZE". That command, with a channel parameter, will cause the scope to capture data only on that channel. The command, without a parameter, will capture data on all channels that are turned on. You can turn channels on and off with separate commands. That will resolve the issue of taking synchronous data on 2 channels.

  • You have not defined a trigger channel in your code, that I can see. You are probably using Autotrigger. If the scope doesn't see a valid trigger within a certain time, it forces a trigger. Because this is not a "real" trigger, the DIGITIZE command is still waiting for a trigger. You need to turn off Autotrigger, and make sure that you can, manually, get your scope to trigger reliably on your signal. While you're looking at the manual, look at the section on "Synchronization". Becasue the DIGITIZE command is a macro, it has certain limitations, and you are better off using "Polling Synchronization".

  • Use Channels 1 and 3 if possible, rather than 1 and 2. I don't know exactly which scope you are using, but on many Agilent scopes, the scope will switch to a slower sampling mode if you are using both even and odd channels

  • Lastly, as I have said before. STOP USING THE 8 BIT DATA. IT IS LESS ACCURATE AND WILL GIVE YOU INCORRECT RESULTS. I'm sorry to yell, but I think that we have had this discussion before.

Al

Point your RSS reader here for a feed of the latest messages in all forums