Menu

all about electronic and microcontrollers

Friday, December 30, 2016

Measuring the DC current with a Microcontroller

Basically the microcontrollers doesn’t have specific ports for measuring “dc” current or “ac”  current, but they do have ADC (Analog to Digital Converter) and we can take advantage from this point of view so we can measure analog voltages of a certain range (usually 0-5vcc). The way of doing this is to place a resistance in series with the current path and measure the voltage drop across it. For this trick we need to use a resistor with a very low value just to not affect the original current of the load.

Resistors with a value less than 1 ohm are necessary and can be found in electronic stores. For a proper resistor placed into the circuit we have to pay attention for maximum current used. So, let’s say that you pick 0,47Ohm and the maximum current in the circuit is about 5 A, then the resistor should have the capacity of dissipation equal with: I²xR => 25 x 0,47 = 12 Watts of heat.

The appropriate design for the resistor is to create by yourself a coil from an Cu wire. For  this test I have create one from 1,5 meter Ø 1,3 mm with enameled insulation on outer side, as shown below.
Coil
Now let’s measure its resistance, for example directly with an multimeter. My digital multimeter shows a value equal with 0,4 Ohm. Of course this measurement can have uncertainty, because of very small value which we measure and we don’t had to forget the fact that usually the digital multimeters does not show values beyond 1 decimal digit. Our resistance can be measured respecting the ohm’s law. We can connect in series with the coil resistance (Rs), a known resistor for example 47 ohm and supply a 5vcc as shown below. Next, measure the voltage across Rs and current through it separately using the multimeter. In the current case, I foud the measured voltage and current values to be 25.6mV and 88.6mA. This gives the resistance of the coil equal with 0.289 Ohm. (Rs = V/I).
Now, suppose that the range of current to be measured using this coil resistance is from 0-5A. Then the voltage drop across the coil resistance will be somewhere from 0 – 1.44 V. Because of its low range, this voltage signal may not be accurately measured with a microcontroller’s ADC module. In this case we will use an operational amplifier circuit for a voltage scaling mode. The entire schematic for this design is shown below.

As a description: in the above circuit Rs represent the low value current sensing resistor (our coil resistor) which is connected in series with the consumer (load resistor). Our purpose is to derive the load current (I). The low voltage drop across Rs is amplified by the non-inverting amplifier with 3.5. This is enough to linearly scale Vs (0 – 1.44 V) to Vo (0-5vcc).
At this point we have 0-5vcc signal that corresponds to 0-5A current through Rs. This voltage signal is now more appropriate for ADC conversion with Vref = 5vcc.
Vo= 3.5 x I x RS = 1I (Rs=0,289) => I = Vo/1.
For 10-bit ADC with Vref = 5vcc:
·         Our resolution will be equal with: resolution = 5/1024 = 0.0049 (5mA).
·         For input signal Vo, the ADC O/P will be Vo x 0,0049,
·         Then I = ADC O/P x 0,0049/1 = ADC O/P x 0.0049.



Practical pictures with the experiments.

Logic Gates

In this article I will put on the paper some theoretical knowledge about the Logic Gates.
I will discuss about:
·         Logic Gates
·         Truth Table
·         Logic circuits/network
I will explain how logic gates are used and how truth tables are used to check if combinations of logic gates carry out the required functions.
Logic Gates
A large number of electronic circuits (in computers, control units, embedded systems etc.) are made up of logic gates. These process signals are represented by true or false flag. Signals can be represented as ON or OFF, 1 or 0 as well.
The most common symbols used to represent logic gates are shown below. For sure there are many different logic gates but we will concentrate on these.
Truth Table
Truth tables are used to show logic gate functions. The NOT gate has only one input, but all the others have two inputs.
When constructing a truth table, the binary values 1 and 0 are used. Every possible combination, depending on number of inputs, is produced. Basically, the number of possible combinations of 1s and 0s is 2n where n
= number of inputs. For example, 2 inputs have  combinations, 3 inputs have  combinations and so on. The next section shows how these truth tables are used.
Description of the logic gates
NOT gate
The output (X) is true (1 or ON) if:
Input A is NOT TRUE (0 or OFF)

