Apr 01

Getting Better Quality Sound on Video

Whenever I am faced with watching a video with poor sound quality I feel compelled to stop watching. Its strange that with a media as visual as video how important the sound aspect is. Poor sound makes watching a video really hard, try watching a film on TV where the sound is so low or muffled that you can’t hear the dialect properly – it does not matter how good the film is, without decent, clear sound you will just not enjoy it. As I started to make some video content for my blog I was getting frustrated with the quality of sound I was able to produce. Mostly I am in a room where there are a lot of hard surfaces so the audio ends up full of sound reflections, sounding hollow when using the camera’s built in microphone. There are a number of factors that drive sound quality, including dynamic range and frequency response and the ability to reject unwanted noise. Probably the biggest contributor to poor quality sound though are the reflections you get when you are recording in an enclosed space. To understand what this is, imagine getting one of those small bouncy rubber balls and throwing it hard at a wall, the path the ball will take will be unpredictable and the ball will bounce around the room uncontrollably – this is what happens with sound. The microphone not only picks up your voice, but also picks up some of the reflections which are slightly delayed, and the recoding ends up sounding hollow – like when you sing in the bathroom – sounds OK in the bathroom but this effect really sucks on video.

A good way to solve this is to get the microphone close to you, this way your voice is at a much higher level than the reflections in the room and you get better quality sound. However, being close to a microphone is not always practical or desirable. I want to get good quality sound for my video content but I don’t want to have to be near a microphone, or wear a head set and I also want to be able to move around freey – so no wires either. Getting good sound quality requires you to understand where the poor sound comes from, it takes some practice and most importantly some decent gear too.

I have put together a video comparing various microphone options using my Canon Legria HFS-21 camera and the following microphone combinations: –

Hope you find the comparison useful.

Catch you next time…

This content is published under the Attribution-Noncommercial-Share Alike 3.0 Unported license.

If you found this post useful or interesting, please consider giving me a tib.
Tibs are pocket-change for the internet™.
Feb 16

Fully Programmable Modular Bench Power Supply – Part 11

Here is the latest Revison 0.4 schematic which represents the power supply design as described in this blog and videos with the latest round of prototyping and testing.

  
  

The headline changes from last time are as follows: –

  • I have added -Ve supply using a simple charge pump and a PWM drive from the micro controller.
  • I have added a difference amplifier to correctly handle remote voltage sensing for both PSU voltage control and output voltage read back
  • I have modified the design to use low-side current sensing instead of high-side current sensing. In doing so I have dropped the use of the high side current sense amp MAX4080 and made use of a spare op amp element instead. This saves a $3 part and replaces it with half of a $2 part
  • Removed dedicated buffer amp previously added to drive the ADC, the new design removes the need for this because the voltage and current monitoring are better buffered now. This saves another $2 part.
  • Moved to a faster micro controller PIC18F46K22 which has more memory, more PWM outputs and more I/O pins. No real reason apart from I needed a second PWM output. The firmware is pretty much compatible.

Here is a video overview of the design changes and latest prototype hardware and test setup as well as some basic tests showing load regulation and programmable voltage accuracy benchmarked against a calibrated HP 34401A bench meter.

NOTE: I used a different mic setup and the sound is really poppy and crappy! My apologies…..My dustbin now has a new microphone in it!

You can download the hand-drawn illustrations used in the video here:

So I am working on the final PCB now, in Part 12 I should have a finished module….whoop whoop….Please do comment and like the videos if you find them interesting. Thank you for watching.

This content is published under the Attribution-Noncommercial-Share Alike 3.0 Unported license.

If you found this post useful or interesting, please consider giving me a tib.
Tibs are pocket-change for the internet™.
Jan 14

Fully Programmable Modular Bench Power Supply – Part 10

Well It’s been over three months since my last post so for those of you that have been following the project I am sorry to have kept you waiting. Work events have taken over recently; I have been really busy and as a result have not had much time to dedicate to the project. I have not been idle though, in those three months I designed and had made two revisions of PCB, have built them up and done lots of testing and as a result now have a clear view of an end design save a for a couple of minor things that still need to be done.

First of all, here is the latest schematic which represents the power supply design as described in this blog and videos with what I believe are the modifications required from the latest round of prototyping and testing.

    

