I ve been trying to control PNA over GPIB interface using IC-CAP.
For start frequency settings i give the following set of commands:
PNA = 16
fn = HPIB_open("gpib0")
dum = HPIB_write(fn,PNA,"SENS:FREQ:STAR 2GHz")
dum = HPIB_close(fn)
It works and start frequency is set on PNA.
Problem is that when i try to take the frequency value from the user and send to PNA it gives the error.
Following set of commands is used:
PNA = 16
fn = HPIB_open("gpib0")
LINPUT "Enter Start Frequency","1GHz", freq
dum = HPIB_write(fn,PNA,"SENS:FREQ:STAR freq")
dum = HPIB_close(fn)
The error which appears on PNA screen is "illegal parameter value" error number-224
Please suggest the solution.
For start frequency settings i give the following set of commands:
PNA = 16
fn = HPIB_open("gpib0")
dum = HPIB_write(fn,PNA,"SENS:FREQ:STAR 2GHz")
dum = HPIB_close(fn)
It works and start frequency is set on PNA.
Problem is that when i try to take the frequency value from the user and send to PNA it gives the error.
Following set of commands is used:
PNA = 16
fn = HPIB_open("gpib0")
LINPUT "Enter Start Frequency","1GHz", freq
dum = HPIB_write(fn,PNA,"SENS:FREQ:STAR freq")
dum = HPIB_close(fn)
The error which appears on PNA screen is "illegal parameter value" error number-224
Please suggest the solution.
The error relates to inclusion 'freq' variable inside the quote marks of string sent to PNA.
At the moment, in the IC-CAP PEL, 'freq' is a string and not a number, and what is being sent in quote marks to the instrument is being sent 'literally', i.e. the PNA is receiving "... STAR freq", not ".. STAR 1GHz" as is intended.
The code used was:
LINPUT "Enter Start Frequency","1GHz", freq
dum = HPIB_write(fn,PNA,"SENS:FREQ:STAR freq")
Suggestion for the dum= line:
dum=HPIB_write(fn,PNA,"SENS:FREQ:STAR "&freq )
(as long as freq is not also in a variable table.. if it is, then use "&val$(freq) because if it is also in a variable table then it will be interpreted as a number and one cannot concantenate a string with a numeric via the "&". )
(the & is used to concatenate strings)
NOTE: it is not always transparent to know if a variable is a string or numeric in a particular context. IC-CAP has the functions val() and val$() which enable the user to set/control the casting.
Small PEL example:
value=0
linput "enter value",2,value
print "value is",value ! type is string
print "val$(value) is",val$(value) ! type is string
print "val(value) is ", val(value) ! type is numeric
print "val(value)+val(value) is", val(value)+val(value)
The output to Status Window for this will be:
value is 2
val$(value) is 2
val(value) is 2
val(value)+val(value) is 4
For the first 2 print statements, a string is being printed. In the 3rd print statement, a numeric value is being printed and one can perform 'math' operations with it, like addition etc.
If one were to do:
print value+value or
print val$(value)+val$(value)
i.e. attempt to do 'math' functions in cases where 'value' is 'string' type not numeric, an error would be reported.
(NOTE: this example is for the case where 'value' is not also defined in a Variable Table)
Summary recommendations:
1. note/check if a variable is a string or a numeric
2. check if the variable is defined in a variable table
3. use val() val$() as appropriate..
Best Regards
Else