First attempt here from myself to run in buck mode to drop a 360v nominal HV down to 200v to run the dcdc converter section without modification. Only tested on the bench with low voltages in a Yaris inverter but seems to work well.
Code: Select all
/*
Runs atmega328p buck/boost control on Prius Gen 3 and Yaris/Auris inverters in buck mode to drop Main HV down for DCDC converter.
Experimental code. Only tested on the bench! Use at your own risk!
D.Maguire
*/
#include <Metro.h>
int HVLow = 0; // voltage on low side of converter
int HVHi = 0; // voltage on high side of converter
int SetV = 0; //set point voltage
int PWMDuty = 0; //pwm duty cycle
Metro timer_pwm=Metro(5);
Metro timer_serial=Metro(200);
void setup() {
Serial.begin(9600);//
TCCR1B = TCCR1B & B11111000 | B00000010; // set timer 1 divisor to 8 for PWM frequency of 3921.16 Hz
pinMode(9, OUTPUT); //boost low side
pinMode(10, OUTPUT); //boost Hi side
analogWrite(9,0); //low side off
SetV=15; //set at 15v for bench test with 30v input.
PWMDuty=0;
}
// the loop function runs over and over again forever
void loop() {
HVLow = (analogRead(A0)/1.85);
HVHi = (analogRead(A1)*1.25);
updatePWM(); //call pwm update routine.
serialOUT(); //call serial out routine
}
void serialOUT()
{
if(timer_serial.check()){
Serial.print("Low Vbus = ");
Serial.print(HVLow);
Serial.print("Volts");
Serial.print("\t High Vbus = ");
Serial.print(HVHi);
Serial.print("Volts");
Serial.print("\t PWMDUTY = ");
Serial.println(PWMDuty);
}
}
void updatePWM()
{
if(timer_pwm.check()){
if (HVLow<SetV) PWMDuty++;
if (HVLow>SetV) PWMDuty--;
if (PWMDuty<0) PWMDuty=0;
if (PWMDuty>250) PWMDuty=250;
analogWrite(10,PWMDuty);
}
}