johnny78
Full Member level 5
hi Guys
i need to use an MCU as a voltage regulator
read about pwm & checked for some projects on the net
would you check this please ?
first i think the mosfet is connected wrong way (or im wrong) ?
after correcting the connection(S is the input & D is the output) & upladed the simple pwm code to my UNO
& build the citcuit on 3A dc dc buck conveter which i have removed the lm2596 & connected the IRF4509 on it
but it didt work as a regulator
& tried to drive the mosfet with arduino uno with this code
i need to use an MCU as a voltage regulator
read about pwm & checked for some projects on the net
would you check this please ?
first i think the mosfet is connected wrong way (or im wrong) ?
after correcting the connection(S is the input & D is the output) & upladed the simple pwm code to my UNO
& build the citcuit on 3A dc dc buck conveter which i have removed the lm2596 & connected the IRF4509 on it
but it didt work as a regulator
& tried to drive the mosfet with arduino uno with this code
Code:
/*
* This is an example code for a BUCK converter circuit made with arduino
* I've used arduino NANO. We have to set the timer of the PWM on pin D3
* No feedback is connected here
* Subscribe: http://www.youtube.com/c/electronoobs
* webpage: http://www.electronoobs.com/eng_circuitos_tut10.php
*/
int potentiometer = A0; //From the main potentiometer
int PWM = 3;
void setup() {
pinMode(potentiometer, INPUT);
pinMode(PWM, OUTPUT);
TCCR2B = TCCR2B & B11111000 | B00000001; // pin 3 and 11 PWM frequency of 31372.55 Hz
}
void loop() {
float voltage = analogRead(potentiometer);
int VALUE = map(voltage,0,1024,0,254);
analogWrite(PWM,VALUE);
}