4.27 ZCD - Zero-Crossing Detector

4.27.1 Introduction

The MPLAB® Code Configurator (MCC) Melody Zero-Crossing Detector Peripheral Library (PLIBs) drivers generates APIs to support ZCD-specific peripheral functionality on target MCUs.

The Zero-Crossing Detector (ZCD) module detects when an A/C signal crosses through the ground potential. The actual zero-crossing threshold is the zero-crossing reference voltage, ZCPINV, which is typically 0.75V above ground.

4.27.2 Supported Device Families

PIC12/16F161x PIC12/16F184x PIC16F153xx
PIC16F170x PIC16F171x PIC16F171xx
PIC16F176x PIC16F177x PIC16F180xx
PIC16F181xx PIC16F184xx PIC16F188xx
PIC16F191xx PIC18F-K40 PIC18F-K42
PIC18F-K83 PIC18F-Q10 PIC18F-Q24
PIC18F-Q40 PIC18F-Q41 PIC18F-Q43
PIC18F-Q71 PIC18F-Q83 PIC18F-Q84

4.27.3 Required Header Files:

#include "mcc_generated_files/zcd/zcd.h"

4.27.4 Module Documentation

4.27.4.1 ZCD

This file contains the API prototypes for the ZCD driver.

4.27.4.1.1 Module description

This file contains the API prototypes for the ZCD driver.

Version: ZCD Driver Version 2.11.0
Functions
  • void ZCD_Initialize (void)

    Initializes the ZCD module. This is called only once before calling other ZCD APIs.

  • bool ZCD_IsLogicLevel (void)

    Returns the status of the ZCD pin if it is sinking or sourcing current depending on the selected output polarity.

  • void ZCD_ISR (void)

    Implements the Interrupt Service Routine (ISR) for the ZCD interrupt.

4.27.4.1.2 Function Documentation

ZCD_Initialize()

void ZCD_Initialize (void )

Initializes the ZCD module. This is called only once before calling other ZCD APIs.

Section: Included FilesSection: ZCD Module APIs

Parameters:
None.
Returns:

None.

Section: Included FilesSection: ZCD Module APIs

ZCD_IsLogicLevel()

bool ZCD_IsLogicLevel (void )

Returns the status of the ZCD pin if it is sinking or sourcing current depending on the selected output polarity.

Precondition:

ZCD_Initialize() is already called.

Parameters:
None.
Return values:
True

- ZCD pin is sinking current (Non-inverted polarity) / ZCD pin is sourcing current (Inverted polarity).

False

- ZCD pin is sourcing current (Non-inverted polarity) / ZCD pin is sinking current (Inverted polarity).

ZCD_ISR()

void ZCD_ISR (void )

Implements the Interrupt Service Routine (ISR) for the ZCD interrupt.

Parameters:
None.
Returns:

None.

4.27.5 File Documentation

4.27.5.1 source/zcd.c File Reference

This file contains the API implementation for the ZCD driver.

#include <xc.h>
#include "../zcd.h"

4.27.5.1.1 Functions

  • void ZCD_Initialize (void)

    Initializes the ZCD module. This is called only once before calling other ZCD APIs.

  • bool ZCD_IsLogicLevel (void)

    Returns the status of the ZCD pin if it is sinking or sourcing current depending on the selected output polarity.

  • void ZCD_ISR (void)

    Implements the Interrupt Service Routine (ISR) for the ZCD interrupt.

4.27.5.1.2 Detailed Description

This file contains the API implementation for the ZCD driver.

ZCD Generated Driver File.

Version: ZCD Driver Version 2.11.0

4.27.5.2 source/zcd.h File Reference

#include <xc.h>
#include <stdbool.h>
#include <stdint.h>

4.27.5.2.1 Functions

  • void ZCD_Initialize (void)

    Initializes the ZCD module. This is called only once before calling other ZCD APIs.

  • bool ZCD_IsLogicLevel (void)

    Returns the status of the ZCD pin if it is sinking or sourcing current depending on the selected output polarity.

  • void ZCD_ISR (void)

    Implements the Interrupt Service Routine (ISR) for the ZCD interrupt.

4.27.5.2.2 Detailed Description

ZCD Generated Driver API Header File.