Permalink
Browse files

modified: assemblies/assembly007/assembly007.tcl

	modified:   assemblies/assembly007/measure.tcl
	modified:   hardware/scpi.tcl
  • Loading branch information...
1 parent 93316ae commit a680f675de06bdbd89f430263eb4d64de2299797 @andrey-nakin committed Jun 29, 2012
Showing with 21 additions and 10 deletions.
  1. +1 −4 assemblies/assembly007/assembly007.tcl
  2. +19 −5 assemblies/assembly007/measure.tcl
  3. +1 −1 hardware/scpi.tcl
@@ -193,9 +193,6 @@ proc makeMeasurement {} {
proc display { v sv c sc r sr temp tempErr tempDer write } {
global runtime chartR_T chartR_t chartT_t chartdT_t
- global log
- ${log}::debug "display $temp $tempErr"
-
# Выводим результаты в окно программы
set runtime(temperature) [::measure::format::valueWithErr -prec 6 -- $temp $tempErr "К"]
set runtime(derivative1) [::measure::format::value -prec 3 -- $tempDer "К/мин"]
@@ -287,7 +284,7 @@ pack $p -fill both -padx 10 -pady 5 -expand 1
set chartR_T [canvas $p.r_T -width 200 -height 200]
grid $chartR_T -row 0 -column 0 -sticky news
measure::chart::staticChart -xlabel "T, К" -ylabel "R, Ом" -dots 1 -lines 1 $chartR_T
-measure::chart::${chartR_T}::series result -color green
+measure::chart::${chartR_T}::series result -maxCount 500 -color green
measure::chart::${chartR_T}::series test -maxCount 10 -color #7f7fff
set chartR_t [canvas $p.r_t -width 200 -height 200]
@@ -13,6 +13,7 @@ package require measure::datafile
package require measure::interop
package require measure::ranges
package require measure::measure
+package require measure::listutils
package require scpi
###############################################################################
@@ -50,8 +51,10 @@ proc runTimeStep {} {
}
# Производит регистрацию данных по заданному температурному шагу
+set tempDerValues {}
+
proc runTempStep {} {
- global doMeasurement
+ global doMeasurement tempDerValues
global log
set step [measure::config::get prog.temp.step 1.0]
@@ -61,8 +64,12 @@ proc runTempStep {} {
# Выполняем цикл пока не прервёт пользователь
while { ![measure::interop::isTerminated] } {
+ # текущее время
+ set t [clock milliseconds]
+
# считываем температуру
lassign [readTemp] temp tempErr tempDer
+ measure::listutils::lappend tempDerValues $tempDer 10
if { $doMeasurement
|| $temp > $prevT && $temp > [expr ($prevN + 1) * $step] \
@@ -77,10 +84,17 @@ proc runTempStep {} {
# измеряем сопротивление, но не регистрируем
readResistanceAndWrite $temp $tempErr $tempDer 0
}
-
- after 500 set doMeasurement 0
- vwait doMeasurement
- after cancel set doMeasurement 0
+
+ # определим, какую паузу нужно выдержать в зависимости от dT/dt
+ set der [math::statistics::mean $tempDerValues]
+ set delay [expr 0.05 / (abs($der) / 60000.0)]
+ set delay [expr min($delay, 1000)]
+ set delay [expr int($delay - ([clock milliseconds] - $t))]
+ if { $delay > 50 } {
+ after $delay set doMeasurement 0
+ vwait doMeasurement
+ after cancel set doMeasurement 0
+ }
}
}
View
@@ -17,7 +17,7 @@ namespace eval scpi {
set scpi::ADDR_PREFIX_VISA "visa:"
-set scpi::DELAY_SERIAL 500
+set scpi::DELAY_SERIAL 50
set scpi::DELAY_DEFAULT 5
array set scpi::commandTimes {}

0 comments on commit a680f67

Please sign in to comment.