Electronic Design with Excel
 

 

  Topics | VBA Basics | Back to eCircuit Center

             

RESISTOR DIVIDER

 

SIGNAL ATTENUATION

This is a simple example of using VBA for electronic design EE_Resistor_Divider.xls. You could ask - why  use a VBA function at all? But, even in this case, VBA makes analysis a little easier to explore. Here's the divider circuit.

The gain (or, attenuation) of this circuit is given by

K = R2 / (R1 + R2)

Let's create a simple VBA function to perform this calculation (See VBA Basics).

  Function K_Rdiv1(R1, R2)
   ' Gain of resistor divider
   K_Rdiv1 = R2 / (R2 + R1)

End Function

 

To see the VBA code hit ALT-F11 and double click on the Modules > Module1 in the VBA Project window. This opens the code window for this module.

 

DIVIDER ACCURACY

For this example, the divider is creating a precision +5V reference from an available +10V reference. The +5V level is used as a reference voltage for an ADC. But how accurate is this +5V level? Let's calculate the output given ideal components and then given initial tolerances of the +10V and resistors R1 and R2.

Vs R1 R2 K Rdiv Vo Vo_err Error (%)    
10.0 10000