Here is a video overview of the prototype hardware and test setup as well as some basic tests including load regulation and programmable voltage accuracy benchmarked against a calibrated HP 34401A bench meter.

Here is a video using the software to demonstrate basic set volts, output read-back tests and a benchmark against HP 34401A

I still have the following outstanding issues I want to address before committing effort to laying out a final PCB.

  • The “Output Off” circuit needs to be verified to resolve the glitch shown in the video when turning the PSU output on
  • Verify remote sense circuit and approach
  • Create and test a charge pump to generate a negative supply with a simple regulator, and specifically making sure the diode switching noise does not affect the ADC’s accuracy or stability
  • Create a minimum load constant current source for the regulator, and deal with measuring output current and compensating for the current source
  • There is currently no output protection of any kind, I need to deal with reverse polarity input (connect a battery the wrong way around to the input terminals), power feedback (connect a battery the right way around and power down the PSU), connect mains AC voltage into the output terminals. Apart from passing thoughts I have not looked at circuit protection at all.
  • Verify the accuracy of the current limiting and ADC read-back

In Part 11 I will make further refinements to the design addressing the outstanding items and get a board designed and ordered ready for Part 12 (the final part I hope).

Please do comment and like the videos if you find them interesting. Thank you for watching.

This content is published under the Attribution-Noncommercial-Share Alike 3.0 Unported license.

If you found this post useful or interesting, please consider giving me a tib.
Tibs are pocket-change for the internet™.
Sep 09

Fully Programmable Modular Bench Power Supply – Part 9

After a fairly disappointing start with the 12-bit DAC from Microchip I have chnaged the DAC to a 16-bit resolution part LTC2602 from Linear Technology. The goal of getting a resolution that is as good as the HP3631A Power Supply means getting a programmable resolution of 1mv for the low voltage range and 10mv for the high voltage range. The circuit below achieves these goals with a high degree of accuracy and no missing codes throughout the range. The design also exceeds the dynamic voltage and current range of the HP shown in the table below. Furthermore I made a statement that I would aim to not only achieve the same resolution but I would also attempt to improve on it by a factor of 10, that means getting a resolution of 100µV on the low voltage range and 1mV on the high voltage range. The 16 bit resolution of the DAC was not quite enough to achieve this, there were missing codes so I used the DAC modulation technique I used for the 12-bit DAC and extended the 16-bit DAC to 18 bits of resolution which allowed me to achieve the ten-fold programming resolution with no missing codes across the entire range – marvellous 🙂

Here is a brief video overview of the modified hardware and test environment

And here is a video demonstration of programming, measuring and the achieved resolution.

I focused some more on noise measurements and found that modulating the output of the 16-bit DAC created no detectable ripple – at least with the test equipment that I have. In fact the noise I am measuring swamps any ripple that is being created now. Interestingly, the digital signals from the micro controller driving the DAC (the SPI bus) is now creating more noise than the ripple effect of switching between two adjacent codes. Because the digital switching does impose some noise, there is a compromise to be had – you can get higher resolution but suffer some additional noise. For low-noise applications you can forego the additional resolution and get better signal to noise performance. Thankfully this can be controlled entirely in software so can be easily made a programmable option which is what I will do.

Of course this is just the control circuitry, I have no idea how the noise or accuracy will be represented through the linear regulator part of the design in practice – we shall see.

I have broken the schematic into several pages to make it easer to read.

        

I am happy that the control circuitry and the firmware is now good enough for a Version 1 baseline – this is what we have now. I have increased each range to show the possible extent of each gain option. In the final design the power and voltage ranges required and programmed in the UI/front panel will dictate the actual upper limits of each range, but this table shows the extent of what is possible.

Volt
Range
Volt
Resolution
Volt
Steps
Current
Range
Current
Resolution
Current
Steps
Regulator
Gain
0-8v1mv/1µV8000/800000-8A1mA/0.1mA8000/8000064W maxx2
0-20V10mV/1mV2000/200000-20A10mA/1mA2000/20000400W maxx5
0-40V10mV/1mV4000/400000-4A10mA/1mA4000/40000160W maxx10

