3.27 ZCD - Zero-Crossing Detector

3.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.

3.27.2 Supported Device Families

PIC12/16F161xPIC12/16F184xPIC16F153xx
PIC16F170xPIC16F171xPIC16F171xx
PIC16F176xPIC16F177xPIC16F180xx
PIC16F181xxPIC16F184xxPIC16F188xx
PIC16F191xxPIC18F-K40PIC18F-K42
PIC18F-K83PIC18F-Q10PIC18F-Q24
PIC18F-Q40PIC18F-Q41PIC18F-Q43
PIC18F-Q71PIC18F-Q83PIC18F-Q84

3.27.3 Required Header Files:

#include "mcc_generated_files/zcd/zcd.h"

3.27.4 Module Documentation

3.27.4.1 ZCD

This file contains the API prototypes for the ZCD driver.

3.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.

3.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.

3.27.5 File Documentation

3.27.5.1 source/zcd.c File Reference

This file contains the API implementation for the ZCD driver.

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

3.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.

3.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

3.27.5.2 source/zcd.h File Reference

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

3.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.

3.27.5.2.2 Detailed Description

ZCD Generated Driver API Header File.