Using AC power supply for regulated booster PFC (AC-DC converter charger)

hi, i would like to know how to do the programming code for booster PFC.
I use the DC supply at first to help me power up my boost converter but now i would like to change to AC supply.
But the rectifier voltage current is not being boost up to be higher than capacitor voltage causing the current of rectifier to pass through current at peak voltage level only.

But the rectifier voltage current is not being boost up to be higher than capacitor voltage causing the current of rectifier to pass through current at peak voltage level only.

Want to try that again with words that actually hang together and tell a story?

Post the schematic of what circuit you have and a link to any modules.

i am doing a boost converter power factor correction in ac to dc battery charger controller.

i have to type my code using arduino uno microcontroller to send the correct pwm. perviously i have been doing using dc power supply now i am changing it to ac supply.

this is my working coding for regulated dc output supply with using dc power supply.

``````#include <PWM.h>

#define VREF  (5.0) /* volt */
#define VRATIO  (12.0/(39.0+12.0)) //voltage divider

int32_t frequency = 83000;  //frequency (in Hz)
const int pwmpin = 9; // for output pin (PWM).
const int feedback = A0; // Vout measure input.
int vout = 0;
int vout_average = 0; // For feedback only.
int vtarget = 0;
const int hysteresis = 5; // compare
unsigned char pwm = 1;
double R1=3900;
double R2=1200;

// Convert an output voltage to an ADC value.
// Calculations are done in ADC values (int), not volts (float).
{
return (int)((volt*VRATIO/(VREF))*1023.0);
}

void setup()
{
// Setup serial port for control & debug.
Serial.begin(9600);

// Pins default to inputs, so we only have to setup this one.
pinMode(pwmpin,OUTPUT);
// sets the frequency for the specified pin
bool success = SetPinFrequencySafe(pwmpin, frequency);

//if the pin frequency was set successfully, turn pin 13 on (optional)
if (success) {
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);}

// Set initial output voltage to 10.0 V.
analogWrite(pwmpin, pwm); // Set duty cycle (0 to 255).
Serial.begin(9600);
}

void loop()
{
// Measure the current value of Vout.

// Keep a running average of Vout (for feedback only).
vout_average += vout;

// Adjust PWM so that the target will be reached.
// Use a hysteresis to prevent fast oscillations
// around the target value.

if (vout>vtarget+hysteresis)
{
if (pwm>=1)
{
pwm -= 1;
}
else
{
pwm=0;
}
}
else if (vout<vtarget-hysteresis)
{
pwm += 1;
}

analogWrite (pwmpin, pwm); // Set duty cycle (0 to 255).

delay(10);
}
``````

and i am think since AC power is a sine wave i may need to combine a sine wave arrange reference for my pwm to know how to change. ie. it will boost the rectifier voltage when it is lower than capacitor voltage and at the peak of rectifier voltage it would not boost by change the pwm according.

``````PROGMEM prog_uchar sine256[] =
{
127,130,133,136,139,143,146,149,152,155,158,161,164,167,170,173,176,178,181,184,187,190,192,195,198,200,203,205,208,210,212,215,217,219,221,
223,225,227,229,231,233,234,236,238,239,240,242,243,244,245,247,248,249,249,250,251,252,252,253,253,253,254,254,254,254,254,254,254,253,253,
253,252,252,251,250,249,249,248,247,245,244,243,242,240,239,238,236,234,233,231,229,227,225,223,221,219,217,215,212,210,208,205,203,200,198,
195,192,190,187,184,181,178,176,173,170,167,164,161,158,155,152,149,146,143,139,136,133,130,127,124,121,118,115,111,108,105,102,99,96,93,90,
87,84,81,78,76,73,70,67,64,62,59,56,54,51,49,46,44,42,39,37,35,33,31,29,27,25,23,21,20,18,16,15,14,12,11,10,9,7,6,5,5,4,3,2,2,1,1,1,0,0,0,0,
0,0,0,1,1,1,2,2,3,4,5,5,6,7,9,10,11,12,14,15,16,18,20,21,23,25,27,29,31,33,35,37,39,42,44,46,49,51,54,56,59,62,64,67,70,73,76,78,81,84,87,
90,93,96,99,102,105,108,111,115,118,121,124
};
``````

hope that this would help u understand my tasks

Sorry no. We are missing YOUR schematic, the one with the AC power that does not work.

i am thinking mmaybe i need a input current and voltage sensing into arduino board A1. but i have no idea how to write the code.

Active PFC must control both the input current and the output voltage. The current is shaped by the
rectified line voltage so that the input to the converter appears to be resistive. The output voltage is controlled by changing the average amplitude of the current programming signal. The effective resistance of the resistive load specified to the AC line varies slowly according to the power demands of the actual load. The line current remains proportional to the line voltage,
The basic function of PFC is to make the input current drawn from the system sinusoidal and in phase
with the input voltage.

Need help. how can i modify my code.

my schematic is at top. i upload.

Yes you uploaded it after I made my first post, which made my post look quite stupid didn't it?

You should read the forum rules:-
How to use this forum

The schematic is very poor with too many things going to headers and interconnections not being shown.
It looks like you are making direct un-isolated connections with the mains, which in most countries is illegal.
I can not follow it. If any one else can then you are welcome.