Close

MATLAB Code Finished

A project log for Grid-2-Audio

A convenient adapter to view the electrical grid waveform through your PC's sound card.

david-scholtenDavid Scholten 01/10/2019 at 10:400 Comments

So, after all this time I've finally drawn the line and said enough is enough - The code is done.

Here is the final format of the MATLAB figure that is produced throughout measurement:

On the left side (first column) we have from top to bottom:

-The historical Vrms voltage.
-The historical fundamental frequency.
-The historical THD%.
-The historical frequency waterfall spectrum.

(2 second sampling/averaging period!)

On the right side we have:

-The highest peak voltage captured since the recording started (red circle shows location). This is a plot of the actual moment it was detected.
-The highest THD recorded. The plot is of one 20ms period from the sample where the highest THD was recorded. This is NOT the period with the highest THD itself.
-The current cycle is the first 20ms from the current 2 second sample.
-The zoom is the same but zoomed into pi/2 to 2pi/3.
-The left frequency plot is for the first 20 harmonics.
-The right frequency plot is for the 1-20kHz harmonics (i.e. switching frequencies and other strange things). This is best seen as a representation of the current sample for the waterfall of the bottom left.

Here is a 30 minute recording of the data gathering process:

During this recording (I used VLC) the washing machine was running it's cycle and the kettle was used.

The sudden transient spike in the THD near the end is a bug and I have no idea why it is present.

If you watch carefully during the strange activity on the waterfall (example video time stamp: 2.20-2.25), you''ll see the front of the waveform chopped off. While I want to believe that's the washing machine's phase controlled voltage regulation, it's more likely that VLC's stream recording from the desktop was momentarily holding up the soundcard from MATLAB. This is especially apparent when you notice that there period of the waveform shortens by about 20%.  I've never seen this before without VLC recording - So it's a very plausible theory.

I've uploaded the MATLAB code and a bunch of results that I've collected.

What I'll try and do next is record the audio (via soundcard scope) while recording the MATLAB data acquisition using VLC. Then, I'll sink it all up (with the 50Hz hum removed, etc) and make a youtube video. There are two huge problems with this though:

-The sound card is now shared between three programs? I'm sure that will work just fine.
-I need an interesting signal to be present like the changing one in those nice two waterfall diagrams. THIS IS RARE.

So good luck to me and having everything work at once, but it has to happen eventually.

Discussions