Truth table for: X = NOT A
AND gate
The output (X) is true (1 or ON) if:
INPUT A AND INPUT B are BOTH
TRUE (1 or ON).

Truth table for: X = A AND B



OR gate
The output (X) is true (1 or ON) if:
INPUT A OR INPUT B is
TRUE (1 or ON).

Truth table for: X = A OR B


NAND gate
The output (X) is true (1 or ON) if:
INPUT A AND INPUT B are
NOT BOTH TRUE (1 or ON)
Truth table for: X = NOT A AND B


NOR gate
The output (X) is true (1 or ON) if:
INPUT A OR INPUT B are
NOT BOTH TRUE (1 or ON)
Truth table for: X = NOT A OR B


XOR gate
The output (X) is true (1 or ON) if:
INPUT A OR (NOT INPUT B)
OR (NOT INPUT A) OR INPUT B
is TRUE (1 or ON)
Truth table for:
X = A OR (NOT B) OR (NOT A) OR B



Logic circuits/network
Logic gates can be combined together to produce more complex logic circuits (networks).
The output from a logic circuit (network) is checked by producing a truth table.

Two different types of problem are considered here:
·         drawing the truth table from a given logic circuit (network)
·         designing a logic circuit (network) from a given problem and testing it by also drawing a truth table.

Example:
Produce a truth table from the following logic circuit (network).

Note:
To show how this works, we will split
the logic circuit into two parts (shown by
the dotted line).

First part
There are 3 inputs; thus we must have  (8) possible combinations of 1s and 0s.

To find the values (outputs) at points P and Q, it is necessary to consider the truth tables for the NOR gate (output P) and the AND gate (output Q).
P = A NOR B
Q = B AND C

We get:




Second part
There are 8 values from P and Q which form the inputs to the last OR gate.
Hence we get X = P OR Q which gives the following truth table:
Which now gives us the final truth table for the logic circuit given at the start of the example:


So as you can see the possibilities are unlimited. You can design which circuit you like. Good luck.

Linear vs. Switch-Mode Power Supplies

Intro
Linear power supplies were the mainstay of power conversion until the late 1970’s when the first
commercial switch-mode became available. Now apart from very low power wall mount linear power
supplies used for powering consumer items like cell phones and toys, switch-mode power supplies are
dominant.

So what is the difference in how they work?

Linear power supplies have a bulky steel or iron laminated transformer. This transformer has two purposes
- It provides a safety barrier for the low voltage output from the AC input and reduces and the input from
typically 115V or 230VAC to a much lower voltage around say 30VAC.

The low voltage AC output from the transformer is then rectified by two or four diodes and smoothed into
low voltage DC by large electrolytic capacitors.

That low voltage DC is then regulated into the output voltage of choice by a dropping the difference in
voltage across transistor or IC (the shunt regulator).

Switch-mode supplies are a lot more complicated. The 115V or 230VAC voltage is rectified and smoothed
by diodes and capacitors resulting in a high voltage DC. That DC is then converted into a safe, low
voltage, high frequency (typically switching at 100kHz to 500kHz) voltage using a much smaller ferrite
transformer and FETs or transistors. That voltage is then converted into the DC output voltage of choice by
another set of diodes, capacitors and inductors. Corrections to the output voltage due to load or input
changes are achieved by adjusting the pulse width of the high frequency waveform.

Sounds complicated? Yes, but the payoff is worth it!

The advantages and drawbacks of both technologies

Size: - A 50W linear power supply is typically 3 x 5 x 5.5”, whereas a 50W switch-mode can be as small as
3 x 5 x 1”. That’s a size reduction of 80%.

Weight: - A 50W linear weighs 4lbs, a corresponding switcher is 0.75lb. As the power level increases, so
does the weight. I personally remember a two-man lift needed for a 1000W linear. Today I carry a 2000W
in my carry-on luggage when I fly!

Input Voltage Range: - A linear has a very limited input range requiring that the transformer taps be
changed between different countries. Normally on the specification you will see
100/120/220/230/240VAC. This is because when input voltage drops more than 10%, the DC voltage to
the shunt regulator drops too low & the power supply cannot deliver the required output voltage. At input
voltages greater than 10%, too much voltage is delivered to the regulator resulting in overheating.

