mirror of https://github.com/arendst/Tasmota.git
Fix POWCT default calibration
This commit is contained in:
parent
27083e3664
commit
23de275dbe
|
@ -28,7 +28,7 @@
|
|||
* With zero-cross detection
|
||||
* {"NAME":"Sonoff Dual R3 (ZCD)","GPIO":[32,0,0,0,7552,0,0,0,0,576,225,0,0,0,0,0,0,0,0,0,0,7296,7328,224,0,0,0,0,160,161,0,0,0,0,0,0],"FLAG":0,"BASE":1}
|
||||
*
|
||||
* {"NAME":"Sonoff POWCT","GPIO":[32,0,0,0,0,9280,0,0,0,320,0,576,0,9184,9216,0,0,224,0,9248,0,7329,7296,0,0,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1}
|
||||
* {"NAME":"Sonoff POWCT","GPIO":[32,0,0,0,0,9280,0,0,0,288,0,576,0,9184,9216,0,0,224,0,9248,0,7329,7296,0,0,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1}
|
||||
*
|
||||
* Based on datasheet from ChipSea and analysing serial data
|
||||
* See https://github.com/arendst/Tasmota/discussions/10793
|
||||
|
@ -201,10 +201,14 @@ uint32_t Cse7761ReadFallback(uint32_t reg, uint32_t prev, uint32_t size) {
|
|||
/********************************************************************************************/
|
||||
|
||||
uint32_t Cse7761Ref(uint32_t unit) {
|
||||
uint32_t coeff = 1;
|
||||
if (CSE7761_MODEL_POWCT == CSE7761Data.model) {
|
||||
coeff = 5;
|
||||
}
|
||||
switch (unit) {
|
||||
case RmsUC: return 0x400000 * 100 / CSE7761Data.coefficient[RmsUC];
|
||||
case RmsIAC: return (0x800000 * 100 / CSE7761Data.coefficient[RmsIAC]) * 10; // Stay within 32 bits
|
||||
case PowerPAC: return 0x80000000 / CSE7761Data.coefficient[PowerPAC];
|
||||
case RmsIAC: return (0x800000 * 100 / (CSE7761Data.coefficient[RmsIAC] * coeff)) * 10; // Stay within 32 bits
|
||||
case PowerPAC: return 0x80000000 / (CSE7761Data.coefficient[PowerPAC] * coeff);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -255,124 +259,129 @@ bool Cse7761ChipInit(void) {
|
|||
Bit name Function description
|
||||
15-11 NC -, the default is 1
|
||||
10 ADC2ON
|
||||
=1, means ADC current channel B is on (Sonoff Dual R3 Pow)
|
||||
=0, means ADC current channel B is closed
|
||||
=1, means ADC current channel B is on (Sonoff Dual R3)
|
||||
=0, means ADC current channel B is closed (Pow CT)
|
||||
9 NC -, the default is 1.
|
||||
8-6 PGAIB[2:0] Current channel B analog gain selection highest bit
|
||||
=1XX, PGA of current channel B=16 (Sonoff Dual R3 Pow)
|
||||
=1XX, PGA of current channel B=16 (Sonoff Dual R3)
|
||||
=011, PGA of current channel B=8
|
||||
=010, PGA of current channel B=4
|
||||
=001, PGA of current channel B=2
|
||||
=000, PGA of current channel B=1
|
||||
=000, PGA of current channel B=1 (Pow CT)
|
||||
5-3 PGAU[2:0] Highest bit of voltage channel analog gain selection
|
||||
=1XX, PGA of voltage U=16
|
||||
=011, PGA of voltage U=8
|
||||
=010, PGA of voltage U=4
|
||||
=001, PGA of voltage U=2
|
||||
=000, PGA of voltage U=1 (Sonoff Dual R3 Pow)
|
||||
=000, PGA of voltage U=1 (Sonoff Dual R3 / Pow CT)
|
||||
2-0 PGAIA[2:0] Current channel A analog gain selection highest bit
|
||||
=1XX, PGA of current channel A=16 (Sonoff Dual R3 Pow)
|
||||
=1XX, PGA of current channel A=16 (Sonoff Dual R3)
|
||||
=011, PGA of current channel A=8
|
||||
=010, PGA of current channel A=4
|
||||
=001, PGA of current channel A=2
|
||||
=000, PGA of current channel A=1
|
||||
=000, PGA of current channel A=1 (Pow CT)
|
||||
*/
|
||||
Cse7761Write(CSE7761_REG_SYSCON | 0x80, 0xFF04);
|
||||
if (CSE7761_MODEL_POWCT == CSE7761Data.model) {
|
||||
// Cse7761Write(CSE7761_REG_SYSCON | 0x80, 0x0A00); // Pow CT
|
||||
Cse7761Write(CSE7761_REG_SYSCON | 0x80, 0xFE00); // Pow CT - Tasmota (enable B)
|
||||
} else {
|
||||
Cse7761Write(CSE7761_REG_SYSCON | 0x80, 0xFF04); // Sonoff Dual R3
|
||||
}
|
||||
|
||||
/*
|
||||
Energy Measure Control Register (EMUCON) Addr:0x01 Default value: 0x0000
|
||||
Bit name Function description
|
||||
15-14 Tsensor_Step[1:0] Measurement steps of temperature sensor:
|
||||
=2'b00 The first step of temperature sensor measurement, the Offset of OP1 and OP2 is +/+. (Sonoff Dual R3 Pow)
|
||||
=2'b00 The first step of temperature sensor measurement, the Offset of OP1 and OP2 is +/+. (Sonoff Dual R3 / Pow CT)
|
||||
=2'b01 The second step of temperature sensor measurement, the Offset of OP1 and OP2 is +/-.
|
||||
=2'b10 The third step of temperature sensor measurement, the Offset of OP1 and OP2 is -/+.
|
||||
=2'b11 The fourth step of temperature sensor measurement, the Offset of OP1 and OP2 is -/-.
|
||||
After measuring these four results and averaging, the AD value of the current measured temperature can be obtained.
|
||||
13 tensor_en Temperature measurement module control
|
||||
=0 when the temperature measurement module is closed; (Sonoff Dual R3 Pow)
|
||||
=0 when the temperature measurement module is closed; (Sonoff Dual R3 / Pow CT)
|
||||
=1 when the temperature measurement module is turned on;
|
||||
12 comp_off Comparator module close signal:
|
||||
=0 when the comparator module is in working state
|
||||
=1 when the comparator module is off (Sonoff Dual R3 Pow)
|
||||
=1 when the comparator module is off (Sonoff Dual R3 / Pow CT)
|
||||
11-10 Pmode[1:0] Selection of active energy calculation method:
|
||||
Pmode =00, both positive and negative active energy participate in the accumulation,
|
||||
the accumulation method is algebraic sum mode, the reverse REVQ symbol indicates to active power; (Sonoff Dual R3 Pow)
|
||||
the accumulation method is algebraic sum mode, the reverse REVQ symbol indicates to active power; (Sonoff Dual R3 / Pow CT)
|
||||
Pmode = 01, only accumulate positive active energy;
|
||||
Pmode = 10, both positive and negative active energy participate in the accumulation,
|
||||
and the accumulation method is absolute value method. No reverse active power indication;
|
||||
Pmode =11, reserved, the mode is the same as Pmode =00
|
||||
9 NC -
|
||||
8 ZXD1 The initial value of ZX output is 0, and different waveforms are output according to the configuration of ZXD1 and ZXD0:
|
||||
=0, it means that the ZX output changes only at the selected zero-crossing point (Sonoff Dual R3 Pow)
|
||||
=0, it means that the ZX output changes only at the selected zero-crossing point (Sonoff Dual R3 / Pow CT)
|
||||
=1, indicating that the ZX output changes at both the positive and negative zero crossings
|
||||
7 ZXD0
|
||||
=0, indicates that the positive zero-crossing point is selected as the zero-crossing detection signal (Sonoff Dual R3 Pow)
|
||||
=0, indicates that the positive zero-crossing point is selected as the zero-crossing detection signal (Sonoff Dual R3 / Pow CT)
|
||||
=1, indicating that the negative zero-crossing point is selected as the zero-crossing detection signal
|
||||
6 HPFIBOFF
|
||||
=0, enable current channel B digital high-pass filter (Sonoff Dual R3 Pow)
|
||||
=1, turn off the digital high-pass filter of current channel B
|
||||
=0, enable current channel B digital high-pass filter (Sonoff Dual R3)
|
||||
=1, turn off the digital high-pass filter of current channel B (Pow CT)
|
||||
5 HPFIAOFF
|
||||
=0, enable current channel A digital high-pass filter (Sonoff Dual R3 Pow)
|
||||
=0, enable current channel A digital high-pass filter (Sonoff Dual R3 / Pow CT)
|
||||
=1, turn off the digital high-pass filter of current channel A
|
||||
4 HPFUOFF
|
||||
=0, enable U channel digital high pass filter (Sonoff Dual R3 Pow)
|
||||
=0, enable U channel digital high pass filter (Sonoff Dual R3 / Pow CT)
|
||||
=1, turn off the U channel digital high-pass filter
|
||||
3-2 NC -
|
||||
1 PBRUN
|
||||
=1, enable PFB pulse output and active energy register accumulation; (Sonoff Dual R3 Pow)
|
||||
=1, enable PFB pulse output and active energy register accumulation; (Sonoff Dual R3 / Pow CT)
|
||||
=0 (default), turn off PFB pulse output and active energy register accumulation.
|
||||
0 PARUN
|
||||
=1, enable PFA pulse output and active energy register accumulation; (Sonoff Dual R3 Pow)
|
||||
=1, enable PFA pulse output and active energy register accumulation; (Sonoff Dual R3 / Pow CT)
|
||||
=0 (default), turn off PFA pulse output and active energy register accumulation.
|
||||
*/
|
||||
// Cse7761Write(CSE7761_REG_EMUCON | 0x80, 0x1003);
|
||||
// Cse7761Write(CSE7761_REG_EMUCON | 0x80, 0x1043); // Pow CT
|
||||
// Cse7761Write(CSE7761_REG_EMUCON | 0x80, 0x1003); // Sonoff Dual R3
|
||||
Cse7761Write(CSE7761_REG_EMUCON | 0x80, 0x1183); // Tasmota enable zero cross detection on both positive and negative signal
|
||||
|
||||
/*
|
||||
Energy Measure Control Register (EMUCON2) Addr: 0x13 Default value: 0x0001
|
||||
Bit name Function description
|
||||
15-13 NC -
|
||||
12 SDOCmos
|
||||
=1, SDO pin CMOS open-drain output
|
||||
=0, SDO pin CMOS output (Sonoff Dual R3 Pow)
|
||||
=0, SDO pin CMOS output (Sonoff Dual R3 / Pow CT)
|
||||
11 EPB_CB Energy_PB clear signal control, the default is 0, and it needs to be configured to 1 in UART mode.
|
||||
Clear after reading is not supported in UART mode
|
||||
=1, Energy_PB will not be cleared after reading; (Sonoff Dual R3 Pow)
|
||||
=1, Energy_PB will not be cleared after reading; (Sonoff Dual R3 / Pow CT)
|
||||
=0, Energy_PB is cleared after reading;
|
||||
10 EPA_CB Energy_PA clear signal control, the default is 0, it needs to be configured to 1 in UART mode,
|
||||
Clear after reading is not supported in UART mode
|
||||
=1, Energy_PA will not be cleared after reading; (Sonoff Dual R3 Pow)
|
||||
=1, Energy_PA will not be cleared after reading; (Sonoff Dual R3 / Pow CT)
|
||||
=0, Energy_PA is cleared after reading;
|
||||
9-8 DUPSEL[1:0] Average register update frequency control
|
||||
=00, Update frequency 3.4Hz
|
||||
=01, Update frequency 6.8Hz
|
||||
=10, Update frequency 13.65Hz
|
||||
=11, Update frequency 27.3Hz (Sonoff Dual R3 Pow)
|
||||
=11, Update frequency 27.3Hz (Sonoff Dual R3 / Pow CT)
|
||||
7 CHS_IB Current channel B measurement selection signal
|
||||
=1, measure the current of channel B (Sonoff Dual R3 Pow)
|
||||
=1, measure the current of channel B (Sonoff Dual R3 / Pow CT)
|
||||
=0, measure the internal temperature of the chip
|
||||
6 PfactorEN Power factor function enable
|
||||
=1, turn on the power factor output function (Sonoff Dual R3 Pow)
|
||||
=1, turn on the power factor output function (Sonoff Dual R3 / Pow CT)
|
||||
=0, turn off the power factor output function
|
||||
5 WaveEN Waveform data, instantaneous data output enable signal
|
||||
=1, turn on the waveform data output function (Tasmota add frequency)
|
||||
=0, turn off the waveform data output function (Sonoff Dual R3 Pow)
|
||||
=0, turn off the waveform data output function (Sonoff Dual R3 / Pow CT)
|
||||
4 SAGEN Voltage drop detection enable signal, WaveEN=1 must be configured first
|
||||
=1, turn on the voltage drop detection function
|
||||
=0, turn off the voltage drop detection function (Sonoff Dual R3 Pow)
|
||||
=0, turn off the voltage drop detection function (Sonoff Dual R3 / Pow CT)
|
||||
3 OverEN Overvoltage, overcurrent, and overload detection enable signal, WaveEN=1 must be configured first
|
||||
=1, turn on the overvoltage, overcurrent, and overload detection functions
|
||||
=0, turn off the overvoltage, overcurrent, and overload detection functions (Sonoff Dual R3 Pow)
|
||||
=0, turn off the overvoltage, overcurrent, and overload detection functions (Sonoff Dual R3 / Pow CT)
|
||||
2 ZxEN Zero-crossing detection, phase angle, voltage frequency measurement enable signal
|
||||
=1, turn on the zero-crossing detection, phase angle, and voltage frequency measurement functions (Tasmota add frequency)
|
||||
=0, disable zero-crossing detection, phase angle, voltage frequency measurement functions (Sonoff Dual R3 Pow)
|
||||
=0, disable zero-crossing detection, phase angle, voltage frequency measurement functions (Sonoff Dual R3 / Pow CT)
|
||||
1 PeakEN Peak detect enable signal
|
||||
=1, turn on the peak detection function
|
||||
=0, turn off the peak detection function (Sonoff Dual R3 Pow)
|
||||
=0, turn off the peak detection function (Sonoff Dual R3 / Pow CT)
|
||||
0 NC Default is 1
|
||||
*/
|
||||
#ifndef CSE7761_FREQUENCY
|
||||
Cse7761Write(CSE7761_REG_EMUCON2 | 0x80, 0x0FC1); // Sonoff Dual R3 Pow
|
||||
Cse7761Write(CSE7761_REG_EMUCON2 | 0x80, 0x0FC1); // Sonoff Dual R3 / Pow CT
|
||||
#else
|
||||
Cse7761Write(CSE7761_REG_EMUCON2 | 0x80, 0x0FE5); // Tasmota add Frequency
|
||||
|
||||
|
|
Loading…
Reference in New Issue