0
\$\begingroup\$

I'm having trouble with a boost converter I made: it outputs 1.2V with no load and 2.4 with one. I expect to draw 0.25 Amps MAX with Roughly 0.2 Amps continuous. My battery pack is 2P2S NiMH with the cells having 2.4AmH capacity

Code:

byte val=127;

void setup()
{
  analogReference(INTERNAL1V1);
  pinMode(A3,INPUT);
  pinMode(4,OUTPUT);
  analogWrite(4,val);
}

void loop()
{
  if(analogRead(A3)>512)
  {
    val-=1;
    analogWrite(4,val);
  }
  else if(analogRead(A3)<512)
  {
    val+=1;
    analogWrite(4,val);
  }
//endif
  delay(1);
}

Schematic:

schematic

simulate this circuit – Schematic created using CircuitLab

No, I will not buy something off of the self. I want to learn my mistakes and correct them.

\$\endgroup\$
  • \$\begingroup\$ What specifically does the analogWrite() function do? Is it a PWM output function? What waveform (duty cycle, frequency) do you see on pin 4? Do you really have 1mF of capacitance on the output? (Inrush current will be high, potentially saturating L1. If you start the boost while L1 is saturated you may lose Q1.) Why not use a MOSFET in place of the BJT and a Schottky in place of D1? Efficiency will be higher. Is this intended to be a fixed frequency voltage mode PWM scheme? Are you going for dominant pole compensation with very low bandwidth? \$\endgroup\$ – John D Jan 9 '15 at 20:50
  • \$\begingroup\$ analogWrite(byte) makes a pwm on a scale of 0 (0% Duty) to 255 (100% Duty). I don't have an oscilloscope. 1000uf, yes. I only have BJTs, on no Schottkys (I do have switching diodes, though) \$\endgroup\$ – Alexander M Jan 9 '15 at 20:53
  • \$\begingroup\$ So if your output is above the reference you set your PWM to 1/255%, and below the reference you integrate by adding 1 to the PWM value? Sounds like an oscillator to me :) Have you looked at the output on a scope? \$\endgroup\$ – John D Jan 9 '15 at 20:55
  • \$\begingroup\$ @JohnD (Prods due to my comment edit) \$\endgroup\$ – Alexander M Jan 9 '15 at 21:03
  • \$\begingroup\$ Are you sure you're happy with the default 490Hz switching frequency? \$\endgroup\$ – Ignacio Vazquez-Abrams Jan 9 '15 at 21:23
2
\$\begingroup\$

"I want to learn my mistakes and correct them."

Ok, start with the code. I've not used an AtTiny, but there are some things that stand out and should be considered.

  • What starts the loop? Does it just free run? Usually it's best to start the loop from a PWM timer interrupt. That way the ADC is read, and PWM value is updated once per PWM cycle. If the loop free runs, it won't be synchronous with the PWM, and it may not even be consistent if other processes are going on.

  • What is the PWM frequency? Is it 8MHz/256, or ~32KHz? Let's just say it is 32KHz. What is the conversion time of the ADC? can it support 32KHz?

  • What happens to the PWM control output if variable val is less than 0 or greater than 255? Integrator accumulators have to be bounded.

  • What happens if AnalogRead() is equal to 512? Is that implicitly handled by the IF statement as a noop? If so, do you really want a dead spot in the integrator?

  • The integrator can change the PWM control at every sample point, which means it will have way too much gain. Integrators in loops like this need a scale factor which will effectively be less than 1, or a division. That also means that each integrator contribution per sample will end up being some fraction. How do you handle sums of quantities that are each less than 1?

  • Does the AtTiny have a hardware multiplier? If not, are you going to do multiply/divide by left shift/right shift or software algorithm?

Boost converters can be very hard to control. With a 470uH inductor, operation will be continuous conduction mode (CCM). In CCM there are 2 complex poles and a right half plane zero. Either of these will make the control unstable if not properly compensated. Since you don't seem to be familiar with control theory, perhaps you shouldn't even use an integrator, maybe hysteretic or bump control would be better. These types of control don't control as tightly as a PI, but they are simple and an AtTiny could probably support them. First, set the PWM to a fixed duty cycle like 50% (you'll need to experiment to get a workable duty cycle). Then each cycle check if Vo is greater than a set value. If Vo is greater than the set point then don't put out a pulse the next cycle. If Vo is less than or equal to the set point then do put out a pulse the next cycle. Also, for a bump control a smaller value for L1 will be needed to operate in discontinuous conduction mode (DCM). Bump control will not work with CCM since filter Q will be to high, and the output would ring.

Boost

Since a boost has a direct path from the battery through L1 and D1 to the output, even if Q1 never switches, the output won't be less than ~1.8V (that's Vin - 0.6v). It's hard to imagine what could cause an output of 1.2V with no load. But, pretty much every part you are using has a problem.

  • What is the resistance of L1, also saturation current and self resonant frequency? With L1 of 470uH and C2 of 1mF, unless L1 resistance is at least 0.5 Ohms, output filter Q will be over 5, very ringy. Also at 0.5 Ohms, L1 will dissipate ~125mW with Io of .25A. For DCM operation a smaller inductor will be needed anyway. The CCM/DCM boundary can be used to find an upper limit for L1 in DCM operation.

    L1 < \$\frac{V_o}{16 i_{\text{crit}} f_s}\$ or \$\frac{\text{5V}}{\text{(0.25A)} \text{(16)} \text{(30kHz)}}\$ = 38uH

  • Q1 is only being driven with ~2mA, but only has \$\beta\$ of ~20. It will never switch the current needed with that kind of drive. It would be best to change to a logic level FET.

  • D1 needs to be a switching diode and a schottky would be best. Something like a 1N5818 would work.

  • A 5.6V zener should be added across \$V_o\$ to keep the output from over voltage.

If you are going to design a Boost, you should read "Understanding Boost Power Stages".

\$\endgroup\$
1
\$\begingroup\$

TL/DR: this will never work

This is how I would learn it: 1. Run it open loop with initial duty cycle of 50% with ~1K load at the highest possible PWM frequency of your micro. 50% duty will get you close to needed ratio without much effort, you only need to know how duty cycle is calculated. See this -> http://en.wikipedia.org/wiki/Boost_converter . Attempt to achieve your desired load current by substituting resistors. If unsuccessful, calculate necessary inductance for your frequency, substitute (you want ripple current on the order of 10-20%). You may need to substitute micro for one with faster PWM - the code you're using runs at 500Hz which for your current would require much larger inductor. When successful, go to next step.

  1. Read Microchip appnote 1467. From it, learn how to code PID on small micros, and also that this kind of converter is only fast enough for charging batteries which doesn't seem to be your goal.
\$\endgroup\$
0
\$\begingroup\$

First off, always have a load.

If your output voltage is the same as your input voltage, it might mean your duty cycle is dropping to zero. Did you try starting with a fixed 50% duty cycle? What duty cycle are you ending up with? What is your switching frequency? You really need a scope to debug this, or at least a debugger.

Switching converters are not trivial. You might see if you can find an existing control library. It would probably be more reliable than rolling your own.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.