Keysight Power Supply/SCPI


Recommended Posts

Was wondering if anyone had used DAQFactory with any Keysight instruments or instruments that use SCPI code. I am using a power supply and want the voltage to be equal to the control variable in a PID loop, and I also want to be able to use MEASure to measure the current (although that one isn't as important). I have some ideas about using python along with DAQFactory but would be interested if anyone had any other ways they figured it out. :)

Link to comment
Share on other sites

  • 2 weeks later...

BUMP - Also interested in this topic. I have an upcoming project that I would like to use DaqFactory for reading analog inputs and it would be great if I could also use an additional serial comm port with an SCPI. Are there any examples or support for this? I don't see this as a selectable protocol 

Link to comment
Share on other sites

We don't have built in support for this protocol, but it is a rather simple ASCII protocol so easy for you to implement in script.  In fact, you can manually type in commands in the command/alert window, just remember that you have to send either a carriage return, or a carriage return / line feed combo depending on what the device requires.  I would start with just a CR, which you can do at the command alert window using \013.  I found all the commands on the keysight website: 

https://na.support.keysight.com/pxi/help/latest/Programming/GP-IB_Command_Finder/SCPI_Command_Tree.htm

but I am not familiar with your devices so do not know exactly which commands you would want.  But as an example, it looks like if you wanted to turn the RF power on and off you would use the OUTP command, so in the command alert window you would type:

OUTP ON\013

to turn it on.

To query the current state it would be:

OUTP?\013

I'm not quite clear what the response would be, but I am guessing it would be, say:

1\013

if on.

To do this all from script requires very little more.  Instead of \013 you'd have to use chr(13), so to set the output on using script for device "myDevice" you would do:

device.myDevice.write("OUTP ON" + chr(13))

and to read the status you would do:

private string in
device.myDevice.write("OUTP?" + chr(13))
in = device.myDevice.readUntil(13)
global RFPower = strToDouble(in)

This assumes that the device just returns a CR and not a CRLF.  If it returns, say:

1\013\010

then the readUntil() function should be readUntil(10).

Those are the first two steps I take whenever writing protocol scripts: first I try manually reading and controlling the device from the command alert window so that I can check that I am understanding the device documentation correctly (and device documentation is often vague and even incorrect).  Then I'll write some short sequences to do one task.  

Once I have that all figured out, I can then add functions for all the desired commands.  You can do these as separate sequences if you just have a few, or create a class to combine them into one, maybe something like:

class CSCPI
   function RFOnOff(val)
      device.myDevice.purge()
      device.myDevice.write("OUTP " + val + chr(13))
   endfunction

   // etc.
endclass

global SCPI = new(CSCPI)

Then to access a function within the class it would be, for example:

SCPI.RFOnOff(1)

Note that any time you modify the script you will need to rerun that sequence to update the class.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.