powerMeter

package
v1.0.0-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// VoltageRange Input range (+-) in mV
	VoltageRange float64 = 0.250
	// CurrentRange Input range (+-) in mV
	CurrentRange            float64 = 0.250
	StartSingleConvert              = 0xE0
	StartMultiConvert               = 0xE8
	SYNC0                   byte    = 0xFE
	SYNC1                   byte    = 0xFF
	PowerUpHaltControl              = 0xA0
	PowerDownMode0                  = 0x80
	PowerDownMode1                  = 0x88
	PowerDownMode2                  = 0x90
	PowerDownMode3                  = 0x98
	CalibrateControl                = 0xC0
	CalibrateCurrent                = 0x08
	CalibrateVoltage                = 0x10
	CalibrateCurrentVoltage         = 0x18
	CalibrateGain                   = 0x02
	CalibrateOffset                 = 0x01
	CalibrateAll                    = 0x1B
	ConfigRegister                  = 0x00 << 1
	CurrentOffsetRegister           = 0x01 << 1
	CurrentGainRegister             = 0x02 << 1
	VoltageOffsetRegister           = 0x03 << 1
	VoltageGainRegister             = 0x04 << 1
	CycleCountRegister              = 0x05 << 1
	PulseRateRegister               = 0x06 << 1
	LastCurrentRegister             = 0x07 << 1
	LastVoltageRegister             = 0x08 << 1
	LastPowerRegister               = 0x09 << 1
	TotalEnergyRegister             = 0x0A << 1
	RmsCurrentRegister              = 0x0B << 1
	RmsVoltageRegister              = 0x0C << 1
	TimeBaseCaliRegister            = 0x0D << 1
	StatusRegister                  = 0x0F << 1
	InterruptMaskRegister           = 0x1A << 1
	WriteRegister           int32   = 0x40
	ReadRegister            int32   = ^WriteRegister
	ChipReset                       = 0x01 << 7
	SignBit                         = 0x01 << 23
	DataReady                       = 0x01 << 23
	ConversionReady                 = 0x01 << 20
)
View Source
const (
	TypeC5460A = "cs5460a"
)

Supported power meters

Variables

View Source
var (
	ErrPowerMeterUnsupported = errors.New("power meter type not supported")
	ErrPowerMeterDisabled    = errors.New("power meter not enabled")
)

Functions

This section is empty.

Types

type C5460A

type C5460A struct {
	EnablePin int

	SpiBus               int
	VoltageDividerOffset float64
	ShuntOffset          float64
	VoltageMultiplier    float64
	CurrentMultiplier    float64
	PowerMultiplier      float64
	// contains filtered or unexported fields
}

func NewCS5460PowerMeter

func NewCS5460PowerMeter(enablePin int, spiBus int, voltageDividerOffset float64, shuntOffset float64) (*C5460A, error)

func (*C5460A) GetCurrent

func (receiver *C5460A) GetCurrent() float64

func (*C5460A) GetEnergy

func (receiver *C5460A) GetEnergy() float64

func (*C5460A) GetPower

func (receiver *C5460A) GetPower() float64

func (*C5460A) GetRMSCurrent

func (receiver *C5460A) GetRMSCurrent() float64

func (*C5460A) GetRMSVoltage

func (receiver *C5460A) GetRMSVoltage() float64

func (*C5460A) GetVoltage

func (receiver *C5460A) GetVoltage() float64

func (*C5460A) Reset

func (receiver *C5460A) Reset()

type PowerMeter

type PowerMeter interface {
	Reset()
	GetEnergy() float64
	GetPower() float64
	GetCurrent() float64
	GetVoltage() float64
	GetRMSCurrent() float64
	GetRMSVoltage() float64
}

PowerMeter is an abstraction for measurement hardware.

func NewPowerMeter

func NewPowerMeter(meterSettings settings.PowerMeter) (PowerMeter, error)

NewPowerMeter creates a new power meter based on the connector settings.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL