Basics of Design • CC Blog • Research & Design Hub

Understanding Mesh Circuits

Written by Stuart Ball

How to Use and Calculate Them

Microcontrollers and other digital systems concern mostly ones and zeros but when connections to the real word are needed it can get messy. Stuart writes about mesh analysis and how mesh circuits can be calculated and applied in practical scenarios.


  • What is mesh circuit analysis?
  • How does Thevenin’s theorem apply here?
  • How can analog signals be scaled for MCUs?
  • What resistor values ensure safe MCU input?
  • How do AC signals affect mesh circuits?
  • mesh circuit analysis
  • thevenin equivalents
  • analog signal scaling
  • voltage dividers
  • embedded system interfacing
  • resistor network design
  • ac circuit analysis
  • adc input filtering
  • signal level shifting
  • microcontroller analog input design

When working with microcontrollers and other digital systems, we don’t usually have to be concerned about anything but ones and zeros, right? But sometimes our MCU has to connect to the real world, and that can be messy. Sometimes we have to use that algebra that we couldn’t see the need for in high school to make sure that we get the inputs or outputs we want and do it without damaging anything in the process. And in some cases, mesh analysis is how we handle that. I want to show you a few simple mesh circuits, and how they may be calculated and applied in practical scenarios. If you went to EE school, you probably saw this material in a fundamentals of electrical engineering course.

FIGURE 1
Simple voltage divider mesh circuit
FIGURE 1
Simple voltage divider mesh circuit
SIMPLE MESH CIRCUIT

Figure 1 shows a simple mesh circuit of three resistors. For a review of resistors, see my article “Getting Started with Resistors” in Circuit Cellar issue 382. Let’s say that we need to calculate the voltage across the 2K resistor R2. This is fairly simple to do using series/parallel resistor calculations. R2 is 2K, R3 is 3K, so the value of R2 and R3 in parallel is 1.2K.

The current through R1 plus the parallel combination of R2 and R3 is:

The voltage across the parallel combination of R2 and R3 is:

2.27ma x 1.2K = 2.73 v

So the current through R2 is 2.73V/2K = 1.36 ma.

This simple example illustrates some general principles of mesh circuits:

  • The sum of the currents into a node (connection) is zero. The current flowing into the junction of R1, R2, and R3 has to equal the current flowing out. So the 2.27ma flowing in through R1 has to equal the two currents flowing out through R2 and R3. Note that in doing the calculations, you can (and usually do) assume that all currents are positive, flowing into the circuit. When you do the math, at least one will turn negative.
  • If two currents are flowing through a component, the total current is the sum of the currents. For example, the current through R1 is the sum of the currents in R2 and R3.
  • The sum of the voltages in a mesh loop will add up to equal the voltage source. The 5V input voltage equals the voltage across R1 (2.27ma x 1K = 2.27V) plus the voltage across the parallel combination of R2 and R3 (2.73V).

Figure 2 shows a somewhat more complicated circuit. I’ve relabeled the resistors so there isn’t any confusion between the two figures. This circuit is identical to the original circuit except that resistor R5 (was R2 in the original circuit) is connected to +3V at one end instead of to ground. Now, let’s find the current through the three resistors:

FIGURE 2
Resistor T-circuit
FIGURE 2
Resistor T-circuit

The current flowing into R6 equals the sum of the currents through R4 and R5. I’ve labeled the junction of the three resistors as voltage Vj, and I’ve labeled the currents through the resistors as i4, i5, and i6 (using lowercase “i” to avoid font confusion). We don’t yet know Vj, but we can write an equation for R4 and R5 based on the fact that the current through each resistor is equal to the voltage across the resistor divided by the resistance. We know that the total current into and out of the junction of the three resistors has to be zero:

Eq1: i4 + i5 + i6 = 0

I’m assuming here that all three currents are positive. That obviously can’t be true, one or more of them will end up with a negative sign before we’re done.

We know that i6 = -Vj/R6 (negative because Vj is assumed positive indicating that current is flowing out of the junction)

The currents through R4 and R5 (remember, R4 = 1K and R5 = 2K) are calculated by:

Eq2: i4 = (5 – Vj)/R4 = (5 – Vj)/1000

Eq3: i5 = (3 – Vj)/R5 = (3 – Vj)/2000

Since we know that i6 = -Vj/R6, we can rewrite Eq1 like this:

Now we can solve for Vi:

5 – Vj + 1.5 – 0.5Vj – 0.333Vj = 0

6.5 = 1.833Vj; Vj = 3.54 volts

Now we can find i4 using Eq2:

i4 = (5-Vj)/1000 = 1.45ma

Using Eq3 for i5:

i5 = (3-Vj)/2000 = -0.273ma

And finally, using i6 = -Vj/R6, i6 = -3.72/3000 or -1.18ma

Note that the current i5 is shown on the figure as flowing into the junction but as you can see, it’s actually flowing from the junction to the 3V supply, because the voltage Vj is higher than 3V. Current i6 is also flowing out of the junction. Hence, i5 and i6 have negative signs. Note that this implies that the 3V supply must be able to sink current. In working mesh problems, it’s common to assume an ideal voltage source with zero impedance and infinite source/sink capabilities. Sometimes real voltage sources don’t act that way.

