Test and Measurement Instrument control using PHP

Sunday, December 11th, 2011

There are various ways of remote controlling instruments such as remote desktop or VNC for getting access to the screen but often you want it to do something specific in an automated way. Many people use tools such as Labiew or even full on programming languages like Visual C, C#, VB etc with drivers (VXI or LXI) to achieve robust production solutions. Often when I am asked by customers to assist with some remote control, I turn to a web scripting language called PHP. Its not the normal scripting language people think of for instrument remote control but it has some benefits for me:

  1. It has socket support allowing control to port 5025 by sending SCPI commands as ASCII to write commands and read results.
  2. Its fast to develop, is very much like C but with simplicity.
  3. Has built in support for Regular Expressions and Text Parsing meaning string manipulation is quick and easy.
  4. As I’m familiar with the language I can knock up scripts quickly and send the SCPI command sequence to the customer.
  5. It can be used with a web server. There are possibilities with PHP to build a scaleable instrument remote control solution that is becomes a web application, meaning easy control of instruments just by logging onto a website.
  6. If required a complex system could be developed to easily store and recall results from a MySQL back end.

Of course there are other languages that could be used and are often used by customers such as Perl or Python to achieve the above tasks, I just happen to get on with PHP.

A simple example might be something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Allow the script to hang around waiting for connections
set_time_limit (0);
 
$fsq_ip_address = '192.168.1.2';
$port = 5025; 
 
// open socket to instrument 
$fsq= fsockopen ($fsq_ip_address, $port, $errno, $errstr, 10); 
 
// open the output file for results 
$fp = fopen ("output.txt", "w+"); 
 
// query instrument for its details and output result 
writescpi($fsq, "*IDN?"); 
$result = readscpi($fsq); 
logger("Instrument: " . $result); 
 
// close sockets and file 
fclose ($fsq);
fclose ($fp); 
 
// Function Definitions 
// Write string to the socket (output errors if debug enabled) 
function writescpi($inst, $msg) 
{ 	
  global $debug; 	
  fputs ($inst, $msg . "\n");
 
  if ($debug == true) 	
   { 	        
    print ("\nCmd: " . $msg); 		
    fputs ($inst, "syst:err?\n"); 		
    $result = readscpi($inst); 		
    print ("Result: " . $result . "\n"); 	
  } 
} 
 
// Read string from the socket 
function readscpi($inst) 
{ 	
  $buf = fgets ($inst,100000); 	
  $buf = trim ($buf); 	
  return $buf; 
} 
 
// output to screen and to file at the same time 
function logger($result) 
{ 	
  global $fp; 	
  print ($result . "\n"); 	
  fwrite ($fp, $result); 
}
Post Tags: » » »

The highest performance spectrum analyzer ever – R&S FSW

Friday, September 30th, 2011

Rohde and Schwarz FSW high performance spectrum analyzerWhen we talk about spectrum analysis what do we consider the most important aspects? Normally it depends on whether your background is based on time domain (scopes) or frequency domain measurements.

The scope guys will tell you bandwidth is everything so you can see the smallest glitch in a time domain signal. If you want to inspect all the detail possible in the frequency domain a spectrum analyzer is really the only tool you really should be using.  The frequency domain guys will tell you its all about dynamic range (spurious free dynamic range) and phase noise performance.

Without these aspects it is not possible to get the detail required on the smallest spurs that may be created in a device under test. Or to characterise distortion performance of amplifiers with precision. Scope A/D converters have very wide bandwidth but do not have the resolution or spurious free dynamic range required to create an accurate picture of spurious and other phenomena in the frequency domain.

With this in mind, R&S has released what is seen as the highest performance spectrum analyzer ever to the market and below is an overview of what makes it so high performance, and why it is important for measurement tasks in the frequency domain.

R&S FSW Performance Overview – all the important points that make it the highest performing spectrum analyzer ever

Continue reading » » The highest performance spectrum analyzer ever – R&S FSW

Post Tags: » » » »

R&S FSV gets noise correction as free of charge upgrade

Saturday, August 13th, 2011

The latest 1.61 SP2 firmware for the R&S FSV Signal Analyzer sneakily included noise correction as a free of charge upgrade. This functionality is normally reserved for high end instruments as it gives an improvement in dynamic range for any given resolution bandwidth and allows measurements of signals close to the noise floor of an analyzer. Our previous post on this topic explains how this works and also gives information on R&S application note 1EF76: Improved Dynamic Range with Noise Correction. If I get time and happen to grab some screen shots in the coming weeks I’ll make sure I post them to give you an idea of what it looks like on the FSV.

Post Tags: » »

Spectrum Analyzer Noise Correction for Increased Dynamic Range

Tuesday, July 19th, 2011

In a previous post we talked about noise figure and how ultimately thermal noise limits the performance of a spectrum analyzer. This limits our ability to see signals that would be in the noise floor of the analyzer. For quite some time it has been possible to “remove” the noise of a spectrum analyzer from the measurement to give an improved dynamic range. This can be extremely useful when trying to view spurs or improve channel power measurements and can give the user a significant performance increase (depending on settings) and allow us to measure almost to the thermal limit of -174dBm/Hz at lower frequencies (1GHz).

Sometimes it may be difficult to measure spurs due to them being such low power and also the power of a carrier being fed into the analyzer which may have the effect of over driving the input. The input signal may also be pulsed (as in this case) which means a longer sweep time is needed to see the whole spectrum. The challenge here is the trade off in resolution bandwidth, sweep speed and dynamic range.

The plot below shows the noise floor of spectrum analyzer with noise correction disabled and a normalised noise floor (1Hz RBW) of around -135dBm/Hz at the 11.5GHz center frequency. In this application we still want to see the peak of our input signal and do a relative measurement between the peak and any spurs or the noise floor, hence the use of delta markers on the screen.

Continue reading » » Spectrum Analyzer Noise Correction for Increased Dynamic Range

Post Tags: » » »

R&S RTO Oscilloscope has Spectrum Analyser Sensitivity

Thursday, June 30th, 2011

After some time playing with the RTO Richard and I decided to take a look at how it performed as a Spectrum Analyser.  When traditional oscilloscopes produce an FFT of the incoming time domain signal, they simply FFT the time domain samples produced. This means, the maximum resolution obtainable for a scope with an 8 bit A/D would be 8 bits. Traditional scopes also require you to set individual FFT parameters such as FFT size, record length, sample rates etc. As a user of a spectrum analyser its much more likely the person will want to set a span, center frequency and resolution bandwidth to gain instant information on the signal of interest.

Continue reading » » R&S RTO Oscilloscope has Spectrum Analyser Sensitivity

Post Tags: » »