Tty To Rs232
Tty To Rs232
Tty To Rs232
DESIGN IDEAS
FIGURE 1
A microcontroller can provide a PLL function to obtain a precise reference-locked frequency. www.ednmag.com EDN AUGUST 3, 1998
b 115
EDN
most significant bit with the reference signal that enters the controller via the analog comparator. A count-and-dump function integrates the XOR output over 255 DDS cycles. Upon every 256th DDS cycle, the phase value routes to the DAC at Port D of the controller. Every loop lasts exactly 12 clock cycles. Thus, the DDS cycle frequency is one-twelfth of the controllers clock frequency. The program performs a
DESIGN IDEAS
phase comparison between the DDS and the reference. The DAC voltage controls the VCXO. By using other increments for the DDS, you can easily adapt the program for other clock or reference frequencies. You can also use the circuit for demodulating phase-modulated signals. (DI #2229) e To Vote For This Design, Circle No. 301
FIGURE 2
The frequency-lock circuit in Figure 1 uses DDS techniques to provide a precise submultiple of the reference frequency.
FIGURE 1
An inverter, a few XOR gates, and some passive components generate a deadtime interval for switch commutation. 116 b EDN AUGUST 3, 1998
EDN
DESIGN IDEAS
you can build around a few logic XOR gates. The principle uses the truth table of an XOR or XNOR gate: that the output is high or low only when both inputs have different logic states. The logic states come from the RC networks R1-C1 and R4-C5. The output of the IC1 and IC4 gates is thus a short pulse whose width depends on the RC time constants of the input network. This pulse blanks the signal delivered to the output and thus generates the required dead time. You can easily model the logic functions using Intusofts (www.intusoft.com) IsSpice4 Analog Behavioral Modeling features (List ing 1 ). You need to feed the subcircuit with the dead-time value as well as the output high and low levels. The input clock is TTL/CMOS-compatible. By changing the B5 line to V= V(26,20)<100MV ? {VHIGH} : {VLOW}, the generator becomes suitable for driving a synchronous rectifier (Figure 2 ). Figure 3 clearly shows the absence of overlap between commutations. You can download Listing 1 from EDNs Web site, www.ednmag.com. At the registered-user area, go into the Software Center to download the file from DISIG, #2228. (DI #2228) e To Vote For This Design, Circle No. 302
FIGURE 2
The circuit in Figure 1 generates the dead time to prevent cross-conduction in this synchronous-rectifier circuit. FIGURE 3
Current waveforms for the MOSFETs in Figure 2 show no simultaneous conduction. 118 b EDN AUGUST 3, 1998
EDN
DESIGN IDEAS
FIGURE 1
An optocoupler and two resistors configure a TTY-to-RS-232C translator. Use the circuit in (a) when a negative supply is available; otherwise, use the circuit in (b).
FIGURE 1
However, in all but the most demanding applications, this delay of a few microseconds should be unobjectionable. For such applications, this technique can save on the additional hardware you need to provide an external port. The demo program uses the setup in Figure 1 . To output a bit, the routine makes the Timer1_Out pin assume either a 1 or 0 state by activating MaxCount A or B, respectively, and stopping the timer in that state. The state of the Timer_Out pin reflects which Max register the timer uses (register 1 for Max Reg A). To read an input fed to the Timer0_In pin, the routine keeps Timer0 running. Timer0 is configured so that it counts only if the Timer0_In pin is high. Thus, if Timer0 increments during two consecutive reads separated by a small delay greater than a timer clock period, it means the input level is high. Listing 1 is a demo C program for obtaining output via the Timer1_Out pin and inputs via the Timer0_In pin. The program sends logic 1 or 0 to the Timer1_Out pin, based on the key (1 or 0) the user presses. If Timer1_Out connects to Timer0_In, as the dashed line in Figure 1 shows, the program reads and displays the inputs logic level through the Timer0_In pin. In the demo system, an RS-232C port on the 80186 hardware, connected to a terminal, serves for user keyboard input. TABLE 1TIMER CONTROL-WORD BITS The demo C program is written and compiled using an Intel IC86 compiler on an 8-MHz Bit 0 Set to 1 for continuous-mode running; 0 for one-shot mode 80186 system. However, the same technique is Bit 1 1 for time to alternate between maximum-count register A and B; 0 for A only Bit 2 1 to select external clock for the timer; 0 for internal, that is, CPU clock/4 applicable to other mPs/mCs having similar Bit 3 If 1, Timer 2 output is used as clock, else internal clock (CPU clock/4) is used timer capabilities. Table 1 gives the timer conBit 4 If 0, the input level gates the timer on or off (timer will count for a high) trol-word bits. Table 2 provides the default Bit 5 This is a read-only bit set when the timer reaches its maximum value Bit 11 This bit has to be 0 80186 timer register addresses. Bit 12 This read-only bit indicates which maximum-count register is in use (0 indicates A) You can download Listing 1 from EDNs Web Bit 13 If set, interrupts are generated on every terminal count Bit 14 If 0, Bit 15 (enable/disable) is ignored, else Bit 15 will take effect site, www.ednmag.com. At the registered-user Bit 15 If set, the timer is enabled; 0 stops the timer area, go into the Software Center to download Notes: All bits except bits 5 and 12 are read/write. the file from DI-SIG, #2231. (DI #2231) e
Bits 5 and 12 are read-only. Bits not shown don't care.
EDN
DESIGN IDEAS
a straight line to the curve and measure the maximum deviation of the output curve from this line. Another way is to perform a quadratic fit and monitor the second-order coefficient as a measure of straightness. Although both of these methods work, extracting the data from Spice output files
FIGURE 2
y (V(3))
(a)
4 TIME (SEC)
10
Notice that when the feedback factor, a, is zero, the gain is simply equal to xKG. To understand the method, assume initially that x is linear. Introducing a small positive or negative a generates an output that is concave upward or downward, respectively. Now, if the input x exhibits an upward or downward curve, then the proper choice of a bends the curve in the opposite direction to improve the overall linearity. One way to measure the nonlinearity of the output is to fit
a (V(6))
(b)
4 TIME (SEC)
10
FIGURE 1
dy dt (V(8))
(c)
10
TIME (SEC)
dy dt (V(8))
(d)
4 TIME (SEC)
10
Multiplicative feedback (a) is one way to linearize an RTD. You can drive a corresponding Spice circuit (b) with a triangle waveform to measure the circuits nonlinearity and determine the value of a, for which the derivative of the output is flattest. 124 b EDN AUGUST 3, 1998
Spice makes it easy to view the output (a), the value of a (b), and the derivative of the output for two horizontal scales (c and d). The optimum value of a is the point at which the derivative is flattest, which occurs approximately 3 to 4 sec into the simulation, or when a ' 18 mV.
EDN
DESIGN IDEAS
and curve-fitting over a range of values for a are difficult and time-consuming. FIGURE 3 Alternatively, you can obtain some measure of nonlinearity by sweeping the temperature with a linear ramp function and then taking a derivative of the output response. A linear output should produce a constant derivative, and a concave upward or downward response produces an increasing or decreasing derivative, respectively. Therefore, the goal of this optimizing method is to find the value of a that results in the flattest derivative. However, because the input-ramp function increases without bound, this method instead uses a triangle wave to sweep the temperature. Now, by slowly sweeping a over many cycles of the triangle wave, a single simulation can measure the circuits performance with varying parameters. In the Spice circuit, VTEMP drives the A practical implementation of the RTD linearizing circuit includes linearity, gain, input temperature linearly from 0 to and offset adjustments. 4008 C with a 1-Hz triangle waveform (Figure 1b ). (You can download the corresponding Spice three adjustments until the circuit achieves the correct outnetlist from EDNs Web site, www.ednmag. com. At the reg- put voltages for the RTD resistances corresponding to the low, istered-user area, go into the Software Center to download midpoint, and high calibration temperatures (Figure 3 and the file from DI-SIG, #2224.) ERTD simulates the RTDs Reference 2 ). This circuit realizes the fixed gain and feedback response versus temperature using a second-order polynomi- terms as currents. Op amp IC1 implements the multiplier by al. To counteract the RTDs concave-downward behavior, the first summing the fixed and feedback currents and then mulcircuit introduces a positive feedback factor, a, with a con- tiplying the result by the RTDs resistance. IC2 provides addicave-upward characteristic. VALPHA sweeps a linearly for 10 tional gain, G, producing an output voltage given by sec. Therefore, the simulation determines the performance of V OUT = R RTD (i FIXED + i FB ) G , the circuit for the a range over 10 cycles of the triangle wave. The sum of the positive-feedback term, EFB, and a fixed term, VFIX, controls the gain of the multiplying block, EMULT. where G=R2/R1. The feedback-factor calculation is EGAIN provides a gain of G. Current source GDIFF and induci 1 tor LDIFF form the differentiator. = FB = . VOUT R FB The linearized output and the a parameter appear in Fig ure 2a and b, respectively. Figure 2c shows the output derivative, and Figure 2d shows only the tops of the derivatives A feedback factor of a =0.00002 (RFB=50 kV) in Figure 3 positive cycles. Note how the derivative in Figure 2d flattens, reduces the linearity error from 3.08 C to less than 0.18 C surrounded by a decreasing and increasing derivative to the over a 4008 C range. (DI #2224) e left and right of the optimal behavior, respectively. You can start with a broad range for a and then quickly narrow the References search after several simulations. Note that sweeping alpha during the triangle-wave cycles has some influence on the 1. Sheingold, D, Transducer Interfacing Handbook, Anaoutput response and, consequently, its derivative. However, log Devices, Norwood, MA, 1980, pg 99. this effect lessens as you narrow the range of a. 2. The Linear Applications Handbook, 1990, Linear You can implement the positive-feedback factor as a poten- Technology, Application Note 6, pg 2. tiometer with an adjustment range that brackets the optimum value as determined by your simulations. Note that the To Vote For This Design, Circle No. 305 overall gain and offset of the output versus temperature vary as a varies. Therefore, the final circuit should include a gain and offset adjustment in addition to the linearity adjustment. In one suggested circuit implementation, you repeat the
EDN
DESIGN IDEAS
Address
CIRCLE NO. 10