0
\$\begingroup\$

I was working on designing a feedback compensator for my buck converter. I decided to use the compensator circuit in the feedback and give its output to Arduino which gives the duty cycle as shown below. The Arduino senses the voltage and directly generates a duty cycle without any other calculations. I have figured out my transfer functions and is of the form shown below. : enter image description here

enter image description here

An example of how my compensator equation will look like.

This compensator will give me some analog circuit based on OP-amps, capacitors and resistors.

I have seen some people implementing PID controllers in other applications, but I want to ask if an Arduino would be sufficient implementing the transfer function of this type. Also, which one should be preferred in this case...should I go for the analog hardware or the digital one in this case.

Finally, I want to ask that if I want to implement the given transfer function is a microcontroller than do I have to process it in the time domain i.e. converting this complete equation in time domain and then performing the calculations like integrations derivative etc.???

I need some suggestions as I am new into this.

\$\endgroup\$
2
  • \$\begingroup\$ Which Arduino? The brand covers a wide range of capabilities. \$\endgroup\$ Commented Apr 21 at 18:09
  • \$\begingroup\$ @TimWilliams Arduino Uno \$\endgroup\$
    – kam1212
    Commented Apr 21 at 18:26

2 Answers 2

1
\$\begingroup\$

Arduino Uno will be able to close the control loop if the switching frequency is around mains frequency (50-60Hz). Hopefully. Even then you may end up coding some math in assembly for things to be fast enough. So, if you want to run a switcher with the secondary winding of a mains transformer used as the inductor - go for it. It doesn't need to be practical, you are learning, and it will be way, way easier to debug such a relatively slow switching converter, with affordable instrumentation (low end oscilloscopes, home-made current sense amplifiers, etc.).

For a typical converter running at 100kHz, the innermost control loop must be updated at a rate >10MHz, so you'll need a much faster MCU, and ideally a core dedicated just to controlling the converter. A 12-bit 25Ms/s ADC would be a reasonable starting point. To close the loop I'd suggest a hard-realtime processor core or an FPGA. Parallax Propeller II would have plenty enough processing power to close the control loop at 100kHz, but it may require more than one core working in parallel. Prop II also has high-bandwidth 8-bit DACs (one per each GPIO pin!) - should you need those.

Otherwise, you'll have to learn basics of VHDL or Verilog and get yourself an FPGA development board. Prop II has a bit more on-board analog hardware than most FPGAs, so it is more versatile when doing digital control loops that aren't too complex to implement on it. FPGAs - even fairly small ones - have lots of DSP resources, and that's relatively hard to beat on a microcontroller. Prop II can do 8 16x16 multiplications in parallel at 100MHz instruction rate. A $5 Efinity FPGA chip can do these multiplications at a higher rate. But FPGAs don't come with the analog goodies that Prop II has.

\$\endgroup\$
3
  • \$\begingroup\$ So by using a multicore processor I have to implement the integral , derivative and the proportional terms in different cores and then use their results for further processing?? Is this how I should approach it? \$\endgroup\$
    – kam1212
    Commented Apr 22 at 14:15
  • \$\begingroup\$ @kam1212 Not really. Not all control is PID and not all control can be easily split across cores. You have to start with a design for the control loop to know how many arithmetic operations you’ll need to do for each loop update. There will be several loops nested, eg. innermost current control loop wrapped by a voltage control loop. You’ll also need to know the necessary loop update rate. So that’s all math and simulation. Only after all that is done and you’re reasonably sure the concept works will you even begin looking for any hardware and firmware. 80% of the work is design on “paper”. \$\endgroup\$ Commented Apr 23 at 16:24
  • \$\begingroup\$ But don’t use literal paper. Use and learn Mathematica if you can afford a home license - it’s an absolute steal for the price. That will let you simulate things in a very flexible way. Otherwise, you can probably use Octave for purely numerical simulations. You’ll need to have some working knowledge of univariate calculus and linear algebra, and Verbal Kint’s (a user here) switching converter design book has most of the math in one place. You’ll also be doing Spice simulations, MicroCap would be a good starting point for that. \$\endgroup\$ Commented Apr 23 at 16:28
1
\$\begingroup\$

This will work in principle, but it requires that the ADC conversion and the PID computation be completed with negligible delay. Any delay adds (linear) phase to the PID loop and tends to make the system unstable.

If your PWM is at (say) 100 kHz (== 10 us), and your ADC + computation takes 2 us, you add 360*2u/10u = 72 degrees of phase at 100 kHz, and 7.2 degrees at 10 kHz.

In addition, there is noise from ADC resolution; PID computation and resolution of the PWM generator. This doesn't affect accuracy, but may make the output noisier.

Another way of thinking about it: Consider when (in the current cycle), the next PWM is calculated. A conventional PWM loop (comparing a linear ramp with an error amplifier signal) has what is called 'natural sampling' which doesn't introduce excessive delays. Think of it having the computation repeating at a very high frequency (>> PWM rate) and at each instant deciding if the current PWM cycle should be terminated. An MCU approach generally computes the next PWM width once during the current cycle. It doesn't 'update' this info based on even more recent ADC data. Because of this delay (net PWM computed during current PWM), the phase delay is quite significant.

To make this work, you will need to have a relatively low BW for your loop. It will work, but load (and line) response will be poorer.

\$\endgroup\$
2
  • \$\begingroup\$ so you mean to say I should prefer the analog design in case of my converter and just leave the sensing part to the arduino? \$\endgroup\$
    – kam1212
    Commented Apr 21 at 17:31
  • \$\begingroup\$ No, a complete analog design is required if the ADC or PID loop cannot execute fast enough. \$\endgroup\$
    – jp314
    Commented Apr 21 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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