I’m seeking assistance with the final stages of my project design. The circuit assembly is already complete, and now I’m in need of the appropriate programming code to bring the project to fruition. My project revolves around creating a circuit to enhance the power factor. While I’ve made substantial progress, I’m now facing the coding aspect, which I’d like assistance with. I’ve attached an image of the circuit that I’ve meticulously put together. I’ve opted to utilize the PIC16F877A microcontroller for its implementation.
The code required for this endeavor is in the C programming language. The primary objective of the code is to continually monitor the power factor. If the power factor falls below 0.95, I want the code to activate a relay. Additionally, if the reading significantly deviates from the target, I intend for both relays to activate.
I deeply appreciate any support you can provide to help me achieve this critical coding task. Thank you for your invaluable assistance.
Below is an explanation of the steps involved in the automatic power factor controller code:
CODE EXPLANATION OF AUTOMATIC POWER FACTOR CONTROLLER
STEP 1:
Initialize the system and microcontroller.
STEP 2:
Configure a specific port for the LCD display, assigning pins as outputs and inputs as needed.
STEP 3:
Set the timer prescale value and initialize it to zero.
STEP 4:
Upon receiving an interrupt, start the timer’s counting operation.
STEP 5:
When the second interrupt is received, halt the timer and store its value in a designated variable.
STEP 6:
Use the stored timer value to calculate the phase difference between two waveforms.
STEP 7:
Perform necessary calculations to determine the phase angle of the signal and subsequently compute the power factor.
STEP 8:
Display the calculated power factor on the LCD display.
STEP 9:
Utilize the obtained power factor value to make decisions regarding the addition of capacitors in the circuit. Employ relays to incorporate capacitors as needed.
STEP 10:
Set the desired power factor value, completing the configuration.