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).
int vout_to_adc(float volt)
  return (int)((volt*VRATIO/(VREF))*1023.0);

void setup()
  // Setup serial port for control & debug.
  // Pins default to inputs, so we only have to setup this one.
 // 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.
  vtarget = vout_to_adc(20.0);
  analogWrite(pwmpin, pwm); // Set duty cycle (0 to 255).

void loop()
  // Measure the current value of Vout.
  vout = analogRead(feedback);

  // 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 if (vout<vtarget-hysteresis) 
    pwm += 1;

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


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[] =

hope that this would help u understand my tasks :slight_smile:

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.

Please understand, your words make little sense without a schematic. Are you serious about wanting help?

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.