Thevenin Method: There is another way to solve this type of problem using the Thevenin method (see the sidebar), where the circuit, minus the load, is reduced to the “Thevenin equivalent”, which is a voltage source in series with a resistance. From the point of the view of the load, the 5V and 3V supplies and their respective series resistors looks exactly like the Thevenin voltage and a (different) series resistor. For this example, I’ll designate R6 as the load and find the Thevenin equivalents for the other two branches.

FIGURE 3 
Thevenin circuit for resistor T-circuit
FIGURE 3
Thevenin circuit for resistor T-circuit

Using the principles described in the sidebar, to calculate the Thevenin equivalent circuit, you first remove the load resistor, R6, and calculate the open circuit voltage where the load resistor would be (Figure 3A). The current through R4 and R5 is (5 – 3)/(R4 + R5) or 667µa. The voltage across R5 is 667µa x R5 or 1.333V. So, with the 3V offset, the voltage at the junction of R4 and R5 is 4.333v.

Next, we remove the voltages and replace them with a short circuit (Figure 3B). We then calculate the impedance of the circuit, which is R4 in parallel with R5, or 667 Ω.

The resulting equivalent circuit is in Figure 3C. The Thevenin equivalent of the 5V and 3V supplies and R4 and R5 is Vth and Rth. If we put load resistor R6 back in the circuit, we find that the current is 4.333V/(667 + 3000) or 1.18ma, the same as the previous method (shown as positive since it’s just the current in the circuit and not a mesh current). Note that VTH and RTH aren’t in the circuit; they are models that are derived from the actual values.

SO WHAT?

OK, fine. You can calculate these currents and voltages. But if you’ve got a Spice program, it will do that for you. And what does an academic exercise in calculating mesh circuit values have to do with embedded system design?

Take a look at Figure 4. Let’s say you need to capture a time-varying signal on the input of your MCU. It might be a signal from a sensor or an audio signal. It doesn’t matter. You need to sample it with an ADC (Analog to Digital Converter) and do some calculations on the values you read. The MCU operates on 3.3V, and the analog input has to be between ground and Vcc.

FIGURE 4
ADC input network
FIGURE 4
ADC input network

Now look at Figure 5, which represents the signal itself. I’ve shown the signal as a sine wave, but that doesn’t matter. What matters is that the signal swings from -0.5V to +4V, outside the 0-3.3V range of the MCU input. You need to both level-shift and scale the signal so it is within the range of the MCU ADC input.

Figure 5
Sine input with negative offset
Figure 5
Sine input with negative offset

This problem is a mesh circuit like the previous example, except that you need to work it backward to find resistor values that will produce a voltage to the MCU input that is within the acceptable range. The signal is 4.5V peak-to-peak, so it needs to be attenuated by at least 3.3/4.5V or 0.733 to bring it within the 0-3.3V range of the MCU input. But because of the -0.5V bias on the input, it also needs to be level shifted up so that the lowest voltage doesn’t go below ground.

This circuit has a minor difference from the circuit in Figure 2, which is that instead of fixed 5V and 3V inputs, this one has a fixed 3.3V input and another input that varies between -0.5V and 4V. We can’t just attenuate the input with a voltage divider because that will still leave a negative offset. Even if the MCU can handle the negative voltage without damage, the ADC won’t be able to convert values below ground.

In this case, we don’t care what the currents are in the resistors, as long as our solution doesn’t require a negative resistance and we don’t exceed the resistor power ratings. What we want to solve for is the MCU input voltage, to be sure it’s within acceptable limits.

When the load (R9) is in the circuit, I’m going to say we want the junction of the three resistors to be between 0.1V and 3V. To solve this problem, I’m going to work backward from the desired voltage at the MCU input to calculate the necessary resistor values to produce the desired voltage.

When Vin is 4V, we want the MCU input to be 3V. When Vin is -0.5V, we want the MCU input to be 0.1V. This provides a little margin to allow for standard resistor tolerances. Trying to calculate exactly 0V and exactly 3.3V for the voltage swing will likely result in resistor values that are not available.

I’ll select 1K for the load resistor R9 to provide a relatively low impedance to the MCU input. The current through R9 at 4V input will be 3V/1000 or 3ma, which will be flowing out of the R7-R8-R9 junction. The current at a -0.5V input will be 0.1V/1000 or 100µa.

In both conditions, the current through R9 is the sum of the current through R7 and the current through R8. Write these equations for the 4V and -0.5V input values:

(4-3)/R8 + (3.3-3)/R7 = 3ma

(-0.5-0.1)/R8 + (3.3-0.1)/R7 = 100µa.

So:

1/R8 + 0.3/R7 = 3ma

-0.6/R8 + 3.2/R7 = 100µa.

— ADVERTISMENT—

—Advertise Here—

Now we need to solve the first of these two for R7 in terms of R8, and then plug that value into the second equation:

