160 lines
5.1 KiB
Plaintext
160 lines
5.1 KiB
Plaintext
# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent
|
|
driver keysight_N8740A = {
|
|
vendor = keysight; device = N8740A;
|
|
protocol = std
|
|
class = instrument
|
|
simulation_group = environment_simulation
|
|
group = {
|
|
type = int;
|
|
var output_enable = {
|
|
readable = 2; read_command = 'OUTPUT:STATE?';
|
|
writeable = 1; write_command = 'OUTPUT:STATE ';
|
|
allowed = '0,1';
|
|
}
|
|
type = float;
|
|
var amps = {
|
|
readable = 1; read_command = 'MEASURE:SCALAR:CURRENT:DC?';
|
|
units = 'A';
|
|
}
|
|
var volts = {
|
|
readable = 1; read_command = 'MEASURE:SCALAR:VOLTAGE:DC?';
|
|
units = 'V';
|
|
}
|
|
var setpoint = {
|
|
readable = 1; fetch_function = read_setpoint; read_command = 'SOURCE:VOLTAGE?';
|
|
writeable = 1; write_function = write_setpoint; write_command = 'SOURCE:VOLTAGE ';
|
|
driveable = working_setpoint;
|
|
tolerance = 1; property settle_time = 5;
|
|
lowerlimit = 0; upperlimit = 150;
|
|
units = 'V';
|
|
}
|
|
var ramp_rate = {
|
|
type = float;
|
|
value = 1.0;
|
|
units = 'V/S';
|
|
writeable = 1; write_function = write_direct;
|
|
lowerlimit = 0; upperlimit = 15;
|
|
}
|
|
var working_setpoint = {
|
|
type = float;
|
|
readable = 1; read_command = 'SOURCE:VOLTAGE?';
|
|
writeable = 1; write_function = write_direct;
|
|
units = 'V';
|
|
}
|
|
}
|
|
group current = {
|
|
type = float;
|
|
var prot_enable = {
|
|
type = int;
|
|
readable = 1; read_command = 'SOURCE:CURRENT:PROTECTION:STATE?';
|
|
writeable = 1; write_command = 'SOURCE:CURRENT:PROTECTION:STATE ';
|
|
allowed = '0,1';
|
|
}
|
|
var prot_limit = {
|
|
readable = 1; read_command = 'SOURCE:CURRENT?';
|
|
writeable = 1; write_command = 'SOURCE:CURRENT ';
|
|
lowerlimit = 0; upperlimit = 22;
|
|
units = 'A';
|
|
}
|
|
}
|
|
group voltage = {
|
|
type = float;
|
|
var lolimit = {
|
|
readable = 1; read_command = 'SOURCE:VOLTAGE:LIMIT:LOW?';
|
|
writeable = 1; write_command = 'SOURCE:VOLTAGE:LIMIT:LOW ';
|
|
units = 'V';
|
|
}
|
|
var hilimit = {
|
|
readable = 1; read_command = 'SOURCE:VOLTAGE:PROTECTION?';
|
|
writeable = 1; write_command = 'SOURCE:VOLTAGE:PROTECTION ';
|
|
lowerlimit = 0; upperlimit = 165;
|
|
units = 'V';
|
|
}
|
|
}
|
|
group system = {
|
|
type = text;
|
|
data = false; control = false; mutable = false; nxsave = false;
|
|
var ident = {
|
|
readable = 15; read_command = '*IDN?';
|
|
}
|
|
var error = {
|
|
readable = 1; read_command = 'SYSTEM:ERROR?';
|
|
}
|
|
var version = {
|
|
readable = 15; read_command = 'SYSTEM:VERSION?';
|
|
}
|
|
}
|
|
code setValue = {
|
|
@TCL
|
|
set cmd "${cmd_str}${par}@@NOREPLY@@"
|
|
@END
|
|
}
|
|
code write_direct = {
|
|
@TCL
|
|
set cmd "@@NOSEND@@"
|
|
sct result ""
|
|
if { [sct target] != [sct oldval] } {
|
|
debug_log ${tc_root} 1 "[sct] changed to new:[sct target], from old:[sct oldval]"
|
|
sct oldval [sct target]
|
|
sct update [sct target]
|
|
sct utime readtime
|
|
}
|
|
@END
|
|
}
|
|
code write_setpoint = {
|
|
@TCL
|
|
set cmd "@@NOSEND@@"
|
|
sct result ""
|
|
sct ramp_start_time [sct utime]
|
|
sct ramp_start_value [hval ${tc_root}/working_setpoint]
|
|
sct ramp_rate_value [hval ${tc_root}/ramp_rate]
|
|
if { [sct target] != [sct oldval] } {
|
|
debug_log ${tc_root} 1 "[sct] changed to new:[sct target], from old:[sct oldval]"
|
|
sct oldval [sct target]
|
|
sct update [sct target]
|
|
sct utime readtime
|
|
}
|
|
@END
|
|
}
|
|
code read_setpoint = {
|
|
@TCL
|
|
if { [hpropexists [sct] target] } {
|
|
set target [sct target]
|
|
if { [hval ${tc_root}/working_setpoint] != ${target} } {
|
|
set elapsed_time [expr {[sct utime] - [sct ramp_start_time]}]
|
|
debug_log ${tc_root} 1 "read_setpoint elapsed_time = ${elapsed_time}"
|
|
if {[hpropexists [sct] ramp_rate_value] && [sct ramp_rate_value] > 0.0} {
|
|
set ramped_value [expr {[sct ramp_rate_value] * ${elapsed_time}}]
|
|
debug_log ${tc_root} 1 "read_setpoint ramped_value = ${ramped_value}"
|
|
if { ${target} > [hval ${tc_root}/working_setpoint] } {
|
|
set working_setpoint [expr {[sct ramp_start_value] + ${ramped_value}}]
|
|
debug_log ${tc_root} 1 "read_setpoint working_setpoint+ = ${working_setpoint}"
|
|
if { ${working_setpoint} > ${target} } {
|
|
set working_setpoint ${target}
|
|
}
|
|
} else {
|
|
set working_setpoint [expr {[sct ramp_start_value] - ${ramped_value}}]
|
|
debug_log ${tc_root} 1 "read_setpoint working_setpoint- = ${working_setpoint}"
|
|
if { ${working_setpoint} < ${target} } {
|
|
set working_setpoint ${target}
|
|
}
|
|
}
|
|
} else {
|
|
set working_setpoint ${target}
|
|
debug_log ${tc_root} 1 "read_setpoint working_setpoint = ${working_setpoint}"
|
|
}
|
|
if {![hpropexists [sct] ramp_rate_value] || [sct ramp_rate_value] != [hval ${tc_root}/ramp_rate]} {
|
|
sct ramp_start_time [sct utime]
|
|
sct ramp_start_value [hval ${tc_root}/working_setpoint]
|
|
sct ramp_rate_value [hval ${tc_root}/ramp_rate]
|
|
}
|
|
set cmd "SOURCE:VOLTAGE ${working_setpoint}@@NOREPLY@@"
|
|
sct result [hval ${tc_root}/working_setpoint]
|
|
}
|
|
} else {
|
|
# cmd is fine
|
|
}
|
|
@END
|
|
}
|
|
}
|