cx34

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package cx34 provides a client for working with the Chiltrix CX34 heat pump.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DebugSequenceInfo

func DebugSequenceInfo(states []*State) string

func DiffStates

func DiffStates(a, b *State) (string, map[Register]bool)

DiffStates returns a human readable description of the difference between two State values.

Types

type AirConditioningMode added in v0.0.3

type AirConditioningMode uint8

AirConditioningMode specifies whether the heat pump is configured to heat, cool, heat+domestic hot water, or cool+domestic hot water.

const (
	AirConditioningModeCooling AirConditioningMode = 0
	AirConditioningModeHeating AirConditioningMode = 1
)

Valid AirConditioningMode values.

func (AirConditioningMode) IsCooling added in v0.0.3

func (m AirConditioningMode) IsCooling() bool

IsCooling reports if the mode is cooling or cooling+domestic hot water.

func (AirConditioningMode) IsHeating added in v0.0.3

func (m AirConditioningMode) IsHeating() bool

IsHeating reports if the mode is heating or heating+domestic hot water.

type Client

type Client struct {
	chiltrix.ReadWriteServiceServer
	// contains filtered or unexported fields
}

Client is used to communicate with the Chiltrix CX34 heat pump.

func Connect

func Connect(p *Params) (*Client, error)

Connect connects a new client to the heat pump or returns an error.

func (*Client) CheckConnection

func (c *Client) CheckConnection() error

CheckConnection attempts to connect to the heat pump and returns an error if the connection fails.

func (*Client) ReadState

func (c *Client) ReadState() (*State, error)

ReadState returns a snapshot of the state of the heat pump.

func (*Client) SetParameter added in v0.0.3

SetParameter sets the target heating temperature for the CX34.

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger(debug, raw io.Writer) *Logger

func (*Logger) Write

func (l *Logger) Write(p []byte) (n int, err error)

type Mode

type Mode string

Mode indicates the protocol that should be used to communicate with the CX34.

const (
	// Modbus mode uses modbus to communicate with the CX34. This is a
	// standardized protocol, but so far the library doesn't support it.
	Modbus Mode = "modbus"

	// CX34Text uses a proprietary protocol from Onrom to communicate with the CX34.
	CX34Text Mode = "cx34text"
)

Valid modes.

type Params

type Params struct {
	// The /dev/ttyX device shown by dmesg for the RS-485 connection to the heat pump.
	TTYDevice string
	LogWriter io.Writer
	Mode      Mode
}

Params configures the connection to the Chiltrix.

type Register

type Register uint16

Register is a modsbus register

