Sunday, 27 July 2014

Multi Channel Meter

So after all that background...

Recently I've blogged about DIY Isolated Supplies and Microcontrolled Analogue Gain, as these have been necessary building blocks for my latest project - a multi channel voltage / current meter.

Why Isolated Supplies?

My end goal for this project was to be able to measure input and output power for other projects.  For example if you take a switch mode power supply, you may want to measure the input voltage and current, and then compare it to your output voltage and current.  

With this known, you can then calculate your input and output power and thus derive your converter's efficiency.

To do this 'traditionally' you would need 4 multi-meters.

It also means your will probably end up taking measurements manually - unless you're lucky enough to have 4 logging meters.  

So I decided to take a microcontroller approach, using built in ADC's to measure up to 4 independent channels.   My original idea was as follows:

Original Architecture

However, as detailed in my earlier entry, this falls over when you realise that this architecture uses a common ground and I need to separate each measurement channel.  Stupid multimeters with their batteries and inherently isolated designs.

A New Direction

So, my design is now required to run 4 isolated supplies so I can take my measurements.  This now brings new issues with my starting architecture:
  • How do I share my control signals over the required isolation barriers?
  • How do I get my analogue signals to my microcontroller so I can take measurements? 
 Looking at the above options, if I were to bring separate control signals over my isolation barrier using discrete optoisolators, my IO count would require many optos and make my design quite bulky.  Then there's the problem of the control and data lines for the ADC.

My little board was growing into a monster!

It was time for a new take - rather than use a single microcontroller, why not use one per channel?  This brings the control lines and ADC control to one side of the isolation barrier, and I only need to bring serial coms per channel over the isolation barrier.  

New Improved Architecture

By choosing open collector optoisolators I could use a 'wired-or' arrangement - each channel can transmit back to the usb - serial converter using the converters single uart.  Nice.  Coms rom the usb - serial converter can broadcast to all channels simultaneously, and if each channel's micro is given a unique ID, each channel can be polled for a measurement response.

Theory Meets Practice

To put my theory to the test, I built the following test board.

First Test Board

There's a few area's about this design that I'll detail later, including:
  • What's great about the MAX4238
  • How the current over-load protection circuit works
  • How I should implement over-voltage protection

But for now note that I used an external 2.048V reference - and then put that through a x2 gain stage to generate a 4.096V reference for the micro's ADC.

Why did I do this?

Rather than base my design on a bipolar supply (i.e. + / - 5V rails) I decided to use a virtual ground around 2.048V.  Add using 4.096V as the high voltage reference for the ADC and I can effectively measure an input voltage of + / - 2.048V.  Unlike my last post where I contemplated using separate channels to read positive and negative values, this allows me to use one channel to measure positive and negative voltages.

So for my ADC (10 bit in this case), a 0V input will be seen as a 2.048V signal, which translates to 512 counts.  Any counts above 512 are due to positive input voltages, any below are conversely negative.  For a 10 bit ADC with 4.096V as a reference, each count is equivalent to 4mV.  MAkes for easier Maths that using 5V as a reference...

Test Board

But I goofed.

I switched my gain setting resistors not to the mid point, but to ground.  If you were wondering why I made such a big fuss about this in my last post, now you know why...

However, the fix was relatively simple.

Fix Is In

Using the analogue switch, I was able to tie the gain setting resistors to 2.048V and switch them in and out.  That's where all the re-writing comes from on the test board above.

Cheap FTW!

One other driving factor with using a 2.048V mid point reference is that I was able to use cheap single supply analog switches to switch both the gain setting resistors, and select between voltage and current measurement modes.

Bi-polar switches exist, but they are real damn expensive.

I'd also goofed my polyswitch footprint so I managed to hack that into place too.

Over at my pals place (Software:  Level Expert) we hooked it up and the damn thing worked.  We coudl track positive and negative voltage swings around the 2.048 virtual ground, and we could switch between voltage and current mode.  The over current protection circuit worked too!

From there I was able to prove the proto could run from my capacitor switched isolated supply (top board) and implement optoisolated serial coms (middle board).

Fast Forward

With all the blocks validated, I designed and built a 4 channel prototype, and as can be seen below, there were still some issues.  One wasn't my fault though!

Ugly, But Works

Software too.

Once the prototype was debugged, Nick 'whipped up' some control and interface software to drive the meter.

So that's the story about how my research and test drove the overall design for this Quad Meter.  Next time I'll chat about it's protection and the performance.

No comments:

Post a Comment