1/R8 = 3ma – 0.3/R7

R8 = 1/(3ma – 0.3/R7)

Putting that into the second equation:

-0.6(3ma – 0.3/R7) + 3.2/R7 = 100µa.

-1.8ma + .18/R7 + 3.2/R7 = 100µa.

3.38/R7 = 1.9ma

3.38 = R7 x 1.9ma

R7 = 1778Ω

Now we can plug that value back into the first equation:

1/R8 + 0.3/1778 = 3ma

1/R8 = 2.83ma; R8 = 353Ω

Now we can check this with the Thevenin method:

Open circuit voltage with R9 removed, input at 4V:

(4 – 3.3)/(353 + 1778) = 328µa

OCV = 3.88V

Open circuit voltage with R9 removed, input at -0.5V:

(-0.5 – 3.3)/(353 + 1778) = -1.783ma

OCV = 0.130

Equivalent resistance = 353||1778 = 294.5Ω

So the Thevenin equivalent with a 4V input is 3.88V and 294.5Ω. Inserting R9 back into the circuit gives 3V at the MCU input. With the -0.5V input, the Thevenin equivalent is 0.130V and 294.5Ω. With R9 in-circuit, the MCU voltage is 0.1V. Again, neither the 3.88V nor the 0.130V source exist in the circuit; they are part of the Thevenin model.

— ADVERTISMENT—

—Advertise Here—

The circuit attenuates the 4.5V p-p input to 2.9V P-P, so the attenuation is 2.9/4.5 or 0.644. The software would have to do the necessary calculations to compensate for the attenuated signal. Also, the 353 ohm and 1778 ohm resistors are not standard values, so in a real design, you would want to select standard values and re-calculate the MCU input voltages to be sure they are still in range. I did the calculations with standard 0.1% resistor values of 352Ω and 1780Ω; the resulting MCU voltage ranged from 0.93V to 3V. Very close to the original values but it requires using 0.1% precision resistors.

The values I calculated here worked with no negative resistances. Part of that is because I set the voltages within the MCU range and let the attenuation be whatever it turned out be. You could create a scenario where you want a specific attenuation and a specific offset. In that case you may find that you can’t select resistors that will hit both targets. If that happened, you’d know because one of the resistors would calculate out to a negative value. In a case like that, you may have to add an op amp to be able to set both targets, or use something other than the 3.3V supply voltage to generate a positive bias.

The resistor values I calculated assume that the input voltage is driven by a low-impedance source, such as an op amp. If that is not the case, you would have to either buffer the input with an opamp or constrain resistor R8 to a large enough value to prevent loading whatever is driving the input. The point being that in a real application you might have constraints that make the problem a little harder.

This is a specific example to show how you might use mesh circuit calculations in an MCU application. The general principle applies to other types of analog inputs where scaling and/or biasing is needed.

The mesh circuits we’ve examined here are relatively simple. Mesh circuits can get quite complex but solving them by hand can become difficult because of the number of equations involved. In some cases, you can use Thevenin equivalents to reduce the number of meshes involved. You can also use matrix math to solve them; that’s beyond the scope of this article.

AC MESH CIRCUITS:

Mesh circuits can contain capacitors and inductors as well. Of course, that only makes sense if there is an AC voltage source in the circuit. The circuits are solved the same way, but now you will be using the AC impedance of the capacitors and resistors, and not the DC resistance. You also have to consider frequency; the AC impedance of a capacitor or inductor is frequency-dependent, so you have to make the calculations based on both the amplitude of the voltage source, and the frequency range over which it operates. In the previous sine wave example, you might have to do four calculations based on the possible combinations of high/low voltage and high/low frequency. In a case like that, you will probably end up with a compromise solution.

Conclusion:

When we think of mesh circuits at all, most of us tend to think of them as something annoying we had to do in engineering/technical school. But they aren’t just an academic exercise and they do have real-world applications. In the embedded world, a lot of what we do is all ones and zeros. But sometimes an embedded system has to connect to something out there in the analog world and that may require translating a signal to something the MCU can accept. I hope this has brought some clarity to the subject. 

PUBLISHED IN CIRCUIT CELLAR MAGAZINE • SEPTEMBER 2024 #410 – Get a PDF of the issue

Keep up-to-date with our FREE Weekly Newsletter!

Don't miss out on upcoming issues of Circuit Cellar.


Note: We’ve made the Dec 2022 issue of Circuit Cellar available as a free sample issue. In it, you’ll find a rich variety of the kinds of articles and information that exemplify a typical issue of the current magazine.

Would you like to write for Circuit Cellar? We are always accepting articles/posts from the technical community. Get in touch with us and let's discuss your ideas.

Sponsor this Article
+ posts

Stuart Ball recently retired from a 40+ year career as an electrical engineer and engineering manager.  His most recent position was as a Principal Engineer at Seagate Technologies.

Supporting Companies

Upcoming Events


Copyright © KCK Media Corp.
All Rights Reserved

Copyright © 2026 KCK Media Corp.

Understanding Mesh Circuits

by Stuart Ball time to read: 11 min