filter settings
This commit is contained in:
parent
e2d57edf45
commit
0ffeb62954
14
config.toml
14
config.toml
@ -1,28 +1,30 @@
|
|||||||
|
# TH7 demo configuration file.
|
||||||
[TH7]
|
[TH7]
|
||||||
port = 9090
|
port = 9090 # web port
|
||||||
debug = true
|
debug = true # enable to use simulated PCB for development
|
||||||
|
|
||||||
[DB]
|
[DB]
|
||||||
type = "sqlite3"
|
type = "sqlite3"
|
||||||
path = "test.db"
|
path = "test.db"
|
||||||
freq = 60
|
freq = 60
|
||||||
|
|
||||||
|
[Channel_1]
|
||||||
|
type = 'U'
|
||||||
|
filter.samples = 100
|
||||||
|
filter.type = 1
|
||||||
|
|
||||||
[Channel_2]
|
[Channel_2]
|
||||||
type = 'N'
|
type = 'N'
|
||||||
unit = 'C'
|
|
||||||
filter.samples = 20
|
filter.samples = 20
|
||||||
|
|
||||||
[Channel_3]
|
[Channel_3]
|
||||||
type = 'T'
|
type = 'T'
|
||||||
unit = 'C'
|
|
||||||
|
|
||||||
[Channel_4]
|
[Channel_4]
|
||||||
type = 'K'
|
type = 'K'
|
||||||
unit = 'C'
|
|
||||||
|
|
||||||
[Channel_6]
|
[Channel_6]
|
||||||
type = 'J'
|
type = 'J'
|
||||||
unit = 'C'
|
|
||||||
offset = -23.1
|
offset = -23.1
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,20 +12,19 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
ErrConfigBadThermocoupleType = errors.New("unrecognised thermocouple type")
|
ErrConfigBadThermocoupleType = errors.New("unrecognised thermocouple type")
|
||||||
ErrConfigBadTemperatureUnit = errors.New("unrecognised temperature unit")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
thermocoupleTypes = map[string]thermocouple.Type{
|
thermocoupleTypes = map[string]thermocouple.Type{
|
||||||
"B": thermocouple.B,
|
"B": thermocouple.B,
|
||||||
"E": thermocouple.E,
|
"E": thermocouple.E,
|
||||||
"J": thermocouple.J,
|
"J": thermocouple.J,
|
||||||
"K": thermocouple.K,
|
"K": thermocouple.K,
|
||||||
"N": thermocouple.N,
|
"N": thermocouple.N,
|
||||||
"R": thermocouple.R,
|
"R": thermocouple.R,
|
||||||
"S": thermocouple.S,
|
"S": thermocouple.S,
|
||||||
"T": thermocouple.T,
|
"T": thermocouple.T,
|
||||||
"UV": thermocouple.None,
|
"U": thermocouple.None, // for uV measurements
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -100,6 +99,7 @@ func Load() (config.Config, error) {
|
|||||||
c.Thermo = tc
|
c.Thermo = tc
|
||||||
|
|
||||||
c.Filter.SampleSize = v.GetInt(head + ".filter.samples")
|
c.Filter.SampleSize = v.GetInt(head + ".filter.samples")
|
||||||
|
c.Filter.Type = v.GetInt(head + ".filter.type")
|
||||||
|
|
||||||
cfg.Channels = append(cfg.Channels, c)
|
cfg.Channels = append(cfg.Channels, c)
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
type Filter struct {
|
type Filter struct {
|
||||||
SampleSize int `json:"sample_size"`
|
SampleSize int `json:"sample_size"`
|
||||||
|
Type int `json:"type"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Channel struct {
|
type Channel struct {
|
||||||
|
@ -9,3 +9,33 @@ func AlphaBetaFilter(arr []float64, init float64) float64 {
|
|||||||
}
|
}
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Simple lag filter. value = old * 0.9 + new * 0.1
|
||||||
|
func Lag_1(arr []float64, init float64) float64 {
|
||||||
|
value := init
|
||||||
|
for i := range arr {
|
||||||
|
value = value*0.9 + arr[i]*0.1
|
||||||
|
}
|
||||||
|
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
// Simple lag filter. value = old * 0.95 + new * 0.05
|
||||||
|
func Lag_2(arr []float64, init float64) float64 {
|
||||||
|
value := init
|
||||||
|
for i := range arr {
|
||||||
|
value = value*0.95 + arr[i]*0.05
|
||||||
|
}
|
||||||
|
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
// Simple lag filter. value = old * 0.99 + new * 0.01
|
||||||
|
func Lag_3(arr []float64, init float64) float64 {
|
||||||
|
value := init
|
||||||
|
for i := range arr {
|
||||||
|
value = value*0.99 + arr[i]*0.01
|
||||||
|
}
|
||||||
|
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user