# A Simple 1-Wire® DAC

### 要約

Connecting the outputs of a 1-Wire addressable switch (DS2408) to a resistor network allows the

A similar version of this article was published on September 29, 2009 on the Planet Analog website.

Among devices available with a 1-Wire interface, the best known are memories, temperature sensors, battery monitors, and addressable switches. One-Wire ADCs are also available, but no 1-Wire DACs. You can, however, build a simple 1-Wire DAC using addressable switches.

The circuit (Figure 1) consists of a multi-channel 1-Wire addressable switch (DS2408, U1), a current mirror (Q1, Q2), and a resistor network (Rα, Rβ, Rγ, Rδ, RX). U1's open-drain output transistors (P0-P3) either conduct (logic 0) or present a high impedance (logic 1). If the logic state of an output port is 0, then current flows to ground through the resistor connected to that port.

I_{REF} is calculated as follows:

As explained in the Reference¹, the current I_{O} is described by equation (2):

where V_{A} represents the early voltage of Q2 and β is the current gain, assuming Q1 and Q2 have identical characteristics. For V_{CB} values from 4.3V to 0.2V and typical values for V_{A} (20) and β (180), the mirror ratio MR ranges from 1.20 (high V_{CB}, low current) to 1.00 (low V_{CB}, high current).

The DAC's analog output voltage (VX) is

VX = I_{O} × RL = MR × I_{REF} × RL

When none of the output ports are asserting logic 0, I_{REF} is determined by RX:

I_{REF0} = (V_{CC} - V_{BE}(Q1))/RX

I_{REF0} generates the offset voltage VX0:

VX0 = MR × I_{REF0} × RL

Inserting (4) in (5) and solving for RX yields (6), which lets you calculate the RX value corresponding to a desired offset voltage:

RX = RL × MR × (V_{CC} - V_{BE}(Q1))/VX0

With P0 assigned to the DAC's least-significant bit (LSB), the resistor Rα determines ΔVX, which is the voltage increment between steps. Substituting ΔVX for VX0 in equation (6) yields (7), which lets you calculate Rα:

Rα = RL × MR × (V_{CC} - V_{BE}(Q1))/ΔVX

Because P1 has twice the weight of P0 in a binary system, Rβ must conduct twice as much current. Consequently, Rβ = Rα/2. For the same reasons, Rγ = Rα/4 and Rδ = Rα/8. For these conditions the maximum value of VX is

VX_{MAX} = VX0 + 15 × (V_{CC} - V_{BE}(Q1))/Rα × RL × MR

### Example 1: Full-Range DAC

Table 1 explains the choices for input values. Inserting these values in equations (6) and (7) yields RX = 94.6kΩ and Rα = 18.92kΩ. Given the value Rα = 18.92kΩ, the other (non-standard) values are Rβ = 9.46kΩ, Rγ = 4.73kΩ, and Rδ = 2.365kΩ. To get closer to E24 standard values (5% tolerance), multiply each one with a factor ~1.05, yielding RX = 100kΩ, Rα = 20kΩ, Rβ = 10kΩ, Rγ = 5kΩ, and Rδ = 2.5kΩ. Changing all resistors by the same factor has little effect on the result, and the reduction in I_{REF} is compensated by the increased value of RL, leaving VX unaffected.

Parameter | Explanation |

V_{CC} = 5V |
Maximum voltage for the DS2408 |

VX0 = 0.05V | Design objective |

ΔVX = 0.25V | Design objective |

V_{BE}(Q1) = 0.7V |
Simplification |

MR = 1.1 | Center of the 1.00-to-1.20 MR range |

RL = 1kΩ | To ensure operation with high current gain |

### Example 2: LED-Brightness Control

In Figure 1, the analog output voltage VX controls the light intensity of an LED. Q3 functions as an emitter follower that minimizes the load on VX, and R1 limits the LED current. Assume that the LED voltage drop is 1.9V when ON, and that V_{BE} of Q3 is 0.7V. To keep the LED OFF, VX must be less than 2.6V, i.e., VX0 = 2.5V. To avoid Q2's V_{CE} saturation range, the voltage swing at VX must remain below 2V. This condition demands that ΔVX ≤ 2V/15, i.e., ΔVX = 0.125V. Otherwise, the input values of Table 1 apply.

Repeating the calculations of equations (6) and (7) yields RX = 1.892kΩ, Rα = 37.84kΩ, Rβ = 18.92kΩ, Rγ = 9.46kΩ, and Rδ = 4.73kΩ. Increasing these resistor values by ~5% gets you closer to the standard values: RX = 2kΩ, Rα = 40kΩ, Rβ = 20kΩ, Rγ = 10kΩ, and Rδ = 5kΩ.

The circuit of Figure 1 is simple and efficient, but its weak spot is the current mirror. The mirror ratio varies with V_{CB}(Q2), and both the Early voltage V_{A} and the current gain β change with the collector current. Discrete transistors introduce further imprecision. Using 5% resistors, the actual measurements of VX were within ±10% of the calculated values.

You can improve the current mirror by replacing Q1 and Q2 with a transistor array, or a dual transistor such as the BCV62. (The improved current-mirror designs described in Reference [1] require a third transistor.) Though shown for four switches, this concept can be extended to use all eight ports of U1. Note that this approach increases only the resolution, and not the accuracy or the output-voltage range.

### 参考資料

^{1 }W. Marshall Leach, Current Mirrors, http://users.ece.gatech.edu/~mleach/ece3050/notes/bjt/bjtmirr.pdf