Hello all,
I have a Problem with my project. I am trying to build a boost converter which is also able to control high voltages and currencies and is controlled by a feedback channel. Depending on the temperature of the sensor, the voltage should be x Volt or y Volt. The code works with no problems. I am working with an external battery pack 3S2P. The circuit works with no problems as long I don't connect a consumer which needs high currency. WIth 1000 Ohm, no problem, 220 Ohm also works, but with a 10 Ohm resistor, the circuit is not able to reach the wish voltage for example 20 Voltages. In the following you find the code and the circuit.
Maybe the frequency of the Arduino is not high enough? Maybe wrong inductor / conductor size?
I really appreciate your support. Thanks.
The code is as following.
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Adafruit_BMP280 bmp; // use I2C interface
Adafruit_Sensor *bmp_temp = bmp.getTemperatureSensor();
Adafruit_Sensor *bmp_pressure = bmp.getPressureSensor();
float zwischenspeicherLuftdruck;
float zwischenspeicherTemperatur;
const int onPin = 9;
float onVoltage = 20.0;
float standbyVoltage= 7.0;
const int feedback = A0;
int pwm = 0;
void setup() {
Serial.begin(9600);
Serial.println(F("BMP280 Sensor event test"));
lcd.begin(16,2);
lcd.print("test");
lcd.setCursor(0,1);
lcd.print("phase");
delay(500);
lcd.setCursor(0,1);
lcd.print("Ready");
if (!bmp.begin(0x76)) {
Serial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
while (1) delay(10);
pinMode(onPin, OUTPUT);
pinMode(feedback, INPUT);
/* Default settings from datasheet. /
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, / Operating Mode. /
Adafruit_BMP280::SAMP![1|666x500]
LING_X2, / Temp. oversampling /
Adafruit_BMP280::SAMPLING_X16, / Pressure oversampling /
Adafruit_BMP280::FILTER_X16, / Filtering. /
Adafruit_BMP280::STANDBY_MS_500); / Standby time. */
bmp_temp->printSensorDetails();
sensors_event_t temp_event, pressure_event;
bmp_temp->getEvent(&temp_event);
bmp_pressure->getEvent(&pressure_event);
}
}
void loop() {
//Einspielen von Methoden
sensors_event_t temp_event, pressure_event;
bmp_temp->getEvent(&temp_event);
bmp_pressure->getEvent(&pressure_event);
//gemessene Werte einer Variable zuordnen
zwischenspeicherTemperatur = temp_event.temperature;
zwischenspeicherLuftdruck = pressure_event.pressure; // in hPa
//Ausgabe von Werten, informativ für uns
Serial.print(F("Temperature °C = "));
Serial.println(zwischenspeicherTemperatur);
Serial.print(F("Pressure hpa = "));
Serial.println(zwischenspeicherLuftdruck);
float output = analogRead(feedback);
Serial.print("actual voltage: ");
double actualvoltage =analogRead(feedback);
double actualVoltageReal = actualvoltage / 1023 * 5.0 * 43.0 / 10.0;
Serial.println(actualVoltageReal);
if(zwischenspeicherTemperatur < 44){
Serial.print("power voltage: ");
Serial.println(onVoltage);
if (onVoltage > actualVoltageReal)
{
pwm = pwm+1;
pwm = constrain(pwm, 1, 254);
}
else{
pwm = pwm-1;
pwm = constrain(pwm, 1, 254);
}
analogWrite(onPin, pwm);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("heating");
lcd.setCursor(0,1);
lcd.print(actualVoltageReal);
}
else {
Serial.print("standby voltage: ");
Serial.println(standbyVoltage);
if (standbyVoltage > actualVoltageReal)
{
pwm = pwm+1;
pwm = constrain(pwm, 1, 254);
}
else{
pwm = pwm-1;
pwm = constrain(pwm, 1, 254);
}
analogWrite(onPin, pwm);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("standby");
lcd.setCursor(0,1);
lcd.print(actualVoltageReal);
}
Serial.println(pwm);
Serial.println("___________________");
}