In Part 10 I am going to create the first PCB for the project – Whoo-hoo. However, instead of designing the entire PSU printed circuit board at this stage I am going to focus on the digital control circuitry with the ADC, DAC and Analog switch only. I am going to create a small PCB as a module with a simple 0.1″ pin header (Arduino shield style) with the ADC, DAC, Analog switch, PIC micro controller and power supply parts so I can do the first cut of a board layout to make sure the grounding and noise issues are addressed. It’s not my intention to make this part of the final PSU module but it will be a useful module for prototyping other systems and of course I will not waste too much time if I get it totally wrong :/

Catch you next time….

This content is published under the Attribution-Noncommercial-Share Alike 3.0 Unported license.

If you found this post useful or interesting, please consider giving me a tib.
Tibs are pocket-change for the internet™.
Aug 17

Fully Programmable Modular Bench Power Supply – Part 8

After my initial tests there are two things I now know for sure. The first is I cannot treat the DAC like a programmable voltage source, it’s not going to be accurate enough and secondly, because of the INL of the DAC the resolution needs to be high enough to give me headroom to “trim” the DAC to the correct voltage. On this basis there really are only two practical options to achieve the goal.

The first option is to use a mapping table. Assuming I have a DAC with enough resolution it would be feasible to build some form of calibration rig which could step through each desired voltage then trim the code written to the DAC to get as close as possible for the resolution of the DAC and store that number in a table which can then be written to micro controller as a lookup table. The problem with this approach is its messy, and it would mean that if the calibration was lost in use it would need the calibration rig to re-calibrate it. This is not an ideal solution.

The second option, and the one I will take forward is to build a system where I have an ADC and a DAC and the system is configured so I can read the DAC output. When a given voltage it programmed the ideal DAC code is written to get within a few millivolts of the desired output; and then a software loop is used to trim the DAC code up or down as required to get as close to the required output voltage as possible. If the PSU is to measure up (no pun intended) then it needs a metering function regardless so all I need to do is design the system so I can switch the ADC’s inputs to the DAC for the calibration cycle.

The ADC needs a good resolution, it needs to be accurate and it needs to be low cost. The conversion speed is also important, if its too slow the calibration cycle would take too long to complete. I found a good part for this in the form of the LTC2402 Delta Sigma ADC device from Linear Technologies. I must say at this point that Linear Technologies design support is really great, they have been kind enough to furnish me with sample devices which I have been testing in the design. I have also tested a couple Analog Devices parts too and they were also kind enough to furnish me with sample devices, and these were very close in performance and a bit cheaper too (so not excluded just yet) but for performance in this application Linear Technologies parts so far have the edge – I will talk more about that later on and in future articles because I have tested a few different DAC’s and ADC’s. The following schematic shows the digital control circuitry which is extended to include the ADC chip and a 74HC4053D analogue switch which is used to switch the input of the ADC from monitoring the PSU regulator outputs to monitoring the outputs of the DAC for calibration read-back.

One of the interesting attributes of the ADC chip is it’s a two channel ADC, but in reality though it is actually a single channel ADC with a two channel multiplex on the front end so it samples each channel alternately. This made for an interesting problem to solve because the calibration loop needs the conversions from the ADC to be as fast as possible. The chip its self can only perform a maximum of 6.2 samples per second according to the data sheet, but because of the input multiplexer it can only actually achieve 3.1 samples per second per channel. For normal monitoring three updates per second is acceptable but for calibration I wanted better performance. I configured the analogue switch so in calibration mode I can use both inputs of the ADC to monitor a single channel of the DAC which gives me a calibration loop speed of 6.2 trim and read back per second.

Unlike the DAC, the INL of the ADC is significantly better mainly due to the nature of how it works. The architecture is a switch capacitor system which unlike laser cut resistor strings the charging and discharging of current into a capacitor is significantly more predictable and linear.


PLEASE NOTE: The LED flash is continuous but the video frame rate make it looks like it stopes and starts – which is does not.

In software I have tired two different calibration schemes. The first is the simplest, it sets the ideal code for the target voltage, measures the output of the DAC and does a calculation to determine the difference between the ideal code and the actual code required, then applies this. The second scheme is more complicated. It is the same as the first scheme but then with a second phase of micro trimming which essentially sets a window around the centre point and then adjusts the codes in steps re-reading the output; you can think of this as an electronic/software version of someone turning a variable resistor while watching a meter to get a precise voltage. The second scheme also takes more time as it needs to perform multiple read-backs in order to complete the trim cycle. I have limited the trim cycle to a maximum of eight iterations, in practice it seems to take between 2 and 7 most of the time.

