6 Application Implementation
The application firmware is developed on a PIC18F56Q24 microcontroller and generated using MCC Melody and MPLAB X IDE.
The implemented firmware is performed with the PIC18F56Q24 Curiosity Nano development board.
The MCU peripherals, Timers, Serial Peripheral Interface (SPI), UART, ADCC and ZCDs are used to implement the functions of the phase sequence detection using a three-phase power supply.
The Timer4 (TMR4) is used for scheduling the tasks every 1 ms. It is configured to generate an interrupt for every 1 ms.
Timer2 (TMR2) is configured to generate an overflow interrupt for every 20 ms. It is used for measuring the time in between two ZCD interrupts, thereby calculating the phase shift between the phases of three-phase input.
The SPI is used to integrate the Waveform Click for generating the three-phase emulated signal. It is configured in Host mode with a 6 MHz SPI clock and an SPI Data mode two.
The UART is used for communication between the host computer and application setup. It is configured with a 230400 baud rate.
The ADCC is used for reproducing the input signal on the Data Visualizer (for demonstration) and also for three-phase RMS voltage measurement. It is configured with a 2 MHz ADC_CLK (ADCC clock).
The two ZCD instances are used for detecting the zero cross of the three-phase input signal. They are configured with interrupt on the rising edge signal.