If a piece of equipment is tested in the US and shipped to Europe, or even to Mexico in some cases, the
transformer “taps” have to be manually changed. Forget to set the taps? The power supply will most
certainly blow the fuse, or may well be damaged.

Most switch-mode supplies will operate anywhere in the world (85 to 264VAC), from industrial areas in
Japan to the outback of Australia without any adjustment.
The switch-mode supply will also be able to withstand small losses of AC power in the range of 10-20ms
without affecting the outputs. A linear will not. No one will care if the AC goes missing for 1/100th of a
second when charging your phone, it will take 100 of these interruptions to delay the charge by one second!
Having a piece of equipment reboot 100 times a day will cause some heartbreak!

Efficiency: - A linear power supply because of its design will normally operate at around 60% efficiency
for 24V outputs, whereas a switch-mode is normally 80% or more. Efficiency is a measure of how much
energy the power supply wastes. This has to be removed with fans or heat sinks from the system.

For a 100W output linear, that waste would be 67W. A 100W switch-mode would be just 25W.

67W – 25W = 42W is the extra power lost

Doesn’t sound much, but don’t try touching a 40W light bulb! If the equipment were running 24 hours a
day, then the extra losses would be 367kW hours, even at $0.1 per kW hour, that’s an extra $37 a year for a
power supply that costs around $80.

As a quick note, in Europe, they are trying to limit those losses of all power supplies used by consumers
particularly when operating off load (as many products are left plugged in 24 hours a day). Imagine 250
million power supplies eating up a couple Watts. That equates to the output of a whole power station!

Reliability: - If reliability is calculated using a part count method, then the linear power supply will win.
With the design & quality improvements made in the last few years with switch-mode parts & technology,
in reality this advantage has been negated. I have demonstrated life testing data showing no failures after
over 1,000,000 hours on some Lambda products.

Electrical Ripple and Noise: - This is where the linear really scores!

                                    5v Linear                                                              5v Switch-mode

The linear obviously is a lot “quieter”, by up to a 10,000 times. The topology of the switch-mode supply
with its high frequency switching technology had to have a downside right? So if the noise is 10,000 times
worse, how can anyone use it? Sounds so bad.

In truth, there are some applications (studio mixers and very sensitive test equipment) where low electrical
noise is critical. The others? One of my first sales calls in the USA was to a manufacturer who built
semiconductor fabrication equipment. They used 8 really big linear units in a large box measuring 2x3x4
feet, it was heavy & actually being dictating the size of their end equipment. I told the engineer that I could
replace all eight units with two modular products measuring 5x5x10”. He laughed and said the noise
would be too great. I sent him samples and went to visit three weeks later. He was delighted with the
performance and has been a long term Lambda customer ever since.

Transient Response:
Transient response is how a power supply reacts to a (fast) change in load.

If the output load quickly changes from say full load to half load, the output voltage of the power supply
will rise (overshoot) before the internal control circuit has time to compensate, and then undershoot a little
less as the circuit over compensates. The length of time is takes from the instant of the load change to the
time the output voltage settles back into the load regulation limits can be critical to some loads. Here the
linear again outperforms the switch-mode.

For a 50% change in load the switch-mode will often take 3000us to recover. A linear supply will recover
in 50us.

Is this critical for all applications? There are a few specialized technologies where this is important and
most engineers will advise you if this is critical. For the other instances on board capacitors at the end load
& the inductance of cables is enough to reduce overshoot down ten-fold to where it no longer is a concern.

Low leakage currents and Conducted EMI:
A widely used technique in the design of switch-mode power supplies is to connect special capacitors from
the AC input terminals to Earth. This is a cost effective method to reduce noise from being fed back
through the input wires and potentially affecting other equipment.

These capacitors have a side effect of allowing a “leakage current” to be passed through the Earth or
ground cable. Many safety specifications have limits on the amount of this current that is allowed.
UL1950 allows 3mA, medical industrials less than a tenth of that. The gaming industry is even tighter.

As linear power supplies are “quieter” and do not need these capacitors, they simplify the system filtering,
and allow more of the system leakage current “budget” to be used for other parts like monitors. The overall
size of the system filter can also be reduced. How much that impacts cost & performance varies from
customer to customer.

