Monday, September 30, 2013

Octave Code For Generating Harmonic Elimination PWM Waveforms

I've finally sorted out the code to generate PWM waveforms that you'd use to control an electronic device such as an H-bridge driver.  I must warn you this is engineering coding, error checking is non existent, and things may be a little rough around the edges, but it'll get you started on a version for your specific problem.  It should also be noted that some problems can't be solved.  If the magnitudes are set too high you could end up in a situation where there is more power in the waves spectrum than can be in the actual waveform.  In that case the solver will do its best to minimise the objective function but it won't actually find a solution.

The code will generate a waveform that you can scale to the desired frequency.  By entering two vectors, one containing the harmonics of the output waveform that you want to control, and the second containing the magnitude of the harmonics, a set of switching times will be returned.  It's also important to remember that all even harmonics are automatically zeroed due to the quarter-wave symmetry of the waveform.

As a demonstration I've generated the example waveform below that sets the first harmonic magnitude to 0.5 and all odd harmonics up to the 31st to zero.

The code for this demonstration can be found here.
HE PWM Waveform
HEPWM Waveform
The FFT of the above waveform is shown below.
HE PWM Waveform
FFT of a HEPWM Waveform
Although the magnitude of the first harmonic is set to 0.5 the FFT shows two peaks of 0.25.  This is due to the nature of the FFT showing positive and negative frequency.  These combine to give the 0.5 magnitude.  All the harmonics up to the 31st are however zeroed.

There are still a couple aspects of this method I'd like to investigate, but all the heavy lifting is done and we can get into some practical aspects of the process.


Thursday, September 19, 2013

Fourier Series of Harmonic Elimination PWM Waveforms

Harmonic elimination pulse width modulation waveforms can be used to control or completely dampen specific harmonics in a switched signal, and in my last post I laid the groundwork for calculating the Fourier series of these waveforms.  By making the waveforms quarter-wave symmetric the maths becomes a lot easier by eliminating all even harmonics and giving a set of equations easier to solve.  Half-wave symmetry should also remove even harmonics and give a more versatile, efficient waveform, but for the following exploration of the topic I'll only be focussing on quarter-wave symmetric waveforms.

Below I show how combining simple waveforms from my first post with different alpha values can generate the desired waveform.  Its paramters can be found by solving a set of non linear constrained simultaneous equations.  Solving these is not trivial and requires the use of software like Matlab or Octave.  I am currently working on porting some Matlab code that I wrote several years ago for this specific purpose to Octave.  I would have liked to have it ready for this post but I've had a few things to take care of lately and I'd prefer not to rush it.  It should be ready for my next post though.

You can get the PDF of the work below here.
Harmonic Elimination PWM Equations

Harmonic Elimination PWM Equations

Harmonic Elimination PWM Equations

Sunday, September 8, 2013

Fourier Series of a Quarter-Wave Symmetric Pulsed Waveform

I'm looking into Harmonic Elimination Pulse Width Modulation (HEPWM) and it requires a bit of maths.  So although there isn't anything too exciting in this post, it's laying the groundwork for some future content.

HEPWM is a technique to control the magnitude of harmonics in a PWM waveform.  It takes the basic PWM process that most people are familiar with and tweaks it to allow control of the magnitude of harmonics in the generated waveform.  It's used in a couple of places, but it's biggest use is calculating switching waveforms in DC to AC inverters.  By switching a DC voltage in the correct sequence, you can push the harmonic distortion in the switched waveform into higher frequency harmonics.  This doesn't seem too useful at first but it allows the use of smaller passive filters on the output to remove distortion.  As the distortion is in higher frequency harmonics, the filters can be more basic with a gentle roll-off.

One of the methods used to generate HEPWM waveforms is based upon Quarter-Wave Symmetric (QWS) Pulsed Waveforms.  The Fourier series of the waveform is needed to do further calculations, so I've started at that point.  Although I've only calculated the Fourier series for a very basic QWS Pulsed Waveform, the Fourier series of any QWS waveform can be generated by summing scaled versions of the basic Fourier series I've calculated with different parameters.

You can get the pdf here.
Quarter-Wave Symmetric Waveform
Quarter-Wave Symmetric Waveform
Quarter-Wave Symmetric Waveform