const (
	ACMode                     Register = 141 // 0 = cool, 1 = heat
	TargetACCoolingModeTemp    Register = 142
	TargetACHeatingModeTemp    Register = 143
	TargetDomesticHotWaterTemp Register = 144
	// See page 47-48 of https://www.chiltrix.com/documents/CX34-IOM-3.pdf
	ECWaterPumpMinimumSpeed Register = 53 // 40-80 (corresponding to 40%-80%): Minimum electronically commutated water pump speed.
	// See page 51 of https://www.chiltrix.com/documents/CX34-IOM-3.pdf
	OutPipeTemp                           Register = 200
	CompressorDischargeTemp               Register = 201
	AmbientTemp                           Register = 202
	SuctionTemp                           Register = 203
	PlateHeatExchangerTemp                Register = 204
	ACOutletWaterTemp                     Register = 205
	SolarTemp                             Register = 206
	CompressorCurrentValueP15             Register = 209 // 0.00-30.0A
	WaterFlowRate                         Register = 213 // tenths of a liter per minute
	P03Status                             Register = 214
	P04Status                             Register = 215
	P05Status                             Register = 216
	P06Status                             Register = 217
	P07Status                             Register = 218
	P08Status                             Register = 219 // 0= DHW valid, 1= DHW invalid 0=DHW valid, 1= DHW invalid
	P09Status                             Register = 220 // 0=Heating valid,	1= Heating invalid	AC heating valid= 0 valid, 	1= invalid
	P10Status                             Register = 221 // 0=cooling valid,	1=cooling invalid	0=cooling valid,	1=cooling invalid
	HighPressureSwitchStatus              Register = 222 // 1= on, 0= off 1= on, 0= off
	LowPressureSwitchStatus               Register = 223 // 1=on, 0= off 1=on, 0= off
	SecondHighPressureSwitchStatus        Register = 224 // 1=on, 0= off 1=on, 0= off
	InnerWaterFlowSwitch                  Register = 225 // 1=on, 0= off 1=on, 0= off
	CompressorFrequency                   Register = 227 // Displays the actual operating	frequency	Show actual frequency
	ThermalSwitchStatus                   Register = 228 // 1=on, 0= off 1=on, 0= off
	OutdoorFanMotor                       Register = 229 // 1= run, 0= stop 1=on, 0= off
	ElectricalValve1                      Register = 230 // 1= run, 0= stop 1= run, 0= stop
	ElectricalValve2                      Register = 231 // 1= run, 0= stop 1= run, 0= stop
	ElectricalValve3                      Register = 232 // 1= run, 0= stop 1= run, 0= stop
	ElectricalValve4                      Register = 233 // 1= run, 0= stop 1= run, 0= stop
	C4WaterPump                           Register = 234 // 1= run, 0= stop 1= run, 0= stop
	C5WaterPump                           Register = 235 // 1= run, 0= stop 1= run, 0= stop
	C6waterPump                           Register = 236 // 1= run, 0= stop 1= run, 0= stop
	AccumulativeDaysAFterLastVirusKilling Register = 237 // The accumulative days after last	virus killing	0-99 (From the last complete	sterilization to the present,	cumulative number of days)	0-99 (from the last complete	sterilization to the present,	cumulative number of days)
	OutdoorModularTemp                    Register = 238 // -30~97℃ -30~97℃
	ExpansionValve1OpeningDegree          Register = 239 // 0~500 0~500
	ExpansionValve2OpeningDegree          Register = 240 // 0~500 0~500
	InnerPipeTemp                         Register = 241 // -30~97℃ -30~97℃
	HeatingMethod2TargetTemperature       Register = 242 // -30~97℃ -30~97℃
	IndoorTemperatureControlSwitch        Register = 243 // 1=on, 0= off 1=on, 0= off
	FanType                               Register = 244 // 0= AC fan, 1= EC fan 1,	2= EC fan 2	0= AC fan, 1= EC fan 1,	2= EC fan 2
	ECFanMotor1Speed                      Register = 245 // 0~3000 0~3000
	ECFanMotor2Speed                      Register = 246 //0~3000 0~3000
	WaterPumpTypes                        Register = 247 // 0= AC Water pump	1= EC Water pump	0= AC Water pump	1= EC Water pump
	InternalPumpSpeed                     Register = 248 // (C4) 1~10 (10 Show 100%) 1~10 (10 means 100%)
	BoosterPumpSpeed                      Register = 249 //1~10 (10 Show 100%) 1~10 (10 means 100%)
	InductorACCurrent                     Register = 250 //0~50A 0~50A
	DriverWorkingStatusValue              Register = 251 //Hexadecimal value Hexadecimal values
	CompressorShutDownCode                Register = 252 //Hexadecimal value Hexadecimal values
	DriverAllowedHighestFrequency         Register = 253 //30-120Hz 30-120Hz
	ReduceFrequencyTemperature            Register = 254 //setting	55~200℃ 55~200℃
	InputACVoltage                        Register = 255 //0~550V 0~550V
	InputACCurrent                        Register = 256 //0~50A(IPM test) 0~50A(IPM Check)
	CompressorPhaseCurrent                Register = 257 //0~50A(IPM test) 0~50A(IPM Check)
	BusLineVoltage                        Register = 258 //0~750V 0~750V
	FanShutdownCode                       Register = 259 // Hexadecimal value Hexadecimal values
	IPMTemp                               Register = 260 //55~200℃ 55~200℃
	CompressorTotalRunningTime            Register = 261 //	Will reset after power cycle	0~65000 0~65000 hour

	// Inferred values.
	WaterInletSensorTemp1 Register = 281
	WaterInletSensorTemp2 Register = 282
	CurrentFaultCode      Register = 284 // Set to 32 when I get a P5 error, not sure about other faults.
)

Known Register values.

func (Register) String

func (r Register) String() string

String returns a human-readable name of the modbus register.

type State

type State struct {
	// contains filtered or unexported fields
}

State is a snapshot of the heat pump's state.

func StateFromProto

func StateFromProto(msg *chiltrix.State) (*State, error)

StateFromProto converts a state proto into a State object.

func (*State) ACCurrent

func (s *State) ACCurrent() units.Current

ACCurrent returns the measured input AC Current value.

