Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending SCPI commands to a Rohde and Schwarz FSL via VISA using TCL scripts

Hi,

 

I am a newbie at TCL programming. I wish to automate test cases for a Rhode and Schwarz FSL. As of now I can send individual SCPI commands using the NI-VISA sessions.

 

I need to now write TCL scripts which can pass the SCPI commands to the FSL.

 

Please help me how to go about doing this. Any sort of help/advice will be great 🙂

 

Thanks

 

Rohit

0 Kudos
Message 1 of 5
(8,533 Views)

Hi Rohit,

 

the only thing I can offer you are VXIPnP Instrument Driver which are using VISA for programming in C/C++/etc, but using TCL is from my point of view quite rar.

 

Regards Juergen

 

 

Message 2 of 5
(8,522 Views)

i used the following code from the visa manual

 

#include "visa.h"
#define MAX_CNT 200
int main(void)
{
ViStatus status; /* For checking errors */
ViSession defaultRM, instr; /* Communication channels */
ViUInt32 retCount; /* Return count from string I/O */
ViChar buffer[MAX_CNT]; /* Buffer for string I/O */
/* Begin by initializing the system*/
status = viOpenDefaultRM(&defaultRM);
if (status < VI_SUCCESS) {
/* Error Initializing VISA...exiting*/
return -1;
}
/* Open communication with GPIB Device at Primary Addr 1*/
/* NOTE: For simplicity, we will not show error checking*/
status = viOpen(defaultRM, "GPIB0::1::INSTR", VI_NULL, VI_NULL,
&instr);
/* Set the timeout for message-based communication*/
status = viSetAttribute(instr, VI_ATTR_TMO_VALUE, 5000);
/* Ask the device for identification */
status = viWrite(instr, "*IDN?\n", 6, &retCount);
status = viRead(instr, buffer, MAX_CNT, &retCount);
/* Your code should process the data */
/* Close down the system */
status = viClose(instr);
status = viClose(defaultRM);
return 0;
}

 

 

I have added the header files from the include folder in the VXIPNP folder, still on compiling it in Dev c++ it gives me linker error when i execute it as a C source. When i execute it as a C++ code i get "invalid conversion from `const char*' to `ViByte*'  " on line 22.

 

What should i do. Is there any other compiler i should use?

0 Kudos
Message 3 of 5
(8,502 Views)

please download the RsSpecAn VXIPnP driver and  the Read Trace Example and have a look into the source code. (http://www2.rohde-schwarz.com/product/FSL.html)

 

your posted problem exists a simple solution (as referring to the example):

 

#include <visa.h>

#include "rsspecan.h"

 

...

/* initialize driver */   //implies opening a visa session

 rsspecan_init (instr_desc, id, reset, &instrSession)

 ...

 

hope that helps?

regards juergen

0 Kudos
Message 4 of 5
(8,497 Views)

hi Rohit

 

If your device has a serial port or Ethernet port you can simply do this in Tcl

 


 

#For a socket do set sd [ socket <ip> <port> 

#fconfigure $sd -blocking 0 

 

set fd [ open com1 RDWR]

fconfigure $fd -mode 9600,n,8,1 -blocking 0 

 

puts $fd "*IDN?

flush $fd

 

puts [read $fd]

 

etc..

 

For GPIB ports only get an NI card or USB to GPIB device.

Install the GPIB-tcl package

 

Then read the GPIB-tcl docs.

 

 

Controlling SCPI based devices wtih TCL is trivial, probably the same with a lot of scripting languages, no need to compile code to talk to instruments,thats just crass!

 

Derek 

0 Kudos
Message 5 of 5
(8,269 Views)