(P.S. The command ‘pr’ means “property read”, it reads the EEPROM configuration of the module)

I re-tested with the spot voltages in the previous blog post and the bottom line is, 14-bits is not enough. The MCP4922 is great for the $$ but its not good enough for this project so I will not bother creating another spot voltage table for this variation, that’s a waste of time given we have established the DAC is just not up to the job. In the next article I will try out two 16-bit DAC chips, one from Analog Devices and the other from Linear Technology.

Thanks and keep watching….

This content is published under the Attribution-Noncommercial-Share Alike 3.0 Unported license.

If you found this post useful or interesting, please consider giving me a tib.
Tibs are pocket-change for the internet™.
Jul 30

Fully Programmable Modular Bench Power Supply – Part 7

Now I have the requirements for the control ranges I need its time to get down to the nitty-gritty and get a DAC up and running so we can make some measurements. The maximum dynamic range I need for this project is 6000 individual steps – this was identified in the calculations for the voltage control for the 0-6V rage in Part 5, so let us start there.

There are many options for DAC’s to choose from, I want to keep the cost and component count down so my starting point is a low-cost single component solution from Microchip, part number MCP4822. This is a dual 12-bit DAC with two channels and a built in voltage reference. I get independent voltage and current control from one 8-pin chip – wow! However, there is a problem with this part, it only has 12-bit resolution which will only give me 4096 individual steps and my design calls for 6000. The problem with choosing components with a higher number of bits is that they start to get expensive. I want to see if it’s possible to extend the range of the DAC using software and a technique called “dithering” or “modulation”.

The idea here is pretty simple, to increase the resolution of the DAC you can continuously switch the output between two or more codes, feed the result into a low-pass filter and get the average voltage. If you switch between two adjacent codes with a variable mark space ratio like you do in PWM, it should be possible to extend the range of the DAC without creating large ripples on the voltage head making the low pass filter easy to construct. That is the theory at least, I need to try it and see what the results are in practice.

Before getting too complicated though, I thought it would be good to run the DAC in static mode, set some codes and measure what we get. The DAC has 4096 steps, the internal reference voltage is 2.048v and the chip has a x2 gain option so I should be able to program any voltage between 0v and 4.096v in 1mV steps by simply programming a digital code between 0 and 4096 into the DAC channel. To get this up and running I hooked up a PIC micro controller, the DAC chip and an RS232 serial interface. The firmware in the PIC will allow me to interact with the DAC through a simple serial terminal on my computer.

Before any MPS430, Atmel or Arduino die-hard fans start giving me advice on micro controller choice — forget it. They are all good parts, I just happen to personally like PIC’s because I know them and I have the tools and a whole bunch of them sitting here to play with – if you are not happy with my choice of micro controller thats tough…. I am not going to change it or enter into any debate over the pro’s and cons of other devices – I am sticking with PIC’s for this one and if you try to change my mind I will ignore you – sorry.

Here is the schematic diagram for the prototype I am using.

For the dithering I have decided to extend the DAC by 2 bits. Extending by two bits means I have to write a sequence of four codes continuously in succession to the DAC. I am writing approximately 1000 codes per second within a timer driven high-priority interrupt routine which ensures that the timing remains constant. Timing errors will introduce more DNL errors so the code stream needs to be constant and accurate. The codes written are the base code value followed by the base code value + 1. The two least significant bits from the now 14-bit word controls how many times each of the two values is written. For example, to get four steps between code 100 and code 101 we would write the following codes: –

100.00       100   100   100   100
100.25       100   100   100   101
100.5        100   100   101   101
100.75       100   101   101   101

Extending by 3 bits is an option and would mean I have to write a sequence of eight codes, again following the same explanation as above, here are the codes that would be written

100.00        100   100   100   100   100   100   100   100
100.125       100   100   100   100   100   100   100   101
100.250       100   100   100   100   100   100   101   101
100.375       100   100   100   100   100   101   101   101
100.500       100   100   100   100   101   101   101   101
100.625       100   100   100   101   101   101   101   101
100.750       100   100   101   101   101   101   101   101
100.875       100   101   101   101   101   101   101   101

