Thread Subject: Instrument Control Toolbox help needed

Subject: Instrument Control Toolbox help needed

From: Charles Reel

Date: 3 Feb, 2012 17:38:19

Message: 1 of 2

Hi all,
I am moderately experienced with MATLAB, but I'm brand new to the Instrument Control Toolbox and the world of automated instrument/test equipment control.

What I am trying to do is use SCPI (Standard Commands for Portable Instruments) commands in conjunction with MATLAB to control an Agilent/HP E3631 triple output power supply.

Specifically what I need to do is set an initial voltage out of the +25V output and then increment that voltage using a loop.

The standard command for setting the output I'm referring to is
Apply (P25V, <voltage>,<current>); using SCPI in conjunction with MATLAB you use the command fprintf(obj1, 'Apply P25v,<voltage>,<current>'); so what you are doing is printing a string as far as MATLAB is concerned.

I get that and it works fine, but it's expecting specific numeric values for <voltage> and <current>. What I need to do is make <voltage> a variable that I can increment in a loop.

I tied the following as an experiment; it assumes that communication with the power supply has been established and that the power supply is obj1 which all works fine. It is supposed to initially set the output of the +25V output to 0VDC and then incrementally increase that voltage to 7.5V in (15) .5V steps.

i=1
x=0
for i = 1:15;
    %fprintf(obj1, 'Apply P25v,x,1.0');
    x=x+.5
    i=i+1
end

The “for-loop” in and of itself works fine, so the question becomes, “Can I substitute a variable for one of the parameters in the SCPI command?”

The power supply does not like the x where it is expecting a numeric value for <voltage>.

Can anyonegive me guidance or at least point me in an approriate direction?

Subject: Instrument Control Toolbox help needed

From: dpb

Date: 3 Feb, 2012 17:46:03

Message: 2 of 2

On 2/3/2012 11:38 AM, Charles Reel wrote:
...

> i=1
> x=0
> for i = 1:15;
     cmd=sprintf('Apply P25v,',%f.1,',1.0',x);
     fprintf(obj1, cmd);

...

> The “for-loop” in and of itself works fine, so the question becomes,
> “Can I substitute a variable for one of the parameters in the SCPI
> command?”
> The power supply does not like the x where it is expecting a numeric
> value for <voltage>.
>
> Can anyonegive me guidance or at least point me in an approriate direction?

See above for one solution...

BTW, I'd recommend against using 'i (and j)' for loop indices in
Matlab--by default they are the complex i, j and overloading them will
haunt at some time when do want/need complex variables.

--

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com