Add relay switch time to zero-cross detection

This commit is contained in:
Theo Arends 2021-03-25 09:37:44 +01:00
parent 75308ee1e0
commit 3174056eea
2 changed files with 5 additions and 4 deletions

View File

@ -171,11 +171,10 @@ void ZeroCrossMomentStart(void) {
#endif
uint32_t trigger_moment = TasmotaGlobal.zc_time + TasmotaGlobal.zc_interval - TasmotaGlobal.zc_offset - TasmotaGlobal.zc_code_offset;
if (TimeReachedUsec(trigger_moment)) { // Trigger moment already passed so try next
while (TimeReachedUsec(trigger_moment)) { // Trigger moment already passed so try next
trigger_moment += TasmotaGlobal.zc_interval;
}
uint32_t timeout = millis() +22; // Catch at most 2 * 50Hz pulses
while (!TimeReached(timeout) && !TimeReachedUsec(trigger_moment)) {} // Wait for trigger moment
while (!TimeReachedUsec(trigger_moment)) {} // Wait for trigger moment
#ifdef DEBUG_ZEROCROSS
uint32_t dbg_endtime = micros();

View File

@ -30,6 +30,7 @@
*
* Based on datasheet from ChipSea and analysing serial data
* See https://github.com/arendst/Tasmota/discussions/10793
* https://goldenrelay.en.alibaba.com/product/62119012875-811845870/GOLDEN_GI_1A_5LH_SPST_5V_5A_10A_250VAC_NO_18_5_10_5_15_3mm_sealed_type_all_certificate_compliances_class_F_SPDT_Form_available.html
\*********************************************************************************************/
#define XNRG_19 19
@ -38,6 +39,7 @@
#define CSE7761_FREQUENCY // Add support for frequency monitoring
#define CSE7761_ZEROCROSS // Add zero cross detection
#define CSE7761_ZEROCROSS_OFFSET 2200 // Zero cross offset due to chip calculation (microseconds)
#define CSE7761_RELAY_SWITCHTIME 15000 // Relay (Golden GI-1A-5LH 15ms max) switch time (microseconds)
#define CSE7761_UREF 42563 // RmsUc
#define CSE7761_IREF 52241 // RmsIAC
@ -580,7 +582,7 @@ void Cse7761SnsInit(void) {
#ifdef CSE7761_FREQUENCY
#ifdef CSE7761_ZEROCROSS
ZeroCrossInit(CSE7761_ZEROCROSS_OFFSET);
ZeroCrossInit(CSE7761_ZEROCROSS_OFFSET + CSE7761_RELAY_SWITCHTIME);
#endif // CSE7761_ZEROCROSS
#endif // CSE7761_FREQUENCY