Allow output voltage to be ramped on Keysight PS
This commit is contained in:
@ -21,13 +21,26 @@ driver keysight_N8740A = {
|
||||
units = 'V';
|
||||
}
|
||||
var setpoint = {
|
||||
readable = 1; read_command = 'SOURCE:VOLTAGE?';
|
||||
writeable = 1; write_command = 'SOURCE:VOLTAGE ';
|
||||
driveable = setpoint;
|
||||
tolerance = 1;
|
||||
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;
|
||||
@ -76,4 +89,71 @@ driver keysight_N8740A = {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user