Some switch-mode power supplies (like Lambda’s Vega series) are now available with increased internal
filtering that allows for low leakage versions to be offered to meet medical specifications.

In Summary:

Linear
Switch-mode
Comments
Size
x
OK
Typically, 80% smaller
Weight
x
OK
Typically, 80% lighter
Input Voltage Range
x
OK
10% vs. up to 300% range
Efficiency
x
OK
Calculate it long term!
Reliability
OK
x / OK
Component count method, demonstrated probably equal
Ripple & Noise
OK
x / OK
Up to 10,000 times - often possible to overcome though
Transient Response
OK
x
Up to 100 times - necessary in specialized areas
Low leakage Current
OK
x / OK
Often used in medical systems, switch-mode gaining share


Hope that is useful all those aspects presented here.

As reference for the entire document, you can take a look on https://us.tdk-lambda.com

In this section, below I will share all tests and additional research made so far.



Quad 405-2

With this article I intend to open the discussion about audio power amplifiers. My last passion about the world of microcontroller makes me to let a little bit behind the old and forever passion, probably for most of you, for audio amplifiers.

Theory about this sector can be found in all the internet corners, so here I will put into discussion a couple of schematics and designs which impressed me so far. If some of you come with something new or if it's seen from other angles, let me know, I’m open for discussions and if I will consider the information as valuable one, I'll put it here.

Quad 405-2 a piece of art.
For those who doesn't have any idea about what does it mean quad or 405, I will initiate whit a little introduction:
The company called Quad Electroacoustic founded by Peter J. Walker in 1936 in London is a British manufacturer of hi-fi equipment, based in Huntingdon, England.
The company initially produced only public address equipment but after the war they began to produce equipment designed for use in the home as a result of the rising demand for high quality domestic sound reproduction.
The name "QUAD" is an acronym for "Quality Unit Amplifier Domestic", used to describe the QUAD amplifier. In 1983, when having become known for their QUAD range of products, the Acoustical Manufacturing Co. Ltd changed its name to QUAD Electroacoustic Ltd.

The famous Quad “Current Dumping” amplifier launched in the mid 1970’s, and featured feed forward error correction that effectively removed the class B cross over distortion that plagues this type of output circuit structure.
The design caused a stir in the audio industry at the time of its release, and was the subject of a patent and a paper at an AES convention a year earlier. Although the 0.005% midband distortion placed it firmly in the upper echelons of measured performance in the industry at the time, some reviewers failed to warm to the sound. Nevertheless, this was a landmark design that creatively solved the cross over distortion problem.

Productions:
Current Dumping Power Amplifiers
Quad 405 – 1975 to 1982 – 64,000 units
Quad 405–2 1982 to 1993 – 100,000 units

Quad 405-2 is one of the most known audio power amplifier for its audio performance.

Quad 405-2 Front/Rear


Quad 405-2 Inside view

Quad405-2 PCB-Channel

Technical Specifications
Power output: 100 watts per channel into 8Ω (stereo)
Frequency response:
1.      1dB at 20Hz
2.      0.5dB at 20kHz
3.      3dB at 50kHz

Total harmonic distortion: < 0.01%

Hum and Noise:
‘A’ weighted -96dB ref full power
Unweighted -93dB ref full power (15.7kHz measurement bandwidth)

Left/Right Channel Crosstalk:
1.      80dB @ 100Hz
2.      70dB @ 1kHz
3.      60dB @10kHz

Input sensitivity: 0.5V for 100 watts into 8 ohm load
Speaker load: 4 to 16 ohms (nominal)
Signal to noise ratio: 95dB
Speaker load impedance: 4Ω to 16Ω
Dimensions: 115 x 340.5 x 195mm
Weight: 9kg

MODIFICATIONS

Throughout time a lot of electronic engineers and hi-fi audio hobbyist around the world, start to modify this audio power amplifier from redesigning the electronic schematic, paying attention from quality of components and in/out connectors to the percentage of Ag consistency from the soldering material, at the end to succeed improvements of sound response.

Below I will post a series of electronic schematics starting with the original one and ending with those who has the most significant modifications. All of them are fully functional.