hello
New to arduino and from a not technical background.
Assembled a buck converter as per the wiring diagram but due to some reason not able to get output above 1-2 volts.
IRFZ44N mosfet
12V lead acid battery as power supply for buck converter
5V supply for arduino, ground of lead-acid connected to the arduino.
would be extremely thankful if someone can guide me in the right direction.
/for testing purpose with manual PWM cycle
#define pwmpin 9
#define vdpin A1
#define potpin A0
int Vdread = 0; //voltage divider raw reading
int Potread = 0; //potentiometer raw reading
float Volt = 0.00;
void setup() {
// put your setup code here, to run once:
TCCR1B = TCCR1B & 0b11111000 | 0x01; //increase PWM freq to 31KHz , timer 1 pin D9
pinMode(vdpin, INPUT); // voltage divider read
pinMode(pwmpin, OUTPUT); // PWM mosfet gate
pinMode(potpin, INPUT); //pot read
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
Vdread = analogRead(vdpin); //raw reading of voltage divider
Potread = analogRead(potpin) / 4;
// Volt = (5.00 / 1024.00) * Vdread * 10.9;
// averaging 10 readings of voltage divider
int i = 0;
float sum = 0;
while (i < 11) {
sum += (5.00 / 1024.00) * Vdread * 10.9;
i++;
delay(10);
}
Volt = sum / 10;
// maping PWM duty cycle with potentiometer value
int pwmcycle;
// Potread = 128;
pwmcycle = map(Potread, 0, 255, 0, 100);
analogWrite (pwmpin , Potread);
Serial.println("output Volts " + String(Volt));
Serial.println("PWMreading =" + String(pwmcycle) + "%");
Serial.println("pot reading " + String(Potread));
//resetting variables
i = 0;
sum = 0;
delay(500); // Delay a little bit to improve simulation performance (0.5 sec)
}




