Prius Gen2 Boost Converter - how to use?  [SOLVED]

Topics concerning the Toyota and Lexus inverter drop in boards
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Prius Gen2 Boost Converter - how to use?

Post by catphish »

I'm looking to get a Prius gen2 inverter up and running. I'm hoping to use the internet boost converter to boost my battery voltage (60V or 120V) to 300V to run my motor. I am using the openinverter gen2 Prius board.

Would anyone be able to point me in the direction of how to get the boost converter running? I see the openinverter has a pin to connect to the boost converter pin, but how should this be configured / used?
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Prius Gen2 Boost Converter - how to use?

Post by catphish »

To elaborate on this, it seems clear that to enable the boost converter, the CSDN line should be held low, but I am very confused about the following line from the wiki: "CPWM Enables charge mode when fed 12v via 470R". I don't understand why pulling CPWM to +12v wouldn't simply short out the battery by driving the boost converter into a continuous low switched state. Any pointers appreciated.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Prius Gen2 Boost Converter - how to use?

Post by Pete9008 »

Afraid I don't know the gen 2 too well but on the gen 3 you have direct access to the high and low side IGBT bridge control lines. On the gen 2 I think these are combined onto a single line (deadtime is handled by the inverter) and this sounds like the CPWM line.
I'd expect to need a control loop which monitors the voltage coming out and then controls the duty cycle of the CPWM line to drive the voltage to the desired value, not sure whether this is already in the OpenInverter code??
User avatar
mjc506
Posts: 343
Joined: Wed Sep 09, 2020 9:36 pm
Location: Wales, United Kingdom
Has thanked: 30 times
Been thanked: 28 times

Re: Prius Gen2 Boost Converter - how to use?

Post by mjc506 »

