i'm trying to use Arduino uno as a PID controller to convert a 7-18V dc input to a 24v dc output
i've written this program which seems to work fine in simulation but when i use it in real life using a 9v battery as input i get around 6v in the output instead of 24v (weird considering its a BOOST converter
) and the output voltage decreases over time to around 3.5v
<PID_v1.h>
int pwmPin = 6;
int ledPin = 13;
int analogPin = 0;
int val = 0;
unsigned long previousMillis = 0; // will store last time
const long interval = 500; // interval at which to delay
double Setpoint, Input, Output;
double Kp=0, Ki=40, Kd=0;
PID myPID(&Input, &Output, &Setpoint, Kp, Ki, Kd, DIRECT);
void setup() {
pinMode(pwmPin,OUTPUT);
pinMode(ledPin, OUTPUT); // onboard LED
TCCR0B = (TCCR0B & 0b11111000) | 0x01; // 62KHz
analogWrite(pwmPin, 120);
Serial.begin(9600);
//initialize the variables we're linked to
Input = analogRead(analogPin);
Setpoint = 46; // 46= 24v 92=45V 200=99V
//turn the PID on
myPID.SetMode(AUTOMATIC);
myPID.SetOutputLimits(0,220);
}
void loop() {
Input = analogRead(analogPin); // read the input pin
myPID.Compute();
analogWrite(pwmPin, Output);
// Blink the status LED
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
digitalWrite(ledPin, !digitalRead(ledPin));
Serial.println(Input);
Serial.println(Output);
Serial.println("");
}
}
these are the components that i'm using:
IRLZ44N power MOSFET
100uH 3A inductor
1N5819 schottky diode
47uF 50v capacitor
and i've uploaded the schematics
i can't figure out what the problem is. can somebody help me plz ?