func (*State) ACHeatingTargetTemp

func (s *State) ACHeatingTargetTemp() units.Temperature

ACHeatingTargetTemp returns the active setpoint temperature.

Currently this only returns the target AC temperature in heating mode. It should be updated to return the cooling mode temperature when in cooling mode.

func (*State) ACInletWaterTemp

func (s *State) ACInletWaterTemp() units.Temperature

ACInletWaterTemp returns the temperature at the water inlet; values are -30~97℃.

func (*State) ACMode added in v0.0.3

func (s *State) ACMode() AirConditioningMode

ACMode returns the outlet temperature minust he inlet temperature

func (*State) ACOutletWaterTemp

func (s *State) ACOutletWaterTemp() units.Temperature

ACOutletWaterTemp returns the temperature at the water outlet; values are -30~97℃.

func (*State) ACTargetTemp added in v0.0.3

func (s *State) ACTargetTemp() units.Temperature

ACTargetTemp returns the active setpoint temperature.

func (*State) ACVoltage

func (s *State) ACVoltage() units.Voltage

ACVoltage returns the measured input AC Voltage value.

func (*State) AmbientTemp

func (s *State) AmbientTemp() units.Temperature

AmbientTemp returns the temperature reported by the CX34's ambient temperature sensor.

func (*State) ApparentPower

func (s *State) ApparentPower() units.Power

ApparentPower returns the measured input AC Current times the measured AC Voltage.

I'm guessing there is no way to separate the real and reactive parts of the power value, so the actual power consumption is likely less than the returned value.

func (*State) BoosterPumpSpeed

func (s *State) BoosterPumpSpeed() units.PumpSpeed

BoosterPumpSpeed returns the power setting of the variable-speed water pump external to the CX34. (not tested)

func (*State) COP

COP returns the coefficient of performance for the heat pump.

func (*State) CollectionTime

func (s *State) CollectionTime() time.Time

CollectionTime returns the collection time of the heat pump state log entry.

func (*State) CompressorCurrent

func (s *State) CompressorCurrent() units.Current

CompressorCurrent returns the "Compressor phase current value".

func (*State) DeltaT

func (s *State) DeltaT() units.Temperature

DeltaT returns the outlet temperature minust he inlet temperature

func (*State) FlowRate

func (s *State) FlowRate() units.FlowRate

FlowRate returns the water flow rate measured by the CX34's flow sensor.

The flow sensor is made by the same company that makes this one: https://www.adafruit.com/product/828?gclid=Cj0KCQiAlZH_BRCgARIsAAZHSBmfM9AVkdnye4p7RVf_cbKDm6n6jILBT9ILjkvpg8PnLjz_38tU324aAsk0EALw_wcB

func (*State) InductorACCurrent

func (s *State) InductorACCurrent() units.Current

InductorACCurrent returns the "inductor AC current value P15".

func (*State) InternalPumpSpeed

func (s *State) InternalPumpSpeed() units.PumpSpeed

InternalPumpSpeed returns the power setting of the variable-speed water pump inside of the CX34.

func (*State) MassFlowPerSecond

func (s *State) MassFlowPerSecond() units.Mass

MassFlowPerSecond returns the amount of water flowing through the heat pump per second.

func (*State) Proto

func (s *State) Proto() *chiltrix.State

Proto returns the protobuf form of state.

func (*State) RegisterValues

func (s *State) RegisterValues() map[Register]uint16

RegisterValues returns a map of register values. The map should not be modified by the caller.

func (*State) Report

func (s *State) Report(omitZeros bool, interestingRegisters map[Register]bool) string

Report returns a human readable summary of the state of the heat pump.

func (*State) String

func (s *State) String() string

String returns a human readable summary of the state of the heat pump.

func (*State) SuctionTemp

func (s *State) SuctionTemp() units.Temperature

SuctionTemp returns the "suction temperature" of the unit.

A typical value in heating mode is 3.3 degrees C, so I'm not sure what this measures exactly.

func (*State) UsefulHeatRate

func (s *State) UsefulHeatRate() units.Power

UsefulHeatRate returns the amount of useful heat added or removed from the system per unit time. The value may be negative in the case of cooling.

func (*State) UsefulHeatRateExplained

func (s *State) UsefulHeatRateExplained() string

UsefulHeatRateExplained returns the amount of useful heat added or removed from the system per unit time. The value may be negative in the case of cooling.

Jump to

Keyboard shortcuts

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