The boost converter has 6(?) pins
  • CSDN - shutdown. When 12V (high) both IGBTs are off, isolating battery from HV bus. I've got a scribble saying it can be left unconnected if not needed, but not sure about that.
  • GCNV - Converter ground. Connect to system (LV/12V) ground
  • VH - Analogue DC bus voltage (through a voltage divider, I'm fairly sure the voltages are 5V microcontroller-safe)
  • VL - Battery voltage. Through a voltage divider as above.
  • CT - Converter Temperature. Pretty sure this is the IGBT temp. Again, 0-5V. My notes say up to 20degC is 4.5V, dropping linearly to 0.5V at 150degC
  • CPWM - this is the interesting one:
CPWM. When high (12V), low side IGBT is on (shorts battery). When low (0V), high side IGBT is on. Should default (on microcontroller boot, etc) to low!! Keep PWM away from 0 and 100% duty cycles. Use a 470R resistor to limit current into the pin (much bigger doesn't work, a bit smaller is ok)

Here's some sketchy Arduino code for a Teensy (note that this is pulled out of something bigger, and may not compile as-is. Also that the teensy drives CPWM through an inverting driver, so the PWM is inverted (mainly done to keep CPWM low at boot))

Code: Select all

// Sketch to run the Prius boost converter
//Boost converter defines
#define PWM_RES 12 //bits
#define PWM_FREQ 3662.109 //Hz, for boost converter
#define BOOST_PIN 10 //boost converter pwm input
#define BOOST_ENABLE_PIN 11 //boost converter enable input
#define VH A9 //DC bus voltage
#define VL A20 //Batt voltage
#define ANA_RES 12 //analog read resolution, bits
int32_t pwm_min=0; //may need to be non-zero for real use?
int32_t pwm_max=int32_t(pow(float(2),float(PWM_RES)));
int32_t pwm_val=4096; //initial PWM value
int8_t step_size=1; //rate at which PWM changes. Too large a step will cause oscilation, and too small a slow response. Better to make CPWM duty cycle controlled by PID later
volatile int32_t batt_volt_dig[2]={0,0};
volatile int32_t bus_volt_dig[2]={0,0};
volatile int32_t batt_curr_dig[2]={0,0}; //want to measure batt current too
int32_t batt_volt_offset=625;
int32_t bus_volt_offset=629; //adc reading at 0 volts
const float dig_per_volt_batt=10.015;
const float dig_per_volt_bus=7.651;
const float dig_per_amp_batt=1.0;
float batt_volt=0;
float bus_volt=0;
float batt_current=0;

//battery charging/discharging/dc bus/etc - will adjust boost pwm to keep DC bus voltage correct, while charging and discharging the battery
float battery_volt_max=999.0; //maximum allowed battery voltage when charging
float battery_volt_min=1.0; //minimum allowed battery voltage when discharging
float battery_amps_max=1.0; //amps, maximum in or out allowed (allow different limits for charge and discharge?)
float bus_volt_target=320.0; //target DC bus voltage for AC output (is this a minimum? or does it need to change?)
#define DC_BUS_VOLT_TARGET 320.0 //V DC

const uint32_t serial_interval=250; //ms, reporting interval
uint32_t last_time=0;
uint32_t last_freq_time=0;

//timers
IntervalTimer task_10ms; //read battery and bus voltages

FASTRUN void voltage_update() { //10ms task
  //Butterworth 1st order low pass filter with alpha=0.025 http://www.schwietering.com/jayduino/filtuino/index.php
  batt_volt_dig[0] = batt_volt_dig[1];
  batt_volt_dig[1] = ((((analogRead(VL) * 612030L) >>  4)  //= (   7.2959657268e-2 * x)
        + ((batt_volt_dig[0] * 895569L) >> 1) //+(  0.8540806855*v[0])
        )+262144) >> 19; // round and downshift fixed point /524288
  
  bus_volt_dig[0] = bus_volt_dig[1];
  bus_volt_dig[1] = ((((analogRead(VH) * 612030L) >>  4) + ((bus_volt_dig[0] * 895569L) >> 1))+262144) >> 19;
}

void setup() {
  // put your setup code here, to run once:
  pinMode(LED_BUILTIN, OUTPUT);
  analogReadResolution(ANA_RES);
  //Turn on serial output for debugging
  Serial.begin(115200);
  while (!Serial) {
    //wait for serial monitor
    digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
    delay(100);
  }
  Serial.println("Prius boost converter test sketch");
  update_sine();

  //Set the pwm resolution and frequency
  Serial.println("Boost converter settings:");
  Serial.print("Setting pwm resolution to ");
  Serial.print(PWM_RES);
  Serial.println(" bits...");
  analogWriteResolution(PWM_RES);
  Serial.print("Setting pwm frequency to ");
  Serial.print(PWM_FREQ);
  Serial.println("Hz...");
  analogWriteFrequency(BOOST_PIN, PWM_FREQ);
  Serial.println("...done");
  Serial.println("");
  digitalWrite(LED_BUILTIN, HIGH); //led on
  Serial.print("PWM min = ");
  Serial.print(pwm_min);
  Serial.print(", PWM max = ");
  Serial.print(pwm_max);
  Serial.print(".\nCurrent PWM = ");
  Serial.println(pwm_val);
  task_10ms.begin(voltage_update, 10000);
}

void loop() {
  // put your main code here, to run repeatedly:
  //read voltages
  noInterrupts();
  int32_t batt_dig = batt_volt_dig[0] + batt_volt_dig[1] - batt_volt_offset;
  int32_t bus_dig = bus_volt_dig[0] + bus_volt_dig[1] - bus_volt_offset;
  interrupts();
  batt_volt = float(batt_dig)/dig_per_volt_batt;
  bus_volt = float(bus_dig)/dig_per_volt_bus;
  
  //set pwm
  if (Serial.available() > 0) {
    pwm_val = Serial.parseInt();
  }
  if (pwm_val >= pwm_max) {
    pwm_val = pwm_max;
  }
  else if (pwm_val <= pwm_min) {
    pwm_val = pwm_min;
  }
  analogWrite(BOOST_PIN,pwm_val);

  //reporting
  if (millis()-serial_interval >= last_time) {
    Serial.print("\nBattery voltage: ");
    Serial.print(batt_volt);
    Serial.print("V\nBattery current: ");
    Serial.print(batt_current);
    Serial.print("A\nBus voltage: ");
    Serial.print(bus_volt);
    Serial.print("V\nPWM value: ");
    Serial.println(pwm_val);
    last_time = millis();
  }
}

As far as the gen2 prius controller board... I've not got one. I've a vague recollection there's an ATMEGA mounted to drive the boost regulator? I'd be very careful and check everything with a scope (including during boot and resets) to make sure that CPWM isn't held high for too long ever!
User avatar
johu
Site Admin
Posts: 5681
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 959 times
Contact:

Re: Prius Gen2 Boost Converter - how to use?  [SOLVED]

Post by johu »

The controller board only provides a low side switch for CPWM and ignores the other pins. I used to connect CSDN in parallel to the DC+ relay, that way it is pulled to 12V (=inactive) when the latter is off and grounded (=active) when DC+ switch is on.
CPWM needs to be pulled up to 12V externally, via 470 Ohms or so. Otherwise it does nothing. It is a wired OR of TIM1_CH2N and TIM4_CH4 aka user PWM. User PWM becomes active right after the firmware boots up. You set pwmofs to a value that gets you around the desired 300V bus voltage and set pwmgain=0. No closed loop regulation here.
TIM1_CH2N only becomes active in charge mode as the negative pins are disabled when a Prius board is detected
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Prius Gen2 Boost Converter - how to use?

Post by catphish »

Thanks!

I think I posted this elsewhere, but just wanted to follow up on this thread too. Based on this information I got the boost controller working nicely.

I made a small change to the setup though. Rather than have CPWM pulled high, I added a PNP BJT (ie a high side switch) to my wiring loom to invert the signal. When "user PWM" is active it pulls the line low, which drives the BJT and pulls CPWM high.

This was an easy addition and has 2 major benefits. 1) It fails safe if the STM32 resets, this means I can do software updates etc without worry. 2) Because the signal is now inverted twice (low side switch followed by high side switch), lower values of PWM equate to lower voltages, and a value of zero disables the boost.