I tried the three bits as an academic exercise but I have decided not to go to three bits because of the noise, ripple and integral errors generated. The cost of the filter circuitry and the expansion of the line items in the bill of materials would probably outweigh the cost of upgrading the DAC component to a higher resolution part.

I have selected a number of spot voltages in the range to benchmark what I get from the DAC. The following table sets out the results I measured. (I am using a calibrated HP 34401A meter for all measurements).

Spot VoltageDAC CodeMeasured
MCP4822
(12bit static)
ErrorDAC CodeMeasured
MCP4822
(14bit dith)
Error
000.0015V+0.0015V00.0014V+0.0014V
0.001V10.0015V+0.0015V40.0016V+0.0002V
0.002V20.0024V+0.0014V80.0026V+0.0006V
0.003V30.0034V+0.0004V120.0036V+0.0006V
0.004V40.0044V+0.0004V160.0046V+0.0006V
100mv1000.1024V+0.0024V4000.1026V+0.0026V
500mv5000.5024v+0.002420000.5026V+0.0026V
501mv5010.5034v+0.002420040.5036V+0.0026V
1V10001.0004V+0.0004V40001.0006V+0.0006V
1.5V15001.4975-0.002560001.4977V-0.0023V
2.5V25002.5014+0.0014100002.5016V+0.0016V
3V30002.9993-0.0007120002.9995V-0.0005V
3.001V30013.0002+0.0002120043.0005V+0.0005V
3.002V30023.0012-0.0008120083.0014V+0.0006V
3.9v39003.8968-0.0032156003.8969V-0.0031V
4.095v40954.0916-0.0034163794.0916V-0.0034V

Well, that is disappointing given I am aiming for a precision of 1mV and to get a control voltage of 0-6V I need accurate 500µV steps. So whats wrong here? Having read the data sheet there are some gotcha’s that naively you might ignore as I did. Every DAC has two really important parameters called Integral Non-linearity (INL) and Differential Non-Linearity (DNL). The DNL defines the maximum deviation to expect from the “ideal” voltage for any given code, expressed in LSB’s (or counts from ideal) and INL is the accumulated DNL errors that occur over the whole range. Fundamentally, the DAC is based on a resistor string network and its not easy to make highly accurate resistors, as soon as you start needing more accuracy the cost of the part rises very steeply, and even with the best part money can buy there will still be errors. The more bits you extend the DAC by using dithering, the more error you introduce and the more noise you introduce too. While extending by two bits is probably acceptable with a decent low-pass filter, extending by three bits and beyond is not really practical. As an aside, the noise figures for the MCP4x22 parts are not that great – something one must consider when the reference voltage generated is going to be amplified, the noise will also be amplified.

In summary then, I want accuracy and precision but I want reasonable cost and even if I spend a lot of money I will still have errors. The lesson learned for me is I now no longer think of a DAC as an accurate programmable voltage source – its not, its a close approximation only. The MCP4922 (MCP4822) is a nice part for the $$$ and useful for some things I have no doubt, but its not good enough for what I want to achieve in this project. Even with the resolution extension to 14-bits it falls short. Actually to be fair, even with the errors in the DAC this would be make a pretty good degree of control, its probably more accurate than most of the lower end bench PSU’s out there, but my benchmark is the Agilent E3631A so I need to achieve much better than this. The MCP4x22 device is the best resolution DAC Microchip do so I must now search for other parts instead – Linear Technologies and Analog Devices are the logical starting point for my search.

There is one further possibility which I have yet to try, which is to combine both 12-bit DAC outputs to create a much higher resolution DAC, the block diagram for such a solution is shown in the data sheet for the part. This is well worth a look because if it works well enough, the cost of the two chips may well still be cheaper than an upgraded DAC part. I will build this out at some point and give it a try.

This project also needs to implement metering in order to monitor the output volts and current drawn by the load connected to the PSU, and this needs to be reasonably accurate to 1mV too, thats 5-digits I need which in its self is a tall order. However, it occurred to me that if I could get an ADC that was accurate enough and a DAC with enough resolution to provide headroom for trimming it might be possible to build a self-calibrating system that trims the DAC output to match the desired programmed voltage each time you set a new voltage. That is what I will look at in Part 8.

This content is published under the Attribution-Noncommercial-Share Alike 3.0 Unported license.

If you found this post useful or interesting, please consider giving me a tib.
Tibs are pocket-change for the internet™.