Guard against misinterpreting readings that have a leading zero as octal.
Set the current to the target value when we're within one step rather than within tolerance to avoid undershooting the target. Do not try and get the state when initialising the driver because it will fail to create the driver properly if the RF generator is unavailable on SICS startup. The current is zero when the RF gen is power cycled so it is safe to set the current reading and target current as zero in initialisation so we just set the operating frequency and everything else is left at zero. r3228 | ffr | 2011-06-26 12:18:27 +1000 (Sun, 26 Jun 2011) | 3 lines
This commit is contained in:
committed by
Douglas Clowes
parent
edc7639d65
commit
6b1c629a43
@@ -176,7 +176,8 @@ proc ::scobj::rfgen::rdStatFunc {} {
|
||||
lappend temp "$k $v"
|
||||
continue
|
||||
}
|
||||
if {[string is integer $v]} {
|
||||
# trim leading zeroes to guard against interpreting as octal
|
||||
if {[string is integer [string trimleft $v 0]]} {
|
||||
lappend temp "$k $v"
|
||||
} else {
|
||||
lappend temp "$k -1"
|
||||
@@ -294,6 +295,10 @@ proc ::scobj::rfgen::rampFunc {} {
|
||||
set basePath [sct]
|
||||
set currSuperState [sct ramping]
|
||||
mkStatArr stateArr [hval $basePath/state_report]
|
||||
if {$stateArr(curr) == -1} {
|
||||
# Got invalid current reading try again
|
||||
return idle
|
||||
}
|
||||
|
||||
set targetCurr [sct targetCurr]
|
||||
set SCT_RFGEN [sct contname]
|
||||
@@ -302,8 +307,7 @@ proc ::scobj::rfgen::rampFunc {} {
|
||||
set K3 [sct K3]
|
||||
set targetFreq [sct targetFreq]
|
||||
set output [sct OutputState]
|
||||
|
||||
if { [expr {abs($stateArr(curr) - $targetCurr)}] <= [sct currTol] } {
|
||||
if { [expr {abs($stateArr(curr) - $targetCurr)}] <= 5 } {
|
||||
set curr $targetCurr
|
||||
} elseif {$targetCurr < $stateArr(curr)} {
|
||||
set curr [expr $stateArr(curr)-5]
|
||||
@@ -399,14 +403,14 @@ proc ::scobj::rfgen::mkRFGen {argList} {
|
||||
set SCT_RFGEN sct_rfgen_$pa(NAME)
|
||||
makesctcontroller $SCT_RFGEN rfamp $pa(IP):$pa(PORT)
|
||||
hsetprop /sics/$pa(NAME) contname $SCT_RFGEN
|
||||
mkStatArr stateArr [split [$SCT_RFGEN transact "L:$pa(ADDRESS)"] "|="]
|
||||
# mkStatArr stateArr [split [$SCT_RFGEN transact "L:$pa(ADDRESS)"] "|="]
|
||||
|
||||
hset /sics/$pa(NAME)/flip_current [expr {$stateArr(curr) / 10.0}]
|
||||
hset /sics/$pa(NAME)/flip_frequency $stateArr(freq)
|
||||
hset /sics/$pa(NAME)/flip_voltage $stateArr(voltage)
|
||||
hset /sics/$pa(NAME)/flip_on $stateArr(O)
|
||||
hsetprop /sics/$pa(NAME) targetFreq $stateArr(freq)
|
||||
hsetprop /sics/$pa(NAME) targetCurr $stateArr(curr)
|
||||
hset /sics/$pa(NAME)/flip_current 0
|
||||
hset /sics/$pa(NAME)/flip_frequency $pa(OPFREQ)
|
||||
hset /sics/$pa(NAME)/flip_voltage 0
|
||||
hset /sics/$pa(NAME)/flip_on 0
|
||||
hsetprop /sics/$pa(NAME) targetFreq $pa(OPFREQ)
|
||||
hsetprop /sics/$pa(NAME) targetCurr 0
|
||||
|
||||
$SCT_RFGEN poll /sics/$pa(NAME) $pa(INTERVAL)
|
||||
$SCT_RFGEN write /sics/$pa(NAME)/switch_on
|
||||
|
||||
Reference in New Issue
Block a user