By doing it this way, I'm comfortable just permanently enabling both MSDN and CSDN. I have tested boosting my 30V bench power supply to 90V, and will soon try the same thing with a 60V battery, which should give enough power for my experiments.
RetroZero
Posts: 702
Joined: Tue Oct 29, 2019 2:48 pm
Location: France
Has thanked: 311 times
Been thanked: 38 times
Contact:

Re: Prius Gen2 Boost Converter - how to use?

Post by RetroZero »

Interesting..... Since the toyota PM motors need high voltage, this could be a way of obtaining the 450vdc internally required for optimum performance from a 96s battery pack🤔.... Will watch from the sidelines 👍
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Prius Gen2 Boost Converter - how to use?

Post by arber333 »

RetroZero wrote: Sat Jan 07, 2023 9:57 am Interesting..... Since the toyota PM motors need high voltage, this could be a way of obtaining the 450vdc internally required for optimum performance from a 96s battery pack🤔.... Will watch from the sidelines 👍
I am really seeing the potential for DIY charging from 3phase on the MG1 inputs here.
Since you could reduce 600V rectified to managable 380Vdc for charging your 96S pack....
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Prius Gen2 Boost Converter - how to use?

Post by catphish »

arber333 wrote: Sat Jan 07, 2023 11:10 am I am really seeing the potential for DIY charging from 3phase on the MG1 inputs here.
Since you could reduce 600V rectified to managable 380Vdc for charging your 96S pack....
Yes, this has already been proven to work. Your mains input to MG1 needs to be higher voltage than your battery pack. See:

User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Prius Gen2 Boost Converter - how to use?

Post by catphish »

RetroZero wrote: Sat Jan 07, 2023 9:57 am Interesting..... Since the toyota PM motors need high voltage, this could be a way of obtaining the 450vdc internally required for optimum performance from a 96s battery pack🤔.... Will watch from the sidelines 👍
Yes, as far as I know, this is exactly why the boost converter exists, to run a high voltage motor from the 200V Prius battery. However, most people do not use this in conversions because it can only handle very limited power.
RetroZero
Posts: 702
Joined: Tue Oct 29, 2019 2:48 pm
Location: France
Has thanked: 311 times
Been thanked: 38 times
Contact:

Re: Prius Gen2 Boost Converter - how to use?

Post by RetroZero »

I got the charger part in Buck mode working for testing purposes, but will install an EU/CE bms and charger system to attempt homologation process. I'm more interested in getting the full 80kw out of a duel motor setup running 300vdc.. 😉 So need to boost to about 450v ,but buck when in regen.
User avatar
johu
Site Admin
Posts: 5681
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 959 times
Contact:

Re: Prius Gen2 Boost Converter - how to use?

Post by johu »

RetroZero wrote: Sat Jan 07, 2023 3:38 pm I got the charger part in Buck mode working for testing purposes, but will install an EU/CE bms and charger system to attempt homologation process. I'm more interested in getting the full 80kw out of a duel motor setup running 300vdc.. 😉 So need to boost to about 450v ,but buck when in regen.
You won't get 80 kW through the converter. The current limit must be around 100A (judging from the 20 kW limit @ 200V and peoples experience). So at 360V -> 36 kW.

Apart from that it's a synchronous converter, it acts like a transformer for DC. So if set to 50% it will make 400V from 200V or 200V from 400V in the other direction
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Prius Gen2 Boost Converter - how to use?

Post by Pete9008 »

johu wrote: Sat Jan 07, 2023 7:44 pm Apart from that it's a synchronous converter, it acts like a transformer for DC. So if set to 50% it will make 400V from 200V or 200V from 400V in the other direction
How does that work then? It looks just like a standard buck/boost switcher configuration and in those the PWM value depends on the load impedance?
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Prius Gen2 Boost Converter - how to use?

Post by catphish »

Pete9008 wrote: Sat Jan 07, 2023 8:00 pm How does that work then? It looks just like a standard buck/boost switcher configuration and in those the PWM value depends on the load impedance?
That's a really good question. To me it just looks like a standard switching boost converter. I can only speculate that the reason it's so stable at a fixed PWM value is because the inductor and capacitor are so absurdly large.
User avatar
johu
Site Admin
Posts: 5681
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 959 times
Contact:

Re: Prius Gen2 Boost Converter - how to use?

Post by johu »

Synchronous means it has high and lowside switches. If you look at the diagram of a buck and a boost converter you'll notice that this is both. Seen from one direction it boosts, seen from the other direction it bucks. So say you running 50% duty cycle and you've got your voltage sitting at 200V on the input of the booster. Then it will boost to 400V. So say by regen you raise your 400V to 410V. Then this will be bucked to 205V on the other side. If that happens to be a battery, it will be charged.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Prius Gen2 Boost Converter - how to use?

Post by Pete9008 »

Erm, not sure about that. Although the circuit looks like that I don't believe IGBTs conduct well in the reverse direction and so it is the reverse parallel diode that carries the current in this configuration. When including that it simplifies down to a standard forward boost regulator and a standard reverse buck regulator only one of which is active at any time depending on current flow (which itself depends on PWM, load impedance and source voltage). I can see how the PWM value can be thought of as regulate current in the way you describe but can't see how that works when regulating voltages.

What am I missing?
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Prius Gen2 Boost Converter - how to use?

Post by catphish »

Pete9008 wrote: Sat Jan 07, 2023 10:49 pm Erm, not sure about that. Although the circuit looks like that I don't believe IGBTs conduct well in the reverse direction and so it is the reverse parallel diode that carries the current in this configuration. When including that it simplifies down to a standard forward boost regulator and a standard reverse buck regulator only one of which is active at any time depending on current flow (which itself depends on PWM, load impedance and source voltage). I can see how the PWM value can be thought of as regulate current in the way you describe but can't see how that works when regulating voltages.

What am I missing?
I don't think it really matters whether the top IGBT conducts or not, as the body diode can fill in regardless. So in the forward direction it is indeed a regular boost converter. With regard to its ability to regulate voltages (and this is very speculative):

1) My own experience confirms that it can regulate voltage very well by just adjusting its duty cycle, but I also don't believe it could be independent of load.
2) With my extremely minimal load, the voltage seems very stable, I assume because the size of the inductor and capacitor far exceed the load I am drawing.
3) There are voltage sense lines for both battery voltage and inverter bus voltage, so it seems likely to me that the OEM VCU uses feedback to regulate the voltage by varying the duty cycle.

When used as a buck converter for charging, the situation is similar. We can measure the charge current, and regulate the duty cycle to achieve the desired current. In this case, the low side cycle seems a bit wasteful, but from what I've seen very little real power is used by it.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Prius Gen2 Boost Converter - how to use?

Post by Pete9008 »

Yep, that's how I see it working too :)

Not too sure what you mean by low side cycle though?
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Prius Gen2 Boost Converter - how to use?

Post by catphish »

Pete9008 wrote: Sat Jan 07, 2023 11:15 pm Yep, that's how I see it working too :)

Not too sure what you mean by low side cycle though?
There is a high side switch (that connects the DC bus to the battery) and a low side switch (that short circuits the battery). There are no separate "buck" and "boost" modes, so in all cases, both switches are being operated. Even when charging, you short circuit the battery periodically.

However, now that I've thought this through, I realize that the inductor smooths out this current flow, so when the low side is switched on, this isn't actually pulling current from the battery, it's just reducing the flow of current towards the battery.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Prius Gen2 Boost Converter - how to use?

Post by Pete9008 »

When bucking and the low side is on the current is actually flowing up through the lower IGBT diode and into the inductor to sustain the inductor current flowing to the battery so no losses (other than due to the diode drop) there at all. Need to sketch out the two circuit to make it clear but too late now to do that now!

Edit - think of it this way, when in buck mode the current to the battery has to come from somewhere, when the high side switch is on it comes from the DC bus, when the high side is off the current comes up through the lower IGBTs reverse diode (it will do this regardless of whether the lower IGBT is turned on or not) to sustain the current through the inductor (the IGBT end of the inductor will actually be negative at this point to drive the current through the diode). Think of it as charging the inductor when the high side is on and discharging it when the high side is off.

When boosting the low side IGBT is turned on to store energy into the inductor by ramping up its current. When the low side turns off the inductor current is then forced (by the inductor flyback voltage) to flow though the high side reverse diode (again regardless of whether the high side IGBT is on or off) and onto the DC bus.
User avatar
johu
Site Admin
Posts: 5681
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 959 times
Contact:

Re: Prius Gen2 Boost Converter - how to use?

Post by johu »

My 50% example was a bit over simplified, yes you do need regulation to maintain a fixed voltage :) Same goes for a regular transformer
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Prius Gen2 Boost Converter - how to use?

Post by Pete9008 »

You might be surprised how good the voltage regulation on a normal magnetic AC transformer can be, I had some custom made ones done years ago and the voltage regulation was almost perfect even at loads well above the rating. The post regulation normally present is more to cope with cheap transformers and the rectifier/smoothing cap voltage drops.

Modern commercial transformers are often pretty poor, designed down to a price with the bare minimum of copper and core material and often working on the edge of core saturation at full load!
RetroZero
Posts: 702
Joined: Tue Oct 29, 2019 2:48 pm
Location: France
Has thanked: 311 times
Been thanked: 38 times
Contact:

Re: Prius Gen2 Boost Converter - how to use?

Post by RetroZero »

Well, the 200v boost to 400v sounds promising.
johnspark
Posts: 264
Joined: Fri Apr 12, 2019 10:42 pm
Location: Adelaide, South Australia
Has thanked: 59 times
Been thanked: 48 times

Re: Prius Gen2 Boost Converter - how to use?

Post by johnspark »

I would like to use the boost converter to top up my ~300V battery to 350 V or whatever is needed by my Prius Gen 2 MG1 and MG2 transaxle. I am putting my post here because it is very close to what I want to do even though I have a Camry AVV50R inverter and not a Prius Gen2 Converter. I am thinking if I can keep the voltage low enough, the power required to flow through the inductor is minimal and should be within the limits of the inductor. The only concern is that the boost IGBTs are powerful enough.
evMacGyver
Posts: 108
Joined: Tue Jun 15, 2021 5:44 pm
Location: Finland
Has thanked: 19 times
Been thanked: 5 times

Re: Prius Gen2 Boost Converter - how to use?

Post by evMacGyver »

johnspark wrote: Mon Feb 06, 2023 8:15 am I would like to use the boost converter to top up my ~300V battery to 350 V or whatever is needed by my Prius Gen 2 MG1 and MG2 transaxle.
Why would you like to boost battery voltage higher? I'm not familiar with Prius transaxle, but I'm pretty sure you don't need higher voltage even to reach top RPM from both MGs. For comparison GS450h will get 10000rpm